[PATCH] D109800: [clang] don't mark as Elidable CXXConstruct expressions used in NRVO

2021-09-15 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

There might be some tooling out there that cares about `CXXConstructExpr`s that 
might be elided due to NRVO being marked as elidable. But it's probably OK to 
lose that marking if nothing in-tree is relying on it, and use `isElidable` 
only for copy elision from rvalues and not for NRVO.

I would have expected that we'd also assert for a case like this (in C++14 and 
earlier):

  struct b {};
  struct a : b {
a();
a(a &);
a(const b &);
  };
  a c() {
if (0) { return a(); }
  
return a();
  }

... and that this patch wouldn't help there. But it looks like we don't mark 
the `a(const b&)` constructor call here as elidable, which seems like a bug, 
but might not be one worth fixing?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109800

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


[PATCH] D109800: [clang] don't mark as Elidable CXXConstruct expressions used in NRVO

2021-09-15 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov added a comment.

I can have a look on what is happening with that test case. At best if we 
figure out what is wrong, we could add some FIXMEs and circle back to it after 
we make this whole thing work again.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109800

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


[PATCH] D109800: [clang] don't mark as Elidable CXXConstruct expressions used in NRVO

2021-09-15 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov updated this revision to Diff 372845.
mizvekov added a comment.

Add a couple more test cases where we don't perform copy-elision
on a returned prvalue in pre-C++17 modes, and the corresponding
FIXMEs in the source code.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109800

Files:
  clang/include/clang/Sema/Initialization.h
  clang/lib/CodeGen/CGExprCXX.cpp
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaCoroutine.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaLambda.cpp
  clang/lib/Sema/SemaObjCProperty.cpp
  clang/lib/Sema/SemaStmt.cpp
  clang/test/CodeGen/nrvo-tracking.cpp
  clang/test/CodeGenCXX/copy-elision.cpp

Index: clang/test/CodeGenCXX/copy-elision.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/copy-elision.cpp
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-unknown-gnu -emit-llvm -O1 -fexperimental-new-pass-manager -o - %s | FileCheck %s
+
+template  T test() {
+  return T();
+}
+
+struct A {
+  A();
+  A(A &);
+  A(int);
+  operator int();
+};
+
+// FIXME: There should be copy elision here.
+// CHECK-LABEL: define{{.*}} void @_Z4testI1AET_v
+// CHECK:   call void @_ZN1AC1Ev
+// CHECK-NEXT:  call i32 @_ZN1AcviEv
+// CHECK-NEXT:  call void @_ZN1AC1Ei
+// CHECK-NEXT:  call void @llvm.lifetime.end
+template A test();
+
+struct BSub {};
+struct B : BSub {
+  B();
+  B(B &);
+  B(const BSub &);
+};
+
+// FIXME: There should be copy elision here.
+// CHECK-LABEL: define{{.*}} void @_Z4testI1BET_v
+// CHECK:   call void @_ZN1BC1Ev
+// CHECK:   call void @_ZN1BC1ERK4BSub
+// CHECK-NEXT:  call void @llvm.lifetime.end
+template B test();
Index: clang/test/CodeGen/nrvo-tracking.cpp
===
--- clang/test/CodeGen/nrvo-tracking.cpp
+++ clang/test/CodeGen/nrvo-tracking.cpp
@@ -282,3 +282,40 @@
 }
 
 } // namespace test_alignas
+
+namespace PR51862 {
+
+template  T test() {
+  T a;
+  T b;
+  if (0)
+return a;
+  return b;
+}
+
+struct A {
+  A();
+  A(A &);
+  A(int);
+  operator int();
+};
+
+// CHECK-LABEL: define{{.*}} void @_ZN7PR518624testINS_1AEEET_v
+// CHECK:   call i32 @_ZN7PR518621AcviEv
+// CHECK-NEXT:  call void @_ZN7PR518621AC1Ei
+// CHECK-NEXT:  call void @llvm.lifetime.end
+template A test();
+
+struct BSub {};
+struct B : BSub {
+  B();
+  B(B &);
+  B(const BSub &);
+};
+
+// CHECK-LABEL: define{{.*}} void @_ZN7PR518624testINS_1BEEET_v
+// CHECK:   call void @_ZN7PR518621BC1ERKNS_4BSubE
+// CHECK-NEXT:  call void @llvm.lifetime.end
+template B test();
+
+} // namespace PR51862
Index: clang/lib/Sema/SemaStmt.cpp
===
--- clang/lib/Sema/SemaStmt.cpp
+++ clang/lib/Sema/SemaStmt.cpp
@@ -3653,8 +3653,8 @@
 
 // In C++ the return statement is handled via a copy initialization.
 // the C version of which boils down to CheckSingleAssignmentConstraints.
-InitializedEntity Entity = InitializedEntity::InitializeResult(
-ReturnLoc, FnRetType, NRVOCandidate != nullptr);
+InitializedEntity Entity =
+InitializedEntity::InitializeResult(ReturnLoc, FnRetType);
 ExprResult Res = PerformMoveOrCopyInitialization(
 Entity, NRInfo, RetValExp, SupressSimplerImplicitMoves);
 if (Res.isInvalid()) {
@@ -4085,8 +4085,8 @@
 // the C version of which boils down to CheckSingleAssignmentConstraints.
 if (!HasDependentReturnType && !RetValExp->isTypeDependent()) {
   // we have a non-void function with an expression, continue checking
-  InitializedEntity Entity = InitializedEntity::InitializeResult(
-  ReturnLoc, RetType, NRVOCandidate != nullptr);
+  InitializedEntity Entity =
+  InitializedEntity::InitializeResult(ReturnLoc, RetType);
   ExprResult Res = PerformMoveOrCopyInitialization(
   Entity, NRInfo, RetValExp, SupressSimplerImplicitMoves);
   if (Res.isInvalid()) {
Index: clang/lib/Sema/SemaObjCProperty.cpp
===
--- clang/lib/Sema/SemaObjCProperty.cpp
+++ clang/lib/Sema/SemaObjCProperty.cpp
@@ -1467,8 +1467,7 @@
   LoadSelfExpr, true, true);
   ExprResult Res = PerformCopyInitialization(
   InitializedEntity::InitializeResult(PropertyDiagLoc,
-  getterMethod->getReturnType(),
-  /*NRVO=*/false),
+  getterMethod->getReturnType()),
   PropertyDiagLoc, IvarRefExpr);
   if (!Res.isInvalid()) {
 Expr *ResExpr = Res.getAs();
Index: clang/lib/Sema/SemaLambda.cpp
===
--- clang/lib/Sema/SemaLambda.cpp
+++ cl

[PATCH] D109800: [clang] don't mark as Elidable CXXConstruct expressions used in NRVO

2021-09-15 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov updated this revision to Diff 372846.
mizvekov added a comment.

typo


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109800

Files:
  clang/include/clang/Sema/Initialization.h
  clang/lib/CodeGen/CGExprCXX.cpp
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaCoroutine.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaLambda.cpp
  clang/lib/Sema/SemaObjCProperty.cpp
  clang/lib/Sema/SemaStmt.cpp
  clang/test/CodeGen/nrvo-tracking.cpp
  clang/test/CodeGenCXX/copy-elision.cpp

Index: clang/test/CodeGenCXX/copy-elision.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/copy-elision.cpp
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-unknown-gnu -emit-llvm -O1 -fexperimental-new-pass-manager -o - %s | FileCheck %s
+
+template  T test() {
+  return T();
+}
+
+struct A {
+  A();
+  A(A &);
+  A(int);
+  operator int();
+};
+
+// FIXME: There should be copy elision here.
+// CHECK-LABEL: define{{.*}} void @_Z4testI1AET_v
+// CHECK:   call void @_ZN1AC1Ev
+// CHECK-NEXT:  call i32 @_ZN1AcviEv
+// CHECK-NEXT:  call void @_ZN1AC1Ei
+// CHECK-NEXT:  call void @llvm.lifetime.end
+template A test();
+
+struct BSub {};
+struct B : BSub {
+  B();
+  B(B &);
+  B(const BSub &);
+};
+
+// FIXME: There should be copy elision here.
+// CHECK-LABEL: define{{.*}} void @_Z4testI1BET_v
+// CHECK:   call void @_ZN1BC1Ev
+// CHECK:   call void @_ZN1BC1ERK4BSub
+// CHECK-NEXT:  call void @llvm.lifetime.end
+template B test();
Index: clang/test/CodeGen/nrvo-tracking.cpp
===
--- clang/test/CodeGen/nrvo-tracking.cpp
+++ clang/test/CodeGen/nrvo-tracking.cpp
@@ -282,3 +282,40 @@
 }
 
 } // namespace test_alignas
+
+namespace PR51862 {
+
+template  T test() {
+  T a;
+  T b;
+  if (0)
+return a;
+  return b;
+}
+
+struct A {
+  A();
+  A(A &);
+  A(int);
+  operator int();
+};
+
+// CHECK-LABEL: define{{.*}} void @_ZN7PR518624testINS_1AEEET_v
+// CHECK:   call i32 @_ZN7PR518621AcviEv
+// CHECK-NEXT:  call void @_ZN7PR518621AC1Ei
+// CHECK-NEXT:  call void @llvm.lifetime.end
+template A test();
+
+struct BSub {};
+struct B : BSub {
+  B();
+  B(B &);
+  B(const BSub &);
+};
+
+// CHECK-LABEL: define{{.*}} void @_ZN7PR518624testINS_1BEEET_v
+// CHECK:   call void @_ZN7PR518621BC1ERKNS_4BSubE
+// CHECK-NEXT:  call void @llvm.lifetime.end
+template B test();
+
+} // namespace PR51862
Index: clang/lib/Sema/SemaStmt.cpp
===
--- clang/lib/Sema/SemaStmt.cpp
+++ clang/lib/Sema/SemaStmt.cpp
@@ -3653,8 +3653,8 @@
 
 // In C++ the return statement is handled via a copy initialization.
 // the C version of which boils down to CheckSingleAssignmentConstraints.
-InitializedEntity Entity = InitializedEntity::InitializeResult(
-ReturnLoc, FnRetType, NRVOCandidate != nullptr);
+InitializedEntity Entity =
+InitializedEntity::InitializeResult(ReturnLoc, FnRetType);
 ExprResult Res = PerformMoveOrCopyInitialization(
 Entity, NRInfo, RetValExp, SupressSimplerImplicitMoves);
 if (Res.isInvalid()) {
@@ -4085,8 +4085,8 @@
 // the C version of which boils down to CheckSingleAssignmentConstraints.
 if (!HasDependentReturnType && !RetValExp->isTypeDependent()) {
   // we have a non-void function with an expression, continue checking
-  InitializedEntity Entity = InitializedEntity::InitializeResult(
-  ReturnLoc, RetType, NRVOCandidate != nullptr);
+  InitializedEntity Entity =
+  InitializedEntity::InitializeResult(ReturnLoc, RetType);
   ExprResult Res = PerformMoveOrCopyInitialization(
   Entity, NRInfo, RetValExp, SupressSimplerImplicitMoves);
   if (Res.isInvalid()) {
Index: clang/lib/Sema/SemaObjCProperty.cpp
===
--- clang/lib/Sema/SemaObjCProperty.cpp
+++ clang/lib/Sema/SemaObjCProperty.cpp
@@ -1467,8 +1467,7 @@
   LoadSelfExpr, true, true);
   ExprResult Res = PerformCopyInitialization(
   InitializedEntity::InitializeResult(PropertyDiagLoc,
-  getterMethod->getReturnType(),
-  /*NRVO=*/false),
+  getterMethod->getReturnType()),
   PropertyDiagLoc, IvarRefExpr);
   if (!Res.isInvalid()) {
 Expr *ResExpr = Res.getAs();
Index: clang/lib/Sema/SemaLambda.cpp
===
--- clang/lib/Sema/SemaLambda.cpp
+++ clang/lib/Sema/SemaLambda.cpp
@@ -1978,8 +1978,7 @@
   CallOperator->markUsed(Context);
 
   ExprResult Init = PerformCopyInitialization(
-  Initiali

[PATCH] D109800: [clang] don't mark as Elidable CXXConstruct expressions used in NRVO

2021-09-15 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov updated this revision to Diff 372849.
mizvekov added a comment.

.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109800

Files:
  clang/include/clang/Sema/Initialization.h
  clang/lib/CodeGen/CGExprCXX.cpp
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaCoroutine.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaLambda.cpp
  clang/lib/Sema/SemaObjCProperty.cpp
  clang/lib/Sema/SemaStmt.cpp
  clang/test/CodeGen/nrvo-tracking.cpp
  clang/test/CodeGenCXX/copy-elision.cpp

Index: clang/test/CodeGenCXX/copy-elision.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/copy-elision.cpp
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-unknown-gnu -emit-llvm -O1 -fexperimental-new-pass-manager -o - %s | FileCheck %s
+
+template  T test() {
+  return T();
+}
+
+struct A {
+  A();
+  A(A &);
+  A(int);
+  operator int();
+};
+
+// FIXME: There should be copy elision here.
+// CHECK-LABEL: define{{.*}} void @_Z4testI1AET_v
+// CHECK:   call void @_ZN1AC1Ev
+// CHECK-NEXT:  call i32 @_ZN1AcviEv
+// CHECK-NEXT:  call void @_ZN1AC1Ei
+// CHECK-NEXT:  call void @llvm.lifetime.end
+template A test();
+
+struct BSub {};
+struct B : BSub {
+  B();
+  B(B &);
+  B(const BSub &);
+};
+
+// FIXME: There should be copy elision here.
+// CHECK-LABEL: define{{.*}} void @_Z4testI1BET_v
+// CHECK:   call void @_ZN1BC1Ev
+// CHECK:   call void @_ZN1BC1ERK4BSub
+// CHECK-NEXT:  call void @llvm.lifetime.end
+template B test();
Index: clang/test/CodeGen/nrvo-tracking.cpp
===
--- clang/test/CodeGen/nrvo-tracking.cpp
+++ clang/test/CodeGen/nrvo-tracking.cpp
@@ -282,3 +282,40 @@
 }
 
 } // namespace test_alignas
+
+namespace PR51862 {
+
+template  T test() {
+  T a;
+  T b;
+  if (0)
+return a;
+  return b;
+}
+
+struct A {
+  A();
+  A(A &);
+  A(int);
+  operator int();
+};
+
+// CHECK-LABEL: define{{.*}} void @_ZN7PR518624testINS_1AEEET_v
+// CHECK:   call i32 @_ZN7PR518621AcviEv
+// CHECK-NEXT:  call void @_ZN7PR518621AC1Ei
+// CHECK-NEXT:  call void @llvm.lifetime.end
+template A test();
+
+struct BSub {};
+struct B : BSub {
+  B();
+  B(B &);
+  B(const BSub &);
+};
+
+// CHECK-LABEL: define{{.*}} void @_ZN7PR518624testINS_1BEEET_v
+// CHECK:   call void @_ZN7PR518621BC1ERKNS_4BSubE
+// CHECK-NEXT:  call void @llvm.lifetime.end
+template B test();
+
+} // namespace PR51862
Index: clang/lib/Sema/SemaStmt.cpp
===
--- clang/lib/Sema/SemaStmt.cpp
+++ clang/lib/Sema/SemaStmt.cpp
@@ -3653,8 +3653,8 @@
 
 // In C++ the return statement is handled via a copy initialization.
 // the C version of which boils down to CheckSingleAssignmentConstraints.
-InitializedEntity Entity = InitializedEntity::InitializeResult(
-ReturnLoc, FnRetType, NRVOCandidate != nullptr);
+InitializedEntity Entity =
+InitializedEntity::InitializeResult(ReturnLoc, FnRetType);
 ExprResult Res = PerformMoveOrCopyInitialization(
 Entity, NRInfo, RetValExp, SupressSimplerImplicitMoves);
 if (Res.isInvalid()) {
@@ -4085,8 +4085,8 @@
 // the C version of which boils down to CheckSingleAssignmentConstraints.
 if (!HasDependentReturnType && !RetValExp->isTypeDependent()) {
   // we have a non-void function with an expression, continue checking
-  InitializedEntity Entity = InitializedEntity::InitializeResult(
-  ReturnLoc, RetType, NRVOCandidate != nullptr);
+  InitializedEntity Entity =
+  InitializedEntity::InitializeResult(ReturnLoc, RetType);
   ExprResult Res = PerformMoveOrCopyInitialization(
   Entity, NRInfo, RetValExp, SupressSimplerImplicitMoves);
   if (Res.isInvalid()) {
Index: clang/lib/Sema/SemaObjCProperty.cpp
===
--- clang/lib/Sema/SemaObjCProperty.cpp
+++ clang/lib/Sema/SemaObjCProperty.cpp
@@ -1467,8 +1467,7 @@
   LoadSelfExpr, true, true);
   ExprResult Res = PerformCopyInitialization(
   InitializedEntity::InitializeResult(PropertyDiagLoc,
-  getterMethod->getReturnType(),
-  /*NRVO=*/false),
+  getterMethod->getReturnType()),
   PropertyDiagLoc, IvarRefExpr);
   if (!Res.isInvalid()) {
 Expr *ResExpr = Res.getAs();
Index: clang/lib/Sema/SemaLambda.cpp
===
--- clang/lib/Sema/SemaLambda.cpp
+++ clang/lib/Sema/SemaLambda.cpp
@@ -1978,8 +1978,7 @@
   CallOperator->markUsed(Context);
 
   ExprResult Init = PerformCopyInitialization(
-  Initialized

[PATCH] D109865: [NFC] `goto fail` has failed us in the past...

2021-09-15 Thread Chris Bieneman via Phabricator via cfe-commits
beanz created this revision.
beanz added reviewers: rsmith, harlanhaskins, bkramer.
beanz requested review of this revision.
Herald added a project: clang.

This patch replaces reliance on `goto failure` pattern with
`llvm::scope_exit`.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D109865

Files:
  clang/lib/Frontend/FrontendAction.cpp

Index: clang/lib/Frontend/FrontendAction.cpp
===
--- clang/lib/Frontend/FrontendAction.cpp
+++ clang/lib/Frontend/FrontendAction.cpp
@@ -27,6 +27,7 @@
 #include "clang/Serialization/ASTDeserializationListener.h"
 #include "clang/Serialization/ASTReader.h"
 #include "clang/Serialization/GlobalModuleIndex.h"
+#include "llvm/ADT/ScopeExit.h"
 #include "llvm/Support/BuryPointer.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/FileSystem.h"
@@ -558,8 +559,20 @@
   bool HasBegunSourceFile = false;
   bool ReplayASTFile = Input.getKind().getFormat() == InputKind::Precompiled &&
usesPreprocessorOnly();
+
+  // If we fail, reset state since the client will not end up calling the
+  // matching EndSourceFile(). All paths that return true should release this.
+  auto FailureCleanup = llvm::make_scope_exit([&]() {
+if (HasBegunSourceFile)
+  CI.getDiagnosticClient().EndSourceFile();
+CI.clearOutputFiles(/*EraseFiles=*/true);
+CI.getLangOpts().setCompilingModule(LangOptions::CMK_None);
+setCurrentInput(FrontendInputFile());
+setCompilerInstance(nullptr);
+  });
+
   if (!BeginInvocation(CI))
-goto failure;
+return false;
 
   // If we're replaying the build of an AST file, import it and set up
   // the initial state from its build.
@@ -580,7 +593,7 @@
 ASTUnit::LoadPreprocessorOnly, ASTDiags, CI.getFileSystemOpts(),
 CI.getCodeGenOpts().DebugTypeExtRefs);
 if (!AST)
-  goto failure;
+  return false;
 
 // Options relating to how we treat the input (but not what we do with it)
 // are inherited from the AST unit.
@@ -649,7 +662,7 @@
 CI.getCodeGenOpts().DebugTypeExtRefs);
 
 if (!AST)
-  goto failure;
+  return false;
 
 // Inform the diagnostic client we are processing a source file.
 CI.getDiagnosticClient().BeginSourceFile(CI.getLangOpts(), nullptr);
@@ -669,20 +682,21 @@
 
 // Initialize the action.
 if (!BeginSourceFileAction(CI))
-  goto failure;
+  return false;
 
 // Create the AST consumer.
 CI.setASTConsumer(CreateWrappedASTConsumer(CI, InputFile));
 if (!CI.hasASTConsumer())
-  goto failure;
+  return false;
 
+FailureCleanup.release();
 return true;
   }
 
   // Set up the file and source managers, if needed.
   if (!CI.hasFileManager()) {
 if (!CI.createFileManager()) {
-  goto failure;
+  return false;
 }
   }
   if (!CI.hasSourceManager())
@@ -710,12 +724,13 @@
 
 // Initialize the action.
 if (!BeginSourceFileAction(CI))
-  goto failure;
+  return false;
 
 // Initialize the main file entry.
 if (!CI.InitializeSourceManager(CurrentInput))
-  goto failure;
+  return false;
 
+FailureCleanup.release();
 return true;
   }
 
@@ -748,7 +763,7 @@
 
   if (!Found) {
 CI.getDiagnostics().Report(diag::err_fe_no_pch_in_dir) << PCHInclude;
-goto failure;
+return false;
   }
 }
   }
@@ -765,7 +780,7 @@
 
   // Initialize the main file entry.
   if (!CI.InitializeSourceManager(Input))
-goto failure;
+return false;
 
   // For module map files, we first parse the module map and synthesize a
   // "" buffer before more conventional processing.
@@ -777,11 +792,11 @@
 if (loadModuleMapForModuleBuild(CI, Input.isSystem(),
 Input.isPreprocessed(),
 PresumedModuleMapFile, OffsetToContents))
-  goto failure;
+  return false;
 
 auto *CurrentModule = prepareToBuildModule(CI, Input.getFile());
 if (!CurrentModule)
-  goto failure;
+  return false;
 
 CurrentModule->PresumedModuleMapFile = PresumedModuleMapFile;
 
@@ -792,7 +807,7 @@
   // Otherwise, convert the module description to a suitable input buffer.
   auto Buffer = getInputBufferForModule(CI, CurrentModule);
   if (!Buffer)
-goto failure;
+return false;
 
   // Reinitialize the main file entry to refer to the new input.
   auto Kind = CurrentModule->IsSystem ? SrcMgr::C_System : SrcMgr::C_User;
@@ -805,7 +820,7 @@
 
   // Initialize the action.
   if (!BeginSourceFileAction(CI))
-goto failure;
+return false;
 
   // If we were asked to load any module map files, do so now.
   for (const auto &Filename : CI.getFrontendOpts().ModuleMapFiles) {
@@ -839,7 +854,7 @@
 std::unique_ptr Consumer =
 CreateWrappedASTConsumer(CI, PresumedInputFile);
 if (!Consumer)
-  goto failure;
+  return false;
 
 // FIXME: s

[PATCH] D109800: [clang] don't mark as Elidable CXXConstruct expressions used in NRVO

2021-09-15 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov updated this revision to Diff 372852.
mizvekov added a comment.

add another FIXME.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109800

Files:
  clang/include/clang/Sema/Initialization.h
  clang/lib/CodeGen/CGExprCXX.cpp
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaCoroutine.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaLambda.cpp
  clang/lib/Sema/SemaObjCProperty.cpp
  clang/lib/Sema/SemaStmt.cpp
  clang/test/CodeGen/nrvo-tracking.cpp
  clang/test/CodeGenCXX/copy-elision.cpp

Index: clang/test/CodeGenCXX/copy-elision.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/copy-elision.cpp
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-unknown-gnu -emit-llvm -O1 -fexperimental-new-pass-manager -o - %s | FileCheck %s
+
+template  T test() {
+  return T();
+}
+
+struct A {
+  A();
+  A(A &);
+  A(int);
+  operator int();
+};
+
+// FIXME: There should be copy elision here.
+// CHECK-LABEL: define{{.*}} void @_Z4testI1AET_v
+// CHECK:   call void @_ZN1AC1Ev
+// CHECK-NEXT:  call i32 @_ZN1AcviEv
+// CHECK-NEXT:  call void @_ZN1AC1Ei
+// CHECK-NEXT:  call void @llvm.lifetime.end
+template A test();
+
+struct BSub {};
+struct B : BSub {
+  B();
+  B(B &);
+  B(const BSub &);
+};
+
+// FIXME: There should be copy elision here.
+// CHECK-LABEL: define{{.*}} void @_Z4testI1BET_v
+// CHECK:   call void @_ZN1BC1Ev
+// CHECK:   call void @_ZN1BC1ERK4BSub
+// CHECK-NEXT:  call void @llvm.lifetime.end
+template B test();
Index: clang/test/CodeGen/nrvo-tracking.cpp
===
--- clang/test/CodeGen/nrvo-tracking.cpp
+++ clang/test/CodeGen/nrvo-tracking.cpp
@@ -282,3 +282,40 @@
 }
 
 } // namespace test_alignas
+
+namespace PR51862 {
+
+template  T test() {
+  T a;
+  T b;
+  if (0)
+return a;
+  return b;
+}
+
+struct A {
+  A();
+  A(A &);
+  A(int);
+  operator int();
+};
+
+// CHECK-LABEL: define{{.*}} void @_ZN7PR518624testINS_1AEEET_v
+// CHECK:   call i32 @_ZN7PR518621AcviEv
+// CHECK-NEXT:  call void @_ZN7PR518621AC1Ei
+// CHECK-NEXT:  call void @llvm.lifetime.end
+template A test();
+
+struct BSub {};
+struct B : BSub {
+  B();
+  B(B &);
+  B(const BSub &);
+};
+
+// CHECK-LABEL: define{{.*}} void @_ZN7PR518624testINS_1BEEET_v
+// CHECK:   call void @_ZN7PR518621BC1ERKNS_4BSubE
+// CHECK-NEXT:  call void @llvm.lifetime.end
+template B test();
+
+} // namespace PR51862
Index: clang/lib/Sema/SemaStmt.cpp
===
--- clang/lib/Sema/SemaStmt.cpp
+++ clang/lib/Sema/SemaStmt.cpp
@@ -3653,8 +3653,8 @@
 
 // In C++ the return statement is handled via a copy initialization.
 // the C version of which boils down to CheckSingleAssignmentConstraints.
-InitializedEntity Entity = InitializedEntity::InitializeResult(
-ReturnLoc, FnRetType, NRVOCandidate != nullptr);
+InitializedEntity Entity =
+InitializedEntity::InitializeResult(ReturnLoc, FnRetType);
 ExprResult Res = PerformMoveOrCopyInitialization(
 Entity, NRInfo, RetValExp, SupressSimplerImplicitMoves);
 if (Res.isInvalid()) {
@@ -4085,8 +4085,8 @@
 // the C version of which boils down to CheckSingleAssignmentConstraints.
 if (!HasDependentReturnType && !RetValExp->isTypeDependent()) {
   // we have a non-void function with an expression, continue checking
-  InitializedEntity Entity = InitializedEntity::InitializeResult(
-  ReturnLoc, RetType, NRVOCandidate != nullptr);
+  InitializedEntity Entity =
+  InitializedEntity::InitializeResult(ReturnLoc, RetType);
   ExprResult Res = PerformMoveOrCopyInitialization(
   Entity, NRInfo, RetValExp, SupressSimplerImplicitMoves);
   if (Res.isInvalid()) {
Index: clang/lib/Sema/SemaObjCProperty.cpp
===
--- clang/lib/Sema/SemaObjCProperty.cpp
+++ clang/lib/Sema/SemaObjCProperty.cpp
@@ -1467,8 +1467,7 @@
   LoadSelfExpr, true, true);
   ExprResult Res = PerformCopyInitialization(
   InitializedEntity::InitializeResult(PropertyDiagLoc,
-  getterMethod->getReturnType(),
-  /*NRVO=*/false),
+  getterMethod->getReturnType()),
   PropertyDiagLoc, IvarRefExpr);
   if (!Res.isInvalid()) {
 Expr *ResExpr = Res.getAs();
Index: clang/lib/Sema/SemaLambda.cpp
===
--- clang/lib/Sema/SemaLambda.cpp
+++ clang/lib/Sema/SemaLambda.cpp
@@ -1978,8 +1978,7 @@
   CallOperator->markUsed(Context);
 
   ExprResult Init = PerformCopyInitialization(
-

[PATCH] D95588: [RISCV] Implement the MC layer support of P extension

2021-09-15 Thread Jim Lin via Phabricator via cfe-commits
Jim added a comment.

Any feedback? I think this patch is good enough to be accepted.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95588

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


[PATCH] D108567: Implement #pragma clang final extension

2021-09-15 Thread Chris Bieneman via Phabricator via cfe-commits
beanz added inline comments.



Comment at: clang/docs/LanguageExtensions.rst:3968-3984
+Final Macros
+
+
+Clang supports the pragma ``#pragma clang final``, which can be used to
+mark macros as final, meaning they cannot be undef'd or re-defined. For 
example:
+
+.. code-block:: c

aaron.ballman wrote:
> Design question: would it make sense to extend this slightly so that the 
> macro does not have to be defined in order to be finalized? e.g., this could 
> be used as a way for a library author to say "this identifier cannot be 
> defined as a macro"?
That's an interesting thought. I can look into that. Since the current 
implementation relies on the identifier info I'm not sure how much work it 
would be to support that.



Comment at: clang/docs/LanguageExtensions.rst:3979
+   #undef FINAL_MACRO  // warning: FINAL_MACRO is marked final and should not 
be undefined
+   #define FINAL_MACRO // warning: FINAL_MACRO is marked final and should not 
be redefined
+

aaron.ballman wrote:
> What happens if the redefinition is to the same token sequence as the 
> original definition? e.g.,
> ```
> #define FINAL_MACRO 1+1
> #pragma clang final(FINAL_MACRO)
> #define FINAL_MACRO 1+1 // ok?
> #define FINAL_MACRO (1+1) // Whoa...slow your roll there, champ!
> ```
`-Wmacro-redefined` currently warns on redefinitions even if they are the same 
as the existing definition.

The implementation in this patch only triggers on redefining macros that have 
been undef'd and relies on `-Wmacro-redefined` to catch masking redefinitions. 
Although I should probably change that so that final catches on both.



Comment at: clang/include/clang/Basic/DiagnosticLexKinds.td:544
+  ExtWarn<"macro %0 has been marked as final and should not be "
+  "%select{un|re}1defined">,
+  InGroup;

aaron.ballman wrote:
> Heh, I like your approach, but a goal of %select is to ease translation of 
> our diagnostics to other languages (in theory, anyway).
Ha... Okay... Can do :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108567

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


[PATCH] D109635: [OpenMP] Support construct trait set for Clang

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

LGTM, thanks :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109635

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


[PATCH] D108567: Implement #pragma clang final extension

2021-09-15 Thread Chris Bieneman via Phabricator via cfe-commits
beanz updated this revision to Diff 372862.
beanz added a comment.

Updates based on feedback from @aaron.ballman.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108567

Files:
  clang/docs/LanguageExtensions.rst
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticLexKinds.td
  clang/include/clang/Basic/IdentifierTable.h
  clang/include/clang/Lex/Preprocessor.h
  clang/lib/Lex/PPDirectives.cpp
  clang/lib/Lex/Pragma.cpp
  clang/lib/Lex/Preprocessor.cpp
  clang/test/Lexer/Inputs/final-macro.h
  clang/test/Lexer/Inputs/unsafe-macro.h
  clang/test/Lexer/deprecate-macro.c
  clang/test/Lexer/final-macro.c
  clang/test/Lexer/pedantic-macro-interplay.c

Index: clang/test/Lexer/pedantic-macro-interplay.c
===
--- clang/test/Lexer/pedantic-macro-interplay.c
+++ clang/test/Lexer/pedantic-macro-interplay.c
@@ -11,4 +11,17 @@
 // not-expected-warning@+1{{macro 'UNSAFE_MACRO_2' has been marked as deprecated: Don't use this!}}
 #pragma clang restrict_expansion(UNSAFE_MACRO_2, "Don't use this!")
 
-// expected-no-diagnostics
+
+#define Foo 1
+#pragma clang final(Foo)
+// expected-note@+2{{macro marked 'deprecated' here}}
+// expected-note@+1{{macro marked 'deprecated' here}}
+#pragma clang deprecated(Foo)
+// expected-note@+1{{macro marked 'restrict_expansion' here}}
+#pragma clang restrict_expansion(Foo)
+
+// Test that unsafe_header and deprecated markings stick around after the undef
+#include "Inputs/final-macro.h"
+
+// expected-warning@+1{{macro 'Foo' has been marked as deprecated}}
+const int X = Foo;
Index: clang/test/Lexer/final-macro.c
===
--- /dev/null
+++ clang/test/Lexer/final-macro.c
@@ -0,0 +1,46 @@
+// RUN: %clang_cc1 -Wfinal-macro %s -fsyntax-only -verify
+
+// Test warning production
+#define Foo 1
+// expected-note@+4{{macro marked 'final' here}}
+// expected-note@+3{{macro marked 'final' here}}
+// expected-note@+2{{macro marked 'final' here}}
+// expected-note@+1{{macro marked 'final' here}}
+#pragma clang final(Foo)
+#pragma clang deprecated(Foo)
+#pragma clang header_unsafe(Foo)
+
+// expected-warning@+2{{macro 'Foo' has been marked as final and should not be redefined}}
+// expected-note@+1{{previous definition is here}}
+#define Foo 1
+
+// expected-warning@+2{{macro 'Foo' has been marked as final and should not be redefined}}
+// expected-warning@+1{{'Foo' macro redefined}}
+#define Foo 2
+
+// expected-warning@+1{{redefining builtin macro}}
+#define __TIME__ 1
+
+// expected-warning@+1{{undefining builtin macro}}
+#undef __TIMESTAMP__
+
+// expected-warning@+1{{macro 'Foo' has been marked as final and should not be undefined}}
+#undef Foo
+// expected-warning@+1{{macro 'Foo' has been marked as final and should not be redefined}}
+#define Foo 3
+
+// Test parse errors
+// expected-error@+1{{expected (}}
+#pragma clang final
+
+// expected-error@+1{{expected )}}
+#pragma clang final(Foo
+
+// expected-error@+1{{no macro named 'Baz'}}
+#pragma clang final(Baz)
+
+// expected-error@+1{{expected identifier}}
+#pragma clang final(4)
+
+// expected-error@+1{{expected (}}
+#pragma clang final Baz
Index: clang/test/Lexer/deprecate-macro.c
===
--- clang/test/Lexer/deprecate-macro.c
+++ clang/test/Lexer/deprecate-macro.c
@@ -6,7 +6,7 @@
 // expected-error@+1{{expected identifier}}
 #pragma clang deprecated(4
 
-// expected-error@+1{{no macro named foo}}
+// expected-error@+1{{no macro named 'foo'}}
 #pragma clang deprecated(foo)
 
 #define bar 1
@@ -48,7 +48,7 @@
 #endif
 
 int main(int argc, char** argv) {
-// expected-error@+1{{no macro named main}}
+// expected-error@+1{{no macro named 'main'}}
 #pragma clang deprecated(main)
 
   // expected-warning@+1{{macro 'foo' has been marked as deprecated}}
Index: clang/test/Lexer/Inputs/unsafe-macro.h
===
--- clang/test/Lexer/Inputs/unsafe-macro.h
+++ clang/test/Lexer/Inputs/unsafe-macro.h
@@ -4,7 +4,7 @@
 // expected-error@+1{{expected identifier}}
 #pragma clang restrict_expansion(4
 
-// expected-error@+1{{no macro named foo}}
+// expected-error@+1{{no macro named 'foo'}}
 #pragma clang restrict_expansion(foo)
 
 
Index: clang/test/Lexer/Inputs/final-macro.h
===
--- /dev/null
+++ clang/test/Lexer/Inputs/final-macro.h
@@ -0,0 +1,4 @@
+// expected-warning@+2{{macro 'Foo' has been marked as deprecated}}
+// expected-warning@+1{{macro 'Foo' has been marked as unsafe for use in headers}}
+#if Foo
+#endif
Index: clang/lib/Lex/Preprocessor.cpp
===
--- clang/lib/Lex/Preprocessor.cpp
+++ clang/lib/Lex/Preprocessor.cpp
@@ -1413,26 +1413,46 @@
   return true;
 }
 
-void Prep

[PATCH] D93298: [RISCV] add the MC layer support of Zfinx extension

2021-09-15 Thread Shao-Ce Sun via Phabricator via cfe-commits
achieveartificialintelligence updated this revision to Diff 372863.
achieveartificialintelligence added a comment.

support zfinx-1.0-rc


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93298

Files:
  llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
  llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp
  llvm/lib/Target/RISCV/RISCV.td
  llvm/lib/Target/RISCV/RISCVInstrInfo.td
  llvm/lib/Target/RISCV/RISCVInstrInfoZdinx.td
  llvm/lib/Target/RISCV/RISCVInstrInfoZfinx.td
  llvm/lib/Target/RISCV/RISCVInstrInfoZhinx.td
  llvm/lib/Target/RISCV/RISCVRegisterInfo.td
  llvm/lib/Target/RISCV/RISCVSubtarget.h
  llvm/test/MC/RISCV/rv32i-invalid.s
  llvm/test/MC/RISCV/rv32zdinx-invalid.s
  llvm/test/MC/RISCV/rv32zdinx-valid.s
  llvm/test/MC/RISCV/rv32zfinx-invalid.s
  llvm/test/MC/RISCV/rv32zfinx-valid.s
  llvm/test/MC/RISCV/rv32zhinx-invalid.s
  llvm/test/MC/RISCV/rv32zhinx-valid.s
  llvm/test/MC/RISCV/rv32zhinxmin-invalid.s
  llvm/test/MC/RISCV/rv32zhinxmin-valid.s
  llvm/test/MC/RISCV/rv64zdinx-invalid.s
  llvm/test/MC/RISCV/rv64zdinx-valid.s
  llvm/test/MC/RISCV/rv64zfinx-invalid.s
  llvm/test/MC/RISCV/rv64zfinx-valid.s
  llvm/test/MC/RISCV/rv64zhinx-invalid.s
  llvm/test/MC/RISCV/rv64zhinx-valid.s
  llvm/test/MC/RISCV/rv64zhinxmin-valid.s
  llvm/test/MC/RISCV/rvzfdinx-aliases-valid.s
  llvm/test/MC/RISCV/rvzfhinx-aliases-valid.s
  llvm/test/MC/RISCV/rvzfinx-aliases-valid.s

Index: llvm/test/MC/RISCV/rvzfinx-aliases-valid.s
===
--- /dev/null
+++ llvm/test/MC/RISCV/rvzfinx-aliases-valid.s
@@ -0,0 +1,82 @@
+# RUN: llvm-mc %s -triple=riscv32 -mattr=+experimental-zfinx -riscv-no-aliases \
+# RUN: | FileCheck -check-prefix=CHECK-INST %s
+# RUN: llvm-mc %s -triple=riscv32 -mattr=+experimental-zfinx \
+# RUN: | FileCheck -check-prefix=CHECK-ALIAS %s
+# RUN: llvm-mc %s -triple=riscv64 -mattr=+experimental-zfinx -riscv-no-aliases \
+# RUN: | FileCheck -check-prefix=CHECK-INST %s
+# RUN: llvm-mc %s -triple=riscv64 -mattr=+experimental-zfinx \
+# RUN: | FileCheck -check-prefix=CHECK-ALIAS %s
+# RUN: llvm-mc -filetype=obj -triple riscv32 -mattr=+experimental-zfinx < %s \
+# RUN: | llvm-objdump -d --mattr=+experimental-zfinx -M no-aliases - \
+# RUN: | FileCheck -check-prefix=CHECK-INST %s
+# RUN: llvm-mc -filetype=obj -triple riscv32 -mattr=+experimental-zfinx < %s \
+# RUN: | llvm-objdump -d --mattr=+experimental-zfinx - \
+# RUN: | FileCheck -check-prefix=CHECK-ALIAS %s
+# RUN: llvm-mc -filetype=obj -triple riscv64 -mattr=+experimental-zfinx < %s \
+# RUN: | llvm-objdump -d --mattr=+experimental-zfinx -M no-aliases - \
+# RUN: | FileCheck -check-prefix=CHECK-INST %s
+# RUN: llvm-mc -filetype=obj -triple riscv64 -mattr=+experimental-zfinx < %s \
+# RUN: | llvm-objdump -d --mattr=+experimental-zfinx - \
+# RUN: | FileCheck -check-prefix=CHECK-ALIAS %s
+
+##===--===##
+## Assembler Pseudo Instructions (User-Level ISA, Version 2.2, Chapter 20)
+##===--===##
+
+# CHECK-INST: fsgnjx.s s1, s2, s2
+# CHECK-ALIAS: fabs.s s1, s2
+fabs.s s1, s2
+# CHECK-INST: fsgnjn.s s2, s3, s3
+# CHECK-ALIAS: fneg.s s2, s3
+fneg.s s2, s3
+
+# CHECK-INST: flt.s tp, s6, s5
+# CHECK-ALIAS: flt.s tp, s6, s5
+fgt.s x4, s5, s6
+# CHECK-INST: fle.s t2, s1, s0
+# CHECK-ALIAS: fle.s t2, s1, s0
+fge.s x7, x8, x9
+
+##===--===##
+## Aliases which omit the rounding mode.
+##===--===##
+
+# CHECK-INST: fmadd.s a0, a1, a2, a3, dyn
+# CHECK-ALIAS: fmadd.s a0, a1, a2, a3{{[[:space:]]}}
+fmadd.s x10, x11, x12, x13
+# CHECK-INST: fmsub.s a4, a5, a6, a7, dyn
+# CHECK-ALIAS: fmsub.s a4, a5, a6, a7{{[[:space:]]}}
+fmsub.s x14, x15, x16, x17
+# CHECK-INST: fnmsub.s s2, s3, s4, s5, dyn
+# CHECK-ALIAS: fnmsub.s s2, s3, s4, s5{{[[:space:]]}}
+fnmsub.s x18, x19, x20, x21
+# CHECK-INST: fnmadd.s s6, s7, s8, s9, dyn
+# CHECK-ALIAS: fnmadd.s s6, s7, s8, s9{{[[:space:]]}}
+fnmadd.s x22, x23, x24, x25
+# CHECK-INST: fadd.s s10, s11, t3, dyn
+# CHECK-ALIAS: fadd.s s10, s11, t3{{[[:space:]]}}
+fadd.s x26, x27, x28
+# CHECK-INST: fsub.s t4, t5, t6, dyn
+# CHECK-ALIAS: fsub.s t4, t5, t6{{[[:space:]]}}
+fsub.s x29, x30, x31
+# CHECK-INST: fmul.s s0, s1, s2, dyn
+# CHECK-ALIAS: fmul.s s0, s1, s2{{[[:space:]]}}
+fmul.s s0, s1, s2
+# CHECK-INST: fdiv.s s3, s4, s5, dyn
+# CHECK-ALIAS: fdiv.s s3, s4, s5{{[[:space:]]}}
+fdiv.s s3, s4, s5
+# CHECK-INST: sqrt.s s6, s7, dyn
+# CHECK-ALIAS: sqrt.s s6, s7{{[[:space:]]}}
+fsqrt.s s6, s7
+# CHECK-INST: fcvt.w.s a0, s5, dyn
+# CHECK-ALIAS: fcvt.w.s a0, s5{{[[:space:]]}}
+fcvt.w.s a0, s5
+# CHECK-INST: fcvt.wu.s a1, s6, dyn
+# CHECK-ALIAS: fcvt.wu.s a1, s6{{[[:space:]]}}
+fcvt.wu.s a

[PATCH] D108621: [HIPSPV] Add CUDA->SPIR-V address space mapping

2021-09-15 Thread Henry Linjamäki via Phabricator via cfe-commits
linjamaki marked an inline comment as done.
linjamaki added inline comments.



Comment at: clang/lib/Basic/Targets/SPIR.h:59
+// translation). This mapping is enabled when the language mode is HIP.
+1, // cuda_device
+// cuda_constant pointer can be casted to default/"flat" pointer, but in

bader wrote:
> keryell wrote:
> > Anastasia wrote:
> > > bader wrote:
> > > > Anastasia wrote:
> > > > > I am slightly confused as in the LLVM project those address spaces 
> > > > > are for SPIR not SPIR-V though. It is however used outside of LLVM 
> > > > > project by some tools like SPIRV-LLVM Translator as a path to SPIR-V, 
> > > > > but it has only been done as a workaround since we had no SPIR-V 
> > > > > support in the LLVM project yet. And if we are adding it let's do it 
> > > > > clean to avoid/resolve any confusion.
> > > > > 
> > > > > I think we need to keep both because some vendors do target/use SPIR 
> > > > > but not SPIR-V.
> > > > > 
> > > > > So if you are interested in SPIR-V and not SPIR you should probably 
> > > > > add a new target that will make things cleaner.
> > > > > I think we need to keep both because some vendors do target/use SPIR 
> > > > > but not SPIR-V.
> > > > 
> > > > @Anastasia, could you elaborate more on the difference between SPIR and 
> > > > SPIR-V?
> > > > I would like to understand what these terms mean in the context of LLVM 
> > > > project.
> > > Their conceptual differences are just that they are two different 
> > > intermediate formats.
> > > 
> > > The important thing to highlight is that it is not impossible that some 
> > > vendors use SPIR (without using SPIR-V) even despite the fact it has been 
> > > discontinued by Khronos. 
> > > 
> > > Nobody has deprecated or discontinued SPIR in the LLVM project yet.
> > > Their conceptual differences are just that they are two different 
> > > intermediate formats.
> > > 
> > > The important thing to highlight is that it is not impossible that some 
> > > vendors use SPIR (without using SPIR-V) even despite the fact it has been 
> > > discontinued by Khronos. 
> > > 
> > > Nobody has deprecated or discontinued SPIR in the LLVM project yet.
> > 
> > All the official Xilinx OpenCL stack is based on legacy SPIR (encoded in 
> > LLVM 6.x IR but this is another story) and I suspect this is the case for 
> > other companies.
> > So, do not deprecate or discontinue, please. :-)
> > The important thing to highlight is that it is not impossible that some 
> > vendors use SPIR (without using SPIR-V) even despite the fact it has been 
> > discontinued by Khronos.
> > Nobody has deprecated or discontinued SPIR in the LLVM project yet.
> 
> Strictly speaking `SPIR` is not defined as an intermediate language. Khronos 
> defines `SPIR-1.2` and `SPIR-2.0` formats which are based on LLVM 3.2 and 
> LLVM 3.4 version (https://www.khronos.org/spir/). There is no definition of 
> SPIR format based on current version of LLVM IR. Another note is that 
> metadata and intrinsics emitted for OpenCL with clang-14 doesn't follow 
> neither `SPIR-1.2` nor `SPIR-2.0`.
> 
> I always think of LLVM IR as leaving thing that is subject to change by LLVM 
> community, so tools working with LLVM IR must adjust to the particular 
> version (e.g. release version like LLVM 13 or ToT). We apply this logic to 
> SPIRV-LLVM-Translator tool and update it according to LLVM format changes 
> (e.g. kernel argument information defined in Khronos spec must be named 
> metadata whereas clang emits function metadata).
> 
> > I am slightly confused as in the LLVM project those address spaces are for 
> > SPIR not SPIR-V though.
> [skip]
> > Their conceptual differences are just that they are two different 
> > intermediate formats.
> 
> If this is the only difference, I don't think it a good idea to create 
> another LLVM target to separate SPIR and SPIR-V. From my point of view it 
> creates logic ambiguity and code duplication with no additional value. 
> @Anastasia, what problems do you see if we continue treating LLVM IR with 
> spir* target triple as LLVM IR representation of SPIR-V format?
The state of SPIR 1.2/2.0 in Clang seems to be that the SPIR target has 
transformed to mean “SPIR 1.2/2.0 derivative”, but that does not still make it 
SPIR-V, which is not based on LLVM IR. When one is targeting spir* there is 
ambiguity on whether one is aiming to produce the old-SPIR-derivative or 
SPIR-V. Considering that there are still SPIR-derivative consumers, in my 
opinion we should have separate LLVM targets for SPIR-V to have explicit 
disambiguation of intent for producing the SPIR-derivative vs SPIR-V.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108621

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


[PATCH] D93298: [RISCV] add the MC layer support of Zfinx extension

2021-09-15 Thread Shao-Ce Sun via Phabricator via cfe-commits
achieveartificialintelligence updated this revision to Diff 372866.
achieveartificialintelligence added a comment.

Updating D93298 : [RISCV] add the MC layer 
support of Zfinx extension


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93298

Files:
  llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
  llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp
  llvm/lib/Target/RISCV/RISCV.td
  llvm/lib/Target/RISCV/RISCVInstrInfo.td
  llvm/lib/Target/RISCV/RISCVInstrInfoZdinx.td
  llvm/lib/Target/RISCV/RISCVInstrInfoZfinx.td
  llvm/lib/Target/RISCV/RISCVInstrInfoZhinx.td
  llvm/lib/Target/RISCV/RISCVRegisterInfo.td
  llvm/lib/Target/RISCV/RISCVSubtarget.h
  llvm/test/MC/RISCV/rv32i-invalid.s
  llvm/test/MC/RISCV/rv32zdinx-invalid.s
  llvm/test/MC/RISCV/rv32zdinx-valid.s
  llvm/test/MC/RISCV/rv32zfinx-invalid.s
  llvm/test/MC/RISCV/rv32zfinx-valid.s
  llvm/test/MC/RISCV/rv32zhinx-invalid.s
  llvm/test/MC/RISCV/rv32zhinx-valid.s
  llvm/test/MC/RISCV/rv32zhinxmin-invalid.s
  llvm/test/MC/RISCV/rv32zhinxmin-valid.s
  llvm/test/MC/RISCV/rv64zdinx-invalid.s
  llvm/test/MC/RISCV/rv64zdinx-valid.s
  llvm/test/MC/RISCV/rv64zfinx-invalid.s
  llvm/test/MC/RISCV/rv64zfinx-valid.s
  llvm/test/MC/RISCV/rv64zhinx-invalid.s
  llvm/test/MC/RISCV/rv64zhinx-valid.s
  llvm/test/MC/RISCV/rv64zhinxmin-valid.s
  llvm/test/MC/RISCV/rvzdinx-aliases-valid.s
  llvm/test/MC/RISCV/rvzfinx-aliases-valid.s
  llvm/test/MC/RISCV/rvzhinx-aliases-valid.s

Index: llvm/test/MC/RISCV/rvzhinx-aliases-valid.s
===
--- /dev/null
+++ llvm/test/MC/RISCV/rvzhinx-aliases-valid.s
@@ -0,0 +1,83 @@
+# RUN: llvm-mc %s -triple=riscv32 -mattr=+experimental-zhinx -riscv-no-aliases \
+# RUN: | FileCheck -check-prefix=CHECK-INST %s
+# RUN: llvm-mc %s -triple=riscv32 -mattr=+experimental-zhinx \
+# RUN: | FileCheck -check-prefix=CHECK-ALIAS %s
+# RUN: llvm-mc %s -triple=riscv64 -mattr=+experimental-zhinx -riscv-no-aliases \
+# RUN: | FileCheck -check-prefix=CHECK-INST %s
+# RUN: llvm-mc %s -triple=riscv64 -mattr=+experimental-zhinx \
+# RUN: | FileCheck -check-prefix=CHECK-ALIAS %s
+# RUN: llvm-mc -filetype=obj -triple riscv32 -mattr=+experimental-zhinx < %s \
+# RUN: | llvm-objdump -d --mattr=+experimental-zhinx -M no-aliases - \
+# RUN: | FileCheck -check-prefix=CHECK-INST %s
+# RUN: llvm-mc -filetype=obj -triple riscv32 -mattr=+experimental-zhinx < %s \
+# RUN: | llvm-objdump -d --mattr=+experimental-zhinx - \
+# RUN: | FileCheck -check-prefix=CHECK-ALIAS %s
+# RUN: llvm-mc -filetype=obj -triple riscv64 -mattr=+experimental-zhinx < %s \
+# RUN: | llvm-objdump -d --mattr=+experimental-zhinx -M no-aliases - \
+# RUN: | FileCheck -check-prefix=CHECK-INST %s
+# RUN: llvm-mc -filetype=obj -triple riscv64 -mattr=+experimental-zhinx < %s \
+# RUN: | llvm-objdump -d --mattr=+experimental-zhinx - \
+# RUN: | FileCheck -check-prefix=CHECK-ALIAS %s
+
+##===--===##
+## Assembler Pseudo Instructions (User-Level ISA, Version 2.2, Chapter 20)
+##===--===##
+
+# CHECK-INST: fsgnjx.h s1, s2, s2
+# CHECK-ALIAS: fabs.h s1, s2
+fabs.h s1, s2
+# CHECK-INST: fsgnjn.h s2, s3, s3
+# CHECK-ALIAS: fneg.h s2, s3
+fneg.h s2, s3
+
+# CHECK-INST: flt.h tp, s6, s5
+# CHECK-ALIAS: flt.h tp, s6, s5
+fgt.h x4, s5, s6
+# CHECK-INST: fle.h t2, s1, s0
+# CHECK-ALIAS: fle.h t2, s1, s0
+fge.h x7, x8, x9
+
+
+##===--===##
+## Aliases which omit the rounding mode.
+##===--===##
+
+# CHECK-INST: fmadd.h a0, a1, a2, a3, dyn
+# CHECK-ALIAS: fmadd.h a0, a1, a2, a3{{[[:space:]]}}
+fmadd.h x10, x11, x12, x13
+# CHECK-INST: fmsub.h a4, a5, a6, a7, dyn
+# CHECK-ALIAS: fmsub.h a4, a5, a6, a7{{[[:space:]]}}
+fmsub.h x14, x15, x16, x17
+# CHECK-INST: fnmsub.h s2, s3, s4, s5, dyn
+# CHECK-ALIAS: fnmsub.h s2, s3, s4, s5{{[[:space:]]}}
+fnmsub.h x18, x19, x20, x21
+# CHECK-INST: fnmadd.h s6, s7, s8, s9, dyn
+# CHECK-ALIAS: fnmadd.h s6, s7, s8, s9{{[[:space:]]}}
+fnmadd.h x22, x23, x24, x25
+# CHECK-INST: fadd.h s10, s11, t3, dyn
+# CHECK-ALIAS: fadd.h s10, s11, t3{{[[:space:]]}}
+fadd.h x26, x27, x28
+# CHECK-INST: fsub.h t4, t5, t6, dyn
+# CHECK-ALIAS: fsub.h t4, t5, t6{{[[:space:]]}}
+fsub.h x29, x30, x31
+# CHECK-INST: fmul.h s0, s1, s2, dyn
+# CHECK-ALIAS: fmul.h s0, s1, s2{{[[:space:]]}}
+fmul.h s0, s1, s2
+# CHECK-INST: fdiv.h s3, s4, s5, dyn
+# CHECK-ALIAS: fdiv.h s3, s4, s5{{[[:space:]]}}
+fdiv.h s3, s4, s5
+# CHECK-INST: fsqrt.h s6, s7, dyn
+# CHECK-ALIAS: fsqrt.h s6, s7{{[[:space:]]}}
+fsqrt.h s6, s7
+# CHECK-INST: fcvt.w.h a0, s5, dyn
+# CHECK-ALIAS: fcvt.w.h a0, s5{{[[:space:]]}}
+fcvt.w.h a0, s5
+# CHECK-INS

[PATCH] D106804: [test-suite] Add tests for FP classification intrinsics

2021-09-15 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff added a comment.

If nobody objects, I would commit this change, as it would be useful in the 
forthcoming return of `llvm.isnan`.


Repository:
  rT test-suite

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

https://reviews.llvm.org/D106804

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


[clang] 1f1c71a - [X86][InlineAsm] Use mem size information (*word ptr) for "global variable + registers" memory expression in inline asm.

2021-09-15 Thread Xiang1 Zhang via cfe-commits

Author: Xiang1 Zhang
Date: 2021-09-15T16:11:14+08:00
New Revision: 1f1c71aeacc1c4eab385c074714508b6e7121f73

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

LOG: [X86][InlineAsm] Use mem size information (*word ptr) for "global variable 
+ registers" memory expression in inline asm.

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

Added: 
clang/test/CodeGen/X86/ms_fmul.c

Modified: 
llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp

Removed: 




diff  --git a/clang/test/CodeGen/X86/ms_fmul.c 
b/clang/test/CodeGen/X86/ms_fmul.c
new file mode 100644
index ..a0a1be9e217c
--- /dev/null
+++ b/clang/test/CodeGen/X86/ms_fmul.c
@@ -0,0 +1,21 @@
+// REQUIRES: x86-registered-target
+
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fasm-blocks -emit-llvm %s 
-o - | FileCheck %s
+// RUN: %clang_cc1 -triple i386-unknown-unknown -fasm-blocks -emit-llvm %s -o 
- | FileCheck %s
+
+// This test is designed to check if we use the mem size info for parsing MS
+// InlineAsm which use a global variable and one/two registers in a memory
+// expression. If we not use this mem size info, there will be error of
+// ambiguous operand size for some instructions. (e.g. 'fmul')
+__attribute__((aligned (16)))
+static const unsigned int static_const_table[] = { 0x0080, };
+
+
+void __attribute__ ((naked)) foo(void)
+{__asm{
+fmul qword ptr [static_const_table + 0x00f0 +edx]
+ret
+}}
+
+// CHECK-LABEL: foo
+// CHECK: call void asm sideeffect inteldialect "fmul qword ptr 
static_const_table[edx + $$240]\0A\09ret"

diff  --git a/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp 
b/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
index d96a6be5d92e..f849ebfe76e2 100644
--- a/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
+++ b/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
@@ -1759,7 +1759,7 @@ bool X86AsmParser::CreateMemForMSInlineAsm(
   // registers in a mmory expression, and though unaccessible via rip/eip.
   if (IsGlobalLV && (BaseReg || IndexReg)) {
 Operands.push_back(
-X86Operand::CreateMem(getPointerWidth(), Disp, Start, End));
+X86Operand::CreateMem(getPointerWidth(), Disp, Start, End, Size));
 return false;
   }
   // Otherwise, we set the base register to a non-zero value



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


[PATCH] D109739: [X86][InlineAsm][Bugfix] Use mem size information (*word ptr) for "global variable + registers" memory expression in inline asm.

2021-09-15 Thread Xiang Zhang via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG1f1c71aeacc1: [X86][InlineAsm] Use mem size information 
(*word ptr) for "global variable +… (authored by xiangzhangllvm).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109739

Files:
  clang/test/CodeGen/X86/ms_fmul.c
  llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp


Index: llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
===
--- llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
+++ llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
@@ -1759,7 +1759,7 @@
   // registers in a mmory expression, and though unaccessible via rip/eip.
   if (IsGlobalLV && (BaseReg || IndexReg)) {
 Operands.push_back(
-X86Operand::CreateMem(getPointerWidth(), Disp, Start, End));
+X86Operand::CreateMem(getPointerWidth(), Disp, Start, End, Size));
 return false;
   }
   // Otherwise, we set the base register to a non-zero value
Index: clang/test/CodeGen/X86/ms_fmul.c
===
--- /dev/null
+++ clang/test/CodeGen/X86/ms_fmul.c
@@ -0,0 +1,21 @@
+// REQUIRES: x86-registered-target
+
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fasm-blocks -emit-llvm %s 
-o - | FileCheck %s
+// RUN: %clang_cc1 -triple i386-unknown-unknown -fasm-blocks -emit-llvm %s -o 
- | FileCheck %s
+
+// This test is designed to check if we use the mem size info for parsing MS
+// InlineAsm which use a global variable and one/two registers in a memory
+// expression. If we not use this mem size info, there will be error of
+// ambiguous operand size for some instructions. (e.g. 'fmul')
+__attribute__((aligned (16)))
+static const unsigned int static_const_table[] = { 0x0080, };
+
+
+void __attribute__ ((naked)) foo(void)
+{__asm{
+fmul qword ptr [static_const_table + 0x00f0 +edx]
+ret
+}}
+
+// CHECK-LABEL: foo
+// CHECK: call void asm sideeffect inteldialect "fmul qword ptr 
static_const_table[edx + $$240]\0A\09ret"


Index: llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
===
--- llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
+++ llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
@@ -1759,7 +1759,7 @@
   // registers in a mmory expression, and though unaccessible via rip/eip.
   if (IsGlobalLV && (BaseReg || IndexReg)) {
 Operands.push_back(
-X86Operand::CreateMem(getPointerWidth(), Disp, Start, End));
+X86Operand::CreateMem(getPointerWidth(), Disp, Start, End, Size));
 return false;
   }
   // Otherwise, we set the base register to a non-zero value
Index: clang/test/CodeGen/X86/ms_fmul.c
===
--- /dev/null
+++ clang/test/CodeGen/X86/ms_fmul.c
@@ -0,0 +1,21 @@
+// REQUIRES: x86-registered-target
+
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fasm-blocks -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -triple i386-unknown-unknown -fasm-blocks -emit-llvm %s -o - | FileCheck %s
+
+// This test is designed to check if we use the mem size info for parsing MS
+// InlineAsm which use a global variable and one/two registers in a memory
+// expression. If we not use this mem size info, there will be error of
+// ambiguous operand size for some instructions. (e.g. 'fmul')
+__attribute__((aligned (16)))
+static const unsigned int static_const_table[] = { 0x0080, };
+
+
+void __attribute__ ((naked)) foo(void)
+{__asm{
+fmul qword ptr [static_const_table + 0x00f0 +edx]
+ret
+}}
+
+// CHECK-LABEL: foo
+// CHECK: call void asm sideeffect inteldialect "fmul qword ptr static_const_table[edx + $$240]\0A\09ret"
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D109812: [compiler-rt] Move -fno-omit-frame-pointer check to common config-ix

2021-09-15 Thread Michał Górny via Phabricator via cfe-commits
mgorny created this revision.
mgorny added reviewers: tstellar, cryptoad.
Herald added a subscriber: dberris.
mgorny requested review of this revision.

9ee64c374605683ae80b9641d5312a72c2a67336 
 has 
started using
COMPILER_RT_HAS_OMIT_FRAME_POINTER_FLAG inside scudo.  However,
the relevant CMake check was performed in builtin-config-ix.cmake,
so the definition was missing when builtins were not built.  Move
the check to config-ix.cmake, so that it runs unconditionally of
the components being built.

Fixes PR#51847


https://reviews.llvm.org/D109812

Files:
  compiler-rt/cmake/builtin-config-ix.cmake
  compiler-rt/cmake/config-ix.cmake


Index: compiler-rt/cmake/config-ix.cmake
===
--- compiler-rt/cmake/config-ix.cmake
+++ compiler-rt/cmake/config-ix.cmake
@@ -61,6 +61,7 @@
 
 # CodeGen options.
 check_c_compiler_flag(-ffreestanding 
COMPILER_RT_HAS_FFREESTANDING_FLAG)
+check_c_compiler_flag(-fomit-frame-pointer   
COMPILER_RT_HAS_OMIT_FRAME_POINTER_FLAG)
 check_c_compiler_flag(-std=c11   COMPILER_RT_HAS_STD_C11_FLAG)
 check_cxx_compiler_flag(-fPICCOMPILER_RT_HAS_FPIC_FLAG)
 check_cxx_compiler_flag(-fPIECOMPILER_RT_HAS_FPIE_FLAG)
Index: compiler-rt/cmake/builtin-config-ix.cmake
===
--- compiler-rt/cmake/builtin-config-ix.cmake
+++ compiler-rt/cmake/builtin-config-ix.cmake
@@ -10,7 +10,6 @@
 builtin_check_c_compiler_flag(-fno-builtin  
COMPILER_RT_HAS_FNO_BUILTIN_FLAG)
 builtin_check_c_compiler_flag(-std=c11  
COMPILER_RT_HAS_STD_C11_FLAG)
 builtin_check_c_compiler_flag(-fvisibility=hidden   
COMPILER_RT_HAS_VISIBILITY_HIDDEN_FLAG)
-builtin_check_c_compiler_flag(-fomit-frame-pointer  
COMPILER_RT_HAS_OMIT_FRAME_POINTER_FLAG)
 builtin_check_c_compiler_flag(-ffreestanding
COMPILER_RT_HAS_FREESTANDING_FLAG)
 builtin_check_c_compiler_flag(-fxray-instrument 
COMPILER_RT_HAS_XRAY_COMPILER_FLAG)
 


Index: compiler-rt/cmake/config-ix.cmake
===
--- compiler-rt/cmake/config-ix.cmake
+++ compiler-rt/cmake/config-ix.cmake
@@ -61,6 +61,7 @@
 
 # CodeGen options.
 check_c_compiler_flag(-ffreestanding COMPILER_RT_HAS_FFREESTANDING_FLAG)
+check_c_compiler_flag(-fomit-frame-pointer   COMPILER_RT_HAS_OMIT_FRAME_POINTER_FLAG)
 check_c_compiler_flag(-std=c11   COMPILER_RT_HAS_STD_C11_FLAG)
 check_cxx_compiler_flag(-fPICCOMPILER_RT_HAS_FPIC_FLAG)
 check_cxx_compiler_flag(-fPIECOMPILER_RT_HAS_FPIE_FLAG)
Index: compiler-rt/cmake/builtin-config-ix.cmake
===
--- compiler-rt/cmake/builtin-config-ix.cmake
+++ compiler-rt/cmake/builtin-config-ix.cmake
@@ -10,7 +10,6 @@
 builtin_check_c_compiler_flag(-fno-builtin  COMPILER_RT_HAS_FNO_BUILTIN_FLAG)
 builtin_check_c_compiler_flag(-std=c11  COMPILER_RT_HAS_STD_C11_FLAG)
 builtin_check_c_compiler_flag(-fvisibility=hidden   COMPILER_RT_HAS_VISIBILITY_HIDDEN_FLAG)
-builtin_check_c_compiler_flag(-fomit-frame-pointer  COMPILER_RT_HAS_OMIT_FRAME_POINTER_FLAG)
 builtin_check_c_compiler_flag(-ffreestandingCOMPILER_RT_HAS_FREESTANDING_FLAG)
 builtin_check_c_compiler_flag(-fxray-instrument COMPILER_RT_HAS_XRAY_COMPILER_FLAG)
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D109607: [X86] Refactor GetSSETypeAtOffset to fix pr51813

2021-09-15 Thread LuoYuanke via Phabricator via cfe-commits
LuoYuanke added inline comments.



Comment at: clang/lib/CodeGen/TargetInfo.cpp:3421
+if (T0->isHalfTy())
+  T1 = getFPTypeAtOffset(IRType, IROffset + 4, TD);
+// If we can't get a second FP type, return a simple half or float.

Not quite understanding why "+4". Would you comments on it?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109607

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


[PATCH] D109607: [X86] Refactor GetSSETypeAtOffset to fix pr51813

2021-09-15 Thread LuoYuanke via Phabricator via cfe-commits
LuoYuanke added inline comments.



Comment at: clang/test/CodeGen/X86/avx512fp16-abi.c:153
+struct float2 {
+  struct {} s;
+  float a;

Add a test case for "{ struct {}; half; struct {}; half;}?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109607

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


[PATCH] D109362: [SystemZ][z/OS] Add GOFF Support to the DataLayout

2021-09-15 Thread Ulrich Weigand via Phabricator via cfe-commits
uweigand added a comment.

In D109362#3000284 , @anirudhp wrote:

> In D109362#2999688 , @uweigand 
> wrote:
>
>> Looking at the common code parts, it seems the behavior of MM_GOFF is 
>> actually identical to MM_ELF.   Is this correct?   If so, do we really need 
>> a different format type here?
>
> At a future point, we will be changing the local and global prefixes. At that 
> point we would still need a separate `MM_GOFF` field. I feel it would be a 
> bit better to enforce it from now itself.

I see.  Is there a reason why we cannot use the "correct" prefixes to begin 
with?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109362

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


[clang] 3b9470a - [OpenCL] Supports optional image types in C++ for OpenCL 2021

2021-09-15 Thread Justas Janickas via cfe-commits

Author: Justas Janickas
Date: 2021-09-15T10:03:47+01:00
New Revision: 3b9470a6c46d0ecdb586a5a1e9223ea0c832337c

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

LOG: [OpenCL] Supports optional image types in C++ for OpenCL 2021

Adds support for a feature macro `__opencl_c_images` in C++ for
OpenCL 2021 enabling a respective optional core feature from
OpenCL 3.0.

This change aims to achieve compatibility between C++ for OpenCL
2021 and OpenCL 3.0.

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

Added: 


Modified: 
clang/lib/Sema/SemaType.cpp
clang/test/SemaOpenCL/unsupported-image.cl

Removed: 




diff  --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp
index dcf18d3b4ba3d..f7f428c1e6d8d 100644
--- a/clang/lib/Sema/SemaType.cpp
+++ b/clang/lib/Sema/SemaType.cpp
@@ -1732,7 +1732,12 @@ static QualType 
ConvertDeclSpecToType(TypeProcessingState &state) {
 
   if (S.getLangOpts().OpenCL) {
 const auto &OpenCLOptions = S.getOpenCLOptions();
+// FIXME: both variables IsOpenCLC30 and IsOpenCLC30Compatible should be
+// unified into one when __opencl_c_3d_image_writes option is enabled in
+// C++ for OpenCL 2021
 bool IsOpenCLC30 = (S.getLangOpts().OpenCLVersion == 300);
+bool IsOpenCLC30Compatible =
+S.getLangOpts().getOpenCLCompatibleVersion() == 300;
 // OpenCL C v3.0 s6.3.3 - OpenCL image types require __opencl_c_images
 // support.
 // OpenCL C v3.0 s6.2.1 - OpenCL 3d image write types requires support
@@ -1741,7 +1746,7 @@ static QualType ConvertDeclSpecToType(TypeProcessingState 
&state) {
 // that support OpenCL 3.0, cl_khr_3d_image_writes must be returned when 
and
 // only when the optional feature is supported
 if ((Result->isImageType() || Result->isSamplerT()) &&
-(IsOpenCLC30 &&
+(IsOpenCLC30Compatible &&
  !OpenCLOptions.isSupported("__opencl_c_images", S.getLangOpts( {
   S.Diag(DS.getTypeSpecTypeLoc(), diag::err_opencl_requires_extension)
   << 0 << Result << "__opencl_c_images";

diff  --git a/clang/test/SemaOpenCL/unsupported-image.cl 
b/clang/test/SemaOpenCL/unsupported-image.cl
index 40772460e54d1..8db3f61b0146b 100644
--- a/clang/test/SemaOpenCL/unsupported-image.cl
+++ b/clang/test/SemaOpenCL/unsupported-image.cl
@@ -1,6 +1,8 @@
 // RUN: %clang_cc1 -triple spir-unknown-unknown -verify -cl-std=CL3.0 
-cl-ext=-__opencl_c_images,-__opencl_c_read_write_images,-cl_khr_3d_image_writes,-__opencl_c_3d_image_writes
 %s
 // RUN: %clang_cc1 -triple spir-unknown-unknown -verify -cl-std=CL3.0 
-cl-ext=+__opencl_c_images,+__opencl_c_read_write_images,+cl_khr_3d_image_writes,+__opencl_c_3d_image_writes
 %s
 // RUN: %clang_cc1 -triple spir-unknown-unknown -verify -cl-std=CL3.0 
-cl-ext=+__opencl_c_images,+__opencl_c_read_write_images,-cl_khr_3d_image_writes,-__opencl_c_3d_image_writes
 %s
+// RUN: %clang_cc1 -triple spir-unknown-unknown -verify -cl-std=clc++2021 
-cl-ext=-__opencl_c_images,-__opencl_c_read_write_images,-cl_khr_3d_image_writes,-__opencl_c_3d_image_writes
 %s
+// RUN: %clang_cc1 -triple spir-unknown-unknown -verify -cl-std=clc++2021 
-cl-ext=+__opencl_c_images %s
 
 #if defined(__opencl_c_images) && defined(__opencl_c_3d_image_writes)
 //expected-no-diagnostics



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


[PATCH] D109002: [OpenCL] Supports optional image types in C++ for OpenCL 2021

2021-09-15 Thread Justas Janickas via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Topotuna marked an inline comment as done.
Closed by commit rG3b9470a6c46d: [OpenCL] Supports optional image types in C++ 
for OpenCL 2021 (authored by Topotuna).

Changed prior to commit:
  https://reviews.llvm.org/D109002?vs=370237&id=372662#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109002

Files:
  clang/lib/Sema/SemaType.cpp
  clang/test/SemaOpenCL/unsupported-image.cl


Index: clang/test/SemaOpenCL/unsupported-image.cl
===
--- clang/test/SemaOpenCL/unsupported-image.cl
+++ clang/test/SemaOpenCL/unsupported-image.cl
@@ -1,6 +1,8 @@
 // RUN: %clang_cc1 -triple spir-unknown-unknown -verify -cl-std=CL3.0 
-cl-ext=-__opencl_c_images,-__opencl_c_read_write_images,-cl_khr_3d_image_writes,-__opencl_c_3d_image_writes
 %s
 // RUN: %clang_cc1 -triple spir-unknown-unknown -verify -cl-std=CL3.0 
-cl-ext=+__opencl_c_images,+__opencl_c_read_write_images,+cl_khr_3d_image_writes,+__opencl_c_3d_image_writes
 %s
 // RUN: %clang_cc1 -triple spir-unknown-unknown -verify -cl-std=CL3.0 
-cl-ext=+__opencl_c_images,+__opencl_c_read_write_images,-cl_khr_3d_image_writes,-__opencl_c_3d_image_writes
 %s
+// RUN: %clang_cc1 -triple spir-unknown-unknown -verify -cl-std=clc++2021 
-cl-ext=-__opencl_c_images,-__opencl_c_read_write_images,-cl_khr_3d_image_writes,-__opencl_c_3d_image_writes
 %s
+// RUN: %clang_cc1 -triple spir-unknown-unknown -verify -cl-std=clc++2021 
-cl-ext=+__opencl_c_images %s
 
 #if defined(__opencl_c_images) && defined(__opencl_c_3d_image_writes)
 //expected-no-diagnostics
Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -1732,7 +1732,12 @@
 
   if (S.getLangOpts().OpenCL) {
 const auto &OpenCLOptions = S.getOpenCLOptions();
+// FIXME: both variables IsOpenCLC30 and IsOpenCLC30Compatible should be
+// unified into one when __opencl_c_3d_image_writes option is enabled in
+// C++ for OpenCL 2021
 bool IsOpenCLC30 = (S.getLangOpts().OpenCLVersion == 300);
+bool IsOpenCLC30Compatible =
+S.getLangOpts().getOpenCLCompatibleVersion() == 300;
 // OpenCL C v3.0 s6.3.3 - OpenCL image types require __opencl_c_images
 // support.
 // OpenCL C v3.0 s6.2.1 - OpenCL 3d image write types requires support
@@ -1741,7 +1746,7 @@
 // that support OpenCL 3.0, cl_khr_3d_image_writes must be returned when 
and
 // only when the optional feature is supported
 if ((Result->isImageType() || Result->isSamplerT()) &&
-(IsOpenCLC30 &&
+(IsOpenCLC30Compatible &&
  !OpenCLOptions.isSupported("__opencl_c_images", S.getLangOpts( {
   S.Diag(DS.getTypeSpecTypeLoc(), diag::err_opencl_requires_extension)
   << 0 << Result << "__opencl_c_images";


Index: clang/test/SemaOpenCL/unsupported-image.cl
===
--- clang/test/SemaOpenCL/unsupported-image.cl
+++ clang/test/SemaOpenCL/unsupported-image.cl
@@ -1,6 +1,8 @@
 // RUN: %clang_cc1 -triple spir-unknown-unknown -verify -cl-std=CL3.0 -cl-ext=-__opencl_c_images,-__opencl_c_read_write_images,-cl_khr_3d_image_writes,-__opencl_c_3d_image_writes %s
 // RUN: %clang_cc1 -triple spir-unknown-unknown -verify -cl-std=CL3.0 -cl-ext=+__opencl_c_images,+__opencl_c_read_write_images,+cl_khr_3d_image_writes,+__opencl_c_3d_image_writes %s
 // RUN: %clang_cc1 -triple spir-unknown-unknown -verify -cl-std=CL3.0 -cl-ext=+__opencl_c_images,+__opencl_c_read_write_images,-cl_khr_3d_image_writes,-__opencl_c_3d_image_writes %s
+// RUN: %clang_cc1 -triple spir-unknown-unknown -verify -cl-std=clc++2021 -cl-ext=-__opencl_c_images,-__opencl_c_read_write_images,-cl_khr_3d_image_writes,-__opencl_c_3d_image_writes %s
+// RUN: %clang_cc1 -triple spir-unknown-unknown -verify -cl-std=clc++2021 -cl-ext=+__opencl_c_images %s
 
 #if defined(__opencl_c_images) && defined(__opencl_c_3d_image_writes)
 //expected-no-diagnostics
Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -1732,7 +1732,12 @@
 
   if (S.getLangOpts().OpenCL) {
 const auto &OpenCLOptions = S.getOpenCLOptions();
+// FIXME: both variables IsOpenCLC30 and IsOpenCLC30Compatible should be
+// unified into one when __opencl_c_3d_image_writes option is enabled in
+// C++ for OpenCL 2021
 bool IsOpenCLC30 = (S.getLangOpts().OpenCLVersion == 300);
+bool IsOpenCLC30Compatible =
+S.getLangOpts().getOpenCLCompatibleVersion() == 300;
 // OpenCL C v3.0 s6.3.3 - OpenCL image types require __opencl_c_images
 // support.
 // OpenCL C v3.0 s6.2.1 - OpenCL 3d image write ty

[PATCH] D109607: [X86] Refactor GetSSETypeAtOffset to fix pr51813

2021-09-15 Thread Pengfei Wang via Phabricator via cfe-commits
pengfei updated this revision to Diff 372664.
pengfei marked 2 inline comments as done.
pengfei added a comment.

Address Yuanke's comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109607

Files:
  clang/lib/CodeGen/TargetInfo.cpp
  clang/test/CodeGen/X86/avx512fp16-abi.c

Index: clang/test/CodeGen/X86/avx512fp16-abi.c
===
--- clang/test/CodeGen/X86/avx512fp16-abi.c
+++ clang/test/CodeGen/X86/avx512fp16-abi.c
@@ -1,11 +1,12 @@
-// RUN: %clang_cc1 -triple x86_64-linux -emit-llvm  -target-feature +avx512fp16 < %s | FileCheck %s --check-prefixes=CHECK
+// RUN: %clang_cc1 -triple x86_64-linux -emit-llvm  -target-feature +avx512fp16 < %s | FileCheck %s --check-prefixes=CHECK,CHECK-C
+// RUN: %clang_cc1 -triple x86_64-linux -emit-llvm  -target-feature +avx512fp16 -x c++ -std=c++11 < %s | FileCheck %s --check-prefixes=CHECK,CHECK-CPP
 
 struct half1 {
   _Float16 a;
 };
 
 struct half1 h1(_Float16 a) {
-  // CHECK: define{{.*}}half @h1
+  // CHECK: define{{.*}}half @
   struct half1 x;
   x.a = a;
   return x;
@@ -17,7 +18,7 @@
 };
 
 struct half2 h2(_Float16 a, _Float16 b) {
-  // CHECK: define{{.*}}<2 x half> @h2
+  // CHECK: define{{.*}}<2 x half> @
   struct half2 x;
   x.a = a;
   x.b = b;
@@ -31,7 +32,7 @@
 };
 
 struct half3 h3(_Float16 a, _Float16 b, _Float16 c) {
-  // CHECK: define{{.*}}<4 x half> @h3
+  // CHECK: define{{.*}}<4 x half> @
   struct half3 x;
   x.a = a;
   x.b = b;
@@ -47,7 +48,7 @@
 };
 
 struct half4 h4(_Float16 a, _Float16 b, _Float16 c, _Float16 d) {
-  // CHECK: define{{.*}}<4 x half> @h4
+  // CHECK: define{{.*}}<4 x half> @
   struct half4 x;
   x.a = a;
   x.b = b;
@@ -62,7 +63,7 @@
 };
 
 struct floathalf fh(float a, _Float16 b) {
-  // CHECK: define{{.*}}<4 x half> @fh
+  // CHECK: define{{.*}}<4 x half> @
   struct floathalf x;
   x.a = a;
   x.b = b;
@@ -76,7 +77,7 @@
 };
 
 struct floathalf2 fh2(float a, _Float16 b, _Float16 c) {
-  // CHECK: define{{.*}}<4 x half> @fh2
+  // CHECK: define{{.*}}<4 x half> @
   struct floathalf2 x;
   x.a = a;
   x.b = b;
@@ -90,7 +91,7 @@
 };
 
 struct halffloat hf(_Float16 a, float b) {
-  // CHECK: define{{.*}}<4 x half> @hf
+  // CHECK: define{{.*}}<4 x half> @
   struct halffloat x;
   x.a = a;
   x.b = b;
@@ -104,7 +105,7 @@
 };
 
 struct half2float h2f(_Float16 a, _Float16 b, float c) {
-  // CHECK: define{{.*}}<4 x half> @h2f
+  // CHECK: define{{.*}}<4 x half> @
   struct half2float x;
   x.a = a;
   x.b = b;
@@ -120,7 +121,7 @@
 };
 
 struct floathalf3 fh3(float a, _Float16 b, _Float16 c, _Float16 d) {
-  // CHECK: define{{.*}}{ <4 x half>, half } @fh3
+  // CHECK: define{{.*}}{ <4 x half>, half } @
   struct floathalf3 x;
   x.a = a;
   x.b = b;
@@ -138,7 +139,7 @@
 };
 
 struct half5 h5(_Float16 a, _Float16 b, _Float16 c, _Float16 d, _Float16 e) {
-  // CHECK: define{{.*}}{ <4 x half>, half } @h5
+  // CHECK: define{{.*}}{ <4 x half>, half } @
   struct half5 x;
   x.a = a;
   x.b = b;
@@ -147,3 +148,52 @@
   x.e = e;
   return x;
 }
+
+struct float2 {
+  struct {} s;
+  float a;
+  float b;
+};
+
+float pr51813(struct float2 s) {
+  // CHECK-C: define{{.*}} @pr51813(<2 x float>
+  // CHECK-CPP: define{{.*}} @_Z7pr518136float2(double {{.*}}, float
+  return s.a;
+}
+
+struct float3 {
+  float a;
+  struct {} s;
+  float b;
+};
+
+float pr51813_2(struct float3 s) {
+  // CHECK-C: define{{.*}} @pr51813_2(<2 x float>
+  // CHECK-CPP: define{{.*}} @_Z9pr51813_26float3(double {{.*}}, float
+  return s.a;
+}
+
+struct shalf2 {
+  struct {} s;
+  _Float16 a;
+  _Float16 b;
+};
+
+_Float16 sf2(struct shalf2 s) {
+  // CHECK-C: define{{.*}} @sf2(<2 x half>
+  // CHECK-CPP: define{{.*}} @_Z3sf26shalf2(double {{.*}}
+  return s.a;
+};
+
+struct halfs2 {
+  _Float16 a;
+  struct {} s1;
+  _Float16 b;
+  struct {} s2;
+};
+
+_Float16 fs2(struct shalf2 s) {
+  // CHECK-C: define{{.*}} @fs2(<2 x half>
+  // CHECK-CPP: define{{.*}} @_Z3fs26shalf2(double {{.*}}
+  return s.a;
+};
Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -3377,52 +3377,18 @@
   return false;
 }
 
-/// ContainsFloatAtOffset - Return true if the specified LLVM IR type has a
-/// float member at the specified offset.  For example, {int,{float}} has a
-/// float at offset 4.  It is conservatively correct for this routine to return
-/// false.
-static bool ContainsFloatAtOffset(llvm::Type *IRType, unsigned IROffset,
-  const llvm::DataLayout &TD) {
-  // Base case if we find a float.
-  if (IROffset == 0 && IRType->isFloatTy())
-return true;
-
-  // If this is a struct, recurse into the field at the specified offset.
-  if (llvm::StructType *STy = dyn_cast(IRType)) {
-const llvm::StructLayout *SL = TD.getStructLayout(STy);
-unsigned Elt = SL->getE

[PATCH] D109157: [ARM] Mitigate the cve-2021-35465 security vulnurability.

2021-09-15 Thread Alexandros Lamprineas via Phabricator via cfe-commits
labrinea updated this revision to Diff 372674.
labrinea added a comment.

Changes in this revision:

- Replaced the backend option that enables the mitigation with a subtarget 
feature so that it works with LTO (@lenary thanks for the offline hint)
- Enabled the subtarget feature on the affected CPUs


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

https://reviews.llvm.org/D109157

Files:
  clang/docs/ClangCommandLineReference.rst
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Arch/ARM.cpp
  clang/test/Driver/arm-cmse-cve-2021-35465.c
  llvm/lib/Target/ARM/ARM.td
  llvm/lib/Target/ARM/ARMExpandPseudoInsts.cpp
  llvm/lib/Target/ARM/ARMSubtarget.h
  llvm/test/CodeGen/ARM/cmse-cve-2021-35465-return.ll
  llvm/test/CodeGen/ARM/cmse-cve-2021-35465.ll
  llvm/test/CodeGen/ARM/cmse-vlldm-no-reorder.mir

Index: llvm/test/CodeGen/ARM/cmse-vlldm-no-reorder.mir
===
--- llvm/test/CodeGen/ARM/cmse-vlldm-no-reorder.mir
+++ llvm/test/CodeGen/ARM/cmse-vlldm-no-reorder.mir
@@ -1,4 +1,4 @@
-# RUN: llc -mtriple=thumbv8m.main -mcpu=cortex-m33 --float-abi=hard --run-pass=arm-pseudo %s -o - | \
+# RUN: llc -mtriple=thumbv8m.main -mcpu=cortex-m33 -mattr=-fix-cmse-cve-2021-35465 --float-abi=hard --run-pass=arm-pseudo %s -o - | \
 # RUN: FileCheck %s
 --- |
   ; ModuleID = 'cmse-vlldm-no-reorder.ll'
@@ -109,4 +109,4 @@
 # CHECK-NEXT:  $s0 = VMOVSR $r12, 14 /* CC::al */, $noreg
 # CHECK-NEXT:  $sp = tADDspi $sp, 34, 14 /* CC::al */, $noreg
 # CHECK-NEXT:  $sp = t2LDMIA_UPD $sp, 14 /* CC::al */, $noreg, def $r4, def $r5, def $r6, def $r7, def $r8, def $r9, def $r10, def $r11
- 
\ No newline at end of file
+ 
Index: llvm/test/CodeGen/ARM/cmse-cve-2021-35465.ll
===
--- /dev/null
+++ llvm/test/CodeGen/ARM/cmse-cve-2021-35465.ll
@@ -0,0 +1,119 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+;
+; RUN: llc %s -o - -mtriple=thumbv8m.main \
+; RUN:   -mattr=+fp-armv8d16sp,+fix-cmse-cve-2021-35465 | \
+; RUN:   FileCheck %s --check-prefix=CHECK-8M-FP-CVE-2021-35465
+;
+; RUN: llc %s -o - -mtriple=thumbv8m.main -mcpu=cortex-m33 | \
+; RUN:   FileCheck %s --check-prefix=CHECK-8M-FP-CVE-2021-35465
+;
+; RUN: llc %s -o - -mtriple=thumbv8m.main -mcpu=cortex-m35p | \
+; RUN:   FileCheck %s --check-prefix=CHECK-8M-FP-CVE-2021-35465
+;
+; RUN: llc %s -o - -mtriple=thumbv8m.main \
+; RUN:   -mattr=-fpregs,+fix-cmse-cve-2021-35465 | \
+; RUN:   FileCheck %s --check-prefix=CHECK-8M-NOFP-CVE-2021-35465
+;
+; RUN: llc %s -o - -mtriple=thumbv8m.main -mcpu=cortex-m33 -mattr=-fpregs | \
+; RUN:   FileCheck %s --check-prefix=CHECK-8M-NOFP-CVE-2021-35465
+;
+; RUN: llc %s -o - -mtriple=thumbv8m.main -mcpu=cortex-m35p -mattr=-fpregs | \
+; RUN:   FileCheck %s --check-prefix=CHECK-8M-NOFP-CVE-2021-35465
+;
+; RUN: llc %s -o - -mtriple=thumbv8.1m.main \
+; RUN:   -mattr=+fp-armv8d16sp,+fix-cmse-cve-2021-35465 | \
+; RUN:   FileCheck %s --check-prefix=CHECK-81M-CVE-2021-35465
+;
+; RUN: llc %s -o - -mtriple=thumbv8.1m.main -mcpu=cortex-m55 | \
+; RUN:   FileCheck %s --check-prefix=CHECK-81M-CVE-2021-35465
+;
+; RUN: llc %s -o - -mtriple=thumbv8.1m.main \
+; RUN:   -mattr=-fpregs,+fix-cmse-cve-2021-35465 | \
+; RUN:   FileCheck %s --check-prefix=CHECK-81M-CVE-2021-35465
+;
+; RUN: llc %s -o - -mtriple=thumbv8.1m.main -mcpu=cortex-m55 -mattr=-fpregs | \
+; RUN:   FileCheck %s --check-prefix=CHECK-81M-CVE-2021-35465
+;
+
+define void @non_secure_call(void ()* %fptr) {
+; CHECK-8M-FP-CVE-2021-35465-LABEL: non_secure_call:
+; CHECK-8M-FP-CVE-2021-35465:   @ %bb.0:
+; CHECK-8M-FP-CVE-2021-35465-NEXT:push {r7, lr}
+; CHECK-8M-FP-CVE-2021-35465-NEXT:push.w {r4, r5, r6, r7, r8, r9, r10, r11}
+; CHECK-8M-FP-CVE-2021-35465-NEXT:bic r0, r0, #1
+; CHECK-8M-FP-CVE-2021-35465-NEXT:sub sp, #136
+; CHECK-8M-FP-CVE-2021-35465-NEXT:vlstm sp
+; CHECK-8M-FP-CVE-2021-35465-NEXT:mov r1, r0
+; CHECK-8M-FP-CVE-2021-35465-NEXT:mov r2, r0
+; CHECK-8M-FP-CVE-2021-35465-NEXT:mov r3, r0
+; CHECK-8M-FP-CVE-2021-35465-NEXT:mov r4, r0
+; CHECK-8M-FP-CVE-2021-35465-NEXT:mov r5, r0
+; CHECK-8M-FP-CVE-2021-35465-NEXT:mov r6, r0
+; CHECK-8M-FP-CVE-2021-35465-NEXT:mov r7, r0
+; CHECK-8M-FP-CVE-2021-35465-NEXT:mov r8, r0
+; CHECK-8M-FP-CVE-2021-35465-NEXT:mov r9, r0
+; CHECK-8M-FP-CVE-2021-35465-NEXT:mov r10, r0
+; CHECK-8M-FP-CVE-2021-35465-NEXT:mov r11, r0
+; CHECK-8M-FP-CVE-2021-35465-NEXT:mov r12, r0
+; CHECK-8M-FP-CVE-2021-35465-NEXT:msr apsr_nzcvq{{g?}}, r0
+; CHECK-8M-FP-CVE-2021-35465-NEXT:blxns r0
+; CHECK-8M-FP-CVE-2021-35465-NEXT:mrs r12, control
+; CHECK-8M-FP-CVE-2021-35465-NEXT:tst.w r12, #8
+; CHECK-8M-FP-CVE-2021-35465-NEXT:it ne
+; CHECK-8M-FP-CVE-2021-35465-NEXT:vmovne.f32 s0, s0
+; CHECK-8M-FP-CVE-2021-35465-NEXT:vlldm sp
+; CHECK-8M-FP-CVE-2021-35465-NEXT:add sp, #136
+; CHECK-8M

[PATCH] D109707: [HIP] [AlwaysInliner] Disable AlwaysInliner to eliminate undefined symbols

2021-09-15 Thread Anshil Gandhi via Phabricator via cfe-commits
gandhi21299 updated this revision to Diff 372573.
gandhi21299 added a comment.

- converted the HIP test into a CUDA test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109707

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/CodeGenCUDA/amdgpu-alias-undef-symbols.cu
  llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp


Index: llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
===
--- llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
+++ llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
@@ -691,7 +691,7 @@
   PM.addPass(GlobalDCEPass());
 }
 if (EarlyInlineAll && !EnableFunctionCalls)
-  PM.addPass(AMDGPUAlwaysInlinePass());
+  PM.addPass(AMDGPUAlwaysInlinePass(false));
   });
 
   PB.registerCGSCCOptimizerLateEPCallback(
Index: clang/test/CodeGenCUDA/amdgpu-alias-undef-symbols.cu
===
--- /dev/null
+++ clang/test/CodeGenCUDA/amdgpu-alias-undef-symbols.cu
@@ -0,0 +1,16 @@
+// RUN: %clang --offload-arch=gfx906 --cuda-device-only -x hip -emit-llvm -S 
-o - %s \
+// RUN:   -fgpu-rdc -O3 -mllvm -amdgpu-early-inline-all=true -mllvm 
-amdgpu-function-calls=false | \
+// RUN:   FileCheck %s
+
+#include "Inputs/cuda.h"
+
+// CHECK: %struct.B = type { i8 }
+struct B {
+
+  // CHECK: @_ZN1BC1Ei = hidden unnamed_addr alias void (%struct.B*, i32), 
void (%struct.B*, i32)* @_ZN1BC2Ei
+  __device__ B(int x);
+};
+
+__device__ B::B(int x) {
+
+}
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -5084,9 +5084,9 @@
   }
 
   // Enable -mconstructor-aliases except on darwin, where we have to work 
around
-  // a linker bug (see ), and CUDA/AMDGPU device code,
-  // where aliases aren't supported.
-  if (!RawTriple.isOSDarwin() && !RawTriple.isNVPTX() && !RawTriple.isAMDGPU())
+  // a linker bug (see ), and CUDA device code, where
+  // aliases aren't supported.
+  if (!RawTriple.isOSDarwin() && !RawTriple.isNVPTX())
 CmdArgs.push_back("-mconstructor-aliases");
 
   // Darwin's kernel doesn't support guard variables; just die if we


Index: llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
===
--- llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
+++ llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
@@ -691,7 +691,7 @@
   PM.addPass(GlobalDCEPass());
 }
 if (EarlyInlineAll && !EnableFunctionCalls)
-  PM.addPass(AMDGPUAlwaysInlinePass());
+  PM.addPass(AMDGPUAlwaysInlinePass(false));
   });
 
   PB.registerCGSCCOptimizerLateEPCallback(
Index: clang/test/CodeGenCUDA/amdgpu-alias-undef-symbols.cu
===
--- /dev/null
+++ clang/test/CodeGenCUDA/amdgpu-alias-undef-symbols.cu
@@ -0,0 +1,16 @@
+// RUN: %clang --offload-arch=gfx906 --cuda-device-only -x hip -emit-llvm -S -o - %s \
+// RUN:   -fgpu-rdc -O3 -mllvm -amdgpu-early-inline-all=true -mllvm -amdgpu-function-calls=false | \
+// RUN:   FileCheck %s
+
+#include "Inputs/cuda.h"
+
+// CHECK: %struct.B = type { i8 }
+struct B {
+
+  // CHECK: @_ZN1BC1Ei = hidden unnamed_addr alias void (%struct.B*, i32), void (%struct.B*, i32)* @_ZN1BC2Ei
+  __device__ B(int x);
+};
+
+__device__ B::B(int x) {
+
+}
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -5084,9 +5084,9 @@
   }
 
   // Enable -mconstructor-aliases except on darwin, where we have to work around
-  // a linker bug (see ), and CUDA/AMDGPU device code,
-  // where aliases aren't supported.
-  if (!RawTriple.isOSDarwin() && !RawTriple.isNVPTX() && !RawTriple.isAMDGPU())
+  // a linker bug (see ), and CUDA device code, where
+  // aliases aren't supported.
+  if (!RawTriple.isOSDarwin() && !RawTriple.isNVPTX())
 CmdArgs.push_back("-mconstructor-aliases");
 
   // Darwin's kernel doesn't support guard variables; just die if we
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D109707: [HIP] [AlwaysInliner] Disable AlwaysInliner to eliminate undefined symbols

2021-09-15 Thread Anshil Gandhi via Phabricator via cfe-commits
gandhi21299 updated this revision to Diff 372551.
gandhi21299 added a comment.

- added the include header for HIP runtime


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109707

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/CodeGen/amdgpu-alias-undef-symbols.hip
  llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp


Index: llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
===
--- llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
+++ llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
@@ -691,7 +691,7 @@
   PM.addPass(GlobalDCEPass());
 }
 if (EarlyInlineAll && !EnableFunctionCalls)
-  PM.addPass(AMDGPUAlwaysInlinePass());
+  PM.addPass(AMDGPUAlwaysInlinePass(false));
   });
 
   PB.registerCGSCCOptimizerLateEPCallback(
Index: clang/test/CodeGen/amdgpu-alias-undef-symbols.hip
===
--- /dev/null
+++ clang/test/CodeGen/amdgpu-alias-undef-symbols.hip
@@ -0,0 +1,16 @@
+// RUN: %clang --offload-arch=gfx906 --cuda-device-only -emit-llvm -S -o - %s \
+// RUN:   -fgpu-rdc -O3 -mllvm -amdgpu-early-inline-all=true -mllvm 
-amdgpu-function-calls=false | \
+// RUN:   FileCheck %s
+
+#include "hip/hip_runtime.h"
+
+// CHECK: %struct.B = type { i8 }
+struct B {
+
+  // CHECK: @_ZN1BC1Ei = hidden unnamed_addr alias void (%struct.B*, i32), 
void (%struct.B*, i32)* @_ZN1BC2Ei
+  __device__ B(int x);
+};
+
+__device__ B::B(int x) {
+
+}
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -5084,9 +5084,9 @@
   }
 
   // Enable -mconstructor-aliases except on darwin, where we have to work 
around
-  // a linker bug (see ), and CUDA/AMDGPU device code,
-  // where aliases aren't supported.
-  if (!RawTriple.isOSDarwin() && !RawTriple.isNVPTX() && !RawTriple.isAMDGPU())
+  // a linker bug (see ), and CUDA device code, where
+  // aliases aren't supported.
+  if (!RawTriple.isOSDarwin() && !RawTriple.isNVPTX())
 CmdArgs.push_back("-mconstructor-aliases");
 
   // Darwin's kernel doesn't support guard variables; just die if we


Index: llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
===
--- llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
+++ llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
@@ -691,7 +691,7 @@
   PM.addPass(GlobalDCEPass());
 }
 if (EarlyInlineAll && !EnableFunctionCalls)
-  PM.addPass(AMDGPUAlwaysInlinePass());
+  PM.addPass(AMDGPUAlwaysInlinePass(false));
   });
 
   PB.registerCGSCCOptimizerLateEPCallback(
Index: clang/test/CodeGen/amdgpu-alias-undef-symbols.hip
===
--- /dev/null
+++ clang/test/CodeGen/amdgpu-alias-undef-symbols.hip
@@ -0,0 +1,16 @@
+// RUN: %clang --offload-arch=gfx906 --cuda-device-only -emit-llvm -S -o - %s \
+// RUN:   -fgpu-rdc -O3 -mllvm -amdgpu-early-inline-all=true -mllvm -amdgpu-function-calls=false | \
+// RUN:   FileCheck %s
+
+#include "hip/hip_runtime.h"
+
+// CHECK: %struct.B = type { i8 }
+struct B {
+
+  // CHECK: @_ZN1BC1Ei = hidden unnamed_addr alias void (%struct.B*, i32), void (%struct.B*, i32)* @_ZN1BC2Ei
+  __device__ B(int x);
+};
+
+__device__ B::B(int x) {
+
+}
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -5084,9 +5084,9 @@
   }
 
   // Enable -mconstructor-aliases except on darwin, where we have to work around
-  // a linker bug (see ), and CUDA/AMDGPU device code,
-  // where aliases aren't supported.
-  if (!RawTriple.isOSDarwin() && !RawTriple.isNVPTX() && !RawTriple.isAMDGPU())
+  // a linker bug (see ), and CUDA device code, where
+  // aliases aren't supported.
+  if (!RawTriple.isOSDarwin() && !RawTriple.isNVPTX())
 CmdArgs.push_back("-mconstructor-aliases");
 
   // Darwin's kernel doesn't support guard variables; just die if we
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D109506: [clangd] Print current request context along with the stack trace

2021-09-15 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

This is mostly LG with nits, but I think the code-completion handler is wrong, 
and the tests as written won't build on windows.

In D109506#2992201 , @sammccall wrote:

> Oops, forgot one thing: you probably want to instrument the preamble-building 
> in TUScheduler (or in Preamble.cpp?), the background indexing, and code 
> completion.
> Those all run the clang parser and should be a rich source of clang bugs.

You've added code completion (i.e. runWithPreamble), but not preamble-building 
or background-indexing.
This is fine, we can add the others later - just wanted to make sure we're on 
the same page.

In D109506#398 , @0x1eaf wrote:

> I've tried making an integration test in addition to the unit test, but I 
> couldn't find a way to make lit ignore the crashed process exit status:
> : 'RUN: at line 2';   yes '[' | head -n 5 | sh -c "clangd 
> --input-style=delimited 2>&1 || true"
> Exit Code: 141

I think this is related to the fact that tests run with `set -o pipefail`, and 
`yes` fails when `head` closes the pipe.
`not yes` doesn't seem to help because SIGPIPE is actually caught by the shell 
rather than `yes`, thus the 141 code. (Hey, signals again!)
This seems to work: `(yes '[' || :) | head -n 5 | clangd 
--input-style=delimited`

(It is in principle possbile to disable pipefail in lit tests but awkward on a 
per-test level and nobody does it.)




Comment at: clang-tools-extra/clangd/TUScheduler.cpp:556
 
+  /// For calling from ThreadCrashReporter callback.
+  void dumpCurrentRequest(llvm::raw_ostream &OS) const;

Probably worth commenting "May only call from worker thread" or so.

(Unfortunately we have unusual concurrency constraints on the members - some 
such as FileInputs are locked when written on the worker thread, locked when 
read from other threads, unlocked when read from the worker thread, and never 
written from other threads. Because it's confusing it's probably worth being 
explicit).



Comment at: clang-tools-extra/clangd/TUScheduler.cpp:1382
+void ASTWorker::dumpCurrentRequest(llvm::raw_ostream &OS) const {
+  auto &ActionName = CurrentRequest ? CurrentRequest->Name : "";
+  OS << "Signalled during AST action: " << ActionName << "\n";

nit: I'd prefer an explicit type over `auto&` here. Probably StringRef?

(I'm not actually sure what type we're getting and whether the reference is 
dangling).



Comment at: clang-tools-extra/clangd/TUScheduler.cpp:1639
+ThreadCrashReporter ScopedReporter(
+[&Worker]() { Worker->dumpCurrentRequest(llvm::errs()); });
 std::shared_ptr Preamble;

This doesn't seem right.
This code runs on the PreambleThreads threadpool, not on the worker thread. So 
a) the state of the worker thread isn't really relevant and b) we're accessing 
it in a non-threadsafe way.

Instead we need to dump Name, Command, Contents etc separately again.
Maybe dumpCurrentRequest should be a free helper function that takes the 
individual parameters instead.



Comment at: clang-tools-extra/clangd/support/ThreadCrashReporter.cpp:28
+
+  // Traverse to the top of the reporter stack.
+  ThreadCrashReporter *Reporter = CurrentReporter;

I'm not sure the FIFO behavior is much (or at all) better than LIFO[1], and it 
seems like it adds a bit of complexity (we'd only need the  `Next` pointer, and 
there'd be less confusion direction of next vs previous).

[1] (insert joke about python having tracebacks instead of backtraces, because 
they're backwards...)



Comment at: clang-tools-extra/clangd/support/ThreadCrashReporter.h:23
+
+  /// Copies the std::function and sets the copy as current thread-local
+  /// callback. Asserts if the current thread's callback is already set.

Some mention of constraints on the passed function?

e.g. "The callback is likely to be invoked in a signal handler. Most LLVM 
signal handling is not strictly async-signal-safe. However reporters should 
avoid accessing data structures likely to be in a bad state on crash."



Comment at: clang-tools-extra/clangd/support/ThreadCrashReporter.h:25
+  /// callback. Asserts if the current thread's callback is already set.
+  ThreadCrashReporter(const SignalCallback &ThreadLocalCallback);
+  /// Resets the currrent thread's callback to nullptr.

doesn't seem to be any need for a copy here, pass by value and move instead?
(And probably use `llvm::unique_function` to avoid the copyable requirement)



Comment at: clang-tools-extra/clangd/support/ThreadCrashReporter.h:35
+
+  /// Callback to install via sys::AddSignalHandler(), the argument is ignored.
+  /// Any signal filtering is the responsibility of the caller.

This should first have a comment saying wh

[PATCH] D109157: [ARM] Mitigate the cve-2021-35465 security vulnurability.

2021-09-15 Thread Alexandros Lamprineas via Phabricator via cfe-commits
labrinea updated this revision to Diff 372677.
labrinea added a comment.

Changes in this revision:

- added `-verify-machineinstrs` to the tests
- that yield two bugs that I had to address:

  *** Bad machine code: Explicit operand marked as def ***
  - function:func
  - basic block: %bb.0 entry (0x890b6d8)
  - instruction: $d3 = VSTRD $sp, 6, 14, $noreg
  - operand 0:   $d3



  *** Bad machine code: Explicit definition marked as use ***
  - function:non_secure_call
  - basic block: %bb.0  (0x8e0bed8)
  - instruction: t2MRS_M $r12, 20, 14, $noreg
  - operand 0:   $r12


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

https://reviews.llvm.org/D109157

Files:
  clang/docs/ClangCommandLineReference.rst
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Arch/ARM.cpp
  clang/test/Driver/arm-cmse-cve-2021-35465.c
  llvm/lib/Target/ARM/ARM.td
  llvm/lib/Target/ARM/ARMExpandPseudoInsts.cpp
  llvm/lib/Target/ARM/ARMSubtarget.h
  llvm/test/CodeGen/ARM/cmse-cve-2021-35465-return.ll
  llvm/test/CodeGen/ARM/cmse-cve-2021-35465.ll
  llvm/test/CodeGen/ARM/cmse-vlldm-no-reorder.mir

Index: llvm/test/CodeGen/ARM/cmse-vlldm-no-reorder.mir
===
--- llvm/test/CodeGen/ARM/cmse-vlldm-no-reorder.mir
+++ llvm/test/CodeGen/ARM/cmse-vlldm-no-reorder.mir
@@ -1,4 +1,4 @@
-# RUN: llc -mtriple=thumbv8m.main -mcpu=cortex-m33 --float-abi=hard --run-pass=arm-pseudo %s -o - | \
+# RUN: llc -mtriple=thumbv8m.main -mcpu=cortex-m33 -mattr=-fix-cmse-cve-2021-35465 --float-abi=hard --run-pass=arm-pseudo %s -o - | \
 # RUN: FileCheck %s
 --- |
   ; ModuleID = 'cmse-vlldm-no-reorder.ll'
@@ -109,4 +109,4 @@
 # CHECK-NEXT:  $s0 = VMOVSR $r12, 14 /* CC::al */, $noreg
 # CHECK-NEXT:  $sp = tADDspi $sp, 34, 14 /* CC::al */, $noreg
 # CHECK-NEXT:  $sp = t2LDMIA_UPD $sp, 14 /* CC::al */, $noreg, def $r4, def $r5, def $r6, def $r7, def $r8, def $r9, def $r10, def $r11
- 
\ No newline at end of file
+ 
Index: llvm/test/CodeGen/ARM/cmse-cve-2021-35465.ll
===
--- /dev/null
+++ llvm/test/CodeGen/ARM/cmse-cve-2021-35465.ll
@@ -0,0 +1,119 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+;
+; RUN: llc %s -o - -mtriple=thumbv8m.main -verify-machineinstrs \
+; RUN:   -mattr=+fp-armv8d16sp,+fix-cmse-cve-2021-35465 | \
+; RUN:   FileCheck %s --check-prefix=CHECK-8M-FP-CVE-2021-35465
+;
+; RUN: llc %s -o - -mtriple=thumbv8m.main -mcpu=cortex-m33 -verify-machineinstrs | \
+; RUN:   FileCheck %s --check-prefix=CHECK-8M-FP-CVE-2021-35465
+;
+; RUN: llc %s -o - -mtriple=thumbv8m.main -mcpu=cortex-m35p -verify-machineinstrs | \
+; RUN:   FileCheck %s --check-prefix=CHECK-8M-FP-CVE-2021-35465
+;
+; RUN: llc %s -o - -mtriple=thumbv8m.main -verify-machineinstrs \
+; RUN:   -mattr=-fpregs,+fix-cmse-cve-2021-35465 | \
+; RUN:   FileCheck %s --check-prefix=CHECK-8M-NOFP-CVE-2021-35465
+;
+; RUN: llc %s -o - -mtriple=thumbv8m.main -mcpu=cortex-m33 -mattr=-fpregs -verify-machineinstrs | \
+; RUN:   FileCheck %s --check-prefix=CHECK-8M-NOFP-CVE-2021-35465
+;
+; RUN: llc %s -o - -mtriple=thumbv8m.main -mcpu=cortex-m35p -mattr=-fpregs -verify-machineinstrs | \
+; RUN:   FileCheck %s --check-prefix=CHECK-8M-NOFP-CVE-2021-35465
+;
+; RUN: llc %s -o - -mtriple=thumbv8.1m.main -verify-machineinstrs \
+; RUN:   -mattr=+fp-armv8d16sp,+fix-cmse-cve-2021-35465 | \
+; RUN:   FileCheck %s --check-prefix=CHECK-81M-CVE-2021-35465
+;
+; RUN: llc %s -o - -mtriple=thumbv8.1m.main -mcpu=cortex-m55 -verify-machineinstrs | \
+; RUN:   FileCheck %s --check-prefix=CHECK-81M-CVE-2021-35465
+;
+; RUN: llc %s -o - -mtriple=thumbv8.1m.main -verify-machineinstrs \
+; RUN:   -mattr=-fpregs,+fix-cmse-cve-2021-35465 | \
+; RUN:   FileCheck %s --check-prefix=CHECK-81M-CVE-2021-35465
+;
+; RUN: llc %s -o - -mtriple=thumbv8.1m.main -mcpu=cortex-m55 -mattr=-fpregs -verify-machineinstrs | \
+; RUN:   FileCheck %s --check-prefix=CHECK-81M-CVE-2021-35465
+;
+
+define void @non_secure_call(void ()* %fptr) {
+; CHECK-8M-FP-CVE-2021-35465-LABEL: non_secure_call:
+; CHECK-8M-FP-CVE-2021-35465:   @ %bb.0:
+; CHECK-8M-FP-CVE-2021-35465-NEXT:push {r7, lr}
+; CHECK-8M-FP-CVE-2021-35465-NEXT:push.w {r4, r5, r6, r7, r8, r9, r10, r11}
+; CHECK-8M-FP-CVE-2021-35465-NEXT:bic r0, r0, #1
+; CHECK-8M-FP-CVE-2021-35465-NEXT:sub sp, #136
+; CHECK-8M-FP-CVE-2021-35465-NEXT:vlstm sp
+; CHECK-8M-FP-CVE-2021-35465-NEXT:mov r1, r0
+; CHECK-8M-FP-CVE-2021-35465-NEXT:mov r2, r0
+; CHECK-8M-FP-CVE-2021-35465-NEXT:mov r3, r0
+; CHECK-8M-FP-CVE-2021-35465-NEXT:mov r4, r0
+; CHECK-8M-FP-CVE-2021-35465-NEXT:mov r5, r0
+; CHECK-8M-FP-CVE-2021-35465-NEXT:mov r6, r0
+; CHECK-8M-FP-CVE-2021-35465-NEXT:mov r7, r0
+; CHECK-8M-FP-CVE-2021-35465-NEXT:mov r8, r0
+; CHECK-8M-FP-CVE-2021-35465-NEXT:mov r9, r0
+; CHECK-8M-FP-CVE-2021-35465-NEXT:mov r10, r0
+; CHECK-8M-FP-CVE-2021-35465-NEX

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

2021-09-15 Thread Philippe Antoine via Phabricator via cfe-commits
catenacyber added a comment.

Should we still bump `INSTR_PROF_RAW_VERSION ` so that we are able to 
distinguish profraw files produced by clang13 and the ones produced by clang14 ?

Right now, both produce `LLVM raw profile data, version 7`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104556

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


[PATCH] D109157: [ARM] Mitigate the cve-2021-35465 security vulnurability.

2021-09-15 Thread Sam Elliott via Phabricator via cfe-commits
lenary accepted this revision.
lenary added a comment.
This revision is now accepted and ready to land.

LGTM, but the most recent way of implementing this (using target features) was 
something I suggested to Alexandros based on @ostannard's feedback about LTO. I 
think it is cleaner, and this patch is good, but a re-review from others would 
be helpful.


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

https://reviews.llvm.org/D109157

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


[PATCH] D109078: [clang][driver][AIX] Add system libc++ header paths to driver

2021-09-15 Thread Zarko Todorovski via Phabricator via cfe-commits
ZarkoCA accepted this revision.
ZarkoCA added a comment.
This revision is now accepted and ready to land.

Thanks, LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109078

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


[PATCH] D105191: [Clang][OpenMP] Add support for Static Device Libraries

2021-09-15 Thread Saiyedul Islam via Phabricator via cfe-commits
saiislam added a comment.

In D105191#3001056 , @ye-luo wrote:

> 1. modf works now.
>
> 2. if I modify the complile.sh
>
>   clang++ -fopenmp -fopenmp-targets=nvptx64 -c classA.cpp
>   rm -f libmylib.a
>   ar qc libmylib.a classA.o
>   ranlib libmylib.a
>   clang++ -fopenmp -fopenmp-targets=nvptx64 main.cpp -L. -lmylib
>   ./a.out
>
> doesn't work. I think the solution is adding sm_XX to the module name 
> regardless of user command line.
>
> 3,  directly linking static archive doesn't work.
>
>   clang++ -fopenmp -fopenmp-targets=nvptx64 main.cpp libmylib.a
>
> CMake generates this style of link line. So this really needs to work.
>
> only the following case works right now.
>
>   clang++ -fopenmp -fopenmp-targets=nvptx64 main.cpp -L. -lmylib

Thanks for confirming that modf and this patch works with -l/-L options.

The option of adding sm_XX in Bundle Entry ID when user hasn't used -march 
flag, comes under command line simplification. I have a bunch of upcoming 
patches which will significantly simplify OpenMP command line for GPU 
offloading. But, don't you think this feature is different than supporting 
static device libraries and should be dealt separately?

Our plan was always to support SDLs using -l and -L options, as described in 
Greg Rodgers's presentation about static device libraries 
 in last year's LLVM-CTH Workshop. 
It was also discussed in multi company meetings. We can explore supporting 
direct linking of SDLs as described by you, but it seems to me that it is out 
of scope of this patch. What do you think?

PS: We (mulit-company OpenMP-dev meetings) have been tracking this feature for 
a while and we would very much like it to be picked for llvm-13.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105191

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


[PATCH] D105191: [Clang][OpenMP] Add support for Static Device Libraries

2021-09-15 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield added a comment.

In D105191#3001508 , @saiislam wrote:

> PS: We (mulit-company OpenMP-dev meetings) have been tracking this feature 
> for a while and we would very much like it to be picked for llvm-13.

I think llvm-13 is on -final now so I think we've missed the train for big 
feature work. That's not so bad, 14 branches in ~6 months.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105191

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


[PATCH] D108643: Introduce _BitInt, deprecate _ExtInt

2021-09-15 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

> Okay. Sorry if I came down on you personally, I know what it's like to be in 
> the middle on things like this

Thank you, I very much appreciate that.

> I'm not sure if there's a way to get LLVM to treat loaded values as only 
> having N valid bits.
>
> Do you have resources on the patterns of code that you expect to see for 
> `_BitInt` types?  Like, what operations are most important here?
>
> If addition, subtraction, and comparison are the most important operations — 
> especially if we don't consider shifts or multiplication important — the best 
> ABI might actually be to keep the value left-shifted.

I don't have any such resources.  Our users treat them as 'just integers', and 
my understanding is that is the design intent we brought to WG14.  There is 
SOME experimentation to use these as 'Big Ints' as well.


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

https://reviews.llvm.org/D108643

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


[PATCH] D109825: [AArch64]Enabling Cortex-A510 Support

2021-09-15 Thread Mubashar Ahmad via Phabricator via cfe-commits
mubashar_ created this revision.
mubashar_ added a reviewer: MarkMurrayARM.
Herald added subscribers: hiraditya, kristof.beyls.
mubashar_ requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

This patch enables support for Cortex-A510 CPUs.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D109825

Files:
  clang/docs/ReleaseNotes.rst
  clang/test/Driver/aarch64-cpus.c
  llvm/include/llvm/Support/AArch64TargetParser.def
  llvm/lib/Target/AArch64/AArch64.td
  llvm/lib/Target/AArch64/AArch64Subtarget.cpp
  llvm/lib/Target/AArch64/AArch64Subtarget.h
  llvm/unittests/Support/TargetParserTest.cpp

Index: llvm/unittests/Support/TargetParserTest.cpp
===
--- llvm/unittests/Support/TargetParserTest.cpp
+++ llvm/unittests/Support/TargetParserTest.cpp
@@ -983,6 +983,14 @@
  AArch64::AEK_DOTPROD | AArch64::AEK_RCPC |
  AArch64::AEK_SSBS,
  "8.2-A"),
+ARMCPUTestParams("cortex-a510", "armv8.3-a", "crypto-neon-fp-armv8",
+ AArch64::AEK_CRC | AArch64::AEK_CRYPTO |
+ AArch64::AEK_FP | AArch64::AEK_SIMD |
+ AArch64::AEK_RAS | AArch64::AEK_LSE |
+ AArch64::AEK_RDM | AArch64::AEK_RCPC |
+ AArch64::AEK_SVE2 | AArch64::AEK_SVE2BITPERM |
+ AArch64::AEK_DOTPROD | AArch64::AEK_MTE,
+ "8.3-A"),
 ARMCPUTestParams("cyclone", "armv8-a", "crypto-neon-fp-armv8",
  AArch64::AEK_NONE | AArch64::AEK_CRYPTO |
  AArch64::AEK_FP | AArch64::AEK_SIMD,
@@ -1164,7 +1172,7 @@
  AArch64::AEK_LSE | AArch64::AEK_RDM,
  "8.2-A")));
 
-static constexpr unsigned NumAArch64CPUArchs = 48;
+static constexpr unsigned NumAArch64CPUArchs = 49;
 
 TEST(TargetParserTest, testAArch64CPUArchList) {
   SmallVector List;
Index: llvm/lib/Target/AArch64/AArch64Subtarget.h
===
--- llvm/lib/Target/AArch64/AArch64Subtarget.h
+++ llvm/lib/Target/AArch64/AArch64Subtarget.h
@@ -59,6 +59,7 @@
 CortexA77,
 CortexA78,
 CortexA78C,
+CortexA510,
 CortexR82,
 CortexX1,
 ExynosM3,
Index: llvm/lib/Target/AArch64/AArch64Subtarget.cpp
===
--- llvm/lib/Target/AArch64/AArch64Subtarget.cpp
+++ llvm/lib/Target/AArch64/AArch64Subtarget.cpp
@@ -193,6 +193,9 @@
 // FIXME: remove this to enable 64-bit SLP if performance looks good.
 MinVectorRegisterBitWidth = 128;
 break;
+  case CortexA510:
+PrefFunctionLogAlignment = 4;
+break;
   }
 }
 
Index: llvm/lib/Target/AArch64/AArch64.td
===
--- llvm/lib/Target/AArch64/AArch64.td
+++ llvm/lib/Target/AArch64/AArch64.td
@@ -1052,6 +1052,26 @@
   FeatureSSBS,
   FeatureSVE]>;
 
+def ProcCortexA510 : SubtargetFeature<"cortex-a510", "ARMProcFamily",
+  "CortexA510", "Cortex-A510 ARM processors", [
+  HasV8_3aOps,
+  FeatureCrypto,
+  FeatureFPARMv8,
+  FeatureFuseAES,
+  FeatureNEON,
+  FeaturePerfMon,
+  FeaturePostRAScheduler,
+  FeatureSPE,
+  FeatureAM,
+  FeatureMPAM,
+  FeatureETE,
+  FeatureMTE,
+  FeatureSVE2,
+  FeatureSVE2BitPerm,
+  FeatureFullFP16,
+  FeatureFP16FML,
+  FeatureDotProd]>;
+
 def ProcSaphira  : SubtargetFeature<"saphira", "ARMProcFamily", "Saphira",
"Qualcomm Saphira processors", [
FeatureCrypto,
@@ -1191,6 +1211,7 @@
 def : ProcessorModel<"neoverse-n1", CortexA57Model, [ProcNeoverseN1]>;
 def : ProcessorModel<"neoverse-n2", CortexA57Model, [ProcNeoverseN2]>;
 def : ProcessorModel<"neoverse-v1", CortexA57Model, [ProcNeoverseV1]>;
+def : ProcessorModel<"cortex-a510", CortexA57Model, [ProcCortexA510]>;
 def : ProcessorModel<"exynos-m3", ExynosM3Model, [ProcExynosM3]>;
 def : ProcessorModel<"exynos-m4", ExynosM4Model, [ProcExynosM4]>;
 def : ProcessorModel<"exynos-m5", ExynosM5Model, [ProcExynosM4]>;
Index:

[PATCH] D109234: [PGO] Change ThinLTO test for targets with loop unrolling disabled

2021-09-15 Thread Sherwin via Phabricator via cfe-commits
sherwin-dc updated this revision to Diff 372696.
sherwin-dc added a comment.

- Modify test to correctly indicate old/new PM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109234

Files:
  clang/test/CodeGen/pgo-sample-thinlto-summary.c


Index: clang/test/CodeGen/pgo-sample-thinlto-summary.c
===
--- clang/test/CodeGen/pgo-sample-thinlto-summary.c
+++ clang/test/CodeGen/pgo-sample-thinlto-summary.c
@@ -1,9 +1,7 @@
-// RUN: %clang_cc1 -O2 
-fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm -o 
- 2>&1 | FileCheck %s -check-prefix=SAMPLEPGO
-// RUN: %clang_cc1 -O2 
-fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm 
-flto=thin -o - 2>&1 | FileCheck %s -check-prefix=THINLTO
-// RUN: %clang_cc1 -O2 -fexperimental-new-pass-manager 
-fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm -o 
- 2>&1 | FileCheck %s -check-prefix=SAMPLEPGO
-// RUN: %clang_cc1 -O2 -fexperimental-new-pass-manager 
-fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm 
-flto=thin -o - 2>&1 | FileCheck %s -check-prefix=THINLTO
-// Checks if hot call is inlined by normal compile, but not inlined by
-// thinlto compile.
+// RUN: %clang_cc1 -mllvm -debug-pass=Structure -O2 
-fno-experimental-new-pass-manager 
-fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm -o 
- 2>&1 | FileCheck %s -check-prefix=SAMPLEPGO-OLDPM
+// RUN: %clang_cc1 -mllvm -debug-pass=Structure -O2 
-fno-experimental-new-pass-manager 
-fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm 
-flto=thin -o - 2>&1 | FileCheck %s -check-prefix=THINLTO-OLDPM
+// RUN: %clang_cc1 -mllvm -debug-pass=Structure -O2 
-fexperimental-new-pass-manager -fdebug-pass-manager 
-fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm -o 
- 2>&1 | FileCheck %s -check-prefix=SAMPLEPGO
+// RUN: %clang_cc1 -mllvm -debug-pass=Structure -O2 
-fexperimental-new-pass-manager -fdebug-pass-manager 
-fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm 
-flto=thin -o - 2>&1 | FileCheck %s -check-prefix=THINLTO
 
 int baz(int);
 int g;
@@ -13,6 +11,25 @@
 g += baz(i);
 }
 
+// Checks that loop unroll and icp are invoked by normal compile, but not 
thinlto compile.
+
+// SAMPLEPGO:   Running pass: PGOIndirectCallPromotion on [module]
+// SAMPLEPGO:   Running pass: LoopUnrollPass on bar
+
+// SAMPLEPGO-OLDPM: PGOIndirectCallPromotion
+// SAMPLEPGO-OLDPM: Unroll loops
+// SAMPLEPGO-OLDPM: Unroll loops
+
+// THINLTO-NOT: Running pass: PGOIndirectCallPromotion on [module]
+// THINLTO-NOT: Running pass: LoopUnrollPass on bar
+
+// THINLTO-OLDPM-NOT:   PGOIndirectCallPromotion
+// THINLTO-OLDPM:   Unroll loops
+// THINLTO-OLDPM-NOT:   Unroll loops
+
+
+// Checks if hot call is inlined by normal compile, but not inlined by
+// thinlto compile.
 // SAMPLEPGO-LABEL: define {{(dso_local )?}}void @bar
 // THINLTO-LABEL: define {{(dso_local )?}}void @bar
 // SAMPLEPGO-NOT: call{{.*}}foo
@@ -20,27 +37,4 @@
 void bar(int n) {
   for (int i = 0; i < n; i++)
 foo(i);
-}
-
-// Checks if loop unroll is invoked by normal compile, but not thinlto compile.
-// SAMPLEPGO-LABEL: define {{(dso_local )?}}void @unroll
-// THINLTO-LABEL: define {{(dso_local )?}}void @unroll
-// SAMPLEPGO: call{{.*}}baz
-// SAMPLEPGO: call{{.*}}baz
-// THINLTO: call{{.*}}baz
-// THINLTO-NOT: call{{.*}}baz
-void unroll() {
-  for (int i = 0; i < 2; i++)
-baz(i);
-}
-
-// Checks that icp is not invoked for ThinLTO, but invoked for normal 
samplepgo.
-// SAMPLEPGO-LABEL: define {{(dso_local )?}}void @icp
-// THINLTO-LABEL: define {{(dso_local )?}}void @icp
-// SAMPLEPGO: if.true.direct_targ
-// FIXME: the following condition needs to be reversed once
-//LTOPreLinkDefaultPipeline is customized.
-// THINLTO-NOT: if.true.direct_targ
-void icp(void (*p)()) {
-  p();
-}
+}
\ No newline at end of file


Index: clang/test/CodeGen/pgo-sample-thinlto-summary.c
===
--- clang/test/CodeGen/pgo-sample-thinlto-summary.c
+++ clang/test/CodeGen/pgo-sample-thinlto-summary.c
@@ -1,9 +1,7 @@
-// RUN: %clang_cc1 -O2 -fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm -o - 2>&1 | FileCheck %s -check-prefix=SAMPLEPGO
-// RUN: %clang_cc1 -O2 -fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm -flto=thin -o - 2>&1 | FileCheck %s -check-prefix=THINLTO
-// RUN: %clang_cc1 -O2 -fexperimental-new-pass-manager -fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm -o - 2>&1 | FileCheck %s -check-prefix=SAMPLEPGO
-// RUN: %clang_cc1 -O2 -fexperimental-new-pass-manager -fprofile-sample-use=%S/Inputs/pgo-sample-

[PATCH] D109752: [clang-format] Top-level unwrapped lines don't follow a left brace

2021-09-15 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay accepted this revision.
MyDeveloperDay added a comment.
This revision is now accepted and ready to land.

I guess this will prevent member functions in classes being treated as K&R 
functions right? if thats the case them this LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109752

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


[PATCH] D109234: [PGO] Change ThinLTO test for targets with loop unrolling disabled

2021-09-15 Thread Sherwin via Phabricator via cfe-commits
sherwin-dc added inline comments.



Comment at: clang/test/CodeGen/pgo-sample-thinlto-summary.c:27
+// THINLTO-OLDPM-NOT:   PGOIndirectCallPromotion
+// THINLTO-OLDPM:   Unroll loops
+// THINLTO-OLDPM-NOT:   Unroll loops

When printing out passes with the old PM 'Unroll loops' is printed out twice 
with sample PGO and once with thin LTO.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109234

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


[PATCH] D109234: [PGO] Change ThinLTO test for targets with loop unrolling disabled

2021-09-15 Thread Thomas Preud'homme via Phabricator via cfe-commits
thopre added inline comments.



Comment at: clang/test/CodeGen/pgo-sample-thinlto-summary.c:3-4
+// RUN: %clang_cc1 -mllvm -debug-pass=Structure -O2 
-fno-experimental-new-pass-manager 
-fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm 
-flto=thin -o - 2>&1 | FileCheck %s -check-prefix=THINLTO-OLDPM
+// RUN: %clang_cc1 -mllvm -debug-pass=Structure -O2 
-fexperimental-new-pass-manager -fdebug-pass-manager 
-fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm -o 
- 2>&1 | FileCheck %s -check-prefix=SAMPLEPGO
+// RUN: %clang_cc1 -mllvm -debug-pass=Structure -O2 
-fexperimental-new-pass-manager -fdebug-pass-manager 
-fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm 
-flto=thin -o - 2>&1 | FileCheck %s -check-prefix=THINLTO
 

While we now need to explicitely request the old pass manager, the new pass 
manager is the default so we don't need to be explicit.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109234

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


[PATCH] D109825: [AArch64]Enabling Cortex-A510 Support

2021-09-15 Thread Mark Murray via Phabricator via cfe-commits
MarkMurrayARM accepted this revision.
MarkMurrayARM added a comment.
This revision is now accepted and ready to land.

As I did the downstream work for this, I'm happy with it to go in in this form.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109825

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


[PATCH] D109825: [AArch64]Enabling Cortex-A510 Support

2021-09-15 Thread Dave Green via Phabricator via cfe-commits
dmgreen requested changes to this revision.
dmgreen added a comment.
This revision now requires changes to proceed.

> As I did the downstream work for this, I'm happy with it to go in in this 
> form.

This doesn't seem.. wise. Please make sure the reviews you do are at a 
sufficient quality, and it is probably best not to review patches you write 
yourself.




Comment at: llvm/include/llvm/Support/AArch64TargetParser.def:179
   AArch64::AEK_DOTPROD ))
+AARCH64_CPU_NAME("cortex-a510", ARMV8_3A, FK_CRYPTO_NEON_FP_ARMV8, false,
+ (AArch64::AEK_MTE | AArch64::AEK_SVE2 |

Why is this 8.3? The TRM 
(https://developer.arm.com/documentation/101604/0003/The-Cortex-A510--core) 
describes it as implementing the 9.0-A architecture.



Comment at: llvm/lib/Target/AArch64/AArch64.td:1055
 
+def ProcCortexA510 : SubtargetFeature<"cortex-a510", "ARMProcFamily",
+  "CortexA510", "Cortex-A510 ARM 
processors", [

This should be in some sort of order, next to the Cortex-A55. It should 
probably be called ProcA510 for consistency too.



Comment at: llvm/lib/Target/AArch64/AArch64.td:1214
 def : ProcessorModel<"neoverse-v1", CortexA57Model, [ProcNeoverseV1]>;
+def : ProcessorModel<"cortex-a510", CortexA57Model, [ProcCortexA510]>;
 def : ProcessorModel<"exynos-m3", ExynosM3Model, [ProcExynosM3]>;

Ordering. Please use the CortexA55Model. This is not an out of order core like 
the A57.



Comment at: llvm/lib/Target/AArch64/AArch64Subtarget.cpp:196
 break;
+  case CortexA510:
+PrefFunctionLogAlignment = 4;

This can be the same case block as the A53 and A55.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109825

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


[PATCH] D109825: [AArch64]Enabling Cortex-A510 Support

2021-09-15 Thread Mubashar Ahmad via Phabricator via cfe-commits
mubashar_ updated this revision to Diff 372698.
mubashar_ added a comment.

Updated release notes to solve a merge conflict.


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

https://reviews.llvm.org/D109825

Files:
  clang/docs/ReleaseNotes.rst
  clang/test/Driver/aarch64-cpus.c
  llvm/include/llvm/Support/AArch64TargetParser.def
  llvm/lib/Target/AArch64/AArch64.td
  llvm/lib/Target/AArch64/AArch64Subtarget.cpp
  llvm/lib/Target/AArch64/AArch64Subtarget.h
  llvm/unittests/Support/TargetParserTest.cpp

Index: llvm/unittests/Support/TargetParserTest.cpp
===
--- llvm/unittests/Support/TargetParserTest.cpp
+++ llvm/unittests/Support/TargetParserTest.cpp
@@ -983,6 +983,14 @@
  AArch64::AEK_DOTPROD | AArch64::AEK_RCPC |
  AArch64::AEK_SSBS,
  "8.2-A"),
+ARMCPUTestParams("cortex-a510", "armv8.3-a", "crypto-neon-fp-armv8",
+ AArch64::AEK_CRC | AArch64::AEK_CRYPTO |
+ AArch64::AEK_FP | AArch64::AEK_SIMD |
+ AArch64::AEK_RAS | AArch64::AEK_LSE |
+ AArch64::AEK_RDM | AArch64::AEK_RCPC |
+ AArch64::AEK_SVE2 | AArch64::AEK_SVE2BITPERM |
+ AArch64::AEK_DOTPROD | AArch64::AEK_MTE,
+ "8.3-A"),
 ARMCPUTestParams("cyclone", "armv8-a", "crypto-neon-fp-armv8",
  AArch64::AEK_NONE | AArch64::AEK_CRYPTO |
  AArch64::AEK_FP | AArch64::AEK_SIMD,
@@ -1164,7 +1172,7 @@
  AArch64::AEK_LSE | AArch64::AEK_RDM,
  "8.2-A")));
 
-static constexpr unsigned NumAArch64CPUArchs = 48;
+static constexpr unsigned NumAArch64CPUArchs = 49;
 
 TEST(TargetParserTest, testAArch64CPUArchList) {
   SmallVector List;
Index: llvm/lib/Target/AArch64/AArch64Subtarget.h
===
--- llvm/lib/Target/AArch64/AArch64Subtarget.h
+++ llvm/lib/Target/AArch64/AArch64Subtarget.h
@@ -59,6 +59,7 @@
 CortexA77,
 CortexA78,
 CortexA78C,
+CortexA510,
 CortexR82,
 CortexX1,
 ExynosM3,
Index: llvm/lib/Target/AArch64/AArch64Subtarget.cpp
===
--- llvm/lib/Target/AArch64/AArch64Subtarget.cpp
+++ llvm/lib/Target/AArch64/AArch64Subtarget.cpp
@@ -193,6 +193,9 @@
 // FIXME: remove this to enable 64-bit SLP if performance looks good.
 MinVectorRegisterBitWidth = 128;
 break;
+  case CortexA510:
+PrefFunctionLogAlignment = 4;
+break;
   }
 }
 
Index: llvm/lib/Target/AArch64/AArch64.td
===
--- llvm/lib/Target/AArch64/AArch64.td
+++ llvm/lib/Target/AArch64/AArch64.td
@@ -1048,6 +1048,26 @@
   FeatureSSBS,
   FeatureSVE]>;
 
+def ProcCortexA510 : SubtargetFeature<"cortex-a510", "ARMProcFamily",
+  "CortexA510", "Cortex-A510 ARM processors", [
+  HasV8_3aOps,
+  FeatureCrypto,
+  FeatureFPARMv8,
+  FeatureFuseAES,
+  FeatureNEON,
+  FeaturePerfMon,
+  FeaturePostRAScheduler,
+  FeatureSPE,
+  FeatureAM,
+  FeatureMPAM,
+  FeatureETE,
+  FeatureMTE,
+  FeatureSVE2,
+  FeatureSVE2BitPerm,
+  FeatureFullFP16,
+  FeatureFP16FML,
+  FeatureDotProd]>;
+
 def ProcSaphira  : SubtargetFeature<"saphira", "ARMProcFamily", "Saphira",
"Qualcomm Saphira processors", [
FeatureCrypto,
@@ -1187,6 +1207,7 @@
 def : ProcessorModel<"neoverse-n1", CortexA57Model, [ProcNeoverseN1]>;
 def : ProcessorModel<"neoverse-n2", CortexA57Model, [ProcNeoverseN2]>;
 def : ProcessorModel<"neoverse-v1", CortexA57Model, [ProcNeoverseV1]>;
+def : ProcessorModel<"cortex-a510", CortexA57Model, [ProcCortexA510]>;
 def : ProcessorModel<"exynos-m3", ExynosM3Model, [ProcExynosM3]>;
 def : ProcessorModel<"exynos-m4", ExynosM4Model, [ProcExynosM4]>;
 def : ProcessorModel<"exynos-m5", ExynosM5Model, [ProcExynosM4]>;
Index: llvm/include/llvm/Support/AArch64TargetParser.def
===
--- llvm/include/llvm/Support/AArch64Tar

[PATCH] D109825: [AArch64]Enabling Cortex-A510 Support

2021-09-15 Thread Mark Murray via Phabricator via cfe-commits
MarkMurrayARM added a comment.

In D109825#3001622 , @dmgreen wrote:

>> As I did the downstream work for this, I'm happy with it to go in in this 
>> form.
>
> This doesn't seem.. wise. Please make sure the reviews you do are at a 
> sufficient quality, and it is probably best not to review patches you write 
> yourself.

Very good point!

I reduce this to the claim that it has been stable downstream for a couple of 
weeks now.


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

https://reviews.llvm.org/D109825

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


[clang] 274adcb - Implement delimited escape sequences.

2021-09-15 Thread Aaron Ballman via cfe-commits

Author: Corentin Jabot
Date: 2021-09-15T09:54:49-04:00
New Revision: 274adcb866343cb505408d8f401840ea814522c8

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

LOG: Implement delimited escape sequences.

\x{} \u{} and \o{} are accepted in all languages mode
in characters and string literals.

This is a feature proposed for both C++ (P2290R1) and C (N2785). The
papers have been seen by both committees but are not yet adopted into
either standard. However, they do have support from both committees.

Added: 
clang/test/Lexer/char-escapes-delimited.c

Modified: 
clang/include/clang/Basic/DiagnosticLexKinds.td
clang/lib/Lex/Lexer.cpp
clang/lib/Lex/LiteralSupport.cpp
clang/test/Parser/cxx11-user-defined-literals.cpp
clang/test/Preprocessor/ucn-pp-identifier.c
clang/test/Sema/ucn-identifiers.c

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticLexKinds.td 
b/clang/include/clang/Basic/DiagnosticLexKinds.td
index 49c50fb27e624..faa84774167b9 100644
--- a/clang/include/clang/Basic/DiagnosticLexKinds.td
+++ b/clang/include/clang/Basic/DiagnosticLexKinds.td
@@ -127,6 +127,15 @@ def warn_utf8_symbol_zero_width : Warning<
   "identifier contains Unicode character  that is invisible in "
   "some environments">, InGroup>;
 
+def ext_delimited_escape_sequence : Extension<
+  "delimited escape sequences are a Clang extension">,
+  InGroup>;
+def err_delimited_escape_empty : Error<
+  "delimited escape sequence cannot be empty">;
+def err_delimited_escape_missing_brace: Error<
+  "expected '{' after '\\%0' escape sequence">;
+def err_delimited_escape_invalid : Error<
+  "invalid digit '%0' in escape sequence">;
 def err_hex_escape_no_digits : Error<
   "\\%0 used with no following hex digits">;
 def warn_ucn_escape_no_digits : Warning<
@@ -134,6 +143,12 @@ def warn_ucn_escape_no_digits : Warning<
   "treating as '\\' followed by identifier">, InGroup;
 def err_ucn_escape_incomplete : Error<
   "incomplete universal character name">;
+def warn_delimited_ucn_incomplete : Warning<
+  "incomplete delimited universal character name; "
+  "treating as '\\' 'u' '{' identifier">, InGroup;
+def warn_delimited_ucn_empty : Warning<
+  "empty delimited universal character name; "
+  "treating as '\\' 'u' '{' '}'">, InGroup;
 def warn_ucn_escape_incomplete : Warning<
   "incomplete universal character name; "
   "treating as '\\' followed by identifier">, InGroup;

diff  --git a/clang/lib/Lex/Lexer.cpp b/clang/lib/Lex/Lexer.cpp
index 2685924392d05..55693c8f8cf46 100644
--- a/clang/lib/Lex/Lexer.cpp
+++ b/clang/lib/Lex/Lexer.cpp
@@ -3112,6 +3112,10 @@ uint32_t Lexer::tryReadUCN(const char *&StartPtr, const 
char *SlashLoc,
Token *Result) {
   unsigned CharSize;
   char Kind = getCharAndSize(StartPtr, CharSize);
+  bool Delimited = false;
+  bool FoundEndDelimiter = false;
+  unsigned Count = 0;
+  bool Diagnose = Result && !isLexingRawMode();
 
   unsigned NumHexDigits;
   if (Kind == 'u')
@@ -3122,7 +3126,7 @@ uint32_t Lexer::tryReadUCN(const char *&StartPtr, const 
char *SlashLoc,
 return 0;
 
   if (!LangOpts.CPlusPlus && !LangOpts.C99) {
-if (Result && !isLexingRawMode())
+if (Diagnose)
   Diag(SlashLoc, diag::warn_ucn_not_valid_in_c89);
 return 0;
   }
@@ -3131,39 +3135,70 @@ uint32_t Lexer::tryReadUCN(const char *&StartPtr, const 
char *SlashLoc,
   const char *KindLoc = &CurPtr[-1];
 
   uint32_t CodePoint = 0;
-  for (unsigned i = 0; i < NumHexDigits; ++i) {
+  while (Count != NumHexDigits || Delimited) {
 char C = getCharAndSize(CurPtr, CharSize);
+if (!Delimited && C == '{') {
+  Delimited = true;
+  CurPtr += CharSize;
+  continue;
+}
+
+if (Delimited && C == '}') {
+  CurPtr += CharSize;
+  FoundEndDelimiter = true;
+  break;
+}
 
 unsigned Value = llvm::hexDigitValue(C);
 if (Value == -1U) {
-  if (Result && !isLexingRawMode()) {
-if (i == 0) {
-  Diag(BufferPtr, diag::warn_ucn_escape_no_digits)
-<< StringRef(KindLoc, 1);
-} else {
-  Diag(BufferPtr, diag::warn_ucn_escape_incomplete);
-
-  // If the user wrote \U1234, suggest a fixit to \u.
-  if (i == 4 && NumHexDigits == 8) {
-CharSourceRange URange = makeCharRange(*this, KindLoc, KindLoc + 
1);
-Diag(KindLoc, diag::note_ucn_four_not_eight)
-  << FixItHint::CreateReplacement(URange, "u");
-  }
-}
-  }
+  if (!Delimited)
+break;
+  if (Diagnose)
+Diag(BufferPtr, diag::warn_delimited_ucn_incomplete)
+<< StringRef(&C, 1);
+  return 0;
+}
 
+if (CodePoint & 0xF000') {
+  if (Diagnose)
+Diag(KindLoc, diag::err_escape_too_larg

[PATCH] D105191: [Clang][OpenMP] Add support for Static Device Libraries

2021-09-15 Thread Ye Luo via Phabricator via cfe-commits
ye-luo added a comment.

> The option of adding sm_XX in Bundle Entry ID when user hasn't used -march 
> flag, comes under command line simplification. I have a bunch of upcoming 
> patches which will significantly simplify OpenMP command line for GPU 
> offloading. But, don't you think this feature is different than supporting 
> static device libraries and should be dealt separately?

Simplifying command line options is a different topic and we have not agreed 
upon how to do the simplification. In general, that is unrelated to this broken 
test case. But it can probably be fixed later with a separate patch.

> Our plan was always to support SDLs using -l and -L options, as described in 
> Greg Rodgers's presentation about static device libraries 
>  in last year's LLVM-CTH 
> Workshop. It was also discussed in multi company meetings. We can explore 
> supporting direct linking of SDLs as described by you, but it seems to me 
> that it is out of scope of this patch. What do you think?

To me, supporting both -L/-l and libXXX.a are both required for static 
libraries. It is not reasonable to request users to use one way not the other. 
AOMP had no issue working in both ways.

> PS: We (mulit-company OpenMP-dev meetings) have been tracking this feature 
> for a while and we would very much like it to be picked for llvm-13.

Although we wanted to deliver this feature to users, I don't think we should 
tell users that linking static archive works with the current quality. So in my 
view, It is not suitable to backport it o 13.

This patch is good. It makes part of the static linking feature work but we can 
not claim "Static Device Libraries" is fully working. So please update the tile 
and also in the description saying what is working and what is not. Also need a 
test case for nvptx64.
In addition, I'd like to see commitment of addressing both above failed test 
cases before accepting this patch to help incremental development.

by the way, I found offload to x86 with static linking doesn't work with -L. 
-lmylib
https://github.com/ye-luo/openmp-target/blob/master/tests/linking/link_static_fat_bin/compile-x86.sh
I think this can also be addressed separately. FYI, AOMP happily makes it 
working.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105191

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


[PATCH] D109607: [X86] Refactor GetSSETypeAtOffset to fix pr51813

2021-09-15 Thread LuoYuanke via Phabricator via cfe-commits
LuoYuanke accepted this revision.
LuoYuanke added a comment.
This revision is now accepted and ready to land.

LGTM, but pls wait 1 or 2 days for the comments from others.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109607

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


[PATCH] D109828: [clang-cl] Add a /diasdkdir flag and make /winsysroot imply it

2021-09-15 Thread Nico Weber via Phabricator via cfe-commits
thakis created this revision.
thakis added a reviewer: hans.
Herald added subscribers: dang, pengfei.
thakis requested review of this revision.

D109708  added "DIA SDK" to our win sysroot 
for hermetic builds
that use LLVM_ENABLE_DIA_SDK. But the build system still has to
manually pass flags pointing to it.

Since we have a /winsysroot flag, make it look at DIA SDK in
the sysroot.

With this, the following is enough to compile the DIA2Dump example:

out\gn\bin\clang-cl ^

  "sysroot\DIA SDK\Samples\DIA2Dump\DIA2Dump.cpp" ^
  "sysroot\DIA SDK\Samples\DIA2Dump\PrintSymbol.cpp" ^
  "sysroot\DIA SDK\Samples\DIA2Dump\regs.cpp" ^
  /diasdkdir "sysroot\DIA SDK" ^
  ole32.lib oleaut32.lib diaguids.lib

---

Given that the DIA SDK is part of the MSVC installation (at ` C:\Program Files 
(x86)\Microsoft Visual Studio\2017\Professional\DIA SDK` on my machine), I 
think there's a case for letting clang-cl know about it. Arguably, adding `/I 
sysroot\DIA SDK\include` to your cflags isn't super difficult, but one day 
we'll teach lld-link about /winsysroot too, and then it means you don't need to 
know about the `lib\` folder layout inside DIA SDK. Also, if you link through 
clang-cl instead of calling the linker directly, you get that simplification 
with this change already. That's nice for local one-off commands, but in 
practice most projects admittedly call link.exe directly.

So all-in-all, I think this is a good idea, but I could be convinced otherwise 
if others disagree.


https://reviews.llvm.org/D109828

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/MSVC.cpp
  clang/test/Driver/cl-sysroot.cpp

Index: clang/test/Driver/cl-sysroot.cpp
===
--- clang/test/Driver/cl-sysroot.cpp
+++ clang/test/Driver/cl-sysroot.cpp
@@ -1,18 +1,27 @@
 // RUN: rm -rf %t
 // RUN: split-file %s %t
 
-// RUN: %clang_cl /winsysroot %t -### -- %t/foo.cpp 2>&1 | FileCheck %s
-// RUN: %clang_cl /vctoolsdir %t/VC/Tools/MSVC/27.1828.18284 \
-// RUN:   /winsdkdir "%t/Windows Kits/10" \
-// RUN:   -### -- %t/foo.cpp 2>&1 | FileCheck %s
+// RUN: %clang_cl -m64 /winsysroot %t -### -- %t/foo.cpp 2>&1 | FileCheck %s
+// RUN: %clang_cl -m64 \
+// RUN: /diasdkdir "%t/DIA SDK" \
+// RUN: /vctoolsdir %t/VC/Tools/MSVC/27.1828.18284 \
+// RUN: /winsdkdir "%t/Windows Kits/10" \
+// RUN: -### -- %t/foo.cpp 2>&1 | FileCheck %s
 
-// CHECK: "-internal-isystem" "[[ROOT:[^"]*]]{{/|}}VC{{/|}}Tools{{/|}}MSVC{{/|}}27.1828.18284{{/|}}include"
+// CHECK: "-internal-isystem" "[[ROOT:[^"]*]]{{/|}}DIA SDK{{/|}}include"
+// CHECK: "-internal-isystem" "[[ROOT]]{{/|}}VC{{/|}}Tools{{/|}}MSVC{{/|}}27.1828.18284{{/|}}include"
 // CHECK: "-internal-isystem" "[[ROOT]]{{/|}}VC{{/|}}Tools{{/|}}MSVC{{/|}}27.1828.18284{{/|}}atlmfc{{/|}}include"
 // CHECK: "-internal-isystem" "[[ROOT]]{{/|}}Windows Kits{{/|}}10{{/|}}Include{{/|}}10.0.19041.0{{/|}}ucrt"
 // CHECK: "-internal-isystem" "[[ROOT]]{{/|}}Windows Kits{{/|}}10{{/|}}Include{{/|}}10.0.19041.0{{/|}}shared"
 // CHECK: "-internal-isystem" "[[ROOT]]{{/|}}Windows Kits{{/|}}10{{/|}}Include{{/|}}10.0.19041.0{{/|}}um"
 // CHECK: "-internal-isystem" "[[ROOT]]{{/|}}Windows Kits{{/|}}10{{/|}}Include{{/|}}10.0.19041.0{{/|}}winrt"
 
+// CHECK: "-libpath:[[ROOT]]{{/|}}DIA SDK{{/|}}lib{{/|}}amd64"
+// CHECK: "-libpath:[[ROOT]]{{/|}}VC{{/|}}Tools{{/|}}MSVC{{/|}}27.1828.18284{{/|}}lib{{/|}}x64"
+// CHECK: "-libpath:[[ROOT]]{{/|}}VC{{/|}}Tools{{/|}}MSVC{{/|}}27.1828.18284{{/|}}atlmfc{{/|}}lib{{/|}}x64"
+// CHECK: "-libpath:[[ROOT]]{{/|}}Windows Kits{{/|}}10{{/|}}Lib{{/|}}10.0.19041.0{{/|}}ucrt{{/|}}x64"
+// CHECK: "-libpath:[[ROOT]]{{/|}}Windows Kits{{/|}}10{{/|}}Lib{{/|}}10.0.19041.0{{/|}}um{{/|}}x64"
+
 #--- VC/Tools/MSVC/27.1828.18284/include/string
 namespace std {
 class mystring {
@@ -24,6 +33,9 @@
 #--- Windows Kits/10/Include/10.0.19041.0/ucrt/assert.h
 #define myassert(X)
 
+#--- DIA SDK/include/cvconst.h
+#define myotherassert(X)
+
 #--- foo.cpp
 #include 
 #include 
@@ -31,4 +43,5 @@
 void f() {
   std::mystring s;
   myassert(s.empty());
+  myotherassert(s.empty());
 }
Index: clang/lib/Driver/ToolChains/MSVC.cpp
===
--- clang/lib/Driver/ToolChains/MSVC.cpp
+++ clang/lib/Driver/ToolChains/MSVC.cpp
@@ -63,6 +63,8 @@
 using namespace clang;
 using namespace llvm::opt;
 
+static const char *llvmArchToLegacyVCArch(llvm::Triple::ArchType Arch);
+
 static bool canExecute(llvm::vfs::FileSystem &VFS, StringRef Path) {
   auto Status = VFS.status(Path);
   if (!Status)
@@ -396,6 +398,20 @@
   // the environment variable is set however, assume the user knows wh

[clang] 1f3925e - [clang][driver][AIX] Add system libc++ header paths to driver

2021-09-15 Thread David Tenty via cfe-commits

Author: David Tenty
Date: 2021-09-15T10:41:18-04:00
New Revision: 1f3925e25ae010c30273501d24b2bd4e0318fe7a

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

LOG: [clang][driver][AIX] Add system libc++ header paths to driver

This change adds the system libc++ header location to the driver. As well we 
define
the `__LIBC_NO_CPP_MATH_OVERLOADS__` macro when using those headers, in order 
to suppress
conflicting C++ overloads in the system libc headers that were used by XL C++.

Reviewed By: ZarkoCA

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/AIX.cpp
clang/lib/Driver/ToolChains/AIX.h
clang/test/Driver/aix-ld.c
clang/test/Driver/aix-toolchain-include.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/AIX.cpp 
b/clang/lib/Driver/ToolChains/AIX.cpp
index 3000b8416adfd..2a380d9676003 100644
--- a/clang/lib/Driver/ToolChains/AIX.cpp
+++ b/clang/lib/Driver/ToolChains/AIX.cpp
@@ -218,15 +218,44 @@ void AIX::AddClangSystemIncludeArgs(const ArgList 
&DriverArgs,
   addSystemInclude(DriverArgs, CC1Args, UP.str());
 }
 
+void AIX::AddClangCXXStdlibIncludeArgs(
+const llvm::opt::ArgList &DriverArgs,
+llvm::opt::ArgStringList &CC1Args) const {
+
+  if (DriverArgs.hasArg(options::OPT_nostdinc) ||
+  DriverArgs.hasArg(options::OPT_nostdincxx) ||
+  DriverArgs.hasArg(options::OPT_nostdlibinc))
+return;
+
+  switch (GetCXXStdlibType(DriverArgs)) {
+  case ToolChain::CST_Libstdcxx:
+llvm::report_fatal_error(
+"picking up libstdc++ headers is unimplemented on AIX");
+  case ToolChain::CST_Libcxx: {
+llvm::StringRef Sysroot = GetHeaderSysroot(DriverArgs);
+SmallString<128> PathCPP(Sysroot);
+llvm::sys::path::append(PathCPP, "opt/IBM/openxlCSDK", "include", "c++",
+"v1");
+addSystemInclude(DriverArgs, CC1Args, PathCPP.str());
+// Required in order to suppress conflicting C++ overloads in the system
+// libc headers that were used by XL C++.
+CC1Args.push_back("-D__LIBC_NO_CPP_MATH_OVERLOADS__");
+return;
+  }
+  }
+
+  llvm_unreachable("Unexpected C++ library type; only libc++ is supported.");
+}
+
 void AIX::AddCXXStdlibLibArgs(const llvm::opt::ArgList &Args,
   llvm::opt::ArgStringList &CmdArgs) const {
   switch (GetCXXStdlibType(Args)) {
+  case ToolChain::CST_Libstdcxx:
+llvm::report_fatal_error("linking libstdc++ unimplemented on AIX");
   case ToolChain::CST_Libcxx:
 CmdArgs.push_back("-lc++");
 CmdArgs.push_back("-lc++abi");
 return;
-  case ToolChain::CST_Libstdcxx:
-llvm::report_fatal_error("linking libstdc++ unimplemented on AIX");
   }
 
   llvm_unreachable("Unexpected C++ library type; only libc++ is supported.");

diff  --git a/clang/lib/Driver/ToolChains/AIX.h 
b/clang/lib/Driver/ToolChains/AIX.h
index d1ec6d10fb3a0..5fcea1305c7c1 100644
--- a/clang/lib/Driver/ToolChains/AIX.h
+++ b/clang/lib/Driver/ToolChains/AIX.h
@@ -70,6 +70,10 @@ class LLVM_LIBRARY_VISIBILITY AIX : public ToolChain {
   AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
 llvm::opt::ArgStringList &CC1Args) const override;
 
+  void AddClangCXXStdlibIncludeArgs(
+  const llvm::opt::ArgList &DriverArgs,
+  llvm::opt::ArgStringList &CC1Args) const override;
+
   void AddCXXStdlibLibArgs(const llvm::opt::ArgList &Args,
llvm::opt::ArgStringList &CmdArgs) const override;
 

diff  --git a/clang/test/Driver/aix-ld.c b/clang/test/Driver/aix-ld.c
index c5f1061f03466..de70c2f030464 100644
--- a/clang/test/Driver/aix-ld.c
+++ b/clang/test/Driver/aix-ld.c
@@ -584,14 +584,14 @@
 // Check powerpc-ibm-aix7.1.0.0, 32-bit. -stdlib=libstdc++ invokes fatal error.
 // RUN: not --crash %clangxx -no-canonical-prefixes %s 2>&1 -### \
 // RUN:-target powerpc-ibm-aix7.1.0.0 \
-// RUN:-stdlib=libstdc++ \
+// RUN:-stdlib=libstdc++ -nostdinc++ \
 // RUN:--sysroot %S/Inputs/aix_ppc_tree \
 // RUN:   | FileCheck --check-prefix=CHECK-LD-LIBSTDCXX %s
 
 // Check powerpc64-ibm-aix7.1.0.0, 64-bit. -stdlib=libstdc++ invokes fatal 
error.
 // RUN: not --crash %clangxx -no-canonical-prefixes %s 2>&1 -### \
 // RUN:-target powerpc64-ibm-aix7.1.0.0 \
-// RUN:-stdlib=libstdc++ \
+// RUN:-stdlib=libstdc++ -nostdinc++ \
 // RUN:--sysroot %S/Inputs/aix_ppc_tree \
 // RUN:   | FileCheck --check-prefix=CHECK-LD-LIBSTDCXX %s
 // CHECK-LD-LIBSTDCXX: LLVM ERROR: linking libstdc++ unimplemented on AIX

diff  --git a/clang/test/Driver/aix-toolchain-include.cpp 
b/clang/test/Driver/aix-toolchain-include.cpp
index dc8b272936a48..2ea60b2722977 100644
--- a/clang/test/Driver/aix-toolchain-include.cpp
+++ b/clan

[PATCH] D109078: [clang][driver][AIX] Add system libc++ header paths to driver

2021-09-15 Thread David Tenty via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG1f3925e25ae0: [clang][driver][AIX] Add system libc++ header 
paths to driver (authored by daltenty).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109078

Files:
  clang/lib/Driver/ToolChains/AIX.cpp
  clang/lib/Driver/ToolChains/AIX.h
  clang/test/Driver/aix-ld.c
  clang/test/Driver/aix-toolchain-include.cpp

Index: clang/test/Driver/aix-toolchain-include.cpp
===
--- clang/test/Driver/aix-toolchain-include.cpp
+++ clang/test/Driver/aix-toolchain-include.cpp
@@ -5,13 +5,13 @@
 // RUN:		-target powerpc-ibm-aix \
 // RUN:		-resource-dir=%S/Inputs/resource_dir \
 // RUN:		--sysroot=%S/Inputs/basic_aix_tree \
-// RUN:   | FileCheck -check-prefix=CHECK-INTERNAL-INCLUDE %s
+// RUN:   | FileCheck -check-prefixes=CHECK-INTERNAL-INCLUDE,CHECK-INTERNAL-INCLUDE-CXX %s
 
 // RUN: %clangxx -### -no-canonical-prefixes %s 2>&1 \
 // RUN:		-target powerpc64-ibm-aix \
 // RUN:		-resource-dir=%S/Inputs/resource_dir \
 // RUN:		--sysroot=%S/Inputs/basic_aix_tree \
-// RUN:   | FileCheck -check-prefix=CHECK-INTERNAL-INCLUDE %s
+// RUN:   | FileCheck -check-prefixes=CHECK-INTERNAL-INCLUDE,CHECK-INTERNAL-INCLUDE-CXX %s
 
 // RUN: %clang -### -xc -no-canonical-prefixes %s 2>&1 \
 // RUN:		-target powerpc-ibm-aix \
@@ -25,11 +25,13 @@
 // RUN:		--sysroot=%S/Inputs/basic_aix_tree \
 // RUN:   | FileCheck -check-prefix=CHECK-INTERNAL-INCLUDE %s
 
-// CHECK-INTERNAL-INCLUDE:	{{.*}}clang{{.*}}" "-cc1"
-// CHECK-INTERNAL-INCLUDE:	"-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
-// CHECK-INTERNAL-INCLUDE:	"-isysroot" "[[SYSROOT:[^"]+]]"
-// CHECK-INTERNAL-INCLUDE:	"-internal-isystem" "[[RESOURCE_DIR]]{{(/|)}}include"
-// CHECK-INTERNAL-INCLUDE:	"-internal-isystem" "[[SYSROOT]]/usr/include"
+// CHECK-INTERNAL-INCLUDE:  {{.*}}clang{{.*}}" "-cc1"
+// CHECK-INTERNAL-INCLUDE:  "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
+// CHECK-INTERNAL-INCLUDE:  "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-INTERNAL-INCLUDE-CXX:  "-internal-isystem" "[[SYSROOT]]{{(/|)}}opt{{(/|)}}IBM{{(/|)}}openxlCSDK{{(/|)}}include{{(/|)}}c++{{(/|)}}v1"
+// CHECK-INTERNAL-INCLUDE-CXX:  "-D__LIBC_NO_CPP_MATH_OVERLOADS__"
+// CHECK-INTERNAL-INCLUDE:  "-internal-isystem" "[[RESOURCE_DIR]]{{(/|)}}include"
+// CHECK-INTERNAL-INCLUDE:  "-internal-isystem" "[[SYSROOT]]/usr/include"
 
 // Check powerpc-ibm-aix, 32-bit/64-bit. -nostdinc option.
 // RUN: %clangxx -### -no-canonical-prefixes %s 2>&1 \
@@ -98,6 +100,8 @@
 // CHECK-NOSTDLIBINC-INCLUDE:	"-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
 // CHECK-NOSTDLIBINC-INCLUDE:	"-isysroot" "[[SYSROOT:[^"]+]]"
 // CHECK-NOSTDLIBINC-INCLUDE:	"-internal-isystem" "[[RESOURCE_DIR]]{{(/|)}}include"
+// CHECK-NOSTDLIBINC-INCLUDE-NOT:  "-internal-isystem" "[[SYSROOT]]{{(/|)}}opt{{(/|)}}IBM{{(/|)}}openxlCSDK{{(/|)}}include{{(/|)}}c++{{(/|)}}v1"
+// CHECK-NOSTDLIBINC-INCLUDE-NOT:  "-D__LIBC_NO_CPP_MATH_OVERLOADS__"
 // CHECK-NOSTDLIBINC-INCLUDE-NOT:	"-internal-isystem" "[[SYSROOT]]/usr/include"
 
 // Check powerpc-ibm-aix, 32-bit/64-bit. -nobuiltininc option.
@@ -106,14 +110,14 @@
 // RUN:		-resource-dir=%S/Inputs/resource_dir \
 // RUN:		--sysroot=%S/Inputs/basic_aix_tree \
 // RUN:		-nobuiltininc \
-// RUN:   | FileCheck -check-prefix=CHECK-NOBUILTININC-INCLUDE %s
+// RUN:   | FileCheck -check-prefixes=CHECK-NOBUILTININC-INCLUDE,CHECK-NOBUILTININC-INCLUDE-CXX %s
 
 // RUN: %clangxx -### -no-canonical-prefixes %s 2>&1 \
 // RUN:		-target powerpc64-ibm-aix \
 // RUN:		-resource-dir=%S/Inputs/resource_dir \
 // RUN:		--sysroot=%S/Inputs/basic_aix_tree \
 // RUN:		-nobuiltininc \
-// RUN:   | FileCheck -check-prefix=CHECK-NOBUILTININC-INCLUDE %s
+// RUN:   | FileCheck -check-prefixes=CHECK-NOBUILTININC-INCLUDE,CHECK-NOBUILTININC-INCLUDE-CXX  %s
 
 // RUN: %clang -### -xc -no-canonical-prefixes %s 2>&1 \
 // RUN:		-target powerpc-ibm-aix \
@@ -133,4 +137,45 @@
 // CHECK-NOBUILTININC-INCLUDE:	"-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
 // CHECK-NOBUILTININC-INCLUDE:	"-isysroot" "[[SYSROOT:[^"]+]]"
 // CHECK-NOBUILTININC-INCLUDE-NOT:	"-internal-isystem" "[[RESOURCE_DIR]]{{(/|)}}include"
+// CHECK-NOBUILTININC-INCLUDE-CXX:  "-internal-isystem" "[[SYSROOT]]{{(/|)}}opt{{(/|)}}IBM{{(/|)}}openxlCSDK{{(/|)}}include{{(/|)}}c++{{(/|)}}v1"
+// CHECK-NOBUILTININC-INCLUDE-CXX:  "-D__LIBC_NO_CPP_MATH_OVERLOADS__"
 // CHECK-NOBUILTININC-INCLUDE:	"-internal-isystem" "[[SYSROOT]]/usr/include"
+
+// Check powerpc-ibm-aix, 32-bit/64-bit. -nostdinc++ option.
+// RUN: %clangxx -### -no-canonical-prefixes %s 2>&1 \
+// RUN:  -target powerpc-ibm-aix \
+// RUN:  -resource-dir=%S/Inputs/resource_dir \
+// RUN:  --sysroot=%S/Inputs/basic_aix_tree \
+// RUN:  -nostdinc++ \
+// RUN:   | FileCheck -check-prefix=CHECK-NOSTDINCXX-INCLUDE %s
+
+// RUN:

[PATCH] D109812: [compiler-rt] Move -fno-omit-frame-pointer check to common config-ix

2021-09-15 Thread Tom Stellard via Phabricator via cfe-commits
tstellar accepted this revision.
tstellar added a comment.
This revision is now accepted and ready to land.

LGTM.  Thank you.


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

https://reviews.llvm.org/D109812

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


[PATCH] D109234: [PGO] Change ThinLTO test for targets with loop unrolling disabled

2021-09-15 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson added inline comments.



Comment at: clang/test/CodeGen/pgo-sample-thinlto-summary.c:3
+// RUN: %clang_cc1 -mllvm -debug-pass=Structure -O2 
-fno-experimental-new-pass-manager 
-fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm 
-flto=thin -o - 2>&1 | FileCheck %s -check-prefix=THINLTO-OLDPM
+// RUN: %clang_cc1 -mllvm -debug-pass=Structure -O2 
-fexperimental-new-pass-manager -fdebug-pass-manager 
-fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm -o 
- 2>&1 | FileCheck %s -check-prefix=SAMPLEPGO
+// RUN: %clang_cc1 -mllvm -debug-pass=Structure -O2 
-fexperimental-new-pass-manager -fdebug-pass-manager 
-fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm 
-flto=thin -o - 2>&1 | FileCheck %s -check-prefix=THINLTO

thopre wrote:
> While we now need to explicitely request the old pass manager, the new pass 
> manager is the default so we don't need to be explicit.
For the newPM, remove -mllvm -debug-pass=Structure since it isn't doing 
anything, and you are getting the printing from -fdebug-pass-manager. Also 
suggest moving the -fdebug-pass-manager into the position where you currently 
have  -mllvm -debug-pass=Structure so the printing options are in the 
equivalent place for both PM invocations.



Comment at: clang/test/CodeGen/pgo-sample-thinlto-summary.c:27
+// THINLTO-OLDPM-NOT:   PGOIndirectCallPromotion
+// THINLTO-OLDPM:   Unroll loops
+// THINLTO-OLDPM-NOT:   Unroll loops

sherwin-dc wrote:
> When printing out passes with the old PM 'Unroll loops' is printed out twice 
> with sample PGO and once with thin LTO.
I looked at the old PM, the first one is the createSimpleLoopUnrollPass that 
does some full unrolling and peeling of small constant trip count loops. Can 
you just add a comment above the check for the first Unroll loops here for 
ThinLTO to note this. It's the second invocation that we delay until the 
ThinLTO backends.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109234

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


[PATCH] D108138: [WIP] Remove switch statements before vectorization

2021-09-15 Thread Kerry McLaughlin via Phabricator via cfe-commits
kmclaughlin updated this revision to Diff 372706.
kmclaughlin retitled this revision from "[SimplifyCFG] Remove switch statements 
before vectorization" to "[WIP] Remove switch statements before vectorization".
kmclaughlin edited the summary of this revision.
kmclaughlin added a comment.
Herald added subscribers: kerbowa, nhaehnle, jvesely.

- Removed changes to SimplifyCFG and instead run LowerSwitch before 
vectorisation.
- Added `SimpleSwitchConvert` to LowerSwitch which is used if the pass is run 
before vectorisation - this only considers simple switches (where each 
destination block is unique) which are also part of a loop.


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

https://reviews.llvm.org/D108138

Files:
  clang/test/Frontend/optimization-remark-analysis.c
  llvm/include/llvm/Transforms/Utils/LowerSwitch.h
  llvm/lib/Passes/PassBuilder.cpp
  llvm/lib/Transforms/Scalar/StructurizeCFG.cpp
  llvm/lib/Transforms/Utils/FixIrreducible.cpp
  llvm/lib/Transforms/Utils/LowerSwitch.cpp
  llvm/lib/Transforms/Utils/UnifyLoopExits.cpp
  llvm/test/CodeGen/AMDGPU/llc-pipeline.ll
  llvm/test/Other/new-pm-defaults.ll
  llvm/test/Other/new-pm-lto-defaults.ll
  llvm/test/Other/new-pm-thinlto-defaults.ll
  llvm/test/Other/new-pm-thinlto-postlink-pgo-defaults.ll
  llvm/test/Other/new-pm-thinlto-postlink-samplepgo-defaults.ll
  llvm/test/Transforms/LoopVectorize/AArch64/sve-remove-switches.ll
  llvm/test/Transforms/LoopVectorize/remove-switches.ll
  llvm/test/Transforms/LowerSwitch/simple-switches.ll
  llvm/test/Transforms/StructurizeCFG/workarounds/needs-fr-ule.ll

Index: llvm/test/Transforms/StructurizeCFG/workarounds/needs-fr-ule.ll
===
--- llvm/test/Transforms/StructurizeCFG/workarounds/needs-fr-ule.ll
+++ llvm/test/Transforms/StructurizeCFG/workarounds/needs-fr-ule.ll
@@ -13,32 +13,32 @@
 ; CHECK-NEXT:[[PRED11_INV:%.*]] = xor i1 [[PRED11:%.*]], true
 ; CHECK-NEXT:[[PRED12_INV:%.*]] = xor i1 [[PRED12:%.*]], true
 ; CHECK-NEXT:[[PRED13_INV:%.*]] = xor i1 [[PRED13:%.*]], true
-; CHECK-NEXT:br i1 [[PRED0_INV]], label [[IF_THEN:%.*]], label [[FLOW19:%.*]]
-; CHECK:   Flow19:
+; CHECK-NEXT:br i1 [[PRED0_INV]], label [[IF_THEN:%.*]], label [[FLOW18:%.*]]
+; CHECK:   Flow18:
 ; CHECK-NEXT:[[TMP0:%.*]] = phi i1 [ false, [[FLOW3:%.*]] ], [ true, [[ENTRY:%.*]] ]
-; CHECK-NEXT:br i1 [[TMP0]], label [[IF_END:%.*]], label [[FLOW20:%.*]]
+; CHECK-NEXT:br i1 [[TMP0]], label [[IF_END:%.*]], label [[FLOW19:%.*]]
 ; CHECK:   if.end:
-; CHECK-NEXT:br i1 [[PRED1_INV]], label [[IF_ELSE:%.*]], label [[FLOW18:%.*]]
-; CHECK:   Flow18:
+; CHECK-NEXT:br i1 [[PRED1_INV]], label [[IF_ELSE:%.*]], label [[FLOW17:%.*]]
+; CHECK:   Flow17:
 ; CHECK-NEXT:[[TMP1:%.*]] = phi i1 [ false, [[IF_ELSE]] ], [ true, [[IF_END]] ]
 ; CHECK-NEXT:br i1 [[TMP1]], label [[IF_THEN7:%.*]], label [[IF_END16:%.*]]
 ; CHECK:   if.then7:
 ; CHECK-NEXT:br label [[IF_END16]]
 ; CHECK:   if.else:
-; CHECK-NEXT:br label [[FLOW18]]
-; CHECK:   Flow20:
+; CHECK-NEXT:br label [[FLOW17]]
+; CHECK:   Flow19:
 ; CHECK-NEXT:br label [[EXIT:%.*]]
 ; CHECK:   if.end16:
-; CHECK-NEXT:br i1 [[PRED2_INV]], label [[IF_THEN39:%.*]], label [[FLOW16:%.*]]
-; CHECK:   Flow16:
+; CHECK-NEXT:br i1 [[PRED2_INV]], label [[IF_THEN39:%.*]], label [[FLOW15:%.*]]
+; CHECK:   Flow15:
 ; CHECK-NEXT:[[TMP2:%.*]] = phi i1 [ false, [[FLOW5:%.*]] ], [ true, [[IF_END16]] ]
-; CHECK-NEXT:br i1 [[TMP2]], label [[WHILE_COND_PREHEADER:%.*]], label [[FLOW17:%.*]]
+; CHECK-NEXT:br i1 [[TMP2]], label [[WHILE_COND_PREHEADER:%.*]], label [[FLOW16:%.*]]
 ; CHECK:   while.cond.preheader:
 ; CHECK-NEXT:br label [[WHILE_COND:%.*]]
-; CHECK:   Flow17:
-; CHECK-NEXT:br label [[FLOW20]]
+; CHECK:   Flow16:
+; CHECK-NEXT:br label [[FLOW19]]
 ; CHECK:   while.cond:
-; CHECK-NEXT:br i1 [[PRED3_INV]], label [[LOR_RHS:%.*]], label [[FLOW12:%.*]]
+; CHECK-NEXT:br i1 [[PRED3_INV]], label [[LOR_RHS:%.*]], label [[FLOW11:%.*]]
 ; CHECK:   Flow7:
 ; CHECK-NEXT:[[TMP3:%.*]] = phi i1 [ [[PRED7:%.*]], [[COND_END61:%.*]] ], [ false, [[IRR_GUARD:%.*]] ]
 ; CHECK-NEXT:[[TMP4:%.*]] = phi i1 [ false, [[COND_END61]] ], [ true, [[IRR_GUARD]] ]
@@ -46,30 +46,30 @@
 ; CHECK:   cond.true49:
 ; CHECK-NEXT:br label [[FLOW8]]
 ; CHECK:   Flow8:
-; CHECK-NEXT:[[TMP5:%.*]] = phi i1 [ false, [[COND_TRUE49]] ], [ true, [[FLOW7:%.*]] ]
-; CHECK-NEXT:[[TMP6:%.*]] = phi i1 [ [[PRED4_INV]], [[COND_TRUE49]] ], [ [[TMP3]], [[FLOW7]] ]
-; CHECK-NEXT:br i1 [[TMP6]], label [[WHILE_BODY63:%.*]], label [[FLOW9:%.*]]
+; CHECK-NEXT:[[TMP5:%.*]] = phi i1 [ true, [[COND_TRUE49]] ], [ false, [[FLOW7:%.*]] ]
+; CHECK-NEXT:[[TMP6:%.*]] = phi i1 [ false, [[COND_TRUE49]] ], [ true, [[FLOW7]] ]
+; CHECK-NEXT:[[TMP7:%.*]] = phi i1 [ [[PRED4_INV]], [[COND_TRUE49]] ], [ 

[PATCH] D108138: [WIP] Remove switch statements before vectorization

2021-09-15 Thread Kerry McLaughlin via Phabricator via cfe-commits
kmclaughlin added a comment.

Hi all, I've updated this to take a different approach - the new patch runs 
LowerSwitch just before the vectoriser, where it will only consider simple 
switches which are part of a loop. For these switches, the pass will create a 
series of branches and compares which SimplifyCFG is able replace with a switch 
again later if the vectoriser did not make any changes.

I'm happy to split this patch up to make it easier to review, but I thought I 
would first post the changes I have so far to gather some thoughts on whether 
this is a better direction than before? Thanks!


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

https://reviews.llvm.org/D108138

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


[PATCH] D109234: [PGO] Change ThinLTO test for targets with loop unrolling disabled

2021-09-15 Thread Sherwin via Phabricator via cfe-commits
sherwin-dc updated this revision to Diff 372720.
sherwin-dc added a comment.

- Modify test to correctly indicate old/new PM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109234

Files:
  clang/test/CodeGen/pgo-sample-thinlto-summary.c


Index: clang/test/CodeGen/pgo-sample-thinlto-summary.c
===
--- clang/test/CodeGen/pgo-sample-thinlto-summary.c
+++ clang/test/CodeGen/pgo-sample-thinlto-summary.c
@@ -1,9 +1,7 @@
-// RUN: %clang_cc1 -O2 
-fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm -o 
- 2>&1 | FileCheck %s -check-prefix=SAMPLEPGO
-// RUN: %clang_cc1 -O2 
-fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm 
-flto=thin -o - 2>&1 | FileCheck %s -check-prefix=THINLTO
-// RUN: %clang_cc1 -O2 -fexperimental-new-pass-manager 
-fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm -o 
- 2>&1 | FileCheck %s -check-prefix=SAMPLEPGO
-// RUN: %clang_cc1 -O2 -fexperimental-new-pass-manager 
-fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm 
-flto=thin -o - 2>&1 | FileCheck %s -check-prefix=THINLTO
-// Checks if hot call is inlined by normal compile, but not inlined by
-// thinlto compile.
+// RUN: %clang_cc1 -mllvm -debug-pass=Structure -O2 
-fno-experimental-new-pass-manager 
-fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm -o 
- 2>&1 | FileCheck %s -check-prefix=SAMPLEPGO-OLDPM
+// RUN: %clang_cc1 -mllvm -debug-pass=Structure -O2 
-fno-experimental-new-pass-manager 
-fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm 
-flto=thin -o - 2>&1 | FileCheck %s -check-prefix=THINLTO-OLDPM
+// RUN: %clang_cc1 -fdebug-pass-manager -O2 
-fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm -o 
- 2>&1 | FileCheck %s -check-prefix=SAMPLEPGO
+// RUN: %clang_cc1 -fdebug-pass-manager -O2 
-fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm 
-flto=thin -o - 2>&1 | FileCheck %s -check-prefix=THINLTO
 
 int baz(int);
 int g;
@@ -13,6 +11,27 @@
 g += baz(i);
 }
 
+// Checks that loop unroll and icp are invoked by normal compile, but not 
thinlto compile.
+
+// SAMPLEPGO:   Running pass: PGOIndirectCallPromotion on [module]
+// SAMPLEPGO:   Running pass: LoopUnrollPass on bar
+
+// SAMPLEPGO-OLDPM: PGOIndirectCallPromotion
+// SAMPLEPGO-OLDPM: Unroll loops
+// SAMPLEPGO-OLDPM: Unroll loops
+
+// THINLTO-NOT: Running pass: PGOIndirectCallPromotion on [module]
+// THINLTO-NOT: Running pass: LoopUnrollPass on bar
+
+// THINLTO-OLDPM-NOT:   PGOIndirectCallPromotion
+// The first Unroll loop pass is the createSimpleLoopUnrollPass that unrolls 
and peels
+// loops with small constant trip counts. Only the second one is handled by 
ThinLTO.
+// THINLTO-OLDPM:   Unroll loops
+// THINLTO-OLDPM-NOT:   Unroll loops
+
+
+// Checks if hot call is inlined by normal compile, but not inlined by
+// thinlto compile.
 // SAMPLEPGO-LABEL: define {{(dso_local )?}}void @bar
 // THINLTO-LABEL: define {{(dso_local )?}}void @bar
 // SAMPLEPGO-NOT: call{{.*}}foo
@@ -20,27 +39,4 @@
 void bar(int n) {
   for (int i = 0; i < n; i++)
 foo(i);
-}
-
-// Checks if loop unroll is invoked by normal compile, but not thinlto compile.
-// SAMPLEPGO-LABEL: define {{(dso_local )?}}void @unroll
-// THINLTO-LABEL: define {{(dso_local )?}}void @unroll
-// SAMPLEPGO: call{{.*}}baz
-// SAMPLEPGO: call{{.*}}baz
-// THINLTO: call{{.*}}baz
-// THINLTO-NOT: call{{.*}}baz
-void unroll() {
-  for (int i = 0; i < 2; i++)
-baz(i);
-}
-
-// Checks that icp is not invoked for ThinLTO, but invoked for normal 
samplepgo.
-// SAMPLEPGO-LABEL: define {{(dso_local )?}}void @icp
-// THINLTO-LABEL: define {{(dso_local )?}}void @icp
-// SAMPLEPGO: if.true.direct_targ
-// FIXME: the following condition needs to be reversed once
-//LTOPreLinkDefaultPipeline is customized.
-// THINLTO-NOT: if.true.direct_targ
-void icp(void (*p)()) {
-  p();
-}
+}
\ No newline at end of file


Index: clang/test/CodeGen/pgo-sample-thinlto-summary.c
===
--- clang/test/CodeGen/pgo-sample-thinlto-summary.c
+++ clang/test/CodeGen/pgo-sample-thinlto-summary.c
@@ -1,9 +1,7 @@
-// RUN: %clang_cc1 -O2 -fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm -o - 2>&1 | FileCheck %s -check-prefix=SAMPLEPGO
-// RUN: %clang_cc1 -O2 -fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm -flto=thin -o - 2>&1 | FileCheck %s -check-prefix=THINLTO
-// RUN: %clang_cc1 -O2 -fexperimental-new-pass-manager -fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm -o - 2>&1 | FileCheck %s -check-prefix=SAMPLEPGO
-// RUN: %clang_cc1 -O2 -fexperimental-new-pas

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

2021-09-15 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

In D104556#3001497 , @catenacyber 
wrote:

> Should we still bump `INSTR_PROF_RAW_VERSION ` so that we are able to 
> distinguish profraw files produced by clang13 and the ones produced by 
> clang14 ?
>
> Right now, both produce `LLVM raw profile data, version 7`

Yes. 14.0.0 is far away, so there is plenty of time bumping it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104556

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


[PATCH] D108138: [WIP] Remove switch statements before vectorization

2021-09-15 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

Hi. I'm personally still not very okay with the approach as it currently is.

Do you need to run LoopRotate after lowering switches? Anything else? 
But then you don't actually know that after spending all this compile time,
the vectorization will actually happen, and you won't just now need to undo all 
this,
correct? This seems conceptually wrong to me.

Will LV never have to learn to deal with switches properly?
I would assume it will, in which case what is the urgency of this temporary 
approach?

If you really don't want to fix this properly, i'm looking forward to an RFC on 
llvm-dev.


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

https://reviews.llvm.org/D108138

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


[PATCH] D109812: [compiler-rt] Move -fno-omit-frame-pointer check to common config-ix

2021-09-15 Thread Michał Górny via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG210d72e9d6b4: [compiler-rt] Move -fno-omit-frame-pointer 
check to common config-ix (authored by mgorny).
Herald added a project: Sanitizers.
Herald added a subscriber: Sanitizers.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109812

Files:
  compiler-rt/cmake/builtin-config-ix.cmake
  compiler-rt/cmake/config-ix.cmake


Index: compiler-rt/cmake/config-ix.cmake
===
--- compiler-rt/cmake/config-ix.cmake
+++ compiler-rt/cmake/config-ix.cmake
@@ -61,6 +61,7 @@
 
 # CodeGen options.
 check_c_compiler_flag(-ffreestanding 
COMPILER_RT_HAS_FFREESTANDING_FLAG)
+check_c_compiler_flag(-fomit-frame-pointer   
COMPILER_RT_HAS_OMIT_FRAME_POINTER_FLAG)
 check_c_compiler_flag(-std=c11   COMPILER_RT_HAS_STD_C11_FLAG)
 check_cxx_compiler_flag(-fPICCOMPILER_RT_HAS_FPIC_FLAG)
 check_cxx_compiler_flag(-fPIECOMPILER_RT_HAS_FPIE_FLAG)
Index: compiler-rt/cmake/builtin-config-ix.cmake
===
--- compiler-rt/cmake/builtin-config-ix.cmake
+++ compiler-rt/cmake/builtin-config-ix.cmake
@@ -10,7 +10,6 @@
 builtin_check_c_compiler_flag(-fno-builtin  
COMPILER_RT_HAS_FNO_BUILTIN_FLAG)
 builtin_check_c_compiler_flag(-std=c11  
COMPILER_RT_HAS_STD_C11_FLAG)
 builtin_check_c_compiler_flag(-fvisibility=hidden   
COMPILER_RT_HAS_VISIBILITY_HIDDEN_FLAG)
-builtin_check_c_compiler_flag(-fomit-frame-pointer  
COMPILER_RT_HAS_OMIT_FRAME_POINTER_FLAG)
 builtin_check_c_compiler_flag(-ffreestanding
COMPILER_RT_HAS_FREESTANDING_FLAG)
 builtin_check_c_compiler_flag(-fxray-instrument 
COMPILER_RT_HAS_XRAY_COMPILER_FLAG)
 


Index: compiler-rt/cmake/config-ix.cmake
===
--- compiler-rt/cmake/config-ix.cmake
+++ compiler-rt/cmake/config-ix.cmake
@@ -61,6 +61,7 @@
 
 # CodeGen options.
 check_c_compiler_flag(-ffreestanding COMPILER_RT_HAS_FFREESTANDING_FLAG)
+check_c_compiler_flag(-fomit-frame-pointer   COMPILER_RT_HAS_OMIT_FRAME_POINTER_FLAG)
 check_c_compiler_flag(-std=c11   COMPILER_RT_HAS_STD_C11_FLAG)
 check_cxx_compiler_flag(-fPICCOMPILER_RT_HAS_FPIC_FLAG)
 check_cxx_compiler_flag(-fPIECOMPILER_RT_HAS_FPIE_FLAG)
Index: compiler-rt/cmake/builtin-config-ix.cmake
===
--- compiler-rt/cmake/builtin-config-ix.cmake
+++ compiler-rt/cmake/builtin-config-ix.cmake
@@ -10,7 +10,6 @@
 builtin_check_c_compiler_flag(-fno-builtin  COMPILER_RT_HAS_FNO_BUILTIN_FLAG)
 builtin_check_c_compiler_flag(-std=c11  COMPILER_RT_HAS_STD_C11_FLAG)
 builtin_check_c_compiler_flag(-fvisibility=hidden   COMPILER_RT_HAS_VISIBILITY_HIDDEN_FLAG)
-builtin_check_c_compiler_flag(-fomit-frame-pointer  COMPILER_RT_HAS_OMIT_FRAME_POINTER_FLAG)
 builtin_check_c_compiler_flag(-ffreestandingCOMPILER_RT_HAS_FREESTANDING_FLAG)
 builtin_check_c_compiler_flag(-fxray-instrument COMPILER_RT_HAS_XRAY_COMPILER_FLAG)
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D109234: [PGO] Change ThinLTO test for targets with loop unrolling disabled

2021-09-15 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson added inline comments.



Comment at: clang/test/CodeGen/pgo-sample-thinlto-summary.c:28
+// The first Unroll loop pass is the createSimpleLoopUnrollPass that unrolls 
and peels
+// loops with small constant trip counts. Only the second one is handled by 
ThinLTO.
+// THINLTO-OLDPM:   Unroll loops

Nit: The second one is skipped by the ThinLTO compile step (it's done in the 
ThinLTO backends).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109234

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


[PATCH] D109836: [Analyzer] ConversionChecker: track back the cast expression

2021-09-15 Thread Gabor Marton via Phabricator via cfe-commits
martong created this revision.
martong added reviewers: steakhal, Szelethus, NoQ.
Herald added subscribers: manas, ASDenysPetrov, gamesh411, dkrupp, donat.nagy, 
mikhail.ramalho, a.sidorin, rnkovacs, szepet, baloghadamsoftware, xazax.hun, 
whisperity.
martong requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Adding trackExpressionValue to the checker so it tracks the value of the
implicit cast's DeclRefExpression up to initialization/assignment. This
way the report becomes cleaner.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D109836

Files:
  clang/lib/StaticAnalyzer/Checkers/ConversionChecker.cpp
  clang/test/Analysis/conversion-tracking-notes.c
  clang/test/Analysis/conversion.c


Index: clang/test/Analysis/conversion.c
===
--- clang/test/Analysis/conversion.c
+++ clang/test/Analysis/conversion.c
@@ -1,4 +1,7 @@
-// RUN: %clang_analyze_cc1 -Wno-conversion -Wno-tautological-constant-compare 
-analyzer-checker=core,apiModeling,alpha.core.Conversion -verify %s
+// RUN: %clang_analyze_cc1 %s \
+// RUN:   -Wno-conversion -Wno-tautological-constant-compare \
+// RUN:   -analyzer-checker=core,apiModeling,alpha.core.Conversion \
+// RUN:   -verify
 
 unsigned char U8;
 signed char S8;
Index: clang/test/Analysis/conversion-tracking-notes.c
===
--- /dev/null
+++ clang/test/Analysis/conversion-tracking-notes.c
@@ -0,0 +1,26 @@
+// RUN: %clang_analyze_cc1 %s \
+// RUN:   -Wno-conversion -Wno-tautological-constant-compare \
+// RUN:   -analyzer-checker=core,apiModeling,alpha.core.Conversion \
+// RUN:   -analyzer-output=text \
+// RUN:   -verify
+
+unsigned char U8;
+signed char S8;
+
+void track_assign() {
+  unsigned long L = 1000; // expected-note {{'L' initialized to 1000}}
+  int I = -1; // expected-note {{'I' initialized to -1}}
+  U8 *= L; // expected-warning {{Loss of precision in implicit conversion}}
+   // expected-note@-1 {{Loss of precision in implicit conversion}}
+  L *= I;  // expected-warning {{Loss of sign in implicit conversion}}
+   // expected-note@-1 {{Loss of sign in implicit conversion}}
+}
+
+void track_relational(unsigned U, signed S) {
+  if (S < -10) { // expected-note{{Taking true branch}}
+ // expected-note@-1 {{Assuming the condition is true}}
+if (U < S) { // expected-warning {{Loss of sign in implicit conversion}}
+ // expected-note@-1 {{Loss of sign in implicit conversion}}
+}
+  }
+}
Index: clang/lib/StaticAnalyzer/Checkers/ConversionChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/ConversionChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/ConversionChecker.cpp
@@ -49,7 +49,8 @@
 
   bool isLossOfSign(const ImplicitCastExpr *Cast, CheckerContext &C) const;
 
-  void reportBug(ExplodedNode *N, CheckerContext &C, const char Msg[]) const;
+  void reportBug(ExplodedNode *N, const Expr *E, CheckerContext &C,
+ const char Msg[]) const;
 };
 }
 
@@ -108,20 +109,21 @@
 if (!N)
   return;
 if (LossOfSign)
-  reportBug(N, C, "Loss of sign in implicit conversion");
+  reportBug(N, Cast, C, "Loss of sign in implicit conversion");
 if (LossOfPrecision)
-  reportBug(N, C, "Loss of precision in implicit conversion");
+  reportBug(N, Cast, C, "Loss of precision in implicit conversion");
   }
 }
 
-void ConversionChecker::reportBug(ExplodedNode *N, CheckerContext &C,
-  const char Msg[]) const {
+void ConversionChecker::reportBug(ExplodedNode *N, const Expr *E,
+  CheckerContext &C, const char Msg[]) const {
   if (!BT)
 BT.reset(
 new BuiltinBug(this, "Conversion", "Possible loss of 
sign/precision."));
 
   // Generate a report for this bug.
   auto R = std::make_unique(*BT, Msg, N);
+  bugreporter::trackExpressionValue(N, E, *R);
   C.emitReport(std::move(R));
 }
 


Index: clang/test/Analysis/conversion.c
===
--- clang/test/Analysis/conversion.c
+++ clang/test/Analysis/conversion.c
@@ -1,4 +1,7 @@
-// RUN: %clang_analyze_cc1 -Wno-conversion -Wno-tautological-constant-compare -analyzer-checker=core,apiModeling,alpha.core.Conversion -verify %s
+// RUN: %clang_analyze_cc1 %s \
+// RUN:   -Wno-conversion -Wno-tautological-constant-compare \
+// RUN:   -analyzer-checker=core,apiModeling,alpha.core.Conversion \
+// RUN:   -verify
 
 unsigned char U8;
 signed char S8;
Index: clang/test/Analysis/conversion-tracking-notes.c
===
--- /dev/null
+++ clang/test/Analysis/conversion-tracking-notes.c
@@ -0,0 +1,26 @@
+// RUN: %clang_analyze_cc1 %s \
+// RUN:   -Wno-conversion -Wno-tautological-constant-compare \
+// RUN:  

[PATCH] D109362: [SystemZ][z/OS] Add GOFF Support to the DataLayout

2021-09-15 Thread Anirudh Prasad via Phabricator via cfe-commits
anirudhp updated this revision to Diff 372733.
anirudhp added a comment.

- Introduce separate label prefix for `MM_GOFF`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109362

Files:
  clang/lib/Basic/Targets/SystemZ.h
  clang/test/CodeGen/target-data.c
  llvm/docs/LangRef.rst
  llvm/include/llvm/IR/DataLayout.h
  llvm/lib/IR/DataLayout.cpp
  llvm/lib/Target/SystemZ/SystemZTargetMachine.cpp
  llvm/unittests/IR/ManglerTest.cpp

Index: llvm/unittests/IR/ManglerTest.cpp
===
--- llvm/unittests/IR/ManglerTest.cpp
+++ llvm/unittests/IR/ManglerTest.cpp
@@ -156,4 +156,22 @@
 "L..foo");
 }
 
+TEST(ManglerTest, GOFF) {
+  LLVMContext Ctx;
+  DataLayout DL("m:l"); // GOFF
+  Module Mod("test", Ctx);
+  Mod.setDataLayout(DL);
+  Mangler Mang;
+
+  EXPECT_EQ(mangleStr("foo", Mang, DL), "foo");
+  EXPECT_EQ(mangleStr("\01foo", Mang, DL), "foo");
+  EXPECT_EQ(mangleStr("?foo", Mang, DL), "?foo");
+  EXPECT_EQ(mangleFunc("foo", llvm::GlobalValue::ExternalLinkage,
+   llvm::CallingConv::C, Mod, Mang),
+"foo");
+  EXPECT_EQ(mangleFunc("foo", llvm::GlobalValue::PrivateLinkage,
+   llvm::CallingConv::C, Mod, Mang),
+"@foo");
+}
+
 } // end anonymous namespace
Index: llvm/lib/Target/SystemZ/SystemZTargetMachine.cpp
===
--- llvm/lib/Target/SystemZ/SystemZTargetMachine.cpp
+++ llvm/lib/Target/SystemZ/SystemZTargetMachine.cpp
@@ -84,8 +84,9 @@
   // 128-bit floats are aligned only to 64 bits.
   Ret += "-f128:64";
 
-  // When using the vector ABI, 128-bit vectors are also aligned to 64 bits.
-  if (VectorABI)
+  // When using the vector ABI on Linux, 128-bit vectors are also aligned to 64
+  // bits. On z/OS, vector types are always aligned to 64 bits.
+  if (VectorABI || TT.isOSzOS())
 Ret += "-v128:64";
 
   // We prefer 16 bits of aligned for all globals; see above.
Index: llvm/lib/IR/DataLayout.cpp
===
--- llvm/lib/IR/DataLayout.cpp
+++ llvm/lib/IR/DataLayout.cpp
@@ -151,6 +151,8 @@
 //===--===//
 
 const char *DataLayout::getManglingComponent(const Triple &T) {
+  if (T.isOSBinFormatGOFF())
+return "-m:l";
   if (T.isOSBinFormatMachO())
 return "-m:o";
   if (T.isOSWindows() && T.isOSBinFormatCOFF())
@@ -500,6 +502,9 @@
   case 'e':
 ManglingMode = MM_ELF;
 break;
+  case 'l':
+ManglingMode = MM_GOFF;
+break;
   case 'o':
 ManglingMode = MM_MachO;
 break;
Index: llvm/include/llvm/IR/DataLayout.h
===
--- llvm/include/llvm/IR/DataLayout.h
+++ llvm/include/llvm/IR/DataLayout.h
@@ -135,6 +135,7 @@
 MM_MachO,
 MM_WinCOFF,
 MM_WinCOFFX86,
+MM_GOFF,
 MM_Mips,
 MM_XCOFF
   };
@@ -316,6 +317,7 @@
 switch (ManglingMode) {
 case MM_None:
 case MM_ELF:
+case MM_GOFF:
 case MM_Mips:
 case MM_WinCOFF:
 case MM_XCOFF:
@@ -334,6 +336,8 @@
 case MM_ELF:
 case MM_WinCOFF:
   return ".L";
+case MM_GOFF:
+  return "@";
 case MM_Mips:
   return "$";
 case MM_MachO:
Index: llvm/docs/LangRef.rst
===
--- llvm/docs/LangRef.rst
+++ llvm/docs/LangRef.rst
@@ -2593,6 +2593,7 @@
 options are
 
 * ``e``: ELF mangling: Private symbols get a ``.L`` prefix.
+* ``l``: GOFF mangling: Private symbols get a ``.L`` prefix.
 * ``m``: Mips mangling: Private symbols get a ``$`` prefix.
 * ``o``: Mach-O mangling: Private symbols get ``L`` prefix. Other
   symbols get a ``_`` prefix.
Index: clang/test/CodeGen/target-data.c
===
--- clang/test/CodeGen/target-data.c
+++ clang/test/CodeGen/target-data.c
@@ -253,6 +253,38 @@
 // RUN: FileCheck %s -check-prefix=SYSTEMZ-VECTOR
 // SYSTEMZ-VECTOR: target datalayout = "E-m:e-i1:8:16-i8:8:16-i64:64-f128:64-v128:64-a:8:16-n32:64"
 
+// RUN: %clang_cc1 -triple s390x-none-zos -o - -emit-llvm %s | \
+// RUN: FileCheck %s -check-prefix=ZOS
+// RUN: %clang_cc1 -triple s390x-none-zos -target-cpu z10 -o - -emit-llvm %s | \
+// RUN: FileCheck %s -check-prefix=ZOS
+// RUN: %clang_cc1 -triple s390x-none-zos -target-cpu arch8 -o - -emit-llvm %s | \
+// RUN: FileCheck %s -check-prefix=ZOS
+// RUN: %clang_cc1 -triple s390x-none-zos -target-cpu z196 -o - -emit-llvm %s | \
+// RUN: FileCheck %s -check-prefix=ZOS
+// RUN: %clang_cc1 -triple s390x-none-zos -target-cpu arch9 -o - -emit-llvm %s | \
+// RUN: FileCheck %s -check-prefix=ZOS
+// RUN: %clang_cc1 -triple s390x-none-zos -target-cpu zEC12 -o - -emit-llvm %s | \
+// RUN: FileCheck %s -check-prefix=ZOS
+// RU

[PATCH] D109362: [SystemZ][z/OS] Add GOFF Support to the DataLayout

2021-09-15 Thread Anirudh Prasad via Phabricator via cfe-commits
anirudhp added a comment.

In D109362#3001294 , @uweigand wrote:

> In D109362#3000284 , @anirudhp 
> wrote:
>
>> In D109362#2999688 , @uweigand 
>> wrote:
>>
>>> Looking at the common code parts, it seems the behavior of MM_GOFF is 
>>> actually identical to MM_ELF.   Is this correct?   If so, do we really need 
>>> a different format type here?
>>
>> At a future point, we will be changing the local and global prefixes. At 
>> that point we would still need a separate `MM_GOFF` field. I feel it would 
>> be a bit better to enforce it from now itself.
>
> I see.  Is there a reason why we cannot use the "correct" prefixes to begin 
> with?

Nope. I'll update the patch.

In D109362#3001294 , @uweigand wrote:

> In D109362#3000284 , @anirudhp 
> wrote:
>
>> In D109362#2999688 , @uweigand 
>> wrote:
>>
>>> Looking at the common code parts, it seems the behavior of MM_GOFF is 
>>> actually identical to MM_ELF.   Is this correct?   If so, do we really need 
>>> a different format type here?
>>
>> At a future point, we will be changing the local and global prefixes. At 
>> that point we would still need a separate `MM_GOFF` field. I feel it would 
>> be a bit better to enforce it from now itself.
>
> I see.  Is there a reason why we cannot use the "correct" prefixes to begin 
> with?

Nope. I've added it. There should also be a change to the MCAsmInfo fields 
(`PrivateGlobalPrefix` and `PrivateLabelPrefix`). These will be added in when 
the MCAsmInfo interfaces for z/OS are put up.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109362

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


[PATCH] D109362: [SystemZ][z/OS] Add GOFF Support to the DataLayout

2021-09-15 Thread Ulrich Weigand via Phabricator via cfe-commits
uweigand added inline comments.



Comment at: llvm/docs/LangRef.rst:2596
 * ``e``: ELF mangling: Private symbols get a ``.L`` prefix.
+* ``l``: GOFF mangling: Private symbols get a ``.L`` prefix.
 * ``m``: Mips mangling: Private symbols get a ``$`` prefix.

Comment needs to be update now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109362

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


[PATCH] D106393: [PowerPC][AIX] Add support for varargs for complex types on AIX

2021-09-15 Thread Zarko Todorovski via Phabricator via cfe-commits
ZarkoCA updated this revision to Diff 372736.
ZarkoCA added a comment.

- Removed llc tests
- Added a helper function to combine the PPC64_SVR4ABI and AIXABI treatment of 
complex types less than register size


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106393

Files:
  clang/lib/CodeGen/TargetInfo.cpp
  clang/test/CodeGen/aix32-complex-varargs.c
  clang/test/CodeGen/ppc64-varargs-complex.c

Index: clang/test/CodeGen/ppc64-varargs-complex.c
===
--- clang/test/CodeGen/ppc64-varargs-complex.c
+++ clang/test/CodeGen/ppc64-varargs-complex.c
@@ -1,5 +1,6 @@
 // REQUIRES: powerpc-registered-target
 // RUN: %clang_cc1 -triple powerpc64-unknown-linux-gnu -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple powerpc64-ibm-aix-xcoff -emit-llvm -o - %s | FileCheck %s
 
 #include 
 
Index: clang/test/CodeGen/aix32-complex-varargs.c
===
--- /dev/null
+++ clang/test/CodeGen/aix32-complex-varargs.c
@@ -0,0 +1,66 @@
+// REQUIRES: powerpc-registered-target
+// RUN: %clang_cc1 -triple powerpc-ibm-aix-xcoff -emit-llvm -o - %s | FileCheck %s
+
+#include 
+
+void testva (int n, ...)
+{
+  va_list ap;
+
+  _Complex int i   = va_arg(ap, _Complex int);
+// CHECK:  %[[VAR40:[A-Za-z0-9.]+]] = load i8*, i8** %[[VAR100:[A-Za-z0-9.]+]]
+// CHECK-NEXT:  %[[VAR41:[A-Za-z0-9.]+]] = getelementptr inbounds i8, i8* %[[VAR40]]
+// CHECK-NEXT:  store i8* %[[VAR41]], i8** %[[VAR100]], align 4
+// CHECK-NEXT:  %[[VAR4:[A-Za-z0-9.]+]] = bitcast i8* %[[VAR40]] to { i32, i32 }*
+// CHECK-NEXT:  %[[VAR6:[A-Za-z0-9.]+]] = getelementptr inbounds { i32, i32 }, { i32, i32 }* %[[VAR4]], i32 0, i32 0
+// CHECK-NEXT:  %[[VAR7:[A-Za-z0-9.]+]] = load i32, i32* %[[VAR6]]
+// CHECK-NEXT:  %[[VAR8:[A-Za-z0-9.]+]] = getelementptr inbounds { i32, i32 }, { i32, i32 }* %[[VAR4]], i32 0, i32 1
+// CHECK-NEXT:  %[[VAR9:[A-Za-z0-9.]+]] = load i32, i32* %[[VAR8]]
+// CHECK-NEXT:  %[[VAR10:[A-Za-z0-9.]+]] = getelementptr inbounds { i32, i32 }, { i32, i32 }* %[[VARINT:[A-Za-z0-9.]+]], i32 0, i32 0
+// CHECK-NEXT:  %[[VAR11:[A-Za-z0-9.]+]] = getelementptr inbounds { i32, i32 }, { i32, i32 }* %[[VARINT]], i32 0, i32 1
+// CHECK-NEXT:  store i32 %[[VAR7]], i32* %[[VAR10]]
+// CHECK-NEXT:  store i32 %[[VAR9]], i32* %[[VAR11]]
+
+  _Complex short s = va_arg(ap, _Complex short);
+// CHECK:  %[[VAR50:[A-Za-z0-9.]+]] = load i8*, i8** %[[VAR100:[A-Za-z0-9.]+]]
+// CHECK-NEXT:  %[[VAR51:[A-Za-z0-9.]+]] = getelementptr inbounds i8, i8* %[[VAR50]]
+// CHECK-NEXT:  store i8* %[[VAR51]], i8** %[[VAR100]], align 4
+// CHECK-NEXT:  %[[VAR12:[A-Za-z0-9.]+]] = getelementptr inbounds i8, i8* %[[VAR50]], i32 2
+// CHECK-NEXT:  %[[VAR13:[A-Za-z0-9.]+]] = getelementptr inbounds i8, i8* %[[VAR50]], i32 6
+// CHECK-NEXT:  %[[VAR14:[A-Za-z0-9.]+]] = bitcast i8* %[[VAR12]] to i16*
+// CHECK-NEXT:  %[[VAR15:[A-Za-z0-9.]+]] = bitcast i8* %[[VAR13]] to i16*
+// CHECK-NEXT:  %[[VAR16:[A-Za-z0-9.]+]] = load i16, i16* %[[VAR14]], align 2
+// CHECK-NEXT:  %[[VAR17:[A-Za-z0-9.]+]] = load i16, i16* %[[VAR15]], align 2
+// CHECK-NEXT:  %[[VAR18:[A-Za-z0-9.]+]] = getelementptr inbounds { i16, i16 }, { i16, i16 }* %[[VAR19:[A-Za-z0-9.]+]], i32 0, i32 0
+// CHECK-NEXT:  %[[VAR20:[A-Za-z0-9.]+]] = getelementptr inbounds { i16, i16 }, { i16, i16 }* %[[VAR19]], i32 0, i32 1
+// CHECK-NEXT:  store i16 %[[VAR16]], i16* %[[VAR18]]
+// CHECK-NEXT:  store i16 %[[VAR17]], i16* %[[VAR20]]
+
+
+  _Complex char c  = va_arg(ap, _Complex char);
+// CHECK:  %[[VAR60:[A-Za-z0-9.]+]] = load i8*, i8** %[[VAR100:[A-Za-z0-9.]+]]
+// CHECK-NEXT:  %[[VAR61:[A-Za-z0-9.]+]] = getelementptr inbounds i8, i8* %[[VAR60]]
+// CHECK-NEXT:  store i8* %[[VAR61]], i8** %[[VAR100]], align 4
+// CHECK-NEXT:  %[[VAR21:[A-Za-z0-9.]+]] = getelementptr inbounds i8, i8* %[[VAR60]], i32 3
+// CHECK-NEXT:  %[[VAR22:[A-Za-z0-9.]+]] = getelementptr inbounds i8, i8* %[[VAR60]], i32 7
+// CHECK-NEXT:  %[[VAR23:[A-Za-z0-9.]+]] = load i8, i8* %[[VAR21]]
+// CHECK-NEXT:  %[[VAR24:[A-Za-z0-9.]+]] = load i8, i8* %[[VAR22]]
+// CHECK-NEXT:  %[[VAR25:[A-Za-z0-9.]+]] = getelementptr inbounds { i8, i8 }, { i8, i8 }* %[[VAR26:[A-Za-z0-9.]+]], i32 0, i32 0
+// CHECK-NEXT:  %[[VAR27:[A-Za-z0-9.]+]] = getelementptr inbounds { i8, i8 }, { i8, i8 }* %[[VAR26]], i32 0, i32 1
+// CHECK-NEXT:  store i8 %[[VAR23]], i8* %[[VAR25]]
+// CHECK-NEXT:  store i8 %[[VAR24]], i8* %[[VAR27]]
+
+
+  _Complex float f = va_arg(ap, _Complex float);
+// CHECK:  %[[VAR70:[A-Za-z0-9.]+]] = getelementptr inbounds i8, i8* %[[VAR71:[A-Za-z0-9.]+]], i32 8
+// CHECK-NEXT:  store i8* %[[VAR70]], i8** %[[VAR100:[A-Za-z0-9.]+]]
+// CHECK-NEXT:  %[[VAR28:[A-Za-z0-9.]+]] = bitcast i8* %[[VAR71]] to { float, float }*
+// CHECK-NEXT:  %[[VAR29:[A-Za-z0-9.]+]] = getelementptr inbounds { float, float }, { float, float }* %[[VAR28]], i32 0, i32 0
+// CHECK-NEXT:  %[[VAR30:[A-Za-z0-

[PATCH] D109362: [SystemZ][z/OS] Add GOFF Support to the DataLayout

2021-09-15 Thread Anirudh Prasad via Phabricator via cfe-commits
anirudhp updated this revision to Diff 372737.
anirudhp added a comment.

- Update to the documentation as well in account for the update to the global 
prefix.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109362

Files:
  clang/lib/Basic/Targets/SystemZ.h
  clang/test/CodeGen/target-data.c
  llvm/docs/LangRef.rst
  llvm/include/llvm/IR/DataLayout.h
  llvm/lib/IR/DataLayout.cpp
  llvm/lib/Target/SystemZ/SystemZTargetMachine.cpp
  llvm/unittests/IR/ManglerTest.cpp

Index: llvm/unittests/IR/ManglerTest.cpp
===
--- llvm/unittests/IR/ManglerTest.cpp
+++ llvm/unittests/IR/ManglerTest.cpp
@@ -156,4 +156,22 @@
 "L..foo");
 }
 
+TEST(ManglerTest, GOFF) {
+  LLVMContext Ctx;
+  DataLayout DL("m:l"); // GOFF
+  Module Mod("test", Ctx);
+  Mod.setDataLayout(DL);
+  Mangler Mang;
+
+  EXPECT_EQ(mangleStr("foo", Mang, DL), "foo");
+  EXPECT_EQ(mangleStr("\01foo", Mang, DL), "foo");
+  EXPECT_EQ(mangleStr("?foo", Mang, DL), "?foo");
+  EXPECT_EQ(mangleFunc("foo", llvm::GlobalValue::ExternalLinkage,
+   llvm::CallingConv::C, Mod, Mang),
+"foo");
+  EXPECT_EQ(mangleFunc("foo", llvm::GlobalValue::PrivateLinkage,
+   llvm::CallingConv::C, Mod, Mang),
+"@foo");
+}
+
 } // end anonymous namespace
Index: llvm/lib/Target/SystemZ/SystemZTargetMachine.cpp
===
--- llvm/lib/Target/SystemZ/SystemZTargetMachine.cpp
+++ llvm/lib/Target/SystemZ/SystemZTargetMachine.cpp
@@ -84,8 +84,9 @@
   // 128-bit floats are aligned only to 64 bits.
   Ret += "-f128:64";
 
-  // When using the vector ABI, 128-bit vectors are also aligned to 64 bits.
-  if (VectorABI)
+  // When using the vector ABI on Linux, 128-bit vectors are also aligned to 64
+  // bits. On z/OS, vector types are always aligned to 64 bits.
+  if (VectorABI || TT.isOSzOS())
 Ret += "-v128:64";
 
   // We prefer 16 bits of aligned for all globals; see above.
Index: llvm/lib/IR/DataLayout.cpp
===
--- llvm/lib/IR/DataLayout.cpp
+++ llvm/lib/IR/DataLayout.cpp
@@ -151,6 +151,8 @@
 //===--===//
 
 const char *DataLayout::getManglingComponent(const Triple &T) {
+  if (T.isOSBinFormatGOFF())
+return "-m:l";
   if (T.isOSBinFormatMachO())
 return "-m:o";
   if (T.isOSWindows() && T.isOSBinFormatCOFF())
@@ -500,6 +502,9 @@
   case 'e':
 ManglingMode = MM_ELF;
 break;
+  case 'l':
+ManglingMode = MM_GOFF;
+break;
   case 'o':
 ManglingMode = MM_MachO;
 break;
Index: llvm/include/llvm/IR/DataLayout.h
===
--- llvm/include/llvm/IR/DataLayout.h
+++ llvm/include/llvm/IR/DataLayout.h
@@ -135,6 +135,7 @@
 MM_MachO,
 MM_WinCOFF,
 MM_WinCOFFX86,
+MM_GOFF,
 MM_Mips,
 MM_XCOFF
   };
@@ -316,6 +317,7 @@
 switch (ManglingMode) {
 case MM_None:
 case MM_ELF:
+case MM_GOFF:
 case MM_Mips:
 case MM_WinCOFF:
 case MM_XCOFF:
@@ -334,6 +336,8 @@
 case MM_ELF:
 case MM_WinCOFF:
   return ".L";
+case MM_GOFF:
+  return "@";
 case MM_Mips:
   return "$";
 case MM_MachO:
Index: llvm/docs/LangRef.rst
===
--- llvm/docs/LangRef.rst
+++ llvm/docs/LangRef.rst
@@ -2593,6 +2593,7 @@
 options are
 
 * ``e``: ELF mangling: Private symbols get a ``.L`` prefix.
+* ``l``: GOFF mangling: Private symbols get a ``@`` prefix.
 * ``m``: Mips mangling: Private symbols get a ``$`` prefix.
 * ``o``: Mach-O mangling: Private symbols get ``L`` prefix. Other
   symbols get a ``_`` prefix.
Index: clang/test/CodeGen/target-data.c
===
--- clang/test/CodeGen/target-data.c
+++ clang/test/CodeGen/target-data.c
@@ -253,6 +253,38 @@
 // RUN: FileCheck %s -check-prefix=SYSTEMZ-VECTOR
 // SYSTEMZ-VECTOR: target datalayout = "E-m:e-i1:8:16-i8:8:16-i64:64-f128:64-v128:64-a:8:16-n32:64"
 
+// RUN: %clang_cc1 -triple s390x-none-zos -o - -emit-llvm %s | \
+// RUN: FileCheck %s -check-prefix=ZOS
+// RUN: %clang_cc1 -triple s390x-none-zos -target-cpu z10 -o - -emit-llvm %s | \
+// RUN: FileCheck %s -check-prefix=ZOS
+// RUN: %clang_cc1 -triple s390x-none-zos -target-cpu arch8 -o - -emit-llvm %s | \
+// RUN: FileCheck %s -check-prefix=ZOS
+// RUN: %clang_cc1 -triple s390x-none-zos -target-cpu z196 -o - -emit-llvm %s | \
+// RUN: FileCheck %s -check-prefix=ZOS
+// RUN: %clang_cc1 -triple s390x-none-zos -target-cpu arch9 -o - -emit-llvm %s | \
+// RUN: FileCheck %s -check-prefix=ZOS
+// RUN: %clang_cc1 -triple s390x-none-zos -target-cpu zEC12 -o - -emit-llvm %s | \
+// RUN:

[PATCH] D109175: [openmp] Emit deferred diag only when device compilation presents

2021-09-15 Thread Wei Wang via Phabricator via cfe-commits
weiwang added a comment.

In D109175#2989997 , @yaxunl wrote:

> In D109175#2989823 , @weiwang wrote:
>
>> In D109175#2987048 , @jdoerfert 
>> wrote:
>>
>>> In D109175#2986782 , @yaxunl 
>>> wrote:
>>>
 I agree with Johannes and Alexey that deferred diags are only needed when 
 LangOpts.OMPTargetTriples.empty(). However, I am not sure whether it is 
 only needed in device compilation.

 For other offloading languages like CUDA/HIP it is needed in both device 
 and host compilation.
>>>
>>> Technically, we might even want to delay in host only mode for OpenMP, but 
>>> that is something we can revisit (e.g., by dynamically setting a flag based 
>>> on the directives we've seen).
>>> @yaxunl Should we for now check if there is any associated offload job?
>>
>> Shall we go ahead and get this change in and think about more longer term 
>> solution later?
>
> LGTM. This patch should be sufficient to limit deferred diags to OpenMP with 
> offloading. Device compilation is covered by OpenMPIsDevice and host 
> compilation is covered by !LangOpts.OMPTargetTriples.empty(). I will leave 
> the decision to Johannes.

Thanks. @jdoerfert. Could you approve this?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109175

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


[PATCH] D106393: [PowerPC][AIX] Add support for varargs for complex types on AIX

2021-09-15 Thread Zarko Todorovski via Phabricator via cfe-commits
ZarkoCA added a comment.

In D106393#3000122 , @sfertile wrote:

> I suggest we separate the clang change and testing into a standalone patch, 
> and the llvm backend tests into a standalone patch which we can commit 
> separately.

LLVM tests added in https://reviews.llvm.org/D109838


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106393

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


[PATCH] D109175: [openmp] Emit deferred diag only when device compilation presents

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

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109175

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


[clang] ab5f2b5 - [HIP] Diagnose -fopenmp-targets for HIP programs

2021-09-15 Thread Yaxun Liu via cfe-commits

Author: Yaxun (Sam) Liu
Date: 2021-09-15T13:03:57-04:00
New Revision: ab5f2b505a0751bce41f4cec9afa3c1541d485d0

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

LOG: [HIP] Diagnose -fopenmp-targets for HIP programs

Diagnose -fopenmp-targets for HIP programs since
dual HIP and OpenMP offloading in the same compilation
is currently not supported by HIP toolchain.

Reviewed by: Artem Belevich

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

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticDriverKinds.td
clang/lib/Driver/Driver.cpp
clang/test/Driver/hip-options.hip

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td 
b/clang/include/clang/Basic/DiagnosticDriverKinds.td
index c5621ecf328d..0cf49ed397f6 100644
--- a/clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -16,6 +16,8 @@ def err_drv_unsupported_opt_with_suggestion : Error<
   "unsupported option '%0'; did you mean '%1'?">;
 def err_drv_unsupported_opt_for_target : Error<
   "unsupported option '%0' for target '%1'">;
+def err_drv_unsupported_opt_for_language_mode : Error<
+  "unsupported option '%0' for language mode '%1'">;
 def err_drv_unsupported_option_argument : Error<
   "unsupported argument '%1' to option '%0'">;
 def err_drv_unknown_stdin_type : Error<

diff  --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index 0c6b043b5255..b2fb21b7052a 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -680,6 +680,12 @@ void Driver::CreateOffloadingDeviceToolChains(Compilation 
&C,
 }
 C.addOffloadDeviceToolChain(CudaTC.get(), OFK);
   } else if (IsHIP) {
+if (auto *OMPTargetArg =
+C.getInputArgs().getLastArg(options::OPT_fopenmp_targets_EQ)) {
+  Diag(clang::diag::err_drv_unsupported_opt_for_language_mode)
+  << OMPTargetArg->getSpelling() << "HIP";
+  return;
+}
 const ToolChain *HostTC = C.getSingleOffloadToolChain();
 const llvm::Triple &HostTriple = HostTC->getTriple();
 auto OFK = Action::OFK_HIP;

diff  --git a/clang/test/Driver/hip-options.hip 
b/clang/test/Driver/hip-options.hip
index 08a821c89a19..da82410a4fcf 100644
--- a/clang/test/Driver/hip-options.hip
+++ b/clang/test/Driver/hip-options.hip
@@ -87,3 +87,15 @@
 // THINLTO-NOT: clang{{.*}}" "-triple" "amdgcn-amd-amdhsa" {{.*}} 
"-fwhole-program-vtables"
 // THINLTO: clang{{.*}}" "-triple" "x86_64-unknown-linux-gnu" {{.*}} 
"-flto=thin" {{.*}} "-fwhole-program-vtables"
 // THINLTO-NOT: clang{{.*}}" "-triple" "amdgcn-amd-amdhsa" {{.*}} 
"-fwhole-program-vtables"
+
+// Check -fopenmp is allowed with HIP but -fopenmp-targets= is not allowed.
+
+// RUN: %clang -### -target x86_64-unknown-linux-gnu -nogpuinc -nogpulib \
+// RUN:   --offload-arch=gfx906 -fopenmp %s 2>&1 | FileCheck -check-prefix=OMP 
%s
+// OMP-NOT: clang{{.*}} "-triple" "amdgcn-amd-amdhsa" {{.*}} "-fopenmp"
+// OMP: clang{{.*}} "-triple" "x86_64-unknown-linux-gnu" {{.*}} "-fopenmp"
+
+// RUN: not %clang -target x86_64-unknown-linux-gnu -nogpuinc -nogpulib \
+// RUN:   --offload-arch=gfx906 -fopenmp -fopenmp-targets=amdgcn %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=OMPTGT %s
+// OMPTGT: unsupported option '-fopenmp-targets=' for language mode 'HIP'



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


[PATCH] D109718: [HIP] Diagnose -fopenmp-targets for HIP programs

2021-09-15 Thread Yaxun Liu 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 rGab5f2b505a07: [HIP] Diagnose -fopenmp-targets for HIP 
programs (authored by yaxunl).
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109718

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/lib/Driver/Driver.cpp
  clang/test/Driver/hip-options.hip


Index: clang/test/Driver/hip-options.hip
===
--- clang/test/Driver/hip-options.hip
+++ clang/test/Driver/hip-options.hip
@@ -87,3 +87,15 @@
 // THINLTO-NOT: clang{{.*}}" "-triple" "amdgcn-amd-amdhsa" {{.*}} 
"-fwhole-program-vtables"
 // THINLTO: clang{{.*}}" "-triple" "x86_64-unknown-linux-gnu" {{.*}} 
"-flto=thin" {{.*}} "-fwhole-program-vtables"
 // THINLTO-NOT: clang{{.*}}" "-triple" "amdgcn-amd-amdhsa" {{.*}} 
"-fwhole-program-vtables"
+
+// Check -fopenmp is allowed with HIP but -fopenmp-targets= is not allowed.
+
+// RUN: %clang -### -target x86_64-unknown-linux-gnu -nogpuinc -nogpulib \
+// RUN:   --offload-arch=gfx906 -fopenmp %s 2>&1 | FileCheck -check-prefix=OMP 
%s
+// OMP-NOT: clang{{.*}} "-triple" "amdgcn-amd-amdhsa" {{.*}} "-fopenmp"
+// OMP: clang{{.*}} "-triple" "x86_64-unknown-linux-gnu" {{.*}} "-fopenmp"
+
+// RUN: not %clang -target x86_64-unknown-linux-gnu -nogpuinc -nogpulib \
+// RUN:   --offload-arch=gfx906 -fopenmp -fopenmp-targets=amdgcn %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=OMPTGT %s
+// OMPTGT: unsupported option '-fopenmp-targets=' for language mode 'HIP'
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -680,6 +680,12 @@
 }
 C.addOffloadDeviceToolChain(CudaTC.get(), OFK);
   } else if (IsHIP) {
+if (auto *OMPTargetArg =
+C.getInputArgs().getLastArg(options::OPT_fopenmp_targets_EQ)) {
+  Diag(clang::diag::err_drv_unsupported_opt_for_language_mode)
+  << OMPTargetArg->getSpelling() << "HIP";
+  return;
+}
 const ToolChain *HostTC = C.getSingleOffloadToolChain();
 const llvm::Triple &HostTriple = HostTC->getTriple();
 auto OFK = Action::OFK_HIP;
Index: clang/include/clang/Basic/DiagnosticDriverKinds.td
===
--- clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -16,6 +16,8 @@
   "unsupported option '%0'; did you mean '%1'?">;
 def err_drv_unsupported_opt_for_target : Error<
   "unsupported option '%0' for target '%1'">;
+def err_drv_unsupported_opt_for_language_mode : Error<
+  "unsupported option '%0' for language mode '%1'">;
 def err_drv_unsupported_option_argument : Error<
   "unsupported argument '%1' to option '%0'">;
 def err_drv_unknown_stdin_type : Error<


Index: clang/test/Driver/hip-options.hip
===
--- clang/test/Driver/hip-options.hip
+++ clang/test/Driver/hip-options.hip
@@ -87,3 +87,15 @@
 // THINLTO-NOT: clang{{.*}}" "-triple" "amdgcn-amd-amdhsa" {{.*}} "-fwhole-program-vtables"
 // THINLTO: clang{{.*}}" "-triple" "x86_64-unknown-linux-gnu" {{.*}} "-flto=thin" {{.*}} "-fwhole-program-vtables"
 // THINLTO-NOT: clang{{.*}}" "-triple" "amdgcn-amd-amdhsa" {{.*}} "-fwhole-program-vtables"
+
+// Check -fopenmp is allowed with HIP but -fopenmp-targets= is not allowed.
+
+// RUN: %clang -### -target x86_64-unknown-linux-gnu -nogpuinc -nogpulib \
+// RUN:   --offload-arch=gfx906 -fopenmp %s 2>&1 | FileCheck -check-prefix=OMP %s
+// OMP-NOT: clang{{.*}} "-triple" "amdgcn-amd-amdhsa" {{.*}} "-fopenmp"
+// OMP: clang{{.*}} "-triple" "x86_64-unknown-linux-gnu" {{.*}} "-fopenmp"
+
+// RUN: not %clang -target x86_64-unknown-linux-gnu -nogpuinc -nogpulib \
+// RUN:   --offload-arch=gfx906 -fopenmp -fopenmp-targets=amdgcn %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=OMPTGT %s
+// OMPTGT: unsupported option '-fopenmp-targets=' for language mode 'HIP'
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -680,6 +680,12 @@
 }
 C.addOffloadDeviceToolChain(CudaTC.get(), OFK);
   } else if (IsHIP) {
+if (auto *OMPTargetArg =
+C.getInputArgs().getLastArg(options::OPT_fopenmp_targets_EQ)) {
+  Diag(clang::diag::err_drv_unsupported_opt_for_language_mode)
+  << OMPTargetArg->getSpelling() << "HIP";
+  return;
+}
 const ToolChain *HostTC = C.getSingleOffloadToolChain();
 const llvm::Triple &HostTriple = HostTC->getTriple();
 auto OFK = Action::OFK_HIP;
Index: clang/include/clang/Basic/DiagnosticDriverKinds.td
==

[PATCH] D109362: [SystemZ][z/OS] Add GOFF Support to the DataLayout

2021-09-15 Thread Ulrich Weigand via Phabricator via cfe-commits
uweigand accepted this revision.
uweigand added a comment.

This LGTM now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109362

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


[PATCH] D108787: [CUDA] Pass ExecConfig through BuildCallToMemberFunction

2021-09-15 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl accepted this revision.
yaxunl added a comment.

LGTM. Thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108787

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


[PATCH] D109632: [clang] de-duplicate methods from AST files

2021-09-15 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith added inline comments.



Comment at: clang/include/clang/Sema/Sema.h:1423-1426
+ObjCMethodList InstanceMethods;
+ObjCMethodList FactoryMethods;
+llvm::DenseSet AddedInstanceMethods;
+llvm::DenseSet AddedFactoryMethods;

Do these two sets really need to be per-selector (per `GlobalMethods` object in 
GlobalMethodPool)? I feel like they could be global to `Sema`, as long as the 
same `ObjCMethodDecl` is never added to GlobalMethodPool for more than one 
selector. (It seems plausible we have that property since presumably 
ObjCMethodDecl::getSelector is always the key used for inserting into 
GlobalMethodPool below... can you confirm?)

Assuming you can pull the sets out to represent the GlobalMethodPool as a 
whole, then I suggest creating a data structure for GlobalMethodPool that 
encapsulates the DenseMap and the two sets (maybe: rename "GlobalMethods" to 
"GlobalMethodLists", rename "GlobalMethodPool" to "GlobalMethods", and give the 
new data structure the name "GlobalMethodPool"). Best to do it as multiple 
commits: NFC commit(s) to refactor (renames, create new type update call sites 
to use new APIs, etc.), and a final commit that changes the functionality 
(adding the set behaviour) but that doesn't need to touch call sites.

On the other hand, if the sets really need to be per-selector (please explain 
why if so...), please use SmallPtrSet here instead of DenseSet to avoid 
allocation in the common case of 1 decl per selector. I'd suggest encapsulating 
the list/set together somehow (maybe starting with an NFC refactoring to add a 
"list/set" data structure at the top-level (maybe rename ObjCMethodList => 
ObjCMethodListNode, and the new list has a private member called "Head" and 
necessary APIs for insertion/etc), then in a second commit adding the 
SmallPtrSet into the list data structure and use it to gate the "insert" 
operation).



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109632

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


[PATCH] D109557: Adds a BreakBeforeClosingParen option

2021-09-15 Thread Cameron Mulhern via Phabricator via cfe-commits
csmulhern updated this revision to Diff 372748.
csmulhern retitled this revision from "Adds an AlignCloseBracket option" to 
"Adds a BreakBeforeClosingParen option".
csmulhern edited the summary of this revision.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109557

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/include/clang/Format/Format.h
  clang/lib/Format/ContinuationIndenter.cpp
  clang/lib/Format/ContinuationIndenter.h
  clang/lib/Format/Format.cpp
  clang/lib/Format/TokenAnnotator.cpp
  clang/unittests/Format/FormatTest.cpp

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -18242,6 +18242,7 @@
   CHECK_PARSE_BOOL(BinPackArguments);
   CHECK_PARSE_BOOL(BinPackParameters);
   CHECK_PARSE_BOOL(BreakAfterJavaFieldAnnotations);
+  CHECK_PARSE_BOOL(BreakBeforeClosingParen);
   CHECK_PARSE_BOOL(BreakBeforeConceptDeclarations);
   CHECK_PARSE_BOOL(BreakBeforeTernaryOperators);
   CHECK_PARSE_BOOL(BreakStringLiterals);
@@ -22294,6 +22295,95 @@
   "}";
   EXPECT_EQ(Code, format(Code, Style));
 }
+
+TEST_F(FormatTest, BreakBeforeClosingParen) {
+  auto Style = getLLVMStyle();
+  Style.BreakBeforeClosingParen = true;
+
+  StringRef Short = "functionCall(paramA, paramB, paramC);\n"
+"void functionDecl(int a, int b, int c);";
+
+  StringRef Medium = "functionCall(paramA, paramB, paramC, paramD, paramE, "
+ "paramF, paramG, paramH, paramI);\n"
+ "void functionDecl(int argumentA, int argumentB, int "
+ "argumentC, int argumentD, int argumentE);";
+
+  verifyFormat(Short, Style);
+
+  EXPECT_EQ(StringRef("functionCall(paramA, paramB, paramC, paramD, paramE, "
+  "paramF, paramG, paramH,\n"
+  " paramI);\n"
+  "void functionDecl(int argumentA, int argumentB, int "
+  "argumentC, int argumentD,\n"
+  "  int argumentE);"),
+format(Medium, Style));
+
+  Style.AllowAllArgumentsOnNextLine = false;
+  Style.AllowAllConstructorInitializersOnNextLine = false;
+  Style.AllowAllParametersOfDeclarationOnNextLine = false;
+
+  verifyFormat(Short, Style);
+
+  EXPECT_EQ(StringRef("functionCall(paramA, paramB, paramC, paramD, paramE, "
+  "paramF, paramG, paramH,\n"
+  " paramI);\n"
+  "void functionDecl(int argumentA, int argumentB, int "
+  "argumentC, int argumentD,\n"
+  "  int argumentE);"),
+format(Medium, Style));
+
+  Style.AlignAfterOpenBracket = FormatStyle::BAS_AlwaysBreak;
+
+  verifyFormat(Short, Style);
+
+  EXPECT_EQ(StringRef("functionCall(\n"
+  "paramA, paramB, paramC, paramD, paramE, paramF, "
+  "paramG, paramH, paramI\n"
+  ");\n"
+  "void functionDecl(\n"
+  "int argumentA, int argumentB, int argumentC, int "
+  "argumentD, int argumentE\n"
+  ");"),
+format(Medium, Style));
+
+  Style.BinPackArguments = false;
+  Style.BinPackParameters = false;
+
+  verifyFormat(Short, Style);
+
+  EXPECT_EQ(StringRef("functionCall(\n"
+  "paramA,\n"
+  "paramB,\n"
+  "paramC,\n"
+  "paramD,\n"
+  "paramE,\n"
+  "paramF,\n"
+  "paramG,\n"
+  "paramH,\n"
+  "paramI\n"
+  ");\n"
+  "void functionDecl(\n"
+  "int argumentA,\n"
+  "int argumentB,\n"
+  "int argumentC,\n"
+  "int argumentD,\n"
+  "int argumentE\n"
+  ");"),
+format(Medium, Style));
+
+  verifyFormat("outerFunctionCall(\n"
+   "nestedFunctionCall(argument1),\n"
+   "nestedLongFunctionCall(\n"
+   "argument1,\n"
+   "argument2,\n"
+   "argument3,\n"
+   "argument4,\n"
+   "argument5\n"
+   ")\n"
+   ");",
+   Style);
+}
+
 } // namespace
 } // namespace format
 } // namespace clang
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -4188,7 +4188,9 @@
   if (Right.is(TT_ImplicitStringLiteral))
 

[PATCH] D109234: [PGO] Change ThinLTO test for targets with loop unrolling disabled

2021-09-15 Thread Sherwin via Phabricator via cfe-commits
sherwin-dc updated this revision to Diff 372749.
sherwin-dc added a comment.

- Modify test to correctly indicate old/new PM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109234

Files:
  clang/test/CodeGen/pgo-sample-thinlto-summary.c


Index: clang/test/CodeGen/pgo-sample-thinlto-summary.c
===
--- clang/test/CodeGen/pgo-sample-thinlto-summary.c
+++ clang/test/CodeGen/pgo-sample-thinlto-summary.c
@@ -1,9 +1,7 @@
-// RUN: %clang_cc1 -O2 
-fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm -o 
- 2>&1 | FileCheck %s -check-prefix=SAMPLEPGO
-// RUN: %clang_cc1 -O2 
-fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm 
-flto=thin -o - 2>&1 | FileCheck %s -check-prefix=THINLTO
-// RUN: %clang_cc1 -O2 -fexperimental-new-pass-manager 
-fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm -o 
- 2>&1 | FileCheck %s -check-prefix=SAMPLEPGO
-// RUN: %clang_cc1 -O2 -fexperimental-new-pass-manager 
-fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm 
-flto=thin -o - 2>&1 | FileCheck %s -check-prefix=THINLTO
-// Checks if hot call is inlined by normal compile, but not inlined by
-// thinlto compile.
+// RUN: %clang_cc1 -mllvm -debug-pass=Structure -O2 
-fno-experimental-new-pass-manager 
-fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm -o 
- 2>&1 | FileCheck %s -check-prefix=SAMPLEPGO-OLDPM
+// RUN: %clang_cc1 -mllvm -debug-pass=Structure -O2 
-fno-experimental-new-pass-manager 
-fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm 
-flto=thin -o - 2>&1 | FileCheck %s -check-prefix=THINLTO-OLDPM
+// RUN: %clang_cc1 -fdebug-pass-manager -O2 
-fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm -o 
- 2>&1 | FileCheck %s -check-prefix=SAMPLEPGO
+// RUN: %clang_cc1 -fdebug-pass-manager -O2 
-fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm 
-flto=thin -o - 2>&1 | FileCheck %s -check-prefix=THINLTO
 
 int baz(int);
 int g;
@@ -13,6 +11,27 @@
 g += baz(i);
 }
 
+// Checks that loop unroll and icp are invoked by normal compile, but not 
thinlto compile.
+
+// SAMPLEPGO:   Running pass: PGOIndirectCallPromotion on [module]
+// SAMPLEPGO:   Running pass: LoopUnrollPass on bar
+
+// SAMPLEPGO-OLDPM: PGOIndirectCallPromotion
+// SAMPLEPGO-OLDPM: Unroll loops
+// SAMPLEPGO-OLDPM: Unroll loops
+
+// THINLTO-NOT: Running pass: PGOIndirectCallPromotion on [module]
+// THINLTO-NOT: Running pass: LoopUnrollPass on bar
+
+// THINLTO-OLDPM-NOT:   PGOIndirectCallPromotion
+// The first Unroll loop pass is the createSimpleLoopUnrollPass that unrolls 
and peels
+// loops with small constant trip counts. The second one is skipped by ThinLTO.
+// THINLTO-OLDPM:   Unroll loops
+// THINLTO-OLDPM-NOT:   Unroll loops
+
+
+// Checks if hot call is inlined by normal compile, but not inlined by
+// thinlto compile.
 // SAMPLEPGO-LABEL: define {{(dso_local )?}}void @bar
 // THINLTO-LABEL: define {{(dso_local )?}}void @bar
 // SAMPLEPGO-NOT: call{{.*}}foo
@@ -20,27 +39,4 @@
 void bar(int n) {
   for (int i = 0; i < n; i++)
 foo(i);
-}
-
-// Checks if loop unroll is invoked by normal compile, but not thinlto compile.
-// SAMPLEPGO-LABEL: define {{(dso_local )?}}void @unroll
-// THINLTO-LABEL: define {{(dso_local )?}}void @unroll
-// SAMPLEPGO: call{{.*}}baz
-// SAMPLEPGO: call{{.*}}baz
-// THINLTO: call{{.*}}baz
-// THINLTO-NOT: call{{.*}}baz
-void unroll() {
-  for (int i = 0; i < 2; i++)
-baz(i);
-}
-
-// Checks that icp is not invoked for ThinLTO, but invoked for normal 
samplepgo.
-// SAMPLEPGO-LABEL: define {{(dso_local )?}}void @icp
-// THINLTO-LABEL: define {{(dso_local )?}}void @icp
-// SAMPLEPGO: if.true.direct_targ
-// FIXME: the following condition needs to be reversed once
-//LTOPreLinkDefaultPipeline is customized.
-// THINLTO-NOT: if.true.direct_targ
-void icp(void (*p)()) {
-  p();
-}
+}
\ No newline at end of file


Index: clang/test/CodeGen/pgo-sample-thinlto-summary.c
===
--- clang/test/CodeGen/pgo-sample-thinlto-summary.c
+++ clang/test/CodeGen/pgo-sample-thinlto-summary.c
@@ -1,9 +1,7 @@
-// RUN: %clang_cc1 -O2 -fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm -o - 2>&1 | FileCheck %s -check-prefix=SAMPLEPGO
-// RUN: %clang_cc1 -O2 -fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm -flto=thin -o - 2>&1 | FileCheck %s -check-prefix=THINLTO
-// RUN: %clang_cc1 -O2 -fexperimental-new-pass-manager -fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm -o - 2>&1 | FileCheck %s -check-prefix=SAMPLEPGO
-// RUN: %clang_cc1 -O2 -fexperimental-new-pass-mana

[PATCH] D109557: Adds a BreakBeforeClosingParen option

2021-09-15 Thread Cameron Mulhern via Phabricator via cfe-commits
csmulhern added a comment.

In D109557#3000152 , 
@HazardyKnusperkeks wrote:

> I haven't looked too much into it, my main point is that there should be 
> tests for both variants of that option for braces, parenthesis, and angular 
> braces, if they are handled by that option. Otherwise the documentation (and 
> naming?) should be adapted. If the defaults differ, the option has to be 
> reworked, for a finer control.

I went ahead and limited this in scope to explicitly only deal with closing 
parentheses.

> In D109557#2999085 , 
> @MyDeveloperDay wrote:
>
>> This isn't really `AlignCloseBracket` but `BreakBeforeClosingParen` isn't it?
>
> Yeah I thought that too.

Good call. I've renamed the option to BreakBeforeClosingParen.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109557

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


[PATCH] D103835: [CUDA][HIP] Fix store of vtbl in ctor

2021-09-15 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

In D103835#3001011 , @rjmccall wrote:

> Hmm.   I think "v-tables are in the address space of the object pointer" is 
> not a good assumption.  Probably this ought to be determined by the C++ ABI 
> for the target.  In principle it could even be class-specific, but I think we 
> can start by assuming it's universal.
>
> It should be decided by the AST-level ABI abstraction so that it properly 
> affects record layout, since different address spaces can have different 
> pointer sizes.

Sorry my previous description was not accurate.

Currently vtbl addr space is assumed to be the default global addr space of 
LLVM IR, which is determined by the data layout of the LLVM IR. This patch did 
not change that.

The vtbl field of a class is a pointer to default addr space. When the vtbl 
field gets initialized, it is casted to a pointer to default global addr space 
so that the vtbl can be stored to it. The addr space of the vtbl field itself 
should be the same as `this` pointer. So we were talking about a pointer to the 
vtbl field of an object, not the addr space of vtbl.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103835

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


[PATCH] D109234: [PGO] Change ThinLTO test for targets with loop unrolling disabled

2021-09-15 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson accepted this revision.
tejohnson added a comment.
This revision is now accepted and ready to land.

lgtm, thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109234

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


[PATCH] D109828: [clang-cl] Add a /diasdkdir flag and make /winsysroot imply it

2021-09-15 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a comment.

The /winsysroot part makes sense to me, but what's the case for the new 
/diasdkdir flag?




Comment at: clang/lib/Driver/ToolChains/MSVC.cpp:66
 
+static const char *llvmArchToLegacyVCArch(llvm::Triple::ArchType Arch);
+

Maybe move the arch functions up to before visualstudio::Linker::ConstructJob 
instead?

The file is already kind of organized in that way, with lots of static helper 
functions on top, and then the implementations of the member functions.


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

https://reviews.llvm.org/D109828

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


[PATCH] D103835: [CUDA][HIP] Fix store of vtbl in ctor

2021-09-15 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

I see.  Yes, in that case, that sounds right.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103835

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


[PATCH] D109841: Fix vtbl field addr space

2021-09-15 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl created this revision.
yaxunl added reviewers: tra, rjmccall, arichardson.
yaxunl requested review of this revision.

vtbl filed of an object should have same addr space of the object.
Currently it is assumed to be addr space 0 but this may not
be true. This caused issue for some out of tree project.


https://reviews.llvm.org/D109841

Files:
  clang/lib/CodeGen/CGClass.cpp


Index: clang/lib/CodeGen/CGClass.cpp
===
--- clang/lib/CodeGen/CGClass.cpp
+++ clang/lib/CodeGen/CGClass.cpp
@@ -2502,6 +2502,8 @@
 
   // Apply the offsets.
   Address VTableField = LoadCXXThisAddress();
+  unsigned ThisAddrSpace =
+  VTableField.getPointer()->getType()->getPointerAddressSpace();
 
   if (!NonVirtualOffset.isZero() || VirtualOffset)
 VTableField = ApplyNonVirtualAndVirtualOffset(
@@ -2516,10 +2518,11 @@
   llvm::FunctionType::get(CGM.Int32Ty, /*isVarArg=*/true)
   ->getPointerTo(ProgAS)
   ->getPointerTo(GlobalsAS);
-  // vtable field is is derived from `this` pointer, therefore it should be in
-  // default address space.
+  // vtable field is is derived from `this` pointer, therefore they should be 
in
+  // the same addr space. Note it may not be the default address space of LLVM
+  // IR.
   VTableField = Builder.CreatePointerBitCastOrAddrSpaceCast(
-  VTableField, VTablePtrTy->getPointerTo());
+  VTableField, VTablePtrTy->getPointerTo(ThisAddrSpace));
   VTableAddressPoint = Builder.CreatePointerBitCastOrAddrSpaceCast(
   VTableAddressPoint, VTablePtrTy);
 


Index: clang/lib/CodeGen/CGClass.cpp
===
--- clang/lib/CodeGen/CGClass.cpp
+++ clang/lib/CodeGen/CGClass.cpp
@@ -2502,6 +2502,8 @@
 
   // Apply the offsets.
   Address VTableField = LoadCXXThisAddress();
+  unsigned ThisAddrSpace =
+  VTableField.getPointer()->getType()->getPointerAddressSpace();
 
   if (!NonVirtualOffset.isZero() || VirtualOffset)
 VTableField = ApplyNonVirtualAndVirtualOffset(
@@ -2516,10 +2518,11 @@
   llvm::FunctionType::get(CGM.Int32Ty, /*isVarArg=*/true)
   ->getPointerTo(ProgAS)
   ->getPointerTo(GlobalsAS);
-  // vtable field is is derived from `this` pointer, therefore it should be in
-  // default address space.
+  // vtable field is is derived from `this` pointer, therefore they should be in
+  // the same addr space. Note it may not be the default address space of LLVM
+  // IR.
   VTableField = Builder.CreatePointerBitCastOrAddrSpaceCast(
-  VTableField, VTablePtrTy->getPointerTo());
+  VTableField, VTablePtrTy->getPointerTo(ThisAddrSpace));
   VTableAddressPoint = Builder.CreatePointerBitCastOrAddrSpaceCast(
   VTableAddressPoint, VTablePtrTy);
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D108469: Improve handling of static assert messages.

2021-09-15 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin planned changes to this revision.
cor3ntin added a comment.

I'll fix the tests


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108469

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


[PATCH] D103835: [CUDA][HIP] Fix store of vtbl in ctor

2021-09-15 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

https://reviews.llvm.org/D109841


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103835

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


[PATCH] D109841: Fix vtbl field addr space

2021-09-15 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

The following line is always just making a bitcast, then.


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

https://reviews.llvm.org/D109841

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


[PATCH] D109557: Adds a BreakBeforeClosingParen option

2021-09-15 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks added inline comments.



Comment at: clang/unittests/Format/FormatTest.cpp:22301
+  auto Style = getLLVMStyle();
+  Style.BreakBeforeClosingParen = true;
+

Could you also add tests for `false`, even though they are spread over the 
other test cases. That way the option can completely be tested with this case.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109557

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


[PATCH] D108469: Improve handling of static assert messages.

2021-09-15 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D108469#2957652 , @jfb wrote:

> I worry that changing the general `static_assert` printing (adding a colon, 
> and dropping the quotes) will get @hwright's law to drop on us. We can try 
> and see if e.g. users of clang have automated checks for `static_assert` in 
> their CI pipelines or something. I think your new format looks better, but 
> Hyrum is finicky that way... What do others think?

I think it's fine to change; we've never promised diagnostic formatting 
compatibility between versions. I'm sure *someone* is relying on this 
somewhere, but I'm not worried we're going to break a ton of people -- 
hopefully enough folks are tracking trunk that we can find any major issues 
before releasing.

Btw, it looks like the CI is currently failing the LLVM unit tests in 
interesting ways. That should be resolved.

There are changes in `clang/test/Lexer/null-character-in-literal.c` but Phab is 
unhelpful about showing what those changes are because it thinks the file is a 
binary file. Can you explain what's been changed there?




Comment at: clang/lib/Basic/Diagnostic.cpp:791
 
+static void PushEscapedString(StringRef Str, SmallVectorImpl &OutStr) {
+  OutStr.reserve(OutStr.size() + Str.size());

Per coding conventions.



Comment at: clang/lib/Basic/Diagnostic.cpp:793
+  OutStr.reserve(OutStr.size() + Str.size());
+  auto it = reinterpret_cast(Str.data());
+  auto end = it + Str.size();

Please fix the clang-tidy and clang-format warnings.

Also, I think `it` is more commonly considered the name for an iterator, which 
this sort of isn't. I'd recommend going with `Begin` and `End` for names (that 
also fixes the coding style nit with the names).



Comment at: clang/lib/Basic/Diagnostic.cpp:803-806
+  llvm::UTF32 c;
+  llvm::UTF32 *cptr = &c;
+  unsigned char const *start = it;
+  unsigned char const *cp_end = it + llvm::getNumBytesForUTF8(*it);

You should fix these names up for the coding conventions (same suggestion 
applies elsewhere). Also, the local style is `const unsigned char *`.



Comment at: clang/lib/Basic/Diagnostic.cpp:819
+  stream << "";
+  OutStr.append(number.begin(), number.end());
+  continue;

I'm pretty sure you need to call `flush()` before using `number`.



Comment at: clang/lib/Sema/SemaDeclCXX.cpp:16361-16363
+if (StringLiteral *MsgStr = cast(AssertMessage)) {
+  Msg << MsgStr->getString();
+}




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108469

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


[PATCH] D107775: [Clang][AST] Resolve FIXME: Remove ObjCObjectPointer from isSpecifierType

2021-09-15 Thread Alf via Phabricator via cfe-commits
gAlfonso-bit updated this revision to Diff 372766.
gAlfonso-bit added a comment.

git-format


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

https://reviews.llvm.org/D107775

Files:
  clang/lib/AST/DeclPrinter.cpp
  clang/lib/AST/Type.cpp
  clang/lib/AST/TypePrinter.cpp
  clang/unittests/AST/TypePrinterTest.cpp


Index: clang/unittests/AST/TypePrinterTest.cpp
===
--- clang/unittests/AST/TypePrinterTest.cpp
+++ clang/unittests/AST/TypePrinterTest.cpp
@@ -62,4 +62,11 @@
   ASSERT_TRUE(PrintedTypeMatches(
   Code, {}, Matcher, "const N::Type &",
   [](PrintingPolicy &Policy) { Policy.FullyQualifiedName = true; }));
-}
\ No newline at end of file
+}
+
+TEST(TypePrinter, ObjectCPointerType) {
+
+  auto Qual = qualType().bind(ObjCObjectPointerType);
+
+  ASSERT_TRUE(Qual.getTypePtr().isSpecifier() == false);
+}
Index: clang/lib/AST/TypePrinter.cpp
===
--- clang/lib/AST/TypePrinter.cpp
+++ clang/lib/AST/TypePrinter.cpp
@@ -307,7 +307,6 @@
   SaveAndRestore PrevPHIsEmpty(HasEmptyPlaceHolder);
 
   // Print qualifiers as appropriate.
-
   bool CanPrefixQualifiers = false;
   bool NeedARCStrongQualifier = false;
   CanPrefixQualifiers = canPrefixQualifiers(T, NeedARCStrongQualifier);
Index: clang/lib/AST/Type.cpp
===
--- clang/lib/AST/Type.cpp
+++ clang/lib/AST/Type.cpp
@@ -2785,7 +2785,6 @@
   case DependentTemplateSpecialization:
   case ObjCInterface:
   case ObjCObject:
-  case ObjCObjectPointer: // FIXME: object pointers aren't really specifiers
 return true;
   default:
 return false;
Index: clang/lib/AST/DeclPrinter.cpp
===
--- clang/lib/AST/DeclPrinter.cpp
+++ clang/lib/AST/DeclPrinter.cpp
@@ -153,11 +153,14 @@
   while (!BaseType->isSpecifierType()) {
 if (const PointerType *PTy = BaseType->getAs())
   BaseType = PTy->getPointeeType();
+else if (const ObjCObjectPointerType *OPT =
+ BaseType->getAs())
+  BaseType = OPT->getPointeeType();
 else if (const BlockPointerType *BPy = BaseType->getAs())
   BaseType = BPy->getPointeeType();
-else if (const ArrayType* ATy = dyn_cast(BaseType))
+else if (const ArrayType *ATy = dyn_cast(BaseType))
   BaseType = ATy->getElementType();
-else if (const FunctionType* FTy = BaseType->getAs())
+else if (const FunctionType *FTy = BaseType->getAs())
   BaseType = FTy->getReturnType();
 else if (const VectorType *VTy = BaseType->getAs())
   BaseType = VTy->getElementType();


Index: clang/unittests/AST/TypePrinterTest.cpp
===
--- clang/unittests/AST/TypePrinterTest.cpp
+++ clang/unittests/AST/TypePrinterTest.cpp
@@ -62,4 +62,11 @@
   ASSERT_TRUE(PrintedTypeMatches(
   Code, {}, Matcher, "const N::Type &",
   [](PrintingPolicy &Policy) { Policy.FullyQualifiedName = true; }));
-}
\ No newline at end of file
+}
+
+TEST(TypePrinter, ObjectCPointerType) {
+
+  auto Qual = qualType().bind(ObjCObjectPointerType);
+
+  ASSERT_TRUE(Qual.getTypePtr().isSpecifier() == false);
+}
Index: clang/lib/AST/TypePrinter.cpp
===
--- clang/lib/AST/TypePrinter.cpp
+++ clang/lib/AST/TypePrinter.cpp
@@ -307,7 +307,6 @@
   SaveAndRestore PrevPHIsEmpty(HasEmptyPlaceHolder);
 
   // Print qualifiers as appropriate.
-
   bool CanPrefixQualifiers = false;
   bool NeedARCStrongQualifier = false;
   CanPrefixQualifiers = canPrefixQualifiers(T, NeedARCStrongQualifier);
Index: clang/lib/AST/Type.cpp
===
--- clang/lib/AST/Type.cpp
+++ clang/lib/AST/Type.cpp
@@ -2785,7 +2785,6 @@
   case DependentTemplateSpecialization:
   case ObjCInterface:
   case ObjCObject:
-  case ObjCObjectPointer: // FIXME: object pointers aren't really specifiers
 return true;
   default:
 return false;
Index: clang/lib/AST/DeclPrinter.cpp
===
--- clang/lib/AST/DeclPrinter.cpp
+++ clang/lib/AST/DeclPrinter.cpp
@@ -153,11 +153,14 @@
   while (!BaseType->isSpecifierType()) {
 if (const PointerType *PTy = BaseType->getAs())
   BaseType = PTy->getPointeeType();
+else if (const ObjCObjectPointerType *OPT =
+ BaseType->getAs())
+  BaseType = OPT->getPointeeType();
 else if (const BlockPointerType *BPy = BaseType->getAs())
   BaseType = BPy->getPointeeType();
-else if (const ArrayType* ATy = dyn_cast(BaseType))
+else if (const ArrayType *ATy = dyn_cast(BaseType))
   BaseType = ATy->getElementType();
-else if (const FunctionType* FTy = BaseType->getAs())
+else if (const FunctionType *FTy = BaseType->getAs())
   BaseType = FTy->getReturnType();
 else if (c

[PATCH] D107775: [Clang][AST] Resolve FIXME: Remove ObjCObjectPointer from isSpecifierType

2021-09-15 Thread Alf via Phabricator via cfe-commits
gAlfonso-bit added a comment.

@dgoldman I did it!


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

https://reviews.llvm.org/D107775

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


[PATCH] D107717: [LLVM][CMake][NFC] Resolve FIXME: Rename LLVM_CMAKE_PATH to LLVM_CMAKE_DIR throughout the project

2021-09-15 Thread Alf via Phabricator via cfe-commits
gAlfonso-bit added a comment.

@Mordante Alfonso Gregory gfunni...@gmail.com


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

https://reviews.llvm.org/D107717

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


[PATCH] D107717: [LLVM][CMake][NFC] Resolve FIXME: Rename LLVM_CMAKE_PATH to LLVM_CMAKE_DIR throughout the project

2021-09-15 Thread Alf via Phabricator via cfe-commits
gAlfonso-bit updated this revision to Diff 372770.
gAlfonso-bit added a comment.

Rebased to main


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

https://reviews.llvm.org/D107717

Files:
  clang/CMakeLists.txt
  clang/lib/Basic/CMakeLists.txt
  compiler-rt/cmake/Modules/CompilerRTMockLLVMCMakeConfig.cmake
  compiler-rt/cmake/Modules/CompilerRTUtils.cmake
  flang/CMakeLists.txt
  libcxx/cmake/Modules/HandleOutOfTreeLLVM.cmake
  libunwind/CMakeLists.txt
  lld/CMakeLists.txt
  lld/Common/CMakeLists.txt
  lldb/cmake/modules/LLDBStandalone.cmake
  lldb/source/CMakeLists.txt
  llvm/CMakeLists.txt
  llvm/include/llvm/Support/CMakeLists.txt
  runtimes/CMakeLists.txt

Index: runtimes/CMakeLists.txt
===
--- runtimes/CMakeLists.txt
+++ runtimes/CMakeLists.txt
@@ -76,7 +76,7 @@
 
 # This variable makes sure that e.g. llvm-lit is found.
 set(LLVM_MAIN_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../llvm)
-set(LLVM_CMAKE_PATH ${LLVM_MAIN_SRC_DIR}/cmake/modules)
+set(LLVM_CMAKE_DIR ${LLVM_MAIN_SRC_DIR}/cmake/modules)
 
 # This variable is used by individual runtimes to locate LLVM files.
 set(LLVM_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../llvm)
Index: llvm/include/llvm/Support/CMakeLists.txt
===
--- llvm/include/llvm/Support/CMakeLists.txt
+++ llvm/include/llvm/Support/CMakeLists.txt
@@ -3,7 +3,7 @@
 # The VC revision include that we want to generate.
 set(version_inc "${CMAKE_CURRENT_BINARY_DIR}/VCSRevision.h")
 
-set(generate_vcs_version_script "${LLVM_CMAKE_PATH}/GenerateVersionFromVCS.cmake")
+set(generate_vcs_version_script "${LLVM_CMAKE_DIR}/GenerateVersionFromVCS.cmake")
 
 if(LLVM_APPEND_VC_REV)
   set(llvm_source_dir ${LLVM_MAIN_SRC_DIR})
Index: llvm/CMakeLists.txt
===
--- llvm/CMakeLists.txt
+++ llvm/CMakeLists.txt
@@ -295,8 +295,8 @@
 set(LLVM_MAIN_INCLUDE_DIR ${LLVM_MAIN_SRC_DIR}/include ) # --includedir
 set(LLVM_BINARY_DIR   ${CMAKE_CURRENT_BINARY_DIR}  ) # --prefix
 
-# Note: LLVM_CMAKE_PATH does not include generated files
-set(LLVM_CMAKE_PATH ${LLVM_MAIN_SRC_DIR}/cmake/modules)
+# Note: LLVM_CMAKE_DIR does not include generated files
+set(LLVM_CMAKE_DIR ${LLVM_MAIN_SRC_DIR}/cmake/modules)
 set(LLVM_EXAMPLES_BINARY_DIR ${LLVM_BINARY_DIR}/examples)
 set(LLVM_INCLUDE_DIR ${CMAKE_CURRENT_BINARY_DIR}/include)
 
Index: lldb/source/CMakeLists.txt
===
--- lldb/source/CMakeLists.txt
+++ lldb/source/CMakeLists.txt
@@ -8,7 +8,7 @@
 find_first_existing_vc_file("${LLDB_SOURCE_DIR}" lldb_vc)
 
 set(version_inc "${CMAKE_CURRENT_BINARY_DIR}/VCSVersion.inc")
-set(generate_vcs_version_script "${LLVM_CMAKE_PATH}/GenerateVersionFromVCS.cmake")
+set(generate_vcs_version_script "${LLVM_CMAKE_DIR}/GenerateVersionFromVCS.cmake")
 
 if(lldb_vc AND LLVM_APPEND_VC_REV)
   set(lldb_source_dir ${LLDB_SOURCE_DIR})
Index: lldb/cmake/modules/LLDBStandalone.cmake
===
--- lldb/cmake/modules/LLDBStandalone.cmake
+++ lldb/cmake/modules/LLDBStandalone.cmake
@@ -3,8 +3,8 @@
 find_package(LLVM REQUIRED CONFIG HINTS ${LLVM_DIR} NO_CMAKE_FIND_ROOT_PATH)
 find_package(Clang REQUIRED CONFIG HINTS ${Clang_DIR} ${LLVM_DIR}/../clang NO_CMAKE_FIND_ROOT_PATH)
 
-# We set LLVM_CMAKE_PATH so that GetSVN.cmake is found correctly when building SVNVersion.inc
-set(LLVM_CMAKE_PATH ${LLVM_CMAKE_DIR} CACHE PATH "Path to LLVM CMake modules")
+# We set LLVM_CMAKE_DIR so that GetSVN.cmake is found correctly when building SVNVersion.inc
+set(LLVM_CMAKE_DIR ${LLVM_CMAKE_DIR} CACHE PATH "Path to LLVM CMake modules")
 
 set(LLVM_MAIN_SRC_DIR ${LLVM_BUILD_MAIN_SRC_DIR} CACHE PATH "Path to LLVM source tree")
 set(LLVM_MAIN_INCLUDE_DIR ${LLVM_MAIN_INCLUDE_DIR} CACHE PATH "Path to llvm/include")
Index: lld/Common/CMakeLists.txt
===
--- lld/Common/CMakeLists.txt
+++ lld/Common/CMakeLists.txt
@@ -8,7 +8,7 @@
 find_first_existing_vc_file("${LLD_SOURCE_DIR}" lld_vc)
 
 set(version_inc "${CMAKE_CURRENT_BINARY_DIR}/VCSVersion.inc")
-set(generate_vcs_version_script "${LLVM_CMAKE_PATH}/GenerateVersionFromVCS.cmake")
+set(generate_vcs_version_script "${LLVM_CMAKE_DIR}/GenerateVersionFromVCS.cmake")
 
 if(lld_vc AND LLVM_APPEND_VC_REV)
   set(lld_source_dir ${LLD_SOURCE_DIR})
Index: lld/CMakeLists.txt
===
--- lld/CMakeLists.txt
+++ lld/CMakeLists.txt
@@ -27,7 +27,7 @@
 
   list(GET LLVM_CONFIG_OUTPUT 0 OBJ_ROOT)
   list(GET LLVM_CONFIG_OUTPUT 1 MAIN_INCLUDE_DIR)
-  list(GET LLVM_CONFIG_OUTPUT 2 LLVM_CMAKE_PATH)
+  list(GET LLVM_CONFIG_OUTPUT 2 LLVM_CMAKE_DIR)
   list(GET LLVM_CONFIG_OUTPUT 3 MAIN_SRC_DIR)
 
   set(LLVM_OBJ_ROOT ${OBJ_ROOT} CACHE PATH "path to LLVM build tree")
@@ -35,14 +35,14 @@
   set(LLVM_MAIN_SRC_DIR ${MAIN_SR

[PATCH] D109841: Fix vtbl field addr space

2021-09-15 Thread Alexander Richardson via Phabricator via cfe-commits
arichardson accepted this revision.
arichardson added a comment.
This revision is now accepted and ready to land.

Thanks, I can confirm that this fixes the assertions we were seeing after 
merging D103835 . A few minor suggestions 
below:

There's a typo in the commit message, I'd maybe change it to:
`Storing the vtable field of an object should use the same address space as the 
this pointer.`
And maybe change `This caused issue for some out of tree project.` to something 
like `This assumption (added in 054cc3b1b469de4b0cb25d1dc3af43c679c5dc44) 
caused issues for the out-of-tree CHERI targets`.




Comment at: clang/lib/CodeGen/CGClass.cpp:2522-2523
+  // vtable field is is derived from `this` pointer, therefore they should be 
in
+  // the same addr space. Note it may not be the default address space of LLVM
+  // IR.
   VTableField = Builder.CreatePointerBitCastOrAddrSpaceCast(

Maybe this is clearer?



Comment at: clang/lib/CodeGen/CGClass.cpp:2526-2527
+  VTableField, VTablePtrTy->getPointerTo(ThisAddrSpace));
   VTableAddressPoint = Builder.CreatePointerBitCastOrAddrSpaceCast(
   VTableAddressPoint, VTablePtrTy);
 

As noted by @rjmccall, changing this line still allows all tests to pass 
(including our newly added out-of-tree CHERI ones).


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

https://reviews.llvm.org/D109841

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


[PATCH] D109828: [clang-cl] Add a /diasdkdir flag and make /winsysroot imply it

2021-09-15 Thread Nico Weber via Phabricator via cfe-commits
thakis updated this revision to Diff 372782.
thakis marked an inline comment as done.
thakis added a comment.

move arch functions


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

https://reviews.llvm.org/D109828

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/MSVC.cpp
  clang/test/Driver/cl-sysroot.cpp

Index: clang/test/Driver/cl-sysroot.cpp
===
--- clang/test/Driver/cl-sysroot.cpp
+++ clang/test/Driver/cl-sysroot.cpp
@@ -1,18 +1,27 @@
 // RUN: rm -rf %t
 // RUN: split-file %s %t
 
-// RUN: %clang_cl /winsysroot %t -### -- %t/foo.cpp 2>&1 | FileCheck %s
-// RUN: %clang_cl /vctoolsdir %t/VC/Tools/MSVC/27.1828.18284 \
-// RUN:   /winsdkdir "%t/Windows Kits/10" \
-// RUN:   -### -- %t/foo.cpp 2>&1 | FileCheck %s
+// RUN: %clang_cl -m64 /winsysroot %t -### -- %t/foo.cpp 2>&1 | FileCheck %s
+// RUN: %clang_cl -m64 \
+// RUN: /diasdkdir "%t/DIA SDK" \
+// RUN: /vctoolsdir %t/VC/Tools/MSVC/27.1828.18284 \
+// RUN: /winsdkdir "%t/Windows Kits/10" \
+// RUN: -### -- %t/foo.cpp 2>&1 | FileCheck %s
 
-// CHECK: "-internal-isystem" "[[ROOT:[^"]*]]{{/|}}VC{{/|}}Tools{{/|}}MSVC{{/|}}27.1828.18284{{/|}}include"
+// CHECK: "-internal-isystem" "[[ROOT:[^"]*]]{{/|}}DIA SDK{{/|}}include"
+// CHECK: "-internal-isystem" "[[ROOT]]{{/|}}VC{{/|}}Tools{{/|}}MSVC{{/|}}27.1828.18284{{/|}}include"
 // CHECK: "-internal-isystem" "[[ROOT]]{{/|}}VC{{/|}}Tools{{/|}}MSVC{{/|}}27.1828.18284{{/|}}atlmfc{{/|}}include"
 // CHECK: "-internal-isystem" "[[ROOT]]{{/|}}Windows Kits{{/|}}10{{/|}}Include{{/|}}10.0.19041.0{{/|}}ucrt"
 // CHECK: "-internal-isystem" "[[ROOT]]{{/|}}Windows Kits{{/|}}10{{/|}}Include{{/|}}10.0.19041.0{{/|}}shared"
 // CHECK: "-internal-isystem" "[[ROOT]]{{/|}}Windows Kits{{/|}}10{{/|}}Include{{/|}}10.0.19041.0{{/|}}um"
 // CHECK: "-internal-isystem" "[[ROOT]]{{/|}}Windows Kits{{/|}}10{{/|}}Include{{/|}}10.0.19041.0{{/|}}winrt"
 
+// CHECK: "-libpath:[[ROOT]]{{/|}}DIA SDK{{/|}}lib{{/|}}amd64"
+// CHECK: "-libpath:[[ROOT]]{{/|}}VC{{/|}}Tools{{/|}}MSVC{{/|}}27.1828.18284{{/|}}lib{{/|}}x64"
+// CHECK: "-libpath:[[ROOT]]{{/|}}VC{{/|}}Tools{{/|}}MSVC{{/|}}27.1828.18284{{/|}}atlmfc{{/|}}lib{{/|}}x64"
+// CHECK: "-libpath:[[ROOT]]{{/|}}Windows Kits{{/|}}10{{/|}}Lib{{/|}}10.0.19041.0{{/|}}ucrt{{/|}}x64"
+// CHECK: "-libpath:[[ROOT]]{{/|}}Windows Kits{{/|}}10{{/|}}Lib{{/|}}10.0.19041.0{{/|}}um{{/|}}x64"
+
 #--- VC/Tools/MSVC/27.1828.18284/include/string
 namespace std {
 class mystring {
@@ -24,6 +33,9 @@
 #--- Windows Kits/10/Include/10.0.19041.0/ucrt/assert.h
 #define myassert(X)
 
+#--- DIA SDK/include/cvconst.h
+#define myotherassert(X)
+
 #--- foo.cpp
 #include 
 #include 
@@ -31,4 +43,5 @@
 void f() {
   std::mystring s;
   myassert(s.empty());
+  myotherassert(s.empty());
 }
Index: clang/lib/Driver/ToolChains/MSVC.cpp
===
--- clang/lib/Driver/ToolChains/MSVC.cpp
+++ clang/lib/Driver/ToolChains/MSVC.cpp
@@ -63,6 +63,62 @@
 using namespace clang;
 using namespace llvm::opt;
 
+// Windows SDKs and VC Toolchains group their contents into subdirectories based
+// on the target architecture. This function converts an llvm::Triple::ArchType
+// to the corresponding subdirectory name.
+static const char *llvmArchToWindowsSDKArch(llvm::Triple::ArchType Arch) {
+  using ArchType = llvm::Triple::ArchType;
+  switch (Arch) {
+  case ArchType::x86:
+return "x86";
+  case ArchType::x86_64:
+return "x64";
+  case ArchType::arm:
+return "arm";
+  case ArchType::aarch64:
+return "arm64";
+  default:
+return "";
+  }
+}
+
+// Similar to the above function, but for Visual Studios before VS2017.
+static const char *llvmArchToLegacyVCArch(llvm::Triple::ArchType Arch) {
+  using ArchType = llvm::Triple::ArchType;
+  switch (Arch) {
+  case ArchType::x86:
+// x86 is default in legacy VC toolchains.
+// e.g. x86 libs are directly in /lib as opposed to /lib/x86.
+return "";
+  case ArchType::x86_64:
+return "amd64";
+  case ArchType::arm:
+return "arm";
+  case ArchType::aarch64:
+return "arm64";
+  default:
+return "";
+  }
+}
+
+// Similar to the above function, but for DevDiv internal builds.
+static const char *llvmArchToDevDivInternalArch(llvm::Triple::ArchType Arch) {
+  using ArchType = llvm::Triple::ArchType;
+  switch (Arch) {
+  case ArchType::x86:
+return "i386";
+  case ArchType::x86_64:
+return "amd64";
+  case ArchType::arm:
+return "arm";
+  case ArchType::aarch64:
+return "arm64";
+  default:
+return "";
+  }
+}
+
+
 static bool canExecute(llvm::vfs::FileSystem &VFS, StringRef Path) {
   auto Status 

[PATCH] D106393: [PowerPC][AIX] Add support for varargs for complex types on AIX

2021-09-15 Thread Sean Fertile via Phabricator via cfe-commits
sfertile accepted this revision as: sfertile.
sfertile added a comment.
This revision is now accepted and ready to land.

LGTM.




Comment at: clang/test/CodeGen/aix32-complex-varargs.c:2
+// REQUIRES: powerpc-registered-target
+// RUN: %clang_cc1 -triple powerpc-ibm-aix-xcoff -emit-llvm -o - %s | 
FileCheck %s
+

ZarkoCA wrote:
> ZarkoCA wrote:
> > sfertile wrote:
> > > The code-gen for int and float won't change with this patch, lets 
> > > pre-commit this test without the _Complex short and _Complex char 
> > > portions now as an NFC patch.
> > I can't precommit this test unless I also remove the fatal error here:
> > ```
> >  if (Ty->isAnyComplexType())
> > llvm::report_fatal_error("complex type is not supported on AIX yet");
> > ``` 
> > 
> > But I believe that I can commit the llc tests and I'll go ahead and do 
> > that. 
> Sorry, not commit the llc tests but separate them in their own patch.
Sorry, I missed that. I was thinking since the word-size element types didn't 
change we should recommit heir tests, but since it was disabled with a fatal 
error that doesn't make sense.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106393

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


[PATCH] D109828: [clang-cl] Add a /diasdkdir flag and make /winsysroot imply it

2021-09-15 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

In D109828#3002114 , @hans wrote:

> The /winsysroot part makes sense to me, but what's the case for the new 
> /diasdkdir flag?



- If you do have a vcvars shell, you don't need the full sysroot path and it's 
kind of useful (see example in commit message)
- it seems nice to be able to explain /winsysroot as combination of other flags 
in the help text
- it makes writing the test a bit easier
- it makes diasdkdir more like the other flags controlled by /winsysroot




Comment at: clang/lib/Driver/ToolChains/MSVC.cpp:66
 
+static const char *llvmArchToLegacyVCArch(llvm::Triple::ArchType Arch);
+

hans wrote:
> Maybe move the arch functions up to before visualstudio::Linker::ConstructJob 
> instead?
> 
> The file is already kind of organized in that way, with lots of static helper 
> functions on top, and then the implementations of the member functions.
Sure, done. The file has a bunch of other static functions all over the place 
too though :)


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

https://reviews.llvm.org/D109828

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


[PATCH] D109841: Fix vtbl field addr space

2021-09-15 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl marked 2 inline comments as done.
yaxunl added a comment.

In D109841#3002404 , @arichardson 
wrote:

> Thanks, I can confirm that this fixes the assertions we were seeing after 
> merging D103835 . A few minor suggestions 
> below:
>
> There's a typo in the commit message, I'd maybe change it to:
> `Storing the vtable field of an object should use the same address space as 
> the this pointer.`
> And maybe change `This caused issue for some out of tree project.` to 
> something like `This assumption (added in 
> 054cc3b1b469de4b0cb25d1dc3af43c679c5dc44) caused issues for the out-of-tree 
> CHERI targets`.

will do




Comment at: clang/lib/CodeGen/CGClass.cpp:2522-2523
+  // vtable field is is derived from `this` pointer, therefore they should be 
in
+  // the same addr space. Note it may not be the default address space of LLVM
+  // IR.
   VTableField = Builder.CreatePointerBitCastOrAddrSpaceCast(

arichardson wrote:
> Maybe this is clearer?
will do



Comment at: clang/lib/CodeGen/CGClass.cpp:2526-2527
+  VTableField, VTablePtrTy->getPointerTo(ThisAddrSpace));
   VTableAddressPoint = Builder.CreatePointerBitCastOrAddrSpaceCast(
   VTableAddressPoint, VTablePtrTy);
 

arichardson wrote:
> As noted by @rjmccall, changing this line still allows all tests to pass 
> (including our newly added out-of-tree CHERI ones).
will do. I think we can also make changes so that

 
```
VTableField = Builder.CreateBitCast(
  VTableField, VTablePtrTy->getPointerTo(ThisAddrSpace));
```


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

https://reviews.llvm.org/D109841

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


[clang] 40acc0a - Improve type printing of size-dependent const arrays to normalize array-of-const and const-array

2021-09-15 Thread David Blaikie via cfe-commits

Author: David Blaikie
Date: 2021-09-15T13:46:37-07:00
New Revision: 40acc0adad59ac39e9a7a02fcd93161298500c00

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

LOG: Improve type printing of size-dependent const arrays to normalize 
array-of-const and const-array

Follow-on from 2bd84938470bf2e337801faafb8a67710f46429d based on
postcommit feedback from Richard Smith.

The VariableArray case I couldn't figure out how to test/provoke - you
can't write/form a variable array in any context other than a local
variable that I know of, and in that case `const int x[n]` is the
normalized form already (array-of-const) and you can't use typedefs
(since you can't typedef int[n] with variable 'n') to force the
const-array AST that would produce the undesirable type printing "int
const [n]".

Added: 


Modified: 
clang/lib/AST/TypePrinter.cpp
clang/test/AST/ast-dump-array.cpp

Removed: 




diff  --git a/clang/lib/AST/TypePrinter.cpp b/clang/lib/AST/TypePrinter.cpp
index 251db97c7db08..749a3e25d28a4 100644
--- a/clang/lib/AST/TypePrinter.cpp
+++ b/clang/lib/AST/TypePrinter.cpp
@@ -242,13 +242,16 @@ bool TypePrinter::canPrefixQualifiers(const Type *T,
 T->isObjCQualifiedIdType() || T->isObjCQualifiedClassType();
   break;
 
+case Type::DependentSizedArray:
+  NeedARCStrongQualifier = true;
+  LLVM_FALLTHROUGH;
+
 case Type::ConstantArray:
 case Type::IncompleteArray:
   return canPrefixQualifiers(
   cast(UnderlyingType)->getElementType().getTypePtr(),
   NeedARCStrongQualifier);
 case Type::VariableArray:
-case Type::DependentSizedArray:
   NeedARCStrongQualifier = true;
   LLVM_FALLTHROUGH;
 

diff  --git a/clang/test/AST/ast-dump-array.cpp 
b/clang/test/AST/ast-dump-array.cpp
index fe7875ec95c90..2e94f7769e0bd 100644
--- a/clang/test/AST/ast-dump-array.cpp
+++ b/clang/test/AST/ast-dump-array.cpp
@@ -23,5 +23,6 @@ class array {
 
   using array_T_size = T[Size];
   // CHECK: `-DependentSizedArrayType 0x{{[^ ]*}} 'T [Size]' dependent   

+  using const_array_T_size = const T[Size];
+  // CHECK: `-DependentSizedArrayType 0x{{[^ ]*}} 'const T [Size]' dependent   

 };
-



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


[PATCH] D109841: Fix vtbl field addr space

2021-09-15 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 372792.
yaxunl edited the summary of this revision.
yaxunl added a comment.
Herald added a subscriber: jrtc27.

fix comments and casts


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

https://reviews.llvm.org/D109841

Files:
  clang/lib/CodeGen/CGClass.cpp


Index: clang/lib/CodeGen/CGClass.cpp
===
--- clang/lib/CodeGen/CGClass.cpp
+++ clang/lib/CodeGen/CGClass.cpp
@@ -2502,6 +2502,8 @@
 
   // Apply the offsets.
   Address VTableField = LoadCXXThisAddress();
+  unsigned ThisAddrSpace =
+  VTableField.getPointer()->getType()->getPointerAddressSpace();
 
   if (!NonVirtualOffset.isZero() || VirtualOffset)
 VTableField = ApplyNonVirtualAndVirtualOffset(
@@ -2516,12 +2518,11 @@
   llvm::FunctionType::get(CGM.Int32Ty, /*isVarArg=*/true)
   ->getPointerTo(ProgAS)
   ->getPointerTo(GlobalsAS);
-  // vtable field is is derived from `this` pointer, therefore it should be in
-  // default address space.
-  VTableField = Builder.CreatePointerBitCastOrAddrSpaceCast(
-  VTableField, VTablePtrTy->getPointerTo());
-  VTableAddressPoint = Builder.CreatePointerBitCastOrAddrSpaceCast(
-  VTableAddressPoint, VTablePtrTy);
+  // vtable field is is derived from `this` pointer, therefore they should be 
in
+  // the same addr space. Note that this might not be LLVM address space 0.
+  VTableField = Builder.CreateBitCast(VTableField,
+  
VTablePtrTy->getPointerTo(ThisAddrSpace));
+  VTableAddressPoint = Builder.CreateBitCast(VTableAddressPoint, VTablePtrTy);
 
   llvm::StoreInst *Store = Builder.CreateStore(VTableAddressPoint, 
VTableField);
   TBAAAccessInfo TBAAInfo = CGM.getTBAAVTablePtrAccessInfo(VTablePtrTy);


Index: clang/lib/CodeGen/CGClass.cpp
===
--- clang/lib/CodeGen/CGClass.cpp
+++ clang/lib/CodeGen/CGClass.cpp
@@ -2502,6 +2502,8 @@
 
   // Apply the offsets.
   Address VTableField = LoadCXXThisAddress();
+  unsigned ThisAddrSpace =
+  VTableField.getPointer()->getType()->getPointerAddressSpace();
 
   if (!NonVirtualOffset.isZero() || VirtualOffset)
 VTableField = ApplyNonVirtualAndVirtualOffset(
@@ -2516,12 +2518,11 @@
   llvm::FunctionType::get(CGM.Int32Ty, /*isVarArg=*/true)
   ->getPointerTo(ProgAS)
   ->getPointerTo(GlobalsAS);
-  // vtable field is is derived from `this` pointer, therefore it should be in
-  // default address space.
-  VTableField = Builder.CreatePointerBitCastOrAddrSpaceCast(
-  VTableField, VTablePtrTy->getPointerTo());
-  VTableAddressPoint = Builder.CreatePointerBitCastOrAddrSpaceCast(
-  VTableAddressPoint, VTablePtrTy);
+  // vtable field is is derived from `this` pointer, therefore they should be in
+  // the same addr space. Note that this might not be LLVM address space 0.
+  VTableField = Builder.CreateBitCast(VTableField,
+  VTablePtrTy->getPointerTo(ThisAddrSpace));
+  VTableAddressPoint = Builder.CreateBitCast(VTableAddressPoint, VTablePtrTy);
 
   llvm::StoreInst *Store = Builder.CreateStore(VTableAddressPoint, VTableField);
   TBAAAccessInfo TBAAInfo = CGM.getTBAAVTablePtrAccessInfo(VTablePtrTy);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [clang] 2bd8493 - Improve type printing of const arrays to normalize array-of-const and const-array

2021-09-15 Thread David Blaikie via cfe-commits
On Tue, Sep 14, 2021 at 10:04 AM Richard Smith 
wrote:

> On Mon, 13 Sept 2021 at 19:24, David Blaikie via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>>
>> Author: David Blaikie
>> Date: 2021-09-13T19:17:05-07:00
>> New Revision: 2bd84938470bf2e337801faafb8a67710f46429d
>>
>> URL:
>> https://github.com/llvm/llvm-project/commit/2bd84938470bf2e337801faafb8a67710f46429d
>> DIFF:
>> https://github.com/llvm/llvm-project/commit/2bd84938470bf2e337801faafb8a67710f46429d.diff
>>
>> LOG: Improve type printing of const arrays to normalize array-of-const
>> and const-array
>>
>> Since these map to the same effective type - render them the same/in the
>> more legible way (const x[n]).
>>
>
> Nice!
>
>
>> Added:
>>
>>
>> Modified:
>> clang/lib/AST/TypePrinter.cpp
>> clang/test/ARCMT/cxx-checking.mm
>> clang/test/AST/ast-dump-APValue-arithmetic.cpp
>> clang/test/AST/ast-dump-APValue-array.cpp
>> clang/test/CXX/basic/basic.types/p10.cpp
>> clang/test/Sema/assign.c
>> clang/test/Sema/typedef-retain.c
>> clang/test/SemaCXX/reinterpret-cast.cpp
>> clang/test/SemaCXX/static-assert-cxx17.cpp
>>
>> Removed:
>>
>>
>>
>>
>> 
>> diff  --git a/clang/lib/AST/TypePrinter.cpp
>> b/clang/lib/AST/TypePrinter.cpp
>> index aef1e4f3f4953..251db97c7db08 100644
>> --- a/clang/lib/AST/TypePrinter.cpp
>> +++ b/clang/lib/AST/TypePrinter.cpp
>> @@ -200,11 +200,12 @@ bool TypePrinter::canPrefixQualifiers(const Type *T,
>>// type expands to a simple string.
>>bool CanPrefixQualifiers = false;
>>NeedARCStrongQualifier = false;
>> -  Type::TypeClass TC = T->getTypeClass();
>> +  const Type *UnderlyingType = T;
>>if (const auto *AT = dyn_cast(T))
>> -TC = AT->desugar()->getTypeClass();
>> +UnderlyingType = AT->desugar().getTypePtr();
>>if (const auto *Subst = dyn_cast(T))
>> -TC = Subst->getReplacementType()->getTypeClass();
>> +UnderlyingType = Subst->getReplacementType().getTypePtr();
>> +  Type::TypeClass TC = UnderlyingType->getTypeClass();
>>
>>switch (TC) {
>>  case Type::Auto:
>> @@ -243,6 +244,9 @@ bool TypePrinter::canPrefixQualifiers(const Type *T,
>>
>>  case Type::ConstantArray:
>>  case Type::IncompleteArray:
>> +  return canPrefixQualifiers(
>> +  cast(UnderlyingType)->getElementType().getTypePtr(),
>> +  NeedARCStrongQualifier);
>>  case Type::VariableArray:
>>  case Type::DependentSizedArray:
>>
>
> Can we give these two cases the same treatment?
>

Handled the DependentSizedArray in
https://github.com/llvm/llvm-project/commit/40acc0adad59ac39e9a7a02fcd93161298500c00

But per the comment in that commit I wasn't able to reproduce the problem
with a variable array - though we could include it in the handling on
principle/for consistency, even without a test/etc. Perhaps there's a way
to test/provoke the behavior you might know that I couldn't figure out?

Details from the commit:

The VariableArray case I couldn't figure out how to test/provoke - you

can't write/form a variable array in any context other than a local

variable that I know of, and in that case `const int x[n]` is the

normalized form already (array-of-const) and you can't use typedefs

(since you can't typedef int[n] with variable 'n') to force the

const-array AST that would produce the undesirable type printing "int

const [n]".

Oh, also - another quirk of array type printing that I'd be up for
addressing if you've got an opinion on it:

"int [n]" is printed with a space between the "int" and array.
"int *const[n]" is printed without a space before the array (though both
have a space after "int")

ClangFormat formats these as "int[n]" and "int *const[n]" - with *
left/right depending on ClangFormat's heuristics/configuration.

Reckon we should remove the space in "int[n]"?



>
>
>>NeedARCStrongQualifier = true;
>
>
>> diff  --git a/clang/test/ARCMT/cxx-checking.mm b/clang/test/ARCMT/
>> cxx-checking.mm
>> index 952f3cdcbb79c..d6441def09b40 100644
>> --- a/clang/test/ARCMT/cxx-checking.mm
>> +++ b/clang/test/ARCMT/cxx-checking.mm
>> @@ -80,7 +80,7 @@
>>
>>  struct FlexibleArrayMember0 {
>>int length;
>> -  id array[]; // expected-error{{flexible array member 'array' of type
>> 'id __strong[]' with non-trivial destruction}}
>> +  id array[]; // expected-error{{flexible array member 'array' of type
>> '__strong id []' with non-trivial destruction}}
>>  };
>>
>>  struct FlexibleArrayMember1 {
>>
>> diff  --git a/clang/test/AST/ast-dump-APValue-arithmetic.cpp
>> b/clang/test/AST/ast-dump-APValue-arithmetic.cpp
>> index 835d8c8108346..e51c1cee04cfe 100644
>> --- a/clang/test/AST/ast-dump-APValue-arithmetic.cpp
>> +++ b/clang/test/AST/ast-dump-APValue-arithmetic.cpp
>> @@ -36,13 +36,13 @@ void Test() {
>>// CHECK-NEXT:  |   |-value: ComplexFloat 3.141500e+00 + 4.20e+01i
>>
>>constexpr _Complex int ArrayOfComplexInt[10] 

[clang-tools-extra] d249200 - Revert "Re-Revert "clang-tidy: introduce readability-containter-data-pointer check""

2021-09-15 Thread Saleem Abdulrasool via cfe-commits

Author: Saleem Abdulrasool
Date: 2021-09-15T20:52:55Z
New Revision: d249200fa7d540fb0b3ddc065575293e1da11107

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

LOG: Revert "Re-Revert "clang-tidy: introduce 
readability-containter-data-pointer check""

This reverts commit 626586fc253c6f032aedb325dba6b1ff3f11875e.

Tweak the test for Windows.  Windows defaults to delayed template
parsing, which resulted in the main template definition not registering
the test on Windows.  Process the file with the additional
`-fno-delayed-template-parsing` flag to change the default beahviour.
Additionally, add an extra check for the fix it and use a more robust
test to ensure that the value is always evaluated.

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

Added: 
clang-tools-extra/clang-tidy/readability/ContainerDataPointerCheck.cpp
clang-tools-extra/clang-tidy/readability/ContainerDataPointerCheck.h
clang-tools-extra/docs/clang-tidy/checks/readability-data-pointer.rst

clang-tools-extra/test/clang-tidy/checkers/readability-container-data-pointer.cpp

Modified: 
clang-tools-extra/clang-tidy/readability/CMakeLists.txt
clang-tools-extra/clang-tidy/readability/ReadabilityTidyModule.cpp
clang-tools-extra/docs/ReleaseNotes.rst

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/readability/CMakeLists.txt 
b/clang-tools-extra/clang-tidy/readability/CMakeLists.txt
index 78256d6f73251..eba0ab98cb37a 100644
--- a/clang-tools-extra/clang-tidy/readability/CMakeLists.txt
+++ b/clang-tools-extra/clang-tidy/readability/CMakeLists.txt
@@ -7,6 +7,7 @@ add_clang_library(clangTidyReadabilityModule
   AvoidConstParamsInDecls.cpp
   BracesAroundStatementsCheck.cpp
   ConstReturnTypeCheck.cpp
+  ContainerDataPointerCheck.cpp
   ContainerSizeEmptyCheck.cpp
   ConvertMemberFunctionsToStatic.cpp
   DeleteNullPointerCheck.cpp

diff  --git 
a/clang-tools-extra/clang-tidy/readability/ContainerDataPointerCheck.cpp 
b/clang-tools-extra/clang-tidy/readability/ContainerDataPointerCheck.cpp
new file mode 100644
index 0..3a670509ec2e2
--- /dev/null
+++ b/clang-tools-extra/clang-tidy/readability/ContainerDataPointerCheck.cpp
@@ -0,0 +1,117 @@
+//===--- ContainerDataPointerCheck.cpp - clang-tidy 
---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "ContainerDataPointerCheck.h"
+
+#include "clang/Lex/Lexer.h"
+#include "llvm/ADT/StringRef.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+namespace readability {
+ContainerDataPointerCheck::ContainerDataPointerCheck(StringRef Name,
+ ClangTidyContext *Context)
+: ClangTidyCheck(Name, Context) {}
+
+void ContainerDataPointerCheck::registerMatchers(MatchFinder *Finder) {
+  const auto Record =
+  cxxRecordDecl(
+  isSameOrDerivedFrom(
+  namedDecl(
+  has(cxxMethodDecl(isPublic(), hasName("data")).bind("data")))
+  .bind("container")))
+  .bind("record");
+
+  const auto NonTemplateContainerType =
+  
qualType(hasUnqualifiedDesugaredType(recordType(hasDeclaration(Record;
+  const auto TemplateContainerType =
+  qualType(hasUnqualifiedDesugaredType(templateSpecializationType(
+  hasDeclaration(classTemplateDecl(has(Record));
+
+  const auto Container =
+  qualType(anyOf(NonTemplateContainerType, TemplateContainerType));
+
+  Finder->addMatcher(
+  unaryOperator(
+  unless(isExpansionInSystemHeader()), hasOperatorName("&"),
+  hasUnaryOperand(anyOf(
+  ignoringParenImpCasts(
+  cxxOperatorCallExpr(
+  callee(cxxMethodDecl(hasName("operator[]"))
+ .bind("operator[]")),
+  argumentCountIs(2),
+  hasArgument(
+  0,
+  anyOf(ignoringParenImpCasts(
+declRefExpr(
+to(varDecl(anyOf(
+hasType(Container),
+hasType(references(Container))
+.bind("var")),
+ignoringParenImpCasts(hasDescendant(
+declRefExpr(
+to(varDecl(anyOf(
+hasType(Container),
+ 

[clang] 8264846 - Senticify some comments - post-commit review for e4b9f5e851d1fe0ba93cbb11b2ed4558602c379e

2021-09-15 Thread David Blaikie via cfe-commits

Author: David Blaikie
Date: 2021-09-15T13:59:11-07:00
New Revision: 8264846c0ef847adeacca9b8fe0f867a8a378c5e

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

LOG: Senticify some comments - post-commit review for 
e4b9f5e851d1fe0ba93cbb11b2ed4558602c379e

Based on feedback from Paul Robinson.

Added: 


Modified: 
clang/lib/CodeGen/CGDebugInfo.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGDebugInfo.cpp 
b/clang/lib/CodeGen/CGDebugInfo.cpp
index 8abdff010d256..43c9f8c565da0 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -1651,10 +1651,10 @@ CGDebugInfo::getOrCreateInstanceMethodType(QualType 
ThisPtr,
   Qc.removeUnaligned();
   // Keep the removed qualifiers in sync with
   // CreateQualifiedType(const FunctionPrototype*, DIFile *Unit)
-  // on a 'real' member function type, these qualifiers are carried on the type
+  // On a 'real' member function type, these qualifiers are carried on the type
   // of the first parameter, not as separate DW_TAG_const_type (etc) decorator
-  // tags around them. (but in the raw function types with qualifiers, they 
have
-  // to use wrapper types)
+  // tags around them. (But, in the raw function types with qualifiers, they 
have
+  // to use wrapper types.)
 
   // Add "this" pointer.
   const auto *OriginalFunc = cast(



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


  1   2   >