[PATCH] D102479: [clang][driver] Treat unkonwn -flto= values as -flto

2021-05-19 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder updated this revision to Diff 346635.
tbaeder added a comment.

Thanks for the feedback, I think this should work better.


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

https://reviews.llvm.org/D102479

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/lto.c


Index: clang/test/Driver/lto.c
===
--- clang/test/Driver/lto.c
+++ clang/test/Driver/lto.c
@@ -77,3 +77,11 @@
 //
 // CHECK-TUNING-LLDB:   "-plugin-opt=-debugger-tune=lldb"
 // CHECK-NO-TUNING-NOT: "-plugin-opt=-debugger-tune
+//
+// -flto=auto and -flto=jobserver pass along -flto=full
+// RUN: %clang -target x86_64-unknown-linux -### %s -flto=auto 2>&1 | 
FileCheck --check-prefix=FLTO-AUTO %s
+// RUN: %clang -target x86_64-unknown-linux -### %s -flto=jobserver 2>&1 | 
FileCheck --check-prefix=FLTO-JOBSERVER %s
+//
+// FLTO-AUTO: -flto=full
+// FLTO-JOBSERVER: -flto=full
+//
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -4454,7 +4454,14 @@
JA.isDeviceOffloading(Action::OFK_Host));
 
 if (D.isUsingLTO() && !isDeviceOffloadAction) {
-  Args.AddLastArg(CmdArgs, options::OPT_flto, options::OPT_flto_EQ);
+  if (Args.hasArg(options::OPT_flto))
+CmdArgs.push_back("-flto");
+  else {
+if (D.getLTOMode() == LTOK_Thin)
+  CmdArgs.push_back("-flto=thin");
+else
+  CmdArgs.push_back("-flto=full");
+  }
   CmdArgs.push_back("-flto-unit");
 }
   }
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -598,7 +598,9 @@
 void Driver::setLTOMode(const llvm::opt::ArgList ) {
   LTOMode = LTOK_None;
   if (!Args.hasFlag(options::OPT_flto, options::OPT_flto_EQ,
-options::OPT_fno_lto, false))
+options::OPT_fno_lto, false) &&
+  !Args.hasArg(options::OPT_flto_EQ_auto) &&
+  !Args.hasArg(options::OPT_flto_EQ_jobserver))
 return;
 
   StringRef LTOName("full");
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -1950,6 +1950,8 @@
   HelpText<"Force linking the clang builtins runtime library">;
 def flto_EQ : Joined<["-"], "flto=">, Flags<[CoreOption, CC1Option]>, 
Group,
   HelpText<"Set LTO mode to either 'full' or 'thin'">, Values<"thin,full">;
+def flto_EQ_jobserver : Flag<["-"], "flto=jobserver">, Group;
+def flto_EQ_auto : Flag<["-"], "flto=auto">, Group;
 def flto : Flag<["-"], "flto">, Flags<[CoreOption, CC1Option]>, Group,
   HelpText<"Enable LTO in 'full' mode">;
 def fno_lto : Flag<["-"], "fno-lto">, Flags<[CoreOption, CC1Option]>, 
Group,
@@ -4244,8 +4246,6 @@
 defm branch_count_reg : BooleanFFlag<"branch-count-reg">, 
Group;
 defm default_inline : BooleanFFlag<"default-inline">, 
Group;
 defm fat_lto_objects : BooleanFFlag<"fat-lto-objects">, 
Group;
-def : Flag<["-"], "flto=auto">, Group;
-def : Flag<["-"], "flto=jobserver">, 
Group;
 defm float_store : BooleanFFlag<"float-store">, 
Group;
 defm friend_injection : BooleanFFlag<"friend-injection">, 
Group;
 defm function_attribute_list : BooleanFFlag<"function-attribute-list">, 
Group;


Index: clang/test/Driver/lto.c
===
--- clang/test/Driver/lto.c
+++ clang/test/Driver/lto.c
@@ -77,3 +77,11 @@
 //
 // CHECK-TUNING-LLDB:   "-plugin-opt=-debugger-tune=lldb"
 // CHECK-NO-TUNING-NOT: "-plugin-opt=-debugger-tune
+//
+// -flto=auto and -flto=jobserver pass along -flto=full
+// RUN: %clang -target x86_64-unknown-linux -### %s -flto=auto 2>&1 | FileCheck --check-prefix=FLTO-AUTO %s
+// RUN: %clang -target x86_64-unknown-linux -### %s -flto=jobserver 2>&1 | FileCheck --check-prefix=FLTO-JOBSERVER %s
+//
+// FLTO-AUTO: -flto=full
+// FLTO-JOBSERVER: -flto=full
+//
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -4454,7 +4454,14 @@
JA.isDeviceOffloading(Action::OFK_Host));
 
 if (D.isUsingLTO() && !isDeviceOffloadAction) {
-  Args.AddLastArg(CmdArgs, options::OPT_flto, options::OPT_flto_EQ);
+  if (Args.hasArg(options::OPT_flto))
+CmdArgs.push_back("-flto");
+  else {
+if (D.getLTOMode() == LTOK_Thin)
+  CmdArgs.push_back("-flto=thin");
+else
+  CmdArgs.push_back("-flto=full");
+  }
   CmdArgs.push_back("-flto-unit");
 }
   }
Index: clang/lib/Driver/Driver.cpp

[PATCH] D102479: [clang][driver] Treat unkonwn -flto= values as -flto

2021-05-19 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder updated this revision to Diff 346634.

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

https://reviews.llvm.org/D102479

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/lto.c


Index: clang/test/Driver/lto.c
===
--- clang/test/Driver/lto.c
+++ clang/test/Driver/lto.c
@@ -77,3 +77,11 @@
 //
 // CHECK-TUNING-LLDB:   "-plugin-opt=-debugger-tune=lldb"
 // CHECK-NO-TUNING-NOT: "-plugin-opt=-debugger-tune
+//
+// -flto=auto and -flto=jobserver pass along -flto=full
+// RUN: %clang -target x86_64-unknown-linux -### %s -flto=auto 2>&1 | 
FileCheck --check-prefix=FLTO-AUTO %s
+// RUN: %clang -target x86_64-unknown-linux -### %s -flto=jobserver 2>&1 | 
FileCheck --check-prefix=FLTO-JOBSERVER %s
+//
+// FLTO-AUTO: -flto=full
+// FLTO-JOBSERVERE: -flto=full
+//
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -4454,7 +4454,14 @@
JA.isDeviceOffloading(Action::OFK_Host));
 
 if (D.isUsingLTO() && !isDeviceOffloadAction) {
-  Args.AddLastArg(CmdArgs, options::OPT_flto, options::OPT_flto_EQ);
+  if (Args.hasArg(options::OPT_flto))
+CmdArgs.push_back("-flto");
+  else {
+if (D.getLTOMode() == LTOK_Thin)
+  CmdArgs.push_back("-flto=thin");
+else
+  CmdArgs.push_back("-flto=full");
+  }
   CmdArgs.push_back("-flto-unit");
 }
   }
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -598,7 +598,9 @@
 void Driver::setLTOMode(const llvm::opt::ArgList ) {
   LTOMode = LTOK_None;
   if (!Args.hasFlag(options::OPT_flto, options::OPT_flto_EQ,
-options::OPT_fno_lto, false))
+options::OPT_fno_lto, false) &&
+  !Args.hasArg(options::OPT_flto_EQ_auto) &&
+  !Args.hasArg(options::OPT_flto_EQ_jobserver))
 return;
 
   StringRef LTOName("full");
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -1950,6 +1950,8 @@
   HelpText<"Force linking the clang builtins runtime library">;
 def flto_EQ : Joined<["-"], "flto=">, Flags<[CoreOption, CC1Option]>, 
Group,
   HelpText<"Set LTO mode to either 'full' or 'thin'">, Values<"thin,full">;
+def flto_EQ_jobserver : Flag<["-"], "flto=jobserver">, Group;
+def flto_EQ_auto : Flag<["-"], "flto=auto">, Group;
 def flto : Flag<["-"], "flto">, Flags<[CoreOption, CC1Option]>, Group,
   HelpText<"Enable LTO in 'full' mode">;
 def fno_lto : Flag<["-"], "fno-lto">, Flags<[CoreOption, CC1Option]>, 
Group,
@@ -4244,8 +4246,6 @@
 defm branch_count_reg : BooleanFFlag<"branch-count-reg">, 
Group;
 defm default_inline : BooleanFFlag<"default-inline">, 
Group;
 defm fat_lto_objects : BooleanFFlag<"fat-lto-objects">, 
Group;
-def : Flag<["-"], "flto=auto">, Group;
-def : Flag<["-"], "flto=jobserver">, 
Group;
 defm float_store : BooleanFFlag<"float-store">, 
Group;
 defm friend_injection : BooleanFFlag<"friend-injection">, 
Group;
 defm function_attribute_list : BooleanFFlag<"function-attribute-list">, 
Group;


Index: clang/test/Driver/lto.c
===
--- clang/test/Driver/lto.c
+++ clang/test/Driver/lto.c
@@ -77,3 +77,11 @@
 //
 // CHECK-TUNING-LLDB:   "-plugin-opt=-debugger-tune=lldb"
 // CHECK-NO-TUNING-NOT: "-plugin-opt=-debugger-tune
+//
+// -flto=auto and -flto=jobserver pass along -flto=full
+// RUN: %clang -target x86_64-unknown-linux -### %s -flto=auto 2>&1 | FileCheck --check-prefix=FLTO-AUTO %s
+// RUN: %clang -target x86_64-unknown-linux -### %s -flto=jobserver 2>&1 | FileCheck --check-prefix=FLTO-JOBSERVER %s
+//
+// FLTO-AUTO: -flto=full
+// FLTO-JOBSERVERE: -flto=full
+//
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -4454,7 +4454,14 @@
JA.isDeviceOffloading(Action::OFK_Host));
 
 if (D.isUsingLTO() && !isDeviceOffloadAction) {
-  Args.AddLastArg(CmdArgs, options::OPT_flto, options::OPT_flto_EQ);
+  if (Args.hasArg(options::OPT_flto))
+CmdArgs.push_back("-flto");
+  else {
+if (D.getLTOMode() == LTOK_Thin)
+  CmdArgs.push_back("-flto=thin");
+else
+  CmdArgs.push_back("-flto=full");
+  }
   CmdArgs.push_back("-flto-unit");
 }
   }
Index: clang/lib/Driver/Driver.cpp
===
--- 

[PATCH] D97183: [analyzer] Add NoteTag for smart-ptr get()

2021-05-19 Thread Deep Majumder via Phabricator via cfe-commits
RedDocMD updated this revision to Diff 346633.
RedDocMD added a comment.

Removed unnecessary includes


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97183

Files:
  clang/lib/StaticAnalyzer/Checkers/SmartPtr.h
  clang/lib/StaticAnalyzer/Checkers/SmartPtrChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
  clang/test/Analysis/smart-ptr-text-output.cpp

Index: clang/test/Analysis/smart-ptr-text-output.cpp
===
--- clang/test/Analysis/smart-ptr-text-output.cpp
+++ clang/test/Analysis/smart-ptr-text-output.cpp
@@ -306,10 +306,72 @@
 };
 
 void derefAfterBranchingOnUnknownInnerPtr(std::unique_ptr P) {
-  A *RP = P.get();
+  A *RP = P.get(); // expected-note {{Obtained null inner pointer from 'P'}}
   if (!RP) { // expected-note {{Assuming 'RP' is null}}
 // expected-note@-1 {{Taking true branch}}
 P->foo(); // expected-warning {{Dereference of null smart pointer 'P' [alpha.cplusplus.SmartPtr]}}
 // expected-note@-1{{Dereference of null smart pointer 'P'}}
   }
 }
+
+void multipleGetsShouldNotAllHaveNotes(std::unique_ptr P) {
+  A *RP = P.get(); // expected-note {{Obtained null inner pointer from 'P'}}
+  A *dummy1 = P.get();
+  A *dummy2 = P.get();
+  if (!RP) { // expected-note {{Assuming 'RP' is null}}
+// expected-note@-1 {{Taking true branch}}
+P->foo(); // expected-warning {{Dereference of null smart pointer 'P' [alpha.cplusplus.SmartPtr]}}
+// expected-note@-1{{Dereference of null smart pointer 'P'}}
+  }
+}
+
+void getShouldNotAlwaysLeaveANote() {
+  std::unique_ptr P; // expected-note {{Default constructed smart pointer 'P' is null}}
+  A *a = P.get();
+  P->foo(); // expected-warning {{Dereference of null smart pointer 'P' [alpha.cplusplus.SmartPtr]}}
+// expected-note@-1{{Dereference of null smart pointer 'P'}}
+}
+
+void getShouldNotLeaveANoteAfterReset(std::unique_ptr P) {
+  A *a = P.get();
+  P.reset(); // expected-note {{Smart pointer 'P' reset using a null value}}
+  P->foo();  // expected-warning {{Dereference of null smart pointer 'P' [alpha.cplusplus.SmartPtr]}}
+ // expected-note@-1{{Dereference of null smart pointer 'P'}}
+}
+
+void getShouldNotLeaveNoteWhenPtrNotUsed(std::unique_ptr P) {
+  A *a = P.get();
+  if (!P) { // expected-note {{Taking true branch}}
+// expected-note@-1 {{Assuming smart pointer 'P' is null}}
+P->foo(); // expected-warning {{Dereference of null smart pointer 'P' [alpha.cplusplus.SmartPtr]}}
+// expected-note@-1{{Dereference of null smart pointer 'P'}}
+  }
+}
+
+void getShouldLeaveANoteWithWhileLoop(std::unique_ptr P) {
+  A *RP = P.get(); // expected-note {{Obtained null inner pointer from 'P'}}
+  while (!RP) {// expected-note {{Assuming 'RP' is null}}
+// expected-note@-1 {{Loop condition is true.  Entering loop body}}
+P->foo(); // expected-warning {{Dereference of null smart pointer 'P' [alpha.cplusplus.SmartPtr]}}
+// expected-note@-1{{Dereference of null smart pointer 'P'}}
+  }
+}
+
+void getShouldLeaveANoteWithForLoop(std::unique_ptr P) {
+  for (A *RP = P.get(); !RP;) { // expected-note {{Assuming 'RP' is null}}
+// expected-note@-1 {{Loop condition is true.  Entering loop body}}
+// expected-note@-2 {{Obtained null inner pointer from 'P'}}
+P->foo(); // expected-warning {{Dereference of null smart pointer 'P' [alpha.cplusplus.SmartPtr]}}
+// expected-note@-1{{Dereference of null smart pointer 'P'}}
+  }
+}
+
+void getShouldLeaveNoteOnChaining(std::unique_ptr P) {
+  A *praw = P.get(), *other; // expected-note {{Obtained null inner pointer from 'P'}}
+  other = praw;  // expected-note {{Obtained null value here}}
+  if (!other) {  // expected-note {{Assuming 'other' is null}}
+// expected-note@-1 {{Taking true branch}}
+P->foo(); // expected-warning {{Dereference of null smart pointer 'P' [alpha.cplusplus.SmartPtr]}}
+// expected-note@-1{{Dereference of null smart pointer 'P'}}
+  }
+}
\ No newline at end of file
Index: clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
+++ clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
@@ -76,10 +76,14 @@
   {{"release"}, ::handleRelease},
   {{"swap", 1}, ::handleSwap},
   {{"get"}, ::handleGet}};
+  mutable llvm::ImmutableSet::Factory StmtSetFactory;
 };
 } // end of anonymous namespace
 
 REGISTER_MAP_WITH_PROGRAMSTATE(TrackedRegionMap, const MemRegion *, SVal)
+// REGISTER_SET_WITH_PROGRAMSTATE(ExprsFromGet, const Stmt *)
+REGISTER_MAP_WITH_PROGRAMSTATE(ExprsFromGet, const MemRegion *,
+   llvm::ImmutableSet)
 
 // Define the inter-checker API.
 namespace clang {
@@ -106,6 +110,142 @@
   return InnerPointVal &&
  

[PATCH] D97183: [analyzer] Add NoteTag for smart-ptr get()

2021-05-19 Thread Deep Majumder via Phabricator via cfe-commits
RedDocMD updated this revision to Diff 346632.
RedDocMD added a comment.
Herald added a reviewer: teemperor.
Herald added a subscriber: manas.

Added a test for multiple get's


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97183

Files:
  clang/lib/StaticAnalyzer/Checkers/SmartPtr.h
  clang/lib/StaticAnalyzer/Checkers/SmartPtrChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
  clang/test/Analysis/smart-ptr-text-output.cpp

Index: clang/test/Analysis/smart-ptr-text-output.cpp
===
--- clang/test/Analysis/smart-ptr-text-output.cpp
+++ clang/test/Analysis/smart-ptr-text-output.cpp
@@ -306,10 +306,72 @@
 };
 
 void derefAfterBranchingOnUnknownInnerPtr(std::unique_ptr P) {
-  A *RP = P.get();
+  A *RP = P.get(); // expected-note {{Obtained null inner pointer from 'P'}}
   if (!RP) { // expected-note {{Assuming 'RP' is null}}
 // expected-note@-1 {{Taking true branch}}
 P->foo(); // expected-warning {{Dereference of null smart pointer 'P' [alpha.cplusplus.SmartPtr]}}
 // expected-note@-1{{Dereference of null smart pointer 'P'}}
   }
 }
+
+void multipleGetsShouldNotAllHaveNotes(std::unique_ptr P) {
+  A *RP = P.get(); // expected-note {{Obtained null inner pointer from 'P'}}
+  A *dummy1 = P.get();
+  A *dummy2 = P.get();
+  if (!RP) { // expected-note {{Assuming 'RP' is null}}
+// expected-note@-1 {{Taking true branch}}
+P->foo(); // expected-warning {{Dereference of null smart pointer 'P' [alpha.cplusplus.SmartPtr]}}
+// expected-note@-1{{Dereference of null smart pointer 'P'}}
+  }
+}
+
+void getShouldNotAlwaysLeaveANote() {
+  std::unique_ptr P; // expected-note {{Default constructed smart pointer 'P' is null}}
+  A *a = P.get();
+  P->foo(); // expected-warning {{Dereference of null smart pointer 'P' [alpha.cplusplus.SmartPtr]}}
+// expected-note@-1{{Dereference of null smart pointer 'P'}}
+}
+
+void getShouldNotLeaveANoteAfterReset(std::unique_ptr P) {
+  A *a = P.get();
+  P.reset(); // expected-note {{Smart pointer 'P' reset using a null value}}
+  P->foo();  // expected-warning {{Dereference of null smart pointer 'P' [alpha.cplusplus.SmartPtr]}}
+ // expected-note@-1{{Dereference of null smart pointer 'P'}}
+}
+
+void getShouldNotLeaveNoteWhenPtrNotUsed(std::unique_ptr P) {
+  A *a = P.get();
+  if (!P) { // expected-note {{Taking true branch}}
+// expected-note@-1 {{Assuming smart pointer 'P' is null}}
+P->foo(); // expected-warning {{Dereference of null smart pointer 'P' [alpha.cplusplus.SmartPtr]}}
+// expected-note@-1{{Dereference of null smart pointer 'P'}}
+  }
+}
+
+void getShouldLeaveANoteWithWhileLoop(std::unique_ptr P) {
+  A *RP = P.get(); // expected-note {{Obtained null inner pointer from 'P'}}
+  while (!RP) {// expected-note {{Assuming 'RP' is null}}
+// expected-note@-1 {{Loop condition is true.  Entering loop body}}
+P->foo(); // expected-warning {{Dereference of null smart pointer 'P' [alpha.cplusplus.SmartPtr]}}
+// expected-note@-1{{Dereference of null smart pointer 'P'}}
+  }
+}
+
+void getShouldLeaveANoteWithForLoop(std::unique_ptr P) {
+  for (A *RP = P.get(); !RP;) { // expected-note {{Assuming 'RP' is null}}
+// expected-note@-1 {{Loop condition is true.  Entering loop body}}
+// expected-note@-2 {{Obtained null inner pointer from 'P'}}
+P->foo(); // expected-warning {{Dereference of null smart pointer 'P' [alpha.cplusplus.SmartPtr]}}
+// expected-note@-1{{Dereference of null smart pointer 'P'}}
+  }
+}
+
+void getShouldLeaveNoteOnChaining(std::unique_ptr P) {
+  A *praw = P.get(), *other; // expected-note {{Obtained null inner pointer from 'P'}}
+  other = praw;  // expected-note {{Obtained null value here}}
+  if (!other) {  // expected-note {{Assuming 'other' is null}}
+// expected-note@-1 {{Taking true branch}}
+P->foo(); // expected-warning {{Dereference of null smart pointer 'P' [alpha.cplusplus.SmartPtr]}}
+// expected-note@-1{{Dereference of null smart pointer 'P'}}
+  }
+}
\ No newline at end of file
Index: clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
+++ clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
@@ -16,8 +16,11 @@
 
 #include "clang/AST/DeclCXX.h"
 #include "clang/AST/DeclarationName.h"
+#include "clang/AST/Expr.h"
 #include "clang/AST/ExprCXX.h"
+#include "clang/AST/OperationKinds.h"
 #include "clang/AST/Type.h"
+#include "clang/Analysis/PathDiagnostic.h"
 #include "clang/Basic/LLVM.h"
 #include "clang/StaticAnalyzer/Checkers/BuiltinCheckerRegistration.h"
 #include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
@@ -25,10 +28,14 @@
 #include "clang/StaticAnalyzer/Core/CheckerManager.h"
 #include 

[PATCH] D102822: [Clang][CodeGen] Set the size of llvm.lifetime to unknown for scalable types.

2021-05-19 Thread Hsiangkai Wang via Phabricator via cfe-commits
HsiangKai added a comment.

In D102822#2770175 , @craig.topper 
wrote:

> Am I mistaken, or does this test already pass without these changes?

You are right. I didn't confirm it. I need to update the test case. Thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102822

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


[PATCH] D101973: [OpenMP][NFC] Remove SIMD check lines for non-simd tests

2021-05-19 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

In D101973#2770283 , @JonChesterfield 
wrote:

> I can't see a change to a script in this diff. Should there be one? Looks 
> like the test change was done programmatically

It was, but I did not expect to need the script in the future.

If you really want to see how bad my python skills are, here you go ;)

  import os,re
  
  path = "clang/test/OpenMP/"
  for f in os.listdir(path):
  if not os.path.isfile(path+f):
  continue
  fd = open(path + f, "r")
  content = fd.read()
  fd.close()
  
  if "_cc_test_check" not in content:
  continue
  if " simd" in content or " SIMD" in content:
  continue
  if "-fopenmp-simd" not in content:
  continue
  
  changed = False
  lines = content.splitlines()
  newlines = []
  matches = ['// CHECK:', '// CHECK-', '//CHECK:', '//CHECK-']
  empty = 0
  for i in range(len(lines)):
  line = lines[i]
  match = False
  for m in matches:
  if m in line:
  match = True
  break
  if match:
  continue
  if line == "//":
  empty += 1
  if empty > 2:
  continue
  else:
  empty = 0
  if "-fopenmp-simd" not in line:
  newlines.append(line)
  continue
  if "FileCheck" not in line:
  newlines.append(line)
  continue
  m = re.search(r"=((SIMD|CHECK)[^\s]*)", line)
  if not m:
  newlines.append(line)
  continue
  print(m.group(1))
  matches.append(m.group(1))
  
  idx = line.index("FileCheck")
  line = line[:idx]
  line += 'FileCheck %s --implicit-check-not="{{__kmpc|__tgt}}"'
  newlines.append(line)
  changed = True
  
  if changed:
  fd = open(path + f, "w")
  fd.write('\n'.join(newlines))
  fd.close()


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101973

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


[PATCH] D102614: [index] Add support for type of pointers to class members

2021-05-19 Thread Ella Ma via Phabricator via cfe-commits
OikawaKirie added inline comments.



Comment at: clang/lib/Index/USRGeneration.cpp:897
+if (const MemberPointerType *MPT = T->getAs()) {
+  VisitType(QualType(MPT->getClass(), 0));
+  Out << "::*";

akyrtzi wrote:
> A bit better to do `VisitTagDecl(MPT->getClass())`, what do you think?
This was my first version of the patch, which was 
`VisitTagDecl(MPT->getMostRecentCXXRecordDecl())`. However, it cannot handle 
the `TemplateTypeParmType` type, which is presented in the last two CHECKs of 
the test case. Call to method `MemberPointerType::getMostRecentCXXRecordDecl` 
will dereference a nullptr in the function (`getClass()->getAsCXXRecordDecl()` 
returns nullptr) . To fully handle all circumstances, I finally choose to use 
the `VisitType` method.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102614

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


[PATCH] D101973: [OpenMP][NFC] Remove SIMD check lines for non-simd tests

2021-05-19 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield added a comment.

I can't see a change to a script in this diff. Should there be one? Looks like 
the test change was done programmatically


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101973

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


[PATCH] D102805: [M68k] Allow user to preserve certain registers

2021-05-19 Thread Min-Yih Hsu via Phabricator via cfe-commits
myhsu updated this revision to Diff 346627.
myhsu marked an inline comment as done.
myhsu added a comment.

Fix formatting


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

https://reviews.llvm.org/D102805

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Arch/M68k.cpp
  clang/test/Driver/m68k-fixed-register.c
  llvm/lib/Target/M68k/M68k.td
  llvm/lib/Target/M68k/M68kRegisterInfo.cpp
  llvm/lib/Target/M68k/M68kSubtarget.cpp
  llvm/lib/Target/M68k/M68kSubtarget.h
  llvm/test/CodeGen/M68k/reserved-regs.ll

Index: llvm/test/CodeGen/M68k/reserved-regs.ll
===
--- /dev/null
+++ llvm/test/CodeGen/M68k/reserved-regs.ll
@@ -0,0 +1,70 @@
+; RUN: llc -mtriple=m68k -mattr="+reserve-a0" < %s | FileCheck --check-prefix=A0 %s
+; RUN: llc -mtriple=m68k -mattr="+reserve-a1" < %s | FileCheck --check-prefix=A1 %s
+; RUN: llc -mtriple=m68k -mattr="+reserve-a2" < %s | FileCheck --check-prefix=A2 %s
+; RUN: llc -mtriple=m68k -mattr="+reserve-a3" < %s | FileCheck --check-prefix=A3 %s
+; RUN: llc -mtriple=m68k -mattr="+reserve-a4" < %s | FileCheck --check-prefix=A4 %s
+; RUN: llc -mtriple=m68k -mattr="+reserve-a5" < %s | FileCheck --check-prefix=A5 %s
+; RUN: llc -mtriple=m68k -mattr="+reserve-a6" < %s | FileCheck --check-prefix=A6 %s
+; RUN: llc -mtriple=m68k -mattr="+reserve-d0" < %s | FileCheck --check-prefix=D0 %s
+; RUN: llc -mtriple=m68k -mattr="+reserve-d1" < %s | FileCheck --check-prefix=D1 %s
+; RUN: llc -mtriple=m68k -mattr="+reserve-d2" < %s | FileCheck --check-prefix=D2 %s
+; RUN: llc -mtriple=m68k -mattr="+reserve-d3" < %s | FileCheck --check-prefix=D3 %s
+; RUN: llc -mtriple=m68k -mattr="+reserve-d4" < %s | FileCheck --check-prefix=D4 %s
+; RUN: llc -mtriple=m68k -mattr="+reserve-d5" < %s | FileCheck --check-prefix=D5 %s
+; RUN: llc -mtriple=m68k -mattr="+reserve-d6" < %s | FileCheck --check-prefix=D6 %s
+; RUN: llc -mtriple=m68k -mattr="+reserve-d7" < %s | FileCheck --check-prefix=D7 %s
+
+; Used to exhaust all registers
+;
+; A better way to do this might be:
+; ```
+; @var = global [16 x i32] zeroinitializer
+; ...
+; %tmp = load load volatile [16 x i32], [16 x i32]* @var
+; store volatile [16 x i32] %tmp, [16 x i32]* @var
+; ```
+; Which is copied from `test/CodeGen/RISCV/reserved-regs.ll`.
+; But currently we have problem doing codegen for the above snippet
+; (https://bugs.llvm.org/show_bug.cgi?id=50377).
+define void @foo(i32* nocapture readonly %a, i32* nocapture readonly %b, i32* nocapture readonly %c, i32* nocapture readonly %d,
+ i32* nocapture readonly %a1, i32* nocapture readonly %b1, i32* nocapture readonly %c1, i32* nocapture readonly %d1,
+ i32* nocapture readonly %a2, i32* nocapture readonly %b2, i32* nocapture readonly %c2, i32* nocapture readonly %d2,
+ i32* nocapture readonly %a3, i32* nocapture readonly %b3, i32* nocapture readonly %c3, i32* nocapture readonly %d3) {
+entry:
+  %0 = load i32, i32* %a, align 4
+  %1 = load i32, i32* %b, align 4
+  %2 = load i32, i32* %c, align 4
+  %3 = load i32, i32* %d, align 4
+  %4 = load i32, i32* %a1, align 4
+  %5 = load i32, i32* %b1, align 4
+  %6 = load i32, i32* %c1, align 4
+  %7 = load i32, i32* %d1, align 4
+  %8 = load i32, i32* %a2, align 4
+  %9 = load i32, i32* %b2, align 4
+  %10 = load i32, i32* %c2, align 4
+  %11 = load i32, i32* %d2, align 4
+  %12 = load i32, i32* %a3, align 4
+  %13 = load i32, i32* %b3, align 4
+  %14 = load i32, i32* %c3, align 4
+  %15 = load i32, i32* %d3, align 4
+  ; A0-NOT: %a0
+  ; A1-NOT: %a1
+  ; A2-NOT: %a2
+  ; A3-NOT: %a3
+  ; A4-NOT: %a4
+  ; A5-NOT: %a5
+  ; A6-NOT: %a6
+  ; D0-NOT: %d0
+  ; D1-NOT: %d1
+  ; D2-NOT: %d2
+  ; D3-NOT: %d3
+  ; D4-NOT: %d4
+  ; D5-NOT: %d5
+  ; D6-NOT: %d6
+  ; D7-NOT: %d7
+  tail call void @bar(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4, i32 %5, i32 %6, i32 %7, i32 %8, i32 %9, i32 %10, i32 %11, i32 %12, i32 %13, i32 %14, i32 %15)
+  ret void
+}
+
+declare void @bar(i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32)
+
Index: llvm/lib/Target/M68k/M68kSubtarget.h
===
--- llvm/lib/Target/M68k/M68kSubtarget.h
+++ llvm/lib/Target/M68k/M68kSubtarget.h
@@ -18,6 +18,7 @@
 #include "M68kISelLowering.h"
 #include "M68kInstrInfo.h"
 
+#include "llvm/ADT/BitVector.h"
 #include "llvm/CodeGen/SelectionDAGTargetInfo.h"
 #include "llvm/CodeGen/TargetSubtargetInfo.h"
 #include "llvm/IR/DataLayout.h"
@@ -47,6 +48,8 @@
   enum SubtargetEnum { M00, M10, M20, M30, M40, M60 };
   SubtargetEnum SubtargetKind = M00;
 
+  BitVector UserReservedRegister;
+
   InstrItineraryData InstrItins;
 
   /// Small section is used.
@@ -95,6 +98,11 @@
 
   bool isPositionIndependent() const;
 
+  bool isRegisterReservedByUser(Register R) const {
+assert(R < M68k::NUM_TARGET_REGS && "Register out of range");
+return UserReservedRegister[R];
+  }
+
   /// Classify 

[PATCH] D102818: [PGO] Don't reference functions unless value profiling is enabled

2021-05-19 Thread David Li via Phabricator via cfe-commits
davidxl accepted this revision.
davidxl added a comment.
This revision is now accepted and ready to land.

lgtm (value profiling is off by default for FE PGO anyway)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102818

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


[clang] f8444a8 - [clang-offload-bundler] Delimit input/output file names by '--' for llvm-objcopy

2021-05-19 Thread Sergey Dmitriev via cfe-commits

Author: Sergey Dmitriev
Date: 2021-05-19T20:25:05-07:00
New Revision: f8444a8e94227401f816d948ec09ae1b2761d575

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

LOG: [clang-offload-bundler] Delimit input/output file names by '--' for 
llvm-objcopy

That fixes a problem of using bundler with file names starting with dash.

Reviewed By: ABataev

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

Added: 


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

Removed: 




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

diff  --git a/clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp 
b/clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
index 74b7a4539aff5..afa7c292a53f1 100644
--- a/clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
+++ b/clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
@@ -621,6 +621,7 @@ class ObjectFileHandler final : public FileHandler {
 OFFLOAD_BUNDLER_MAGIC_STR + TargetNames[I] 
+
 "=readonly,exclude"));
 }
+ObjcopyArgs.push_back("--");
 ObjcopyArgs.push_back(InputFileNames[HostInputIndex]);
 ObjcopyArgs.push_back(OutputFileNames.front());
 



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


[PATCH] D102752: [clang-offload-bundler] Delimit input/output file names by '--' for llvm-objcopy

2021-05-19 Thread Sergey Dmitriev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf8444a8e9422: [clang-offload-bundler] Delimit input/output 
file names by -- for llvm-objcopy (authored by sdmitriev).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102752

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


Index: clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
===
--- clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
+++ clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
@@ -621,6 +621,7 @@
 OFFLOAD_BUNDLER_MAGIC_STR + TargetNames[I] 
+
 "=readonly,exclude"));
 }
+ObjcopyArgs.push_back("--");
 ObjcopyArgs.push_back(InputFileNames[HostInputIndex]);
 ObjcopyArgs.push_back(OutputFileNames.front());
 
Index: clang/test/Driver/clang-offload-bundler.c
===
--- clang/test/Driver/clang-offload-bundler.c
+++ clang/test/Driver/clang-offload-bundler.c
@@ -274,7 +274,7 @@
 
 // RUN: clang-offload-bundler -type=o 
-targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu
 -inputs=%t.o,%t.tgt1,%t.tgt2 -outputs=%t.bundle3.o -### 2>&1 \
 // RUN: | FileCheck %s -DHOST=%itanium_abi_triple -DINOBJ1=%t.o 
-DINOBJ2=%t.tgt1 -DINOBJ3=%t.tgt2 -DOUTOBJ=%t.bundle3.o --check-prefix 
CK-OBJ-CMD
-// CK-OBJ-CMD: llvm-objcopy{{(.exe)?}}" 
"--add-section=__CLANG_OFFLOAD_BUNDLE__host-[[HOST]]={{.*}}" 
"--set-section-flags=__CLANG_OFFLOAD_BUNDLE__host-[[HOST]]=readonly,exclude" 
"--add-section=__CLANG_OFFLOAD_BUNDLE__openmp-powerpc64le-ibm-linux-gnu=[[INOBJ2]]"
 
"--set-section-flags=__CLANG_OFFLOAD_BUNDLE__openmp-powerpc64le-ibm-linux-gnu=readonly,exclude"
 "--add-section=__CLANG_OFFLOAD_BUNDLE__openmp-x86_64-pc-linux-gnu=[[INOBJ3]]" 
"--set-section-flags=__CLANG_OFFLOAD_BUNDLE__openmp-x86_64-pc-linux-gnu=readonly,exclude"
 "[[INOBJ1]]" "[[OUTOBJ]]"
+// CK-OBJ-CMD: llvm-objcopy{{(.exe)?}}" 
"--add-section=__CLANG_OFFLOAD_BUNDLE__host-[[HOST]]={{.*}}" 
"--set-section-flags=__CLANG_OFFLOAD_BUNDLE__host-[[HOST]]=readonly,exclude" 
"--add-section=__CLANG_OFFLOAD_BUNDLE__openmp-powerpc64le-ibm-linux-gnu=[[INOBJ2]]"
 
"--set-section-flags=__CLANG_OFFLOAD_BUNDLE__openmp-powerpc64le-ibm-linux-gnu=readonly,exclude"
 "--add-section=__CLANG_OFFLOAD_BUNDLE__openmp-x86_64-pc-linux-gnu=[[INOBJ3]]" 
"--set-section-flags=__CLANG_OFFLOAD_BUNDLE__openmp-x86_64-pc-linux-gnu=readonly,exclude"
 "--" "[[INOBJ1]]" "[[OUTOBJ]]"
 
 // RUN: clang-offload-bundler -type=o 
-targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu
 -inputs=%t.o,%t.tgt1,%t.tgt2 -outputs=%t.bundle3.o
 // RUN: clang-offload-bundler -type=o -inputs=%t.bundle3.o -list | FileCheck 
-check-prefix=CKLST %s


Index: clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
===
--- clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
+++ clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
@@ -621,6 +621,7 @@
 OFFLOAD_BUNDLER_MAGIC_STR + TargetNames[I] +
 "=readonly,exclude"));
 }
+ObjcopyArgs.push_back("--");
 ObjcopyArgs.push_back(InputFileNames[HostInputIndex]);
 ObjcopyArgs.push_back(OutputFileNames.front());
 
Index: clang/test/Driver/clang-offload-bundler.c
===
--- clang/test/Driver/clang-offload-bundler.c
+++ clang/test/Driver/clang-offload-bundler.c
@@ -274,7 +274,7 @@
 
 // RUN: clang-offload-bundler -type=o -targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu -inputs=%t.o,%t.tgt1,%t.tgt2 -outputs=%t.bundle3.o -### 2>&1 \
 // RUN: | FileCheck %s -DHOST=%itanium_abi_triple -DINOBJ1=%t.o -DINOBJ2=%t.tgt1 -DINOBJ3=%t.tgt2 -DOUTOBJ=%t.bundle3.o --check-prefix CK-OBJ-CMD
-// CK-OBJ-CMD: llvm-objcopy{{(.exe)?}}" "--add-section=__CLANG_OFFLOAD_BUNDLE__host-[[HOST]]={{.*}}" "--set-section-flags=__CLANG_OFFLOAD_BUNDLE__host-[[HOST]]=readonly,exclude" "--add-section=__CLANG_OFFLOAD_BUNDLE__openmp-powerpc64le-ibm-linux-gnu=[[INOBJ2]]" "--set-section-flags=__CLANG_OFFLOAD_BUNDLE__openmp-powerpc64le-ibm-linux-gnu=readonly,exclude" "--add-section=__CLANG_OFFLOAD_BUNDLE__openmp-x86_64-pc-linux-gnu=[[INOBJ3]]" "--set-section-flags=__CLANG_OFFLOAD_BUNDLE__openmp-x86_64-pc-linux-gnu=readonly,exclude" "[[INOBJ1]]" "[[OUTOBJ]]"
+// CK-OBJ-CMD: llvm-objcopy{{(.exe)?}}" "--add-section=__CLANG_OFFLOAD_BUNDLE__host-[[HOST]]={{.*}}" "--set-section-flags=__CLANG_OFFLOAD_BUNDLE__host-[[HOST]]=readonly,exclude" 

[PATCH] D101976: [OpenMP] Unified entry point for SPMD & generic kernels in the device RTL

2021-05-19 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert updated this revision to Diff 346621.
jdoerfert added a comment.

Drop the `weak` attribute, will solve the problem differently


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101976

Files:
  clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
  clang/lib/CodeGen/CGOpenMPRuntimeGPU.h
  clang/test/OpenMP/amdgcn_target_codegen.cpp
  clang/test/OpenMP/assumes_include_nvptx.cpp
  clang/test/OpenMP/declare_target_codegen_globalization.cpp
  clang/test/OpenMP/nvptx_SPMD_codegen.cpp
  clang/test/OpenMP/nvptx_data_sharing.cpp
  clang/test/OpenMP/nvptx_distribute_parallel_generic_mode_codegen.cpp
  clang/test/OpenMP/nvptx_force_full_runtime_SPMD_codegen.cpp
  clang/test/OpenMP/nvptx_lambda_capturing.cpp
  clang/test/OpenMP/nvptx_multi_target_parallel_codegen.cpp
  clang/test/OpenMP/nvptx_nested_parallel_codegen.cpp
  clang/test/OpenMP/nvptx_parallel_codegen.cpp
  clang/test/OpenMP/nvptx_parallel_for_codegen.cpp
  clang/test/OpenMP/nvptx_target_codegen.cpp
  clang/test/OpenMP/nvptx_target_firstprivate_codegen.cpp
  clang/test/OpenMP/nvptx_target_parallel_codegen.cpp
  clang/test/OpenMP/nvptx_target_parallel_num_threads_codegen.cpp
  clang/test/OpenMP/nvptx_target_parallel_proc_bind_codegen.cpp
  clang/test/OpenMP/nvptx_target_parallel_reduction_codegen.cpp
  clang/test/OpenMP/nvptx_target_parallel_reduction_codegen_tbaa_PR46146.cpp
  clang/test/OpenMP/nvptx_target_printf_codegen.c
  clang/test/OpenMP/nvptx_target_simd_codegen.cpp
  clang/test/OpenMP/nvptx_target_teams_codegen.cpp
  clang/test/OpenMP/nvptx_target_teams_distribute_codegen.cpp
  clang/test/OpenMP/nvptx_target_teams_distribute_parallel_for_codegen.cpp
  
clang/test/OpenMP/nvptx_target_teams_distribute_parallel_for_generic_mode_codegen.cpp
  clang/test/OpenMP/nvptx_target_teams_distribute_parallel_for_simd_codegen.cpp
  clang/test/OpenMP/nvptx_target_teams_distribute_simd_codegen.cpp
  clang/test/OpenMP/nvptx_teams_codegen.cpp
  clang/test/OpenMP/nvptx_teams_reduction_codegen.cpp
  clang/test/OpenMP/remarks_parallel_in_multiple_target_state_machines.c
  clang/test/OpenMP/remarks_parallel_in_target_state_machine.c
  clang/test/OpenMP/target_parallel_debug_codegen.cpp
  clang/test/OpenMP/target_parallel_for_debug_codegen.cpp
  llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
  llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
  llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
  openmp/libomptarget/deviceRTLs/common/include/target.h
  openmp/libomptarget/deviceRTLs/common/src/omptarget.cu
  openmp/libomptarget/deviceRTLs/common/src/parallel.cu
  openmp/libomptarget/deviceRTLs/interface.h
  openmp/libomptarget/deviceRTLs/nvptx/src/target_impl.cu

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


[PATCH] D102822: [Clang][CodeGen] Set the size of llvm.lifetime to unknown for scalable types.

2021-05-19 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment.

Am I mistaken, or does this test already pass without these changes?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102822

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


[PATCH] D102822: [Clang][CodeGen] Set the size of llvm.lifetime to unknown for scalable types.

2021-05-19 Thread Hsiangkai Wang via Phabricator via cfe-commits
HsiangKai created this revision.
HsiangKai added reviewers: craig.topper, frasercrmck, rogfer01.
Herald added subscribers: StephenFan, luismarques, apazos, sameer.abuasal, 
s.egerton, Jim, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, edward-jones, 
zzheng, jrtc27, niosHD, sabuasal, simoncook, johnrusso, rbar, asb.
HsiangKai requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay.
Herald added a project: clang.

If the memory object is scalable type, we do not know the exact size of
it at compile time. Set the size of lifetime marker to unknown if the
object is scalable one.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D102822

Files:
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CGDecl.cpp
  clang/lib/CodeGen/CGExprAgg.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/test/CodeGen/RISCV/riscv-v-lifetime.c

Index: clang/test/CodeGen/RISCV/riscv-v-lifetime.c
===
--- /dev/null
+++ clang/test/CodeGen/RISCV/riscv-v-lifetime.c
@@ -0,0 +1,35 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// REQUIRES: riscv-registered-target
+// RUN: %clang_cc1 -triple riscv64 -target-feature +experimental-v -emit-llvm \
+// RUN:   -O1 -o - %s | FileCheck %s
+
+#include 
+
+extern void use(vint32m1_t *a);
+
+// CHECK-LABEL: @inlined(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[A:%.*]] = alloca , align 4
+// CHECK-NEXT:[[TMP0:%.*]] = bitcast * [[A]] to i8*
+// CHECK-NEXT:call void @llvm.lifetime.start.p0i8(i64 -1, i8* nonnull [[TMP0]]) #[[ATTR4:[0-9]+]]
+// CHECK-NEXT:call void @use(* nonnull [[A]]) #[[ATTR4]]
+// CHECK-NEXT:call void @llvm.lifetime.end.p0i8(i64 -1, i8* nonnull [[TMP0]]) #[[ATTR4]]
+// CHECK-NEXT:ret void
+//
+__attribute__((always_inline)) void inlined() {
+  vint32m1_t a;
+  use();
+}
+
+// CHECK-LABEL: @lifetime_test(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[A_I:%.*]] = alloca , align 4
+// CHECK-NEXT:[[TMP0:%.*]] = bitcast * [[A_I]] to i8*
+// CHECK-NEXT:call void @llvm.lifetime.start.p0i8(i64 -1, i8* nonnull [[TMP0]]) #[[ATTR4]]
+// CHECK-NEXT:call void @use(* nonnull [[A_I]]) #[[ATTR4]]
+// CHECK-NEXT:call void @llvm.lifetime.end.p0i8(i64 -1, i8* nonnull [[TMP0]]) #[[ATTR4]]
+// CHECK-NEXT:ret void
+//
+void lifetime_test() {
+  inlined();
+}
Index: clang/lib/CodeGen/CodeGenFunction.h
===
--- clang/lib/CodeGen/CodeGenFunction.h
+++ clang/lib/CodeGen/CodeGenFunction.h
@@ -2872,7 +2872,7 @@
   void EmitSehTryScopeBegin();
   void EmitSehTryScopeEnd();
 
-  llvm::Value *EmitLifetimeStart(uint64_t Size, llvm::Value *Addr);
+  llvm::Value *EmitLifetimeStart(llvm::TypeSize Size, llvm::Value *Addr);
   void EmitLifetimeEnd(llvm::Value *Size, llvm::Value *Addr);
 
   llvm::Value *EmitCXXNewExpr(const CXXNewExpr *E);
Index: clang/lib/CodeGen/CGExprAgg.cpp
===
--- clang/lib/CodeGen/CGExprAgg.cpp
+++ clang/lib/CodeGen/CGExprAgg.cpp
@@ -276,7 +276,7 @@
 RetAddr = Dest.getAddress();
   } else {
 RetAddr = CGF.CreateMemTemp(RetTy, "tmp", );
-uint64_t Size =
+llvm::TypeSize Size =
 CGF.CGM.getDataLayout().getTypeAllocSize(CGF.ConvertTypeForMem(RetTy));
 LifetimeSizePtr = CGF.EmitLifetimeStart(Size, RetAllocaAddr.getPointer());
 if (LifetimeSizePtr) {
Index: clang/lib/CodeGen/CGDecl.cpp
===
--- clang/lib/CodeGen/CGDecl.cpp
+++ clang/lib/CodeGen/CGDecl.cpp
@@ -1317,11 +1317,15 @@
 /// Emit a lifetime.begin marker if some criteria are satisfied.
 /// \return a pointer to the temporary size Value if a marker was emitted, null
 /// otherwise
-llvm::Value *CodeGenFunction::EmitLifetimeStart(uint64_t Size,
+llvm::Value *CodeGenFunction::EmitLifetimeStart(llvm::TypeSize Size,
 llvm::Value *Addr) {
   if (!ShouldEmitLifetimeMarkers)
 return nullptr;
 
+  // Use -1 as the unknown size.
+  if (Size.isScalable())
+Size = llvm::TypeSize::Fixed(-1);
+
   assert(Addr->getType()->getPointerAddressSpace() ==
  CGM.getDataLayout().getAllocaAddrSpace() &&
  "Pointer should be in alloca address space");
@@ -1551,9 +1555,7 @@
   llvm::TypeSize size =
   CGM.getDataLayout().getTypeAllocSize(allocaTy);
   emission.SizeForLifetimeMarkers =
-  size.isScalable() ? EmitLifetimeStart(-1, AllocaAddr.getPointer())
-: EmitLifetimeStart(size.getFixedSize(),
-AllocaAddr.getPointer());
+  EmitLifetimeStart(size, AllocaAddr.getPointer());
 }
   } else {
 assert(!emission.useLifetimeMarkers());
Index: clang/lib/CodeGen/CGCall.cpp
===
--- 

[PATCH] D101973: [OpenMP][NFC] Remove SIMD check lines for non-simd tests

2021-05-19 Thread Johannes Doerfert via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG6ff380f43987: [OpenMP][NFC] Remove SIMD check lines for 
non-simd tests (authored by jdoerfert).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101973

Files:
  clang/test/OpenMP/cancel_codegen.cpp
  clang/test/OpenMP/cancellation_point_codegen.cpp
  clang/test/OpenMP/debug-info-complex-byval.cpp
  clang/test/OpenMP/debug-info-openmp-array.cpp
  clang/test/OpenMP/distribute_codegen.cpp
  clang/test/OpenMP/distribute_firstprivate_codegen.cpp
  clang/test/OpenMP/distribute_lastprivate_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_firstprivate_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_if_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_lastprivate_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_num_threads_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_private_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_proc_bind_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_reduction_task_codegen.cpp
  clang/test/OpenMP/distribute_private_codegen.cpp
  clang/test/OpenMP/for_firstprivate_codegen.cpp
  clang/test/OpenMP/for_lastprivate_codegen.cpp
  clang/test/OpenMP/for_linear_codegen.cpp
  clang/test/OpenMP/for_private_codegen.cpp
  clang/test/OpenMP/for_reduction_codegen.cpp
  clang/test/OpenMP/for_reduction_task_codegen.cpp
  clang/test/OpenMP/master_taskloop_in_reduction_codegen.cpp
  clang/test/OpenMP/openmp_win_codegen.cpp
  clang/test/OpenMP/parallel_codegen.cpp
  clang/test/OpenMP/parallel_copyin_codegen.cpp
  clang/test/OpenMP/parallel_firstprivate_codegen.cpp
  clang/test/OpenMP/parallel_for_codegen.cpp
  clang/test/OpenMP/parallel_for_lastprivate_conditional.cpp
  clang/test/OpenMP/parallel_for_linear_codegen.cpp
  clang/test/OpenMP/parallel_for_reduction_task_codegen.cpp
  clang/test/OpenMP/parallel_if_codegen.cpp
  clang/test/OpenMP/parallel_master_codegen.cpp
  clang/test/OpenMP/parallel_master_reduction_task_codegen.cpp
  clang/test/OpenMP/parallel_master_taskloop_codegen.cpp
  clang/test/OpenMP/parallel_master_taskloop_lastprivate_codegen.cpp
  clang/test/OpenMP/parallel_private_codegen.cpp
  clang/test/OpenMP/parallel_reduction_codegen.cpp
  clang/test/OpenMP/parallel_reduction_task_codegen.cpp
  clang/test/OpenMP/parallel_sections_codegen.cpp
  clang/test/OpenMP/parallel_sections_reduction_task_codegen.cpp
  clang/test/OpenMP/sections_firstprivate_codegen.cpp
  clang/test/OpenMP/sections_lastprivate_codegen.cpp
  clang/test/OpenMP/sections_private_codegen.cpp
  clang/test/OpenMP/sections_reduction_codegen.cpp
  clang/test/OpenMP/sections_reduction_task_codegen.cpp
  clang/test/OpenMP/single_codegen.cpp
  clang/test/OpenMP/single_firstprivate_codegen.cpp
  clang/test/OpenMP/single_private_codegen.cpp
  clang/test/OpenMP/target_codegen_global_capture.cpp
  clang/test/OpenMP/target_map_codegen_03.cpp
  clang/test/OpenMP/target_parallel_codegen.cpp
  clang/test/OpenMP/target_parallel_for_codegen.cpp
  clang/test/OpenMP/target_parallel_for_reduction_task_codegen.cpp
  clang/test/OpenMP/target_parallel_if_codegen.cpp
  clang/test/OpenMP/target_parallel_num_threads_codegen.cpp
  clang/test/OpenMP/target_parallel_reduction_task_codegen.cpp
  clang/test/OpenMP/target_teams_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_collapse_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_dist_schedule_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_firstprivate_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_lastprivate_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_collapse_codegen.cpp
  
clang/test/OpenMP/target_teams_distribute_parallel_for_dist_schedule_codegen.cpp
  
clang/test/OpenMP/target_teams_distribute_parallel_for_firstprivate_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_if_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_lastprivate_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_order_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_private_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_proc_bind_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_reduction_codegen.cpp
  
clang/test/OpenMP/target_teams_distribute_parallel_for_reduction_task_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_schedule_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_private_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_reduction_codegen.cpp
  clang/test/OpenMP/target_teams_num_teams_codegen.cpp
  clang/test/OpenMP/target_teams_thread_limit_codegen.cpp
  clang/test/OpenMP/task_codegen.cpp
  

[PATCH] D101601: [SelectionDAG] Make fast and linearize visible by clang -pre-RA-sched

2021-05-19 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added inline comments.



Comment at: clang/test/CodeGen/pre-ra-sched.c:1-2
+// RUN: %clang %s -mllvm -pre-RA-sched=fast -c -o - | FileCheck %s
+// RUN: %clang %s -mllvm -pre-RA-sched=linearize -c -o - | FileCheck %s
+

The test as was committed is bogus. It checks the output binary(!) stream for 
an error message when stderr was not even redirected. Please fix.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101601

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


[PATCH] D102558: [Utils] Check for generated functions inline if possible

2021-05-19 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert planned changes to this revision.
jdoerfert added a comment.

This doesn't work properly yet :(


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102558

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


[PATCH] D102469: [sanitizer] Reduce redzone size for small size global objects

2021-05-19 Thread Fangrui Song 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 rGdbc641deb988: [sanitizer] Reduce redzone size for small size 
global objects (authored by condy, committed by MaskRay).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102469

Files:
  clang/test/CodeGen/asan-globals-alias.cpp
  clang/test/CodeGen/asan-globals-odr.cpp
  clang/test/CodeGen/asan-globals.cpp
  clang/test/CodeGen/asan-static-odr.cpp
  llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
  
llvm/test/Instrumentation/AddressSanitizer/AMDGPU/adaptive_constant_global_redzones.ll
  llvm/test/Instrumentation/AddressSanitizer/AMDGPU/adaptive_global_redzones.ll
  llvm/test/Instrumentation/AddressSanitizer/adaptive_global_redzones.ll
  llvm/test/Instrumentation/AddressSanitizer/debug-info-global-var.ll
  llvm/test/Instrumentation/AddressSanitizer/global_cstring_darwin.ll
  llvm/test/Instrumentation/AddressSanitizer/global_lto_merge.ll
  llvm/test/Instrumentation/AddressSanitizer/global_metadata.ll
  llvm/test/Instrumentation/AddressSanitizer/global_metadata_array.ll
  llvm/test/Instrumentation/AddressSanitizer/global_metadata_windows.ll
  llvm/test/Instrumentation/AddressSanitizer/global_with_comdat.ll
  llvm/test/Instrumentation/AddressSanitizer/local_alias.ll
  llvm/test/Instrumentation/AddressSanitizer/odr-check-ignore.ll
  llvm/test/Instrumentation/AddressSanitizer/win-string-literal.ll

Index: llvm/test/Instrumentation/AddressSanitizer/win-string-literal.ll
===
--- llvm/test/Instrumentation/AddressSanitizer/win-string-literal.ll
+++ llvm/test/Instrumentation/AddressSanitizer/win-string-literal.ll
@@ -8,13 +8,13 @@
 ; CHECK: $"??_C@_04JIHMPGLA@asdf?$AA@" = comdat any
 
 ; CHECK: @"??_C@_04JIHMPGLA@asdf?$AA@" =
-; CHECK-SAME: linkonce_odr dso_local constant { [5 x i8], [59 x i8] }
-; CHECK-SAME: { [5 x i8] c"asdf\00", [59 x i8] zeroinitializer }, comdat, align 32
+; CHECK-SAME: linkonce_odr dso_local constant { [5 x i8], [27 x i8] }
+; CHECK-SAME: { [5 x i8] c"asdf\00", [27 x i8] zeroinitializer }, comdat, align 32
 
 ; CHECK: @"__asan_global_??_C@_04JIHMPGLA@asdf?$AA@" =
 ; CHECK-SAME: private global { i64, i64, i64, i64, i64, i64, i64, i64 }
-; CHECK-SAME: { i64 ptrtoint ({ [5 x i8], [59 x i8] }* @"??_C@_04JIHMPGLA@asdf?$AA@" to i64),
-; CHECK-SAME:   i64 5, i64 64, i64 ptrtoint ([17 x i8]* @___asan_gen_.1 to i64),
+; CHECK-SAME: { i64 ptrtoint ({ [5 x i8], [27 x i8] }* @"??_C@_04JIHMPGLA@asdf?$AA@" to i64),
+; CHECK-SAME:   i64 5, i64 32, i64 ptrtoint ([17 x i8]* @___asan_gen_.1 to i64),
 ; CHECK-SAME:   i64 ptrtoint ([8 x i8]* @___asan_gen_ to i64), i64 0,
 ; CHECK-SAME:   i64 ptrtoint ({ [6 x i8]*, i32, i32 }* @___asan_gen_.3 to i64), i64 0 },
 ; CHECK-SAME:   section ".ASAN$GL", comdat($"??_C@_04JIHMPGLA@asdf?$AA@"), align 64
Index: llvm/test/Instrumentation/AddressSanitizer/odr-check-ignore.ll
===
--- llvm/test/Instrumentation/AddressSanitizer/odr-check-ignore.ll
+++ llvm/test/Instrumentation/AddressSanitizer/odr-check-ignore.ll
@@ -11,15 +11,15 @@
 @c = internal global [2 x i32] zeroinitializer, align 4
 @d = unnamed_addr global [2 x i32] zeroinitializer, align 4
 
-; NOALIAS:  @__asan_global_a = private global { i64, i64, i64, i64, i64, i64, i64, i64 } { i64 ptrtoint ({ [2 x i32], [56 x i8] }* @a to i64), i64 8, i64 64, i64 ptrtoint ([2 x i8]* @___asan_gen_.1 to i64), i64 ptrtoint ([8 x i8]* @___asan_gen_ to i64), i64 0, i64 0, i64 0 }
-; NOALIAS-NEXT: @__asan_global_b = private global { i64, i64, i64, i64, i64, i64, i64, i64 } { i64 ptrtoint ({ [2 x i32], [56 x i8] }* @b to i64), i64 8, i64 64, i64 ptrtoint ([2 x i8]* @___asan_gen_.2 to i64), i64 ptrtoint ([8 x i8]* @___asan_gen_ to i64), i64 0, i64 0, i64 -1 }
-; NOALIAS-NEXT: @__asan_global_c = private global { i64, i64, i64, i64, i64, i64, i64, i64 } { i64 ptrtoint ({ [2 x i32], [56 x i8] }* @c to i64), i64 8, i64 64, i64 ptrtoint ([2 x i8]* @___asan_gen_.3 to i64), i64 ptrtoint ([8 x i8]* @___asan_gen_ to i64), i64 0, i64 0, i64 -1 }
-; NOALIAS-NEXT: @__asan_global_d = private global { i64, i64, i64, i64, i64, i64, i64, i64 } { i64 ptrtoint ({ [2 x i32], [56 x i8] }* @d to i64), i64 8, i64 64, i64 ptrtoint ([2 x i8]* @___asan_gen_.4 to i64), i64 ptrtoint ([8 x i8]* @___asan_gen_ to i64), i64 0, i64 0, i64 0 }
+; NOALIAS:  @__asan_global_a = private global { i64, i64, i64, i64, i64, i64, i64, i64 } { i64 ptrtoint ({ [2 x i32], [24 x i8] }* @a to i64), i64 8, i64 32, i64 ptrtoint ([2 x i8]* @___asan_gen_.1 to i64), i64 ptrtoint ([8 x i8]* @___asan_gen_ to i64), i64 0, i64 0, i64 0 }
+; NOALIAS-NEXT: @__asan_global_b = private global { i64, i64, i64, i64, i64, i64, i64, i64 } { i64 ptrtoint ({ [2 x i32], [24 x i8] }* @b to i64), i64 8, i64 32, i64 ptrtoint ([2 x i8]* 

[clang] dbc641d - [sanitizer] Reduce redzone size for small size global objects

2021-05-19 Thread Fangrui Song via cfe-commits

Author: Zhiwei Chen
Date: 2021-05-19T19:18:50-07:00
New Revision: dbc641deb9883c502b5650e36a31c23d11a358fe

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

LOG: [sanitizer] Reduce redzone size for small size global objects

Currently 1 byte global object has a ridiculous 63 bytes redzone.
This patch reduces the redzone size to be less than 32 if the size of global 
object is less than or equal to half of 32 (the minimal size of redzone).
A 12 bytes object has a 20 bytes redzone, a 20 bytes object has a 44 bytes 
redzone.

Reviewed By: MaskRay, #sanitizers, vitalybuka

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

Added: 


Modified: 
clang/test/CodeGen/asan-globals-alias.cpp
clang/test/CodeGen/asan-globals-odr.cpp
clang/test/CodeGen/asan-globals.cpp
clang/test/CodeGen/asan-static-odr.cpp
llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp

llvm/test/Instrumentation/AddressSanitizer/AMDGPU/adaptive_constant_global_redzones.ll

llvm/test/Instrumentation/AddressSanitizer/AMDGPU/adaptive_global_redzones.ll
llvm/test/Instrumentation/AddressSanitizer/adaptive_global_redzones.ll
llvm/test/Instrumentation/AddressSanitizer/debug-info-global-var.ll
llvm/test/Instrumentation/AddressSanitizer/global_cstring_darwin.ll
llvm/test/Instrumentation/AddressSanitizer/global_lto_merge.ll
llvm/test/Instrumentation/AddressSanitizer/global_metadata.ll
llvm/test/Instrumentation/AddressSanitizer/global_metadata_array.ll
llvm/test/Instrumentation/AddressSanitizer/global_metadata_windows.ll
llvm/test/Instrumentation/AddressSanitizer/global_with_comdat.ll
llvm/test/Instrumentation/AddressSanitizer/local_alias.ll
llvm/test/Instrumentation/AddressSanitizer/odr-check-ignore.ll
llvm/test/Instrumentation/AddressSanitizer/win-string-literal.ll

Removed: 




diff  --git a/clang/test/CodeGen/asan-globals-alias.cpp 
b/clang/test/CodeGen/asan-globals-alias.cpp
index cbde2203f721a..fad23fbb0dc6c 100644
--- a/clang/test/CodeGen/asan-globals-alias.cpp
+++ b/clang/test/CodeGen/asan-globals-alias.cpp
@@ -22,8 +22,8 @@ struct input_device_id {
 struct input_device_id joydev_ids[] = { { {1}, 1234 } }; // KASAN ignored
 extern struct input_device_id __attribute__((alias("joydev_ids"))) 
__mod_joydev_ids_device_table;
 
-// ASAN: @aliased_global{{.*}} global { i32, [60 x i8] }{{.*}}, align 32
-// ASAN: @aliased_global_2{{.*}} global { i32, [60 x i8] }{{.*}}, align 32
+// ASAN: @aliased_global{{.*}} global { i32, [28 x i8] }{{.*}}, align 32
+// ASAN: @aliased_global_2{{.*}} global { i32, [28 x i8] }{{.*}}, align 32
 // ASAN: @joydev_ids{{.*}} global { {{.*}}[56 x i8] zeroinitializer }, align 32
 // KASAN: @aliased_global{{.*}} global i32
 // KASAN: @aliased_global_2{{.*}} global i32

diff  --git a/clang/test/CodeGen/asan-globals-odr.cpp 
b/clang/test/CodeGen/asan-globals-odr.cpp
index 4a148c3ce32fe..57f3418e9a030 100644
--- a/clang/test/CodeGen/asan-globals-odr.cpp
+++ b/clang/test/CodeGen/asan-globals-odr.cpp
@@ -14,7 +14,7 @@ int main() {
   return global;
 }
 
-// CHECK: [[VAR:@.*global.*]] ={{.*}} global { i32, [60 x i8] } 
zeroinitializer, align 32
+// CHECK: [[VAR:@.*global.*]] ={{.*}} global { i32, [28 x i8] } 
zeroinitializer, align 32
 
 // INDICATOR0-NOT: __odr_asan_gen
 // INDICATOR1: [[ODR:@.*__odr_asan_gen_.*global.*]] = global i8 0, align 1

diff  --git a/clang/test/CodeGen/asan-globals.cpp 
b/clang/test/CodeGen/asan-globals.cpp
index f49a180c5868f..dfa2c3265a918 100644
--- a/clang/test/CodeGen/asan-globals.cpp
+++ b/clang/test/CodeGen/asan-globals.cpp
@@ -22,9 +22,9 @@ void func() {
   const char *literal = "Hello, world!";
 }
 
-// ASAN: sectioned_global{{.*}} global { i32, [60 x i8] }{{.*}}, align 32
+// ASAN: sectioned_global{{.*}} global { i32, [28 x i8] }{{.*}}, align 32
 // KASAN: sectioned_global{{.*}} global i32
-// ASAN: @__special_global{{.*}} global { i32, [60 x i8] }{{.*}}, align 32
+// ASAN: @__special_global{{.*}} global { i32, [28 x i8] }{{.*}}, align 32
 // KASAN: @__special_global{{.*}} global i32
 
 /// Without -fasynchronous-unwind-tables, ctor and dtor get the uwtable 
attribute.

diff  --git a/clang/test/CodeGen/asan-static-odr.cpp 
b/clang/test/CodeGen/asan-static-odr.cpp
index 7ec3a306cd39d..3ffaab8f2b927 100644
--- a/clang/test/CodeGen/asan-static-odr.cpp
+++ b/clang/test/CodeGen/asan-static-odr.cpp
@@ -11,7 +11,7 @@ int main() {
 
 // CHECK-NOT: __odr_asan_gen
 // CHECK-NOT: private alias
-// CHECK: [[VAR:@.*global.*]] ={{.*}} global { i32, [60 x i8] } 
zeroinitializer, align 32
+// CHECK: [[VAR:@.*global.*]] ={{.*}} global { i32, [28 x i8] } 
zeroinitializer, align 32
 // CHECK: @0 = internal global {{.*}} [[VAR]] to i64), {{.*}}, i64 -1 }]
 // CHECK: call void @__asan_register_globals(i64 ptrtoint 

[PATCH] D102469: [sanitizer] Reduce redzone size for small size global objects

2021-05-19 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay updated this revision to Diff 346614.
MaskRay added a comment.
Herald added a subscriber: steven_wu.

fix test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102469

Files:
  clang/test/CodeGen/asan-globals-alias.cpp
  clang/test/CodeGen/asan-globals-odr.cpp
  clang/test/CodeGen/asan-globals.cpp
  clang/test/CodeGen/asan-static-odr.cpp
  llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
  
llvm/test/Instrumentation/AddressSanitizer/AMDGPU/adaptive_constant_global_redzones.ll
  llvm/test/Instrumentation/AddressSanitizer/AMDGPU/adaptive_global_redzones.ll
  llvm/test/Instrumentation/AddressSanitizer/adaptive_global_redzones.ll
  llvm/test/Instrumentation/AddressSanitizer/debug-info-global-var.ll
  llvm/test/Instrumentation/AddressSanitizer/global_cstring_darwin.ll
  llvm/test/Instrumentation/AddressSanitizer/global_lto_merge.ll
  llvm/test/Instrumentation/AddressSanitizer/global_metadata.ll
  llvm/test/Instrumentation/AddressSanitizer/global_metadata_array.ll
  llvm/test/Instrumentation/AddressSanitizer/global_metadata_windows.ll
  llvm/test/Instrumentation/AddressSanitizer/global_with_comdat.ll
  llvm/test/Instrumentation/AddressSanitizer/local_alias.ll
  llvm/test/Instrumentation/AddressSanitizer/odr-check-ignore.ll
  llvm/test/Instrumentation/AddressSanitizer/win-string-literal.ll

Index: llvm/test/Instrumentation/AddressSanitizer/win-string-literal.ll
===
--- llvm/test/Instrumentation/AddressSanitizer/win-string-literal.ll
+++ llvm/test/Instrumentation/AddressSanitizer/win-string-literal.ll
@@ -8,13 +8,13 @@
 ; CHECK: $"??_C@_04JIHMPGLA@asdf?$AA@" = comdat any
 
 ; CHECK: @"??_C@_04JIHMPGLA@asdf?$AA@" =
-; CHECK-SAME: linkonce_odr dso_local constant { [5 x i8], [59 x i8] }
-; CHECK-SAME: { [5 x i8] c"asdf\00", [59 x i8] zeroinitializer }, comdat, align 32
+; CHECK-SAME: linkonce_odr dso_local constant { [5 x i8], [27 x i8] }
+; CHECK-SAME: { [5 x i8] c"asdf\00", [27 x i8] zeroinitializer }, comdat, align 32
 
 ; CHECK: @"__asan_global_??_C@_04JIHMPGLA@asdf?$AA@" =
 ; CHECK-SAME: private global { i64, i64, i64, i64, i64, i64, i64, i64 }
-; CHECK-SAME: { i64 ptrtoint ({ [5 x i8], [59 x i8] }* @"??_C@_04JIHMPGLA@asdf?$AA@" to i64),
-; CHECK-SAME:   i64 5, i64 64, i64 ptrtoint ([17 x i8]* @___asan_gen_.1 to i64),
+; CHECK-SAME: { i64 ptrtoint ({ [5 x i8], [27 x i8] }* @"??_C@_04JIHMPGLA@asdf?$AA@" to i64),
+; CHECK-SAME:   i64 5, i64 32, i64 ptrtoint ([17 x i8]* @___asan_gen_.1 to i64),
 ; CHECK-SAME:   i64 ptrtoint ([8 x i8]* @___asan_gen_ to i64), i64 0,
 ; CHECK-SAME:   i64 ptrtoint ({ [6 x i8]*, i32, i32 }* @___asan_gen_.3 to i64), i64 0 },
 ; CHECK-SAME:   section ".ASAN$GL", comdat($"??_C@_04JIHMPGLA@asdf?$AA@"), align 64
Index: llvm/test/Instrumentation/AddressSanitizer/odr-check-ignore.ll
===
--- llvm/test/Instrumentation/AddressSanitizer/odr-check-ignore.ll
+++ llvm/test/Instrumentation/AddressSanitizer/odr-check-ignore.ll
@@ -11,15 +11,15 @@
 @c = internal global [2 x i32] zeroinitializer, align 4
 @d = unnamed_addr global [2 x i32] zeroinitializer, align 4
 
-; NOALIAS:  @__asan_global_a = private global { i64, i64, i64, i64, i64, i64, i64, i64 } { i64 ptrtoint ({ [2 x i32], [56 x i8] }* @a to i64), i64 8, i64 64, i64 ptrtoint ([2 x i8]* @___asan_gen_.1 to i64), i64 ptrtoint ([8 x i8]* @___asan_gen_ to i64), i64 0, i64 0, i64 0 }
-; NOALIAS-NEXT: @__asan_global_b = private global { i64, i64, i64, i64, i64, i64, i64, i64 } { i64 ptrtoint ({ [2 x i32], [56 x i8] }* @b to i64), i64 8, i64 64, i64 ptrtoint ([2 x i8]* @___asan_gen_.2 to i64), i64 ptrtoint ([8 x i8]* @___asan_gen_ to i64), i64 0, i64 0, i64 -1 }
-; NOALIAS-NEXT: @__asan_global_c = private global { i64, i64, i64, i64, i64, i64, i64, i64 } { i64 ptrtoint ({ [2 x i32], [56 x i8] }* @c to i64), i64 8, i64 64, i64 ptrtoint ([2 x i8]* @___asan_gen_.3 to i64), i64 ptrtoint ([8 x i8]* @___asan_gen_ to i64), i64 0, i64 0, i64 -1 }
-; NOALIAS-NEXT: @__asan_global_d = private global { i64, i64, i64, i64, i64, i64, i64, i64 } { i64 ptrtoint ({ [2 x i32], [56 x i8] }* @d to i64), i64 8, i64 64, i64 ptrtoint ([2 x i8]* @___asan_gen_.4 to i64), i64 ptrtoint ([8 x i8]* @___asan_gen_ to i64), i64 0, i64 0, i64 0 }
+; NOALIAS:  @__asan_global_a = private global { i64, i64, i64, i64, i64, i64, i64, i64 } { i64 ptrtoint ({ [2 x i32], [24 x i8] }* @a to i64), i64 8, i64 32, i64 ptrtoint ([2 x i8]* @___asan_gen_.1 to i64), i64 ptrtoint ([8 x i8]* @___asan_gen_ to i64), i64 0, i64 0, i64 0 }
+; NOALIAS-NEXT: @__asan_global_b = private global { i64, i64, i64, i64, i64, i64, i64, i64 } { i64 ptrtoint ({ [2 x i32], [24 x i8] }* @b to i64), i64 8, i64 32, i64 ptrtoint ([2 x i8]* @___asan_gen_.2 to i64), i64 ptrtoint ([8 x i8]* @___asan_gen_ to i64), i64 0, i64 0, i64 -1 }
+; NOALIAS-NEXT: @__asan_global_c = private global { i64, 

[PATCH] D98895: [X86][Draft] Disable long double type for -mno-x87 option

2021-05-19 Thread Pengfei Wang via Phabricator via cfe-commits
pengfei added inline comments.



Comment at: clang/test/Sema/x86-no-x87.c:48-61
+void assign2() {
+  struct st_long_double st;
+#ifndef NOERROR
+  // expected-error@+2{{long double is not supported on this target}}
+#endif
+  st.ld = 0.42;
+}

asavonic wrote:
> pengfei wrote:
> > These seems pass with GCC. https://godbolt.org/z/qM4nWhThx
> Right. Assignment of a literal is compiled to just `mov` without any x87 
> instructions, so it is not diagnosed by GCC. On the other hand, assignment of 
> a variable does trigger the error:
> 
> void assign4(double d) {
>   struct st_long_double st;
>   st.ld = d; // error: long double is not supported on this target
> }
> 
> We can update the patch to do the same for some cases, but it does not look 
> very consistent, and makes assumptions on how the code is optimized and 
> compiled.
> 
> GCC has an advantage here, because it emits the diagnostic at a lower level 
> after at lease some optimizations are done. For example, the following code 
> does not trigger an error for GCC because of inlining:
> 
> double get_const() {
>   return 0.42;
> }
> void assign5(struct st_long_double *st) {
>   st->ld = get_const();
> }
> 
I see. Another concern is about the 32 bits. @LiuChen3 had tested in D100091 
that GCC doesn't error for 32 bits. Do we need to consider it here?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98895

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


[PATCH] D102469: [sanitizer] Reduce redzone size for small size global objects

2021-05-19 Thread Zhiwei Chen via Phabricator via cfe-commits
condy marked 3 inline comments as done.
condy added inline comments.



Comment at: llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp:2556
+  uint64_t RZ = 0;
+  if (SizeInBytes < MinRZ / 2) {
+// Reduce redzone size for small size objects, e.g. int, char[1]. MinRZ is

vitalybuka wrote:
> MaskRay wrote:
> > I wonder whether 16-byte array should use this optimization as well (i.e. 
> > `<` => `<=`)
> > 
> > @vitalybuka 
> Agree, <= cutoff looks better here
@MaskRay @vitalybuka Applied


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102469

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


[PATCH] D102469: [sanitizer] Reduce redzone size for small size global objects

2021-05-19 Thread Zhiwei Chen via Phabricator via cfe-commits
condy updated this revision to Diff 346612.
condy added a comment.

Apply optimization when SizeInBytes <= MinRZ/2


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102469

Files:
  clang/test/CodeGen/asan-globals-alias.cpp
  clang/test/CodeGen/asan-globals-odr.cpp
  clang/test/CodeGen/asan-globals.cpp
  clang/test/CodeGen/asan-static-odr.cpp
  llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
  
llvm/test/Instrumentation/AddressSanitizer/AMDGPU/adaptive_constant_global_redzones.ll
  llvm/test/Instrumentation/AddressSanitizer/AMDGPU/adaptive_global_redzones.ll
  llvm/test/Instrumentation/AddressSanitizer/adaptive_global_redzones.ll
  llvm/test/Instrumentation/AddressSanitizer/debug-info-global-var.ll
  llvm/test/Instrumentation/AddressSanitizer/global_cstring_darwin.ll
  llvm/test/Instrumentation/AddressSanitizer/global_metadata.ll
  llvm/test/Instrumentation/AddressSanitizer/global_metadata_array.ll
  llvm/test/Instrumentation/AddressSanitizer/global_metadata_windows.ll
  llvm/test/Instrumentation/AddressSanitizer/global_with_comdat.ll
  llvm/test/Instrumentation/AddressSanitizer/local_alias.ll
  llvm/test/Instrumentation/AddressSanitizer/odr-check-ignore.ll
  llvm/test/Instrumentation/AddressSanitizer/win-string-literal.ll

Index: llvm/test/Instrumentation/AddressSanitizer/win-string-literal.ll
===
--- llvm/test/Instrumentation/AddressSanitizer/win-string-literal.ll
+++ llvm/test/Instrumentation/AddressSanitizer/win-string-literal.ll
@@ -8,13 +8,13 @@
 ; CHECK: $"??_C@_04JIHMPGLA@asdf?$AA@" = comdat any
 
 ; CHECK: @"??_C@_04JIHMPGLA@asdf?$AA@" =
-; CHECK-SAME: linkonce_odr dso_local constant { [5 x i8], [59 x i8] }
-; CHECK-SAME: { [5 x i8] c"asdf\00", [59 x i8] zeroinitializer }, comdat, align 32
+; CHECK-SAME: linkonce_odr dso_local constant { [5 x i8], [27 x i8] }
+; CHECK-SAME: { [5 x i8] c"asdf\00", [27 x i8] zeroinitializer }, comdat, align 32
 
 ; CHECK: @"__asan_global_??_C@_04JIHMPGLA@asdf?$AA@" =
 ; CHECK-SAME: private global { i64, i64, i64, i64, i64, i64, i64, i64 }
-; CHECK-SAME: { i64 ptrtoint ({ [5 x i8], [59 x i8] }* @"??_C@_04JIHMPGLA@asdf?$AA@" to i64),
-; CHECK-SAME:   i64 5, i64 64, i64 ptrtoint ([17 x i8]* @___asan_gen_.1 to i64),
+; CHECK-SAME: { i64 ptrtoint ({ [5 x i8], [27 x i8] }* @"??_C@_04JIHMPGLA@asdf?$AA@" to i64),
+; CHECK-SAME:   i64 5, i64 32, i64 ptrtoint ([17 x i8]* @___asan_gen_.1 to i64),
 ; CHECK-SAME:   i64 ptrtoint ([8 x i8]* @___asan_gen_ to i64), i64 0,
 ; CHECK-SAME:   i64 ptrtoint ({ [6 x i8]*, i32, i32 }* @___asan_gen_.3 to i64), i64 0 },
 ; CHECK-SAME:   section ".ASAN$GL", comdat($"??_C@_04JIHMPGLA@asdf?$AA@"), align 64
Index: llvm/test/Instrumentation/AddressSanitizer/odr-check-ignore.ll
===
--- llvm/test/Instrumentation/AddressSanitizer/odr-check-ignore.ll
+++ llvm/test/Instrumentation/AddressSanitizer/odr-check-ignore.ll
@@ -11,15 +11,15 @@
 @c = internal global [2 x i32] zeroinitializer, align 4
 @d = unnamed_addr global [2 x i32] zeroinitializer, align 4
 
-; NOALIAS:  @__asan_global_a = private global { i64, i64, i64, i64, i64, i64, i64, i64 } { i64 ptrtoint ({ [2 x i32], [56 x i8] }* @a to i64), i64 8, i64 64, i64 ptrtoint ([2 x i8]* @___asan_gen_.1 to i64), i64 ptrtoint ([8 x i8]* @___asan_gen_ to i64), i64 0, i64 0, i64 0 }
-; NOALIAS-NEXT: @__asan_global_b = private global { i64, i64, i64, i64, i64, i64, i64, i64 } { i64 ptrtoint ({ [2 x i32], [56 x i8] }* @b to i64), i64 8, i64 64, i64 ptrtoint ([2 x i8]* @___asan_gen_.2 to i64), i64 ptrtoint ([8 x i8]* @___asan_gen_ to i64), i64 0, i64 0, i64 -1 }
-; NOALIAS-NEXT: @__asan_global_c = private global { i64, i64, i64, i64, i64, i64, i64, i64 } { i64 ptrtoint ({ [2 x i32], [56 x i8] }* @c to i64), i64 8, i64 64, i64 ptrtoint ([2 x i8]* @___asan_gen_.3 to i64), i64 ptrtoint ([8 x i8]* @___asan_gen_ to i64), i64 0, i64 0, i64 -1 }
-; NOALIAS-NEXT: @__asan_global_d = private global { i64, i64, i64, i64, i64, i64, i64, i64 } { i64 ptrtoint ({ [2 x i32], [56 x i8] }* @d to i64), i64 8, i64 64, i64 ptrtoint ([2 x i8]* @___asan_gen_.4 to i64), i64 ptrtoint ([8 x i8]* @___asan_gen_ to i64), i64 0, i64 0, i64 0 }
+; NOALIAS:  @__asan_global_a = private global { i64, i64, i64, i64, i64, i64, i64, i64 } { i64 ptrtoint ({ [2 x i32], [24 x i8] }* @a to i64), i64 8, i64 32, i64 ptrtoint ([2 x i8]* @___asan_gen_.1 to i64), i64 ptrtoint ([8 x i8]* @___asan_gen_ to i64), i64 0, i64 0, i64 0 }
+; NOALIAS-NEXT: @__asan_global_b = private global { i64, i64, i64, i64, i64, i64, i64, i64 } { i64 ptrtoint ({ [2 x i32], [24 x i8] }* @b to i64), i64 8, i64 32, i64 ptrtoint ([2 x i8]* @___asan_gen_.2 to i64), i64 ptrtoint ([8 x i8]* @___asan_gen_ to i64), i64 0, i64 0, i64 -1 }
+; NOALIAS-NEXT: @__asan_global_c = private global { i64, i64, i64, i64, i64, i64, i64, i64 } { i64 ptrtoint ({ [2 x i32], [24 

[PATCH] D102820: [Clang] Check for returns_nonnull when deciding to add allocation null checks

2021-05-19 Thread Di Mo via Phabricator via cfe-commits
modimo updated this revision to Diff 346610.
modimo added a comment.

Go back to single statement return, fix up ATTR_BUILTIN_NOTHROW_NEW test label 
that pointed to nothing to correct ATTR_NOBUILTIN_NOUNWIND_ALLOCSIZE label.


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

https://reviews.llvm.org/D102820

Files:
  clang/lib/AST/ExprCXX.cpp
  clang/test/CodeGenCXX/new.cpp


Index: clang/test/CodeGenCXX/new.cpp
===
--- clang/test/CodeGenCXX/new.cpp
+++ clang/test/CodeGenCXX/new.cpp
@@ -176,6 +176,7 @@
 struct Alloc{
   int x;
   void* operator new[](size_t size);
+  __attribute__((returns_nonnull)) void *operator new[](size_t size, const 
std::nothrow_t &) throw();
   void operator delete[](void* p);
   ~Alloc();
 };
@@ -186,6 +187,10 @@
   // CHECK: call void @_ZN5AllocD1Ev(
   // CHECK: call void @_ZN5AllocdaEPv(i8*
   delete[] new Alloc[10][20];
+  // CHECK: [[P:%.*]] = call nonnull i8* @_ZN5AllocnaEmRKSt9nothrow_t(i64 808, 
{{.*}}) [[ATTR_NOUNWIND:#[^ ]*]]
+  // CHECK-NOT: icmp eq i8* [[P]], null
+  // CHECK: store i64 200
+  delete[] new (nothrow) Alloc[10][20];
   // CHECK: call noalias nonnull i8* @_Znwm
   // CHECK: call void @_ZdlPv(i8*
   delete new bool;
@@ -328,7 +333,7 @@
 // CHECK: call void @_ZdaPv({{.*}}) [[ATTR_BUILTIN_DELETE]]
 delete[] p; // expected-warning {{'delete[]' applied to a pointer that was 
allocated with 'new'; did you mean 'delete'?}}
 
-// CHECK: call noalias i8* @_ZnamRKSt9nothrow_t(i64 3, {{.*}}) 
[[ATTR_BUILTIN_NOTHROW_NEW:#[^ ]*]]
+// CHECK: call noalias i8* @_ZnamRKSt9nothrow_t(i64 3, {{.*}}) 
[[ATTR_NOBUILTIN_NOUNWIND_ALLOCSIZE:#[^ ]*]]
 (void) new (nothrow) S[3];
 
 // CHECK: call i8* @_Znwm15MyPlacementType(i64 4){{$}}
Index: clang/lib/AST/ExprCXX.cpp
===
--- clang/lib/AST/ExprCXX.cpp
+++ clang/lib/AST/ExprCXX.cpp
@@ -275,7 +275,8 @@
 }
 
 bool CXXNewExpr::shouldNullCheckAllocation() const {
-  return getOperatorNew()
+  return !getOperatorNew()->hasAttr() &&
+ getOperatorNew()
  ->getType()
  ->castAs()
  ->isNothrow() &&


Index: clang/test/CodeGenCXX/new.cpp
===
--- clang/test/CodeGenCXX/new.cpp
+++ clang/test/CodeGenCXX/new.cpp
@@ -176,6 +176,7 @@
 struct Alloc{
   int x;
   void* operator new[](size_t size);
+  __attribute__((returns_nonnull)) void *operator new[](size_t size, const std::nothrow_t &) throw();
   void operator delete[](void* p);
   ~Alloc();
 };
@@ -186,6 +187,10 @@
   // CHECK: call void @_ZN5AllocD1Ev(
   // CHECK: call void @_ZN5AllocdaEPv(i8*
   delete[] new Alloc[10][20];
+  // CHECK: [[P:%.*]] = call nonnull i8* @_ZN5AllocnaEmRKSt9nothrow_t(i64 808, {{.*}}) [[ATTR_NOUNWIND:#[^ ]*]]
+  // CHECK-NOT: icmp eq i8* [[P]], null
+  // CHECK: store i64 200
+  delete[] new (nothrow) Alloc[10][20];
   // CHECK: call noalias nonnull i8* @_Znwm
   // CHECK: call void @_ZdlPv(i8*
   delete new bool;
@@ -328,7 +333,7 @@
 // CHECK: call void @_ZdaPv({{.*}}) [[ATTR_BUILTIN_DELETE]]
 delete[] p; // expected-warning {{'delete[]' applied to a pointer that was allocated with 'new'; did you mean 'delete'?}}
 
-// CHECK: call noalias i8* @_ZnamRKSt9nothrow_t(i64 3, {{.*}}) [[ATTR_BUILTIN_NOTHROW_NEW:#[^ ]*]]
+// CHECK: call noalias i8* @_ZnamRKSt9nothrow_t(i64 3, {{.*}}) [[ATTR_NOBUILTIN_NOUNWIND_ALLOCSIZE:#[^ ]*]]
 (void) new (nothrow) S[3];
 
 // CHECK: call i8* @_Znwm15MyPlacementType(i64 4){{$}}
Index: clang/lib/AST/ExprCXX.cpp
===
--- clang/lib/AST/ExprCXX.cpp
+++ clang/lib/AST/ExprCXX.cpp
@@ -275,7 +275,8 @@
 }
 
 bool CXXNewExpr::shouldNullCheckAllocation() const {
-  return getOperatorNew()
+  return !getOperatorNew()->hasAttr() &&
+ getOperatorNew()
  ->getType()
  ->castAs()
  ->isNothrow() &&
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D102820: [Clang] Check for returns_nonnull when deciding to add allocation null checks

2021-05-19 Thread Di Mo via Phabricator via cfe-commits
modimo created this revision.
modimo added reviewers: bruno, lebedev.ri, rsmith.
Herald added subscribers: hoy, wenlei, lxfind.
modimo requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Non-throwing allocators currently will always get null-check code. However, if 
the non-throwing allocator is explicitly annotated with returns_nonnull the 
null check should be elided.

Testing:
ninja check-all
added test case correctly elides


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D102820

Files:
  clang/lib/AST/ExprCXX.cpp
  clang/test/CodeGenCXX/new.cpp


Index: clang/test/CodeGenCXX/new.cpp
===
--- clang/test/CodeGenCXX/new.cpp
+++ clang/test/CodeGenCXX/new.cpp
@@ -176,6 +176,7 @@
 struct Alloc{
   int x;
   void* operator new[](size_t size);
+  __attribute__((returns_nonnull)) void *operator new[](size_t size, const 
std::nothrow_t &) throw();
   void operator delete[](void* p);
   ~Alloc();
 };
@@ -186,6 +187,10 @@
   // CHECK: call void @_ZN5AllocD1Ev(
   // CHECK: call void @_ZN5AllocdaEPv(i8*
   delete[] new Alloc[10][20];
+  // CHECK: [[P:%.*]] = call nonnull i8* @_ZN5AllocnaEmRKSt9nothrow_t(i64 808, 
{{.*}}) [[ATTR_NOBUILTIN_NOUNWIND_ALLOCSIZE:#[^ ]*]]
+  // CHECK-NOT: icmp eq i8* [[P]], null
+  // CHECK: store i64 200
+  delete[] new (nothrow) Alloc[10][20];
   // CHECK: call noalias nonnull i8* @_Znwm
   // CHECK: call void @_ZdlPv(i8*
   delete new bool;
Index: clang/lib/AST/ExprCXX.cpp
===
--- clang/lib/AST/ExprCXX.cpp
+++ clang/lib/AST/ExprCXX.cpp
@@ -275,7 +275,8 @@
 }
 
 bool CXXNewExpr::shouldNullCheckAllocation() const {
-  return getOperatorNew()
+  return !getOperatorNew()->hasAttr() &&
+ getOperatorNew()
  ->getType()
  ->castAs()
  ->isNothrow() &&


Index: clang/test/CodeGenCXX/new.cpp
===
--- clang/test/CodeGenCXX/new.cpp
+++ clang/test/CodeGenCXX/new.cpp
@@ -176,6 +176,7 @@
 struct Alloc{
   int x;
   void* operator new[](size_t size);
+  __attribute__((returns_nonnull)) void *operator new[](size_t size, const std::nothrow_t &) throw();
   void operator delete[](void* p);
   ~Alloc();
 };
@@ -186,6 +187,10 @@
   // CHECK: call void @_ZN5AllocD1Ev(
   // CHECK: call void @_ZN5AllocdaEPv(i8*
   delete[] new Alloc[10][20];
+  // CHECK: [[P:%.*]] = call nonnull i8* @_ZN5AllocnaEmRKSt9nothrow_t(i64 808, {{.*}}) [[ATTR_NOBUILTIN_NOUNWIND_ALLOCSIZE:#[^ ]*]]
+  // CHECK-NOT: icmp eq i8* [[P]], null
+  // CHECK: store i64 200
+  delete[] new (nothrow) Alloc[10][20];
   // CHECK: call noalias nonnull i8* @_Znwm
   // CHECK: call void @_ZdlPv(i8*
   delete new bool;
Index: clang/lib/AST/ExprCXX.cpp
===
--- clang/lib/AST/ExprCXX.cpp
+++ clang/lib/AST/ExprCXX.cpp
@@ -275,7 +275,8 @@
 }
 
 bool CXXNewExpr::shouldNullCheckAllocation() const {
-  return getOperatorNew()
+  return !getOperatorNew()->hasAttr() &&
+ getOperatorNew()
  ->getType()
  ->castAs()
  ->isNothrow() &&
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D20401: [Lexer] Don't merge macro args from different macro files

2021-05-19 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added a comment.

I know this was sped up slightly in 3339c568c43e4644f02289e5edfc78c860f19c9f, 
but this change makes `updateConsecutiveMacroArgTokens` the hottest function in 
clang in a bottom up profile of an entire build of the Linux kernel.  It 
thrashes the one entry LastFileIDLookup cache, and we end up looking up the 
same FileID again and again and again for each token when we expand nested 
function like macros.

Is there anything we can do to speed this up?  Is there any way to record which 
FileID corresponds to a given Token so that we don't have to keep 
rematerializing that?  Is it possible to find whether two SourceLocations 
correspond to the same FileID without having to figure out which FileID in 
particular each belongs to?

> I discussed this bug with Argyrios off-list, who lgtm'd on the condition that 
> it doesn't introduce a performance regression.

Well, I'd say it's a performance regression, though perhaps reported 5 years 
too late.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D20401

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


[PATCH] D102818: [PGO] Don't reference functions unless value profiling is enabled

2021-05-19 Thread Reid Kleckner via Phabricator via cfe-commits
rnk created this revision.
rnk added reviewers: vsk, davidxl, Bigcheese.
Herald added subscribers: wenlei, hiraditya.
rnk requested review of this revision.
Herald added projects: clang, Sanitizers, LLVM.
Herald added a subscriber: Sanitizers.

This reduces the size of chrome.dll.pdb built with optimizations,
coverage, and line table info from 4,690,210,816 to 2,181,128,192, which
makes it possible to fit under the 4GB limit.

This change can greatly reduce binary size in coverage builds, which do
not need value profiling. IR PGO builds are unaffected. There is a minor
behavior change for frontend PGO.

PGO and coverage both use InstrProfiling to create profile data with
counters. PGO records the address of each function in the __profd_
global. It is used later to map runtime function pointer values back to
source-level function names. Coverage does not appear to use this
information.

Recording the address of every function with code coverage drastically
increases code size. Consider this program:

  void foo();
  void bar();
  inline void inlineMe(int x) {
if (x > 0)
  foo();
else
  bar();
  }
  int getVal();
  int main() { inlineMe(getVal()); }

With code coverage, the InstrProfiling pass runs before inlining, and it
captures the address of inlineMe in the __profd_ global. This greatly
increases code size, because now the compiler can no longer delete
trivial code.

One downside to this approach is that users of frontend PGO must apply
the -mllvm -enable-value-profiling flag globally in TUs that enable PGO.
Otherwise, some inline virtual method addresses may not be recorded and
will not be able to be promoted. My assumption is that this mllvm flag
is not popular, and most frontend PGO users don't enable it.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D102818

Files:
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/CodeGenPGO.cpp
  clang/lib/CodeGen/CodeGenPGO.h
  compiler-rt/test/profile/instrprof-value-prof-2.c
  compiler-rt/test/profile/instrprof-value-prof.c
  llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp


Index: llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
===
--- llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
+++ llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
@@ -748,7 +748,26 @@
   return (Prefix + Name + "." + Twine(FuncHash)).str();
 }
 
+static uint64_t getIntModuleFlagOrZero(Module *M, StringRef Flag) {
+  auto *MD = dyn_cast_or_null(M->getModuleFlag(Flag));
+  if (!MD)
+return 0;
+
+  // If the flag is a ConstantAsMetadata, it should be an integer representable
+  // in 64-bits.
+  return cast(MD->getValue())->getZExtValue();
+}
+
 static inline bool shouldRecordFunctionAddr(Function *F) {
+  // Only record function addresses if IR PGO is enabled or if clang value
+  // profiling is enabled. Recording function addresses greatly increases 
object
+  // file size, because it prevents the inliner from deleting functions that
+  // have been inlined everywhere.
+  if (!isIRPGOFlagSet(F->getParent()) &&
+  getIntModuleFlagOrZero(F->getParent(), "EnableValueProfiling") == 0) {
+return false;
+  }
+
   // Check the linkage
   bool HasAvailableExternallyLinkage = F->hasAvailableExternallyLinkage();
   if (!F->hasLinkOnceLinkage() && !F->hasLocalLinkage() &&
Index: compiler-rt/test/profile/instrprof-value-prof.c
===
--- compiler-rt/test/profile/instrprof-value-prof.c
+++ compiler-rt/test/profile/instrprof-value-prof.c
@@ -1,4 +1,4 @@
-// RUN: %clang_profgen -mllvm -vp-static-alloc=false  -O2 -o %t %s
+// RUN: %clang_profgen -mllvm -enable-value-profiling -mllvm 
-vp-static-alloc=false  -O2 -o %t %s
 // RUN: env LLVM_PROFILE_FILE=%t.profraw %run %t
 // RUN: env LLVM_PROFILE_FILE=%t-2.profraw %run %t DO_NOT_INSTRUMENT
 // RUN: llvm-profdata merge -o %t.profdata %t.profraw
Index: compiler-rt/test/profile/instrprof-value-prof-2.c
===
--- compiler-rt/test/profile/instrprof-value-prof-2.c
+++ compiler-rt/test/profile/instrprof-value-prof-2.c
@@ -1,4 +1,4 @@
-// RUN: %clang_profgen -O2 -o %t %s
+// RUN: %clang_profgen -mllvm -enable-value-profiling -O2 -o %t %s
 // RUN: env LLVM_PROFILE_FILE=%t.profraw %run %t
 // RUN: llvm-profdata merge -o %t.profdata %t.profraw
 // RUN: llvm-profdata show --all-functions -ic-targets  %t.profdata > %t.out
Index: clang/lib/CodeGen/CodeGenPGO.h
===
--- clang/lib/CodeGen/CodeGenPGO.h
+++ clang/lib/CodeGen/CodeGenPGO.h
@@ -87,6 +87,10 @@
   // Insert instrumentation or attach profile metadata at value sites
   void valueProfile(CGBuilderTy , uint32_t ValueKind,
 llvm::Instruction *ValueSite, llvm::Value *ValuePtr);
+
+  // Set a module flag indicating if value profiling is enabled.
+  void 

[PATCH] D101973: [OpenMP][NFC] Remove SIMD check lines for non-simd tests

2021-05-19 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert updated this revision to Diff 346604.
jdoerfert added a comment.

Accidentally deleted too many check lines this time ...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101973

Files:
  clang/test/OpenMP/cancel_codegen.cpp
  clang/test/OpenMP/cancellation_point_codegen.cpp
  clang/test/OpenMP/debug-info-complex-byval.cpp
  clang/test/OpenMP/debug-info-openmp-array.cpp
  clang/test/OpenMP/distribute_codegen.cpp
  clang/test/OpenMP/distribute_firstprivate_codegen.cpp
  clang/test/OpenMP/distribute_lastprivate_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_firstprivate_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_if_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_lastprivate_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_num_threads_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_private_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_proc_bind_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_reduction_task_codegen.cpp
  clang/test/OpenMP/distribute_private_codegen.cpp
  clang/test/OpenMP/for_firstprivate_codegen.cpp
  clang/test/OpenMP/for_lastprivate_codegen.cpp
  clang/test/OpenMP/for_linear_codegen.cpp
  clang/test/OpenMP/for_private_codegen.cpp
  clang/test/OpenMP/for_reduction_codegen.cpp
  clang/test/OpenMP/for_reduction_task_codegen.cpp
  clang/test/OpenMP/master_taskloop_in_reduction_codegen.cpp
  clang/test/OpenMP/openmp_win_codegen.cpp
  clang/test/OpenMP/parallel_codegen.cpp
  clang/test/OpenMP/parallel_copyin_codegen.cpp
  clang/test/OpenMP/parallel_firstprivate_codegen.cpp
  clang/test/OpenMP/parallel_for_codegen.cpp
  clang/test/OpenMP/parallel_for_lastprivate_conditional.cpp
  clang/test/OpenMP/parallel_for_linear_codegen.cpp
  clang/test/OpenMP/parallel_for_reduction_task_codegen.cpp
  clang/test/OpenMP/parallel_if_codegen.cpp
  clang/test/OpenMP/parallel_master_codegen.cpp
  clang/test/OpenMP/parallel_master_reduction_task_codegen.cpp
  clang/test/OpenMP/parallel_master_taskloop_codegen.cpp
  clang/test/OpenMP/parallel_master_taskloop_lastprivate_codegen.cpp
  clang/test/OpenMP/parallel_private_codegen.cpp
  clang/test/OpenMP/parallel_reduction_codegen.cpp
  clang/test/OpenMP/parallel_reduction_task_codegen.cpp
  clang/test/OpenMP/parallel_sections_codegen.cpp
  clang/test/OpenMP/parallel_sections_reduction_task_codegen.cpp
  clang/test/OpenMP/sections_firstprivate_codegen.cpp
  clang/test/OpenMP/sections_lastprivate_codegen.cpp
  clang/test/OpenMP/sections_private_codegen.cpp
  clang/test/OpenMP/sections_reduction_codegen.cpp
  clang/test/OpenMP/sections_reduction_task_codegen.cpp
  clang/test/OpenMP/single_codegen.cpp
  clang/test/OpenMP/single_firstprivate_codegen.cpp
  clang/test/OpenMP/single_private_codegen.cpp
  clang/test/OpenMP/target_codegen_global_capture.cpp
  clang/test/OpenMP/target_map_codegen_03.cpp
  clang/test/OpenMP/target_parallel_codegen.cpp
  clang/test/OpenMP/target_parallel_for_codegen.cpp
  clang/test/OpenMP/target_parallel_for_reduction_task_codegen.cpp
  clang/test/OpenMP/target_parallel_if_codegen.cpp
  clang/test/OpenMP/target_parallel_num_threads_codegen.cpp
  clang/test/OpenMP/target_parallel_reduction_task_codegen.cpp
  clang/test/OpenMP/target_teams_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_collapse_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_dist_schedule_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_firstprivate_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_lastprivate_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_collapse_codegen.cpp
  
clang/test/OpenMP/target_teams_distribute_parallel_for_dist_schedule_codegen.cpp
  
clang/test/OpenMP/target_teams_distribute_parallel_for_firstprivate_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_if_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_lastprivate_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_order_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_private_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_proc_bind_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_reduction_codegen.cpp
  
clang/test/OpenMP/target_teams_distribute_parallel_for_reduction_task_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_schedule_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_private_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_reduction_codegen.cpp
  clang/test/OpenMP/target_teams_num_teams_codegen.cpp
  clang/test/OpenMP/target_teams_thread_limit_codegen.cpp
  clang/test/OpenMP/task_codegen.cpp
  clang/test/OpenMP/task_if_codegen.cpp
  

[PATCH] D102814: [AIX] Print printable byte list as quoted string

2021-05-19 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added inline comments.



Comment at: llvm/lib/MC/MCAsmStreamer.cpp:1007-1008
+static inline bool isPrintableString(StringRef Data) {
+  const auto BeginPtr = Data.begin(), EndPtr = Data.end();
+  for (const unsigned char C : make_range(BeginPtr, EndPtr)) {
+if (!isPrint(C))

If going through the whole string, going through `make_range` is not needed.



Comment at: llvm/lib/MC/MCAsmStreamer.cpp:1009
+  for (const unsigned char C : make_range(BeginPtr, EndPtr)) {
+if (!isPrint(C))
+  return false;

`isPrint` returns true for `"`, which does require escaping.



Comment at: llvm/lib/MC/MCAsmStreamer.cpp:1048-1051
   case MCAsmInfo::ACLS_SingleQuotePrefix:
-printCharacterList(printOneCharacterFor([](char C) {
-  const char AsmCharLitBuf[2] = {'\'', C};
-  OS << StringRef(AsmCharLitBuf, sizeof(AsmCharLitBuf));
-}));
+// If the whole string can be printed, print it directly.
+if (isPrintableString(Data))
+  OS << '"' << Data << '"';

This breaks the abstraction. That a "byte-list" directive accepting a list of 
elements where there are single-quote-prefixed character literals is available 
does not mean that the same directive accepts a string argument.

Note: `PrintQuotedString` does print more general strings on AIX (that do not 
contain a newline); however, I do not believe it to be desirable to emit 
control characters and the such "raw".



Comment at: llvm/lib/MC/MCAsmStreamer.cpp:1123-1126
 if (MAI->getAscizDirective() && Data.back() == 0) {
   OS << MAI->getAscizDirective();
   Data = Data.substr(0, Data.size() - 1);
 } else if (LLVM_LIKELY(MAI->getAsciiDirective())) {

Here may be a nice point to add a condition that 
`hasPairedDoubleQuoteStringConstants` means we check `isPrintableString` before 
deciding to use AIX `.string` for `.asciz` and AIX `.byte` for `.ascii`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102814

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


[PATCH] D100252: [clang] Fix for "Bug 27113 - MSVC-compat __identifier implementation incomplete"

2021-05-19 Thread Melvin Fox via Phabricator via cfe-commits
super_concat updated this revision to Diff 346595.
super_concat added a comment.

Correctly handle string literals and add more test cases. Also MSVC 
 by default gives an error when trying to use 
`__identifier` with a string literal but disabling/surprising that error allows 
string literals to be used with `__identifier`. However given how esoteric it 
is, it wouldn't really be necessary for clang to give a warning or error like 
MSVC


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

https://reviews.llvm.org/D100252

Files:
  clang/lib/Lex/PPMacroExpansion.cpp
  clang/test/Parser/MicrosoftExtensions.cpp


Index: clang/test/Parser/MicrosoftExtensions.cpp
===
--- clang/test/Parser/MicrosoftExtensions.cpp
+++ clang/test/Parser/MicrosoftExtensions.cpp
@@ -263,6 +263,12 @@
 
 extern int __identifier(and);
 
+int __identifier("baz") = 0;
+int bar = baz;
+
+void mangled_function();
+extern "C" void __identifier("?mangled_function@@YAXXZ")() {}
+
 void f() {
   __identifier(() // expected-error {{cannot convert '(' token to an 
identifier}}
   __identifier(void) // expected-error {{use of undeclared identifier 'void'}}
@@ -270,8 +276,10 @@
   // FIXME: We should pick a friendlier display name for this token kind.
   __identifier(1) // expected-error {{cannot convert  token 
to an identifier}}
   __identifier(+) // expected-error {{cannot convert '+' token to an 
identifier}}
-  __identifier("foo") // expected-error {{cannot convert  
token to an identifier}}
   __identifier(;) // expected-error {{cannot convert ';' token to an 
identifier}}
+  __identifier("1"); // expected-error {{use of undeclared identifier '1'}}
+  __identifier("+"); // expected-error {{use of undeclared identifier '+'}}
+  __identifier(";"); // expected-error {{use of undeclared identifier ';'}}
 }
 
 class inline_definition_pure_spec {
Index: clang/lib/Lex/PPMacroExpansion.cpp
===
--- clang/lib/Lex/PPMacroExpansion.cpp
+++ clang/lib/Lex/PPMacroExpansion.cpp
@@ -25,6 +25,7 @@
 #include "clang/Lex/ExternalPreprocessorSource.h"
 #include "clang/Lex/HeaderSearch.h"
 #include "clang/Lex/LexDiagnostic.h"
+#include "clang/Lex/LiteralSupport.h"
 #include "clang/Lex/MacroArgs.h"
 #include "clang/Lex/MacroInfo.h"
 #include "clang/Lex/Preprocessor.h"
@@ -1813,7 +1814,14 @@
 
 if (!Tok.isAnnotation() && Tok.getIdentifierInfo())
   Tok.setKind(tok::identifier);
-else {
+else if (Tok.is(tok::string_literal) && !Tok.hasUDSuffix()) {
+  StringLiteralParser Literal(Tok, *this);
+  if (Literal.hadError)
+return;
+
+  Tok.setIdentifierInfo(getIdentifierInfo(Literal.GetString()));
+  Tok.setKind(tok::identifier);
+} else {
   Diag(Tok.getLocation(), diag::err_pp_identifier_arg_not_identifier)
 << Tok.getKind();
   // Don't walk past anything that's not a real token.


Index: clang/test/Parser/MicrosoftExtensions.cpp
===
--- clang/test/Parser/MicrosoftExtensions.cpp
+++ clang/test/Parser/MicrosoftExtensions.cpp
@@ -263,6 +263,12 @@
 
 extern int __identifier(and);
 
+int __identifier("baz") = 0;
+int bar = baz;
+
+void mangled_function();
+extern "C" void __identifier("?mangled_function@@YAXXZ")() {}
+
 void f() {
   __identifier(() // expected-error {{cannot convert '(' token to an identifier}}
   __identifier(void) // expected-error {{use of undeclared identifier 'void'}}
@@ -270,8 +276,10 @@
   // FIXME: We should pick a friendlier display name for this token kind.
   __identifier(1) // expected-error {{cannot convert  token to an identifier}}
   __identifier(+) // expected-error {{cannot convert '+' token to an identifier}}
-  __identifier("foo") // expected-error {{cannot convert  token to an identifier}}
   __identifier(;) // expected-error {{cannot convert ';' token to an identifier}}
+  __identifier("1"); // expected-error {{use of undeclared identifier '1'}}
+  __identifier("+"); // expected-error {{use of undeclared identifier '+'}}
+  __identifier(";"); // expected-error {{use of undeclared identifier ';'}}
 }
 
 class inline_definition_pure_spec {
Index: clang/lib/Lex/PPMacroExpansion.cpp
===
--- clang/lib/Lex/PPMacroExpansion.cpp
+++ clang/lib/Lex/PPMacroExpansion.cpp
@@ -25,6 +25,7 @@
 #include "clang/Lex/ExternalPreprocessorSource.h"
 #include "clang/Lex/HeaderSearch.h"
 #include "clang/Lex/LexDiagnostic.h"
+#include "clang/Lex/LiteralSupport.h"
 #include "clang/Lex/MacroArgs.h"
 #include "clang/Lex/MacroInfo.h"
 #include "clang/Lex/Preprocessor.h"
@@ -1813,7 +1814,14 @@
 
 if (!Tok.isAnnotation() && Tok.getIdentifierInfo())
   Tok.setKind(tok::identifier);
-else {
+else if (Tok.is(tok::string_literal) && !Tok.hasUDSuffix()) {
+  StringLiteralParser Literal(Tok, 

[PATCH] D102801: [CUDA][HIP] Fix implicit constant variable

2021-05-19 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment.

This patch does not appear to fix the second regression introduced by the 
D102237 .

Trying to compile the following code triggers an assertion in CGExpr.cpp:

  class a {
  public:
a(char *);
  };
  void b() {
[](char *c) {
  static a d(c);
  d;
};
  }

With assertions disabled it eventually leads to a different error: 
`Module has a nontrivial global ctor, which NVPTX does not support.`
https://godbolt.org/z/sYE1dKr1W


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

https://reviews.llvm.org/D102801

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


[PATCH] D102237: [CUDA][HIP] Fix non-ODR-use of static device variable

2021-05-19 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment.

In D102237#2769475 , @yaxunl wrote:

> In D102237#2767538 , @tra wrote:
>
>> Here's a slightly simpler reproducer: https://godbolt.org/z/rW6P9e37s
>
> I have a fix for this: https://reviews.llvm.org/D102801

Here's the second regression introduced by this patch. This one triggers an 
assertion in clang:

  class a {
  public:
a(char *);
  };
  void b() {
[](char *c) {
  static a d(c);
  d;
};
  }


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102237

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


[clang] ac06f6d - [test] Fix test

2021-05-19 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2021-05-19T16:23:52-07:00
New Revision: ac06f6d06de408c00923708dd8a795b6ba9d23d7

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

LOG: [test] Fix test

Added: 


Modified: 
clang/test/CodeGenOpenCLCXX/addrspace-constructors.clcpp

Removed: 




diff  --git a/clang/test/CodeGenOpenCLCXX/addrspace-constructors.clcpp 
b/clang/test/CodeGenOpenCLCXX/addrspace-constructors.clcpp
index 5d81bc57603e7..a5e41950649df 100644
--- a/clang/test/CodeGenOpenCLCXX/addrspace-constructors.clcpp
+++ b/clang/test/CodeGenOpenCLCXX/addrspace-constructors.clcpp
@@ -2,8 +2,8 @@
 
 // CHECK: %struct.X = type { i32 }
 
-// CHECK: @ci = dso_local addrspace(2) constant i32 0
-// CHECK: @gi = dso_local addrspace(1) global i32 0
+// CHECK: @ci ={{.*}} addrspace(2) constant i32 0
+// CHECK: @gi ={{.*}} addrspace(1) global i32 0
 __constant int ci = 0;
 __global int gi = 0;
 
@@ -19,9 +19,9 @@ struct X {
   constexpr X(int x) __constant : x(x) {}
 };
 
-// CHECK: @cx1 = dso_local addrspace(2) constant %struct.X zeroinitializer
-// CHECK: @cx2 = dso_local addrspace(2) constant %struct.X { i32 1 }
-// CHECK: @gx = dso_local addrspace(1) global %struct.X zeroinitializer
+// CHECK: @cx1 ={{.*}} addrspace(2) constant %struct.X zeroinitializer
+// CHECK: @cx2 ={{.*}} addrspace(2) constant %struct.X { i32 1 }
+// CHECK: @gx ={{.*}} addrspace(1) global %struct.X zeroinitializer
 __constant X cx1;
 __constant X cx2(1);
 __global X gx;



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


[PATCH] D102583: -fno-semantic-interposition: Don't set dso_local on GlobalVariable

2021-05-19 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

Looks like this breaks check-clang:
http://45.33.8.238/linux/47049/step_7.txt
http://45.33.8.238/macm1/9850/step_7.txt

PTAL!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102583

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


[PATCH] D102583: -fno-semantic-interposition: Don't set dso_local on GlobalVariable

2021-05-19 Thread Fangrui Song via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG37561ba89b7d: -fno-semantic-interposition: Dont set 
dso_local on GlobalVariable (authored by MaskRay).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102583

Files:
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/test/CodeGen/SystemZ/builtins-systemz-zvector-constrained.c
  clang/test/CodeGen/attr-weakref2.c
  clang/test/CodeGen/semantic-interposition.c
  clang/test/CodeGenCUDA/device-stub.cu
  clang/test/CodeGenCUDA/device-var-linkage.cu
  clang/test/CodeGenCUDA/managed-var.cu
  clang/test/CodeGenCUDA/static-device-var-rdc.cu
  clang/test/OpenMP/declare_target_only_one_side_compilation.cpp

Index: clang/test/OpenMP/declare_target_only_one_side_compilation.cpp
===
--- clang/test/OpenMP/declare_target_only_one_side_compilation.cpp
+++ clang/test/OpenMP/declare_target_only_one_side_compilation.cpp
@@ -67,9 +67,9 @@
 // DEVICE-NOT: llvm.used
 // DEVICE-NOT: omp_offload
 
-// HOST-DAG: @G7 = dso_local global i32 0, align 4
+// HOST-DAG: @G7 = global i32 0, align 4
 // HOST-DAG: @_ZL2G8 = internal global i32 0, align 4
-// HOST-DAG: @G9 = dso_local global i32 0, align 4
+// HOST-DAG: @G9 = global i32 0, align 4
 // HOST-DAG: @_ZL3G10 = internal global i32 0, align 4
-// HOST-DAG: @G11 = dso_local global i32 0, align 4
+// HOST-DAG: @G11 = global i32 0, align 4
 // HOST-DAG: @_ZL3G12 = internal global i32 0, align 4
Index: clang/test/CodeGenCUDA/static-device-var-rdc.cu
===
--- clang/test/CodeGenCUDA/static-device-var-rdc.cu
+++ clang/test/CodeGenCUDA/static-device-var-rdc.cu
@@ -51,14 +51,14 @@
 // HOST-DAG: @_ZL1y = internal global i32 undef
 
 // Test normal static device variables
-// INT-DEV-DAG: @_ZL1x = dso_local addrspace(1) externally_initialized global i32 0
+// INT-DEV-DAG: @_ZL1x = addrspace(1) externally_initialized global i32 0
 // INT-HOST-DAG: @[[DEVNAMEX:[0-9]+]] = {{.*}}c"_ZL1x\00"
 
 // Test externalized static device variables
-// EXT-DEV-DAG: @_ZL1x.static.[[HASH:.*]] = dso_local addrspace(1) externally_initialized global i32 0
+// EXT-DEV-DAG: @_ZL1x.static.[[HASH:.*]] = addrspace(1) externally_initialized global i32 0
 // EXT-HOST-DAG: @[[DEVNAMEX:[0-9]+]] = {{.*}}c"_ZL1x.static.[[HASH:.*]]\00"
 
-// POSTFIX: @_ZL1x.static.[[HASH:.*]] = dso_local addrspace(1) externally_initialized global i32 0
+// POSTFIX: @_ZL1x.static.[[HASH:.*]] = addrspace(1) externally_initialized global i32 0
 // POSTFIX: @[[DEVNAMEX:[0-9]+]] = {{.*}}c"_ZL1x.static.[[HASH]]\00"
 
 static __device__ int x;
@@ -69,11 +69,11 @@
 static __device__ int x2;
 
 // Test normal static device variables
-// INT-DEV-DAG: @_ZL1y = dso_local addrspace(4) externally_initialized global i32 0
+// INT-DEV-DAG: @_ZL1y = addrspace(4) externally_initialized global i32 0
 // INT-HOST-DAG: @[[DEVNAMEY:[0-9]+]] = {{.*}}c"_ZL1y\00"
 
 // Test externalized static device variables
-// EXT-DEV-DAG: @_ZL1y.static.[[HASH]] = dso_local addrspace(4) externally_initialized global i32 0
+// EXT-DEV-DAG: @_ZL1y.static.[[HASH]] = addrspace(4) externally_initialized global i32 0
 // EXT-HOST-DAG: @[[DEVNAMEY:[0-9]+]] = {{.*}}c"_ZL1y.static.[[HASH]]\00"
 
 static __constant__ int y;
Index: clang/test/CodeGenCUDA/managed-var.cu
===
--- clang/test/CodeGenCUDA/managed-var.cu
+++ clang/test/CodeGenCUDA/managed-var.cu
@@ -27,21 +27,21 @@
   float x,y,z;
 };
 
-// DEV-DAG: @x.managed = dso_local addrspace(1) externally_initialized global i32 1, align 4
-// DEV-DAG: @x = dso_local addrspace(1) externally_initialized global i32 addrspace(1)* null
+// DEV-DAG: @x.managed = addrspace(1) externally_initialized global i32 1, align 4
+// DEV-DAG: @x = addrspace(1) externally_initialized global i32 addrspace(1)* null
 // NORDC-DAG: @x.managed = internal global i32 1
-// RDC-DAG: @x.managed = dso_local global i32 1
+// RDC-DAG: @x.managed = global i32 1
 // NORDC-DAG: @x = internal externally_initialized global i32* null
-// RDC-DAG: @x = dso_local externally_initialized global i32* null
+// RDC-DAG: @x = externally_initialized global i32* null
 // HOST-DAG: @[[DEVNAMEX:[0-9]+]] = {{.*}}c"x\00"
 __managed__ int x = 1;
 
-// DEV-DAG: @v.managed = dso_local addrspace(1) externally_initialized global [100 x %struct.vec] zeroinitializer, align 4
-// DEV-DAG: @v = dso_local addrspace(1) externally_initialized global [100 x %struct.vec] addrspace(1)* null
+// DEV-DAG: @v.managed = addrspace(1) externally_initialized global [100 x %struct.vec] zeroinitializer, align 4
+// DEV-DAG: @v = addrspace(1) externally_initialized global [100 x %struct.vec] addrspace(1)* null
 __managed__ vec v[100];
 
-// DEV-DAG: @v2.managed = dso_local addrspace(1) externally_initialized global <{ %struct.vec, [99 x %struct.vec] }> <{ 

[clang] 37561ba - -fno-semantic-interposition: Don't set dso_local on GlobalVariable

2021-05-19 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2021-05-19T16:08:28-07:00
New Revision: 37561ba89b7de57bd8ff5ae0691d02604885d4ee

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

LOG: -fno-semantic-interposition: Don't set dso_local on GlobalVariable

`clang -fpic -fno-semantic-interposition` may set dso_local on variables for 
-fpic.

GCC folks consider there are 'address interposition' and 'semantic 
interposition',
and 'disabling semantic interposition' can optimize function calls but
cannot change variable references to use local aliases
(https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100483).

This patch removes dso_local for variables in
`clang -fpic -fno-semantic-interposition` mode so that the built shared objects 
can
work with copy relocations. Building llvm-project tiself with
-fno-semantic-interposition (D102453) should now be safe with trunk Clang.

Example:
```
// a.c
int var;
int *addr() { return var; }

// old: cannot be interposed
movslq  .Lvar$local(%rip), %rax
// new: can be interposed
movqvar@GOTPCREL(%rip), %rax
movslq  (%rax), %rax
```

The local alias lowering for `GlobalVariable`s is kept in case there is a
future option allowing local aliases.

Reviewed By: rnk

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

Added: 


Modified: 
clang/lib/CodeGen/CodeGenModule.cpp
clang/test/CodeGen/SystemZ/builtins-systemz-zvector-constrained.c
clang/test/CodeGen/attr-weakref2.c
clang/test/CodeGen/semantic-interposition.c
clang/test/CodeGenCUDA/device-stub.cu
clang/test/CodeGenCUDA/device-var-linkage.cu
clang/test/CodeGenCUDA/managed-var.cu
clang/test/CodeGenCUDA/static-device-var-rdc.cu
clang/test/OpenMP/declare_target_only_one_side_compilation.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index fa9676a1f32de..e38dee92db293 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -1007,9 +1007,9 @@ static bool shouldAssumeDSOLocal(const CodeGenModule ,
 // On ELF, if -fno-semantic-interposition is specified and the target
 // supports local aliases, there will be neither CC1
 // -fsemantic-interposition nor -fhalf-no-semantic-interposition. Set
-// dso_local if using a local alias is preferable (can avoid GOT
-// indirection).
-if (!GV->canBenefitFromLocalAlias())
+// dso_local on the function if using a local alias is preferable (can 
avoid
+// PLT indirection).
+if (!(isa(GV) && GV->canBenefitFromLocalAlias()))
   return false;
 return !(CGM.getLangOpts().SemanticInterposition ||
  CGM.getLangOpts().HalfNoSemanticInterposition);

diff  --git a/clang/test/CodeGen/SystemZ/builtins-systemz-zvector-constrained.c 
b/clang/test/CodeGen/SystemZ/builtins-systemz-zvector-constrained.c
index 596d502116890..b3912c8427d90 100644
--- a/clang/test/CodeGen/SystemZ/builtins-systemz-zvector-constrained.c
+++ b/clang/test/CodeGen/SystemZ/builtins-systemz-zvector-constrained.c
@@ -66,28 +66,17 @@ void test_core(void) {
   // CHECK-ASM: vsceg %{{.*}}, 0(%{{.*}},%{{.*}}), 1
 
   vd = vec_xl(idx, cptrd);
-  // CHECK-ASM-NEXT: lgfrl   %r3, idx
-  // CHECK-ASM-NEXT: lgrl%r4, cptrd
-  // CHECK-ASM-NEXT: vl  %v0, 0(%r3,%r4){{$}}
+  // CHECK-ASM-NEXT: lgf %r5, 0(%r3)
+  // CHECK-ASM-NEXT: lg  %r13, 0(%r4)
+  // CHECK-ASM-NEXT: vl  %v0, 0(%r5,%r13){{$}}
   // CHECK-ASM-NEXT: vst
 
   vd = vec_xld2(idx, cptrd);
-  // CHECK-ASM-NEXT: lgfrl   %r3, idx
-  // CHECK-ASM-NEXT: lgrl%r4, cptrd
-  // CHECK-ASM-NEXT: vl  %v0, 0(%r3,%r4){{$}}
-  // CHECK-ASM-NEXT: vst
+  // CHECK-ASM:  vst
 
   vec_xst(vd, idx, ptrd);
-  // CHECK-ASM-NEXT: vl
-  // CHECK-ASM-NEXT: lgfrl   %r3, idx
-  // CHECK-ASM-NEXT: lgrl%r4, ptrd
-  // CHECK-ASM-NEXT: vst %v0, 0(%r3,%r4){{$}}
 
   vec_xstd2(vd, idx, ptrd);
-  // CHECK-ASM-NEXT: vl
-  // CHECK-ASM-NEXT: lgfrl   %r3, idx
-  // CHECK-ASM-NEXT: lgrl%r4, ptrd
-  // CHECK-ASM-NEXT: vst %v0, 0(%r3,%r4){{$}}
 
   vd = vec_splat(vd, 0);
   // CHECK: shufflevector <2 x double> %{{.*}}, <2 x double> poison, <2 x i32> 
zeroinitializer

diff  --git a/clang/test/CodeGen/attr-weakref2.c 
b/clang/test/CodeGen/attr-weakref2.c
index 2746819833b15..114f048a85183 100644
--- a/clang/test/CodeGen/attr-weakref2.c
+++ b/clang/test/CodeGen/attr-weakref2.c
@@ -8,7 +8,7 @@ int test1_h(void) {
   return test1_g;
 }
 
-// CHECK: @test2_f = dso_local global i32 0, align 4
+// CHECK: @test2_f = global i32 0, align 4
 int test2_f;
 static int test2_g __attribute__((weakref("test2_f")));
 int test2_h(void) {
@@ -25,7 +25,7 @@ int test3_h(void) {
   return test3_g;
 }
 
-// CHECK: @test4_f = dso_local global i32 0, align 4
+// CHECK: @test4_f = global i32 0, align 4
 extern int 

[clang] 2f8ac07 - PR50402: Use proper constant evaluation rules for checking constraint

2021-05-19 Thread Richard Smith via cfe-commits

Author: Richard Smith
Date: 2021-05-19T16:02:53-07:00
New Revision: 2f8ac0758bbfad72e52ef8602fbbd796e1347784

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

LOG: PR50402: Use proper constant evaluation rules for checking constraint
satisfaction.

Previously we used the rules for constant folding in a non-constant
context, meaning that we'd incorrectly accept foldable non-constant
expressions and that std::is_constant_evaluated() would evaluate to
false.

Added: 


Modified: 
clang/lib/Sema/SemaConcept.cpp
clang/test/SemaTemplate/concepts.cpp
clang/test/SemaTemplate/cxx2a-constraint-caching.cpp
clang/test/SemaTemplate/instantiate-requires-clause.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaConcept.cpp b/clang/lib/Sema/SemaConcept.cpp
index 592bf5633ea5..b67776b5348d 100644
--- a/clang/lib/Sema/SemaConcept.cpp
+++ b/clang/lib/Sema/SemaConcept.cpp
@@ -172,9 +172,11 @@ calculateConstraintSatisfaction(Sema , const Expr 
*ConstraintExpr,
   SmallVector EvaluationDiags;
   Expr::EvalResult EvalResult;
   EvalResult.Diag = 
-  if (!SubstitutedAtomicExpr.get()->EvaluateAsRValue(EvalResult, S.Context)) {
-  // C++2a [temp.constr.atomic]p1
-  //   ...E shall be a constant expression of type bool.
+  if (!SubstitutedAtomicExpr.get()->EvaluateAsConstantExpr(EvalResult,
+   S.Context) ||
+  !EvaluationDiags.empty()) {
+// C++2a [temp.constr.atomic]p1
+//   ...E shall be a constant expression of type bool.
 S.Diag(SubstitutedAtomicExpr.get()->getBeginLoc(),
diag::err_non_constant_constraint_expression)
 << SubstitutedAtomicExpr.get()->getSourceRange();
@@ -183,6 +185,8 @@ calculateConstraintSatisfaction(Sema , const Expr 
*ConstraintExpr,
 return true;
   }
 
+  assert(EvalResult.Val.isInt() &&
+ "evaluating bool expression didn't produce int");
   Satisfaction.IsSatisfied = EvalResult.Val.getInt().getBoolValue();
   if (!Satisfaction.IsSatisfied)
 Satisfaction.Details.emplace_back(ConstraintExpr,
@@ -214,6 +218,13 @@ static bool calculateConstraintSatisfaction(
   Sema::SFINAETrap Trap(S);
   SubstitutedExpression = S.SubstExpr(const_cast(AtomicExpr),
   MLTAL);
+  // Substitution might have stripped off a contextual conversion to
+  // bool if this is the operand of an '&&' or '||'. For example, we
+  // might lose an lvalue-to-rvalue conversion here. If so, put it back
+  // before we try to evaluate.
+  if (!SubstitutedExpression.isInvalid())
+SubstitutedExpression =
+
S.PerformContextuallyConvertToBool(SubstitutedExpression.get());
   if (SubstitutedExpression.isInvalid() || Trap.hasErrorOccurred()) {
 // C++2a [temp.constr.atomic]p1
 //   ...If substitution results in an invalid type or expression, 
the
@@ -523,9 +534,9 @@ static void 
diagnoseWellFormedUnsatisfiedConstraintExpr(Sema ,
   diagnoseWellFormedUnsatisfiedConstraintExpr(S, BO->getRHS(),
   /*First=*/false);
   return;
-case BO_LAnd:
-  bool LHSSatisfied;
-  BO->getLHS()->EvaluateAsBooleanCondition(LHSSatisfied, S.Context);
+case BO_LAnd: {
+  bool LHSSatisfied =
+  BO->getLHS()->EvaluateKnownConstInt(S.Context).getBoolValue();
   if (LHSSatisfied) {
 // LHS is true, so RHS must be false.
 diagnoseWellFormedUnsatisfiedConstraintExpr(S, BO->getRHS(), First);
@@ -535,12 +546,13 @@ static void 
diagnoseWellFormedUnsatisfiedConstraintExpr(Sema ,
   diagnoseWellFormedUnsatisfiedConstraintExpr(S, BO->getLHS(), First);
 
   // RHS might also be false
-  bool RHSSatisfied;
-  BO->getRHS()->EvaluateAsBooleanCondition(RHSSatisfied, S.Context);
+  bool RHSSatisfied =
+  BO->getRHS()->EvaluateKnownConstInt(S.Context).getBoolValue();
   if (!RHSSatisfied)
 diagnoseWellFormedUnsatisfiedConstraintExpr(S, BO->getRHS(),
 /*First=*/false);
   return;
+}
 case BO_GE:
 case BO_LE:
 case BO_GT:
@@ -551,8 +563,12 @@ static void 
diagnoseWellFormedUnsatisfiedConstraintExpr(Sema ,
   BO->getRHS()->getType()->isIntegerType()) {
 Expr::EvalResult SimplifiedLHS;
 Expr::EvalResult SimplifiedRHS;
-BO->getLHS()->EvaluateAsInt(SimplifiedLHS, S.Context);
-BO->getRHS()->EvaluateAsInt(SimplifiedRHS, S.Context);
+BO->getLHS()->EvaluateAsInt(SimplifiedLHS, S.Context,
+Expr::SE_NoSideEffects,
+/*InConstantContext=*/true);
+

[PATCH] D102805: [M68k] Allow user to preserve certain registers

2021-05-19 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added a comment.

Please fix up the linter warnings; LGTM.




Comment at: llvm/lib/Target/M68k/M68kRegisterInfo.cpp:137
+  // Registers reserved by users
+  for (size_t Reg = 0; Reg < getNumRegs(); ++Reg) {
+if (MF.getSubtarget().isRegisterReservedByUser(Reg))

a more common convention in LLVM for `for` loops is:

for (size_t Reg = 0, Total = getNumRegs(); Reg != Total; ++Reg) {

The coding standards aren't very explicit about this though, the case 
https://llvm.org/docs/CodingStandards.html#don-t-evaluate-end-every-time-through-a-loop
 has more to do with iterators.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102805

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


[PATCH] D102791: [WebAssembly] Warn on exception spec for Emscripten EH

2021-05-19 Thread Derek Schuff via Phabricator via cfe-commits
dschuff added a comment.

BTW Is there a way to disable this warning?
Since IIUC this could cause code that was not warning (because it used 
-fno-exceptions or used emscripten's default of -fignore-exceptions) to now 
start warning, sometimes that makes users who use -Werror unhappy.




Comment at: clang/lib/CodeGen/CGException.cpp:495
+CGM.getLangOpts().getExceptionHandling() ==
+LangOptions::ExceptionHandlingKind::None &&
+EST == EST_Dynamic)

Does emscripten's default of `-fignore-exceptions` also end up as haveing 
`ExceptionHandlingKind::None` even though exceptions aren't disabled?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102791

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


[PATCH] D102585: [M68k] Support inline asm operands w/ simple constraints

2021-05-19 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added a comment.

Looking good @myhsu .  Also, I got your LLVM book recently!  You'll need to 
sign it for me at the next llvm conf in person.




Comment at: clang/lib/Basic/Targets/M68k.cpp:197-199
+std::string R = std::string("^") + std::string(Constraint, 2);
+++Constraint;
+return R;

return std::string("^") + std::string(Constraint++, 2);



Comment at: clang/test/Sema/inline-asm-validate-m68k.c:10
+  asm volatile ("" :: "I"(BelowMin)); // expected-error{{value '0' out of 
range for constraint 'I'}}
+  asm volatile ("" :: "I"(AboveMax)); // expected-error{{value '9' out of 
range for constraint 'I'}}
+}

Tests look good. Would you mind please adding an `asm` for each function that 
doesn't require an `expected-error`? ie. is valid input?

Also, `volatile` keyword is not necessary when there are no output operands. 
See also: https://gcc.gnu.org/onlinedocs/gcc/Extended-Asm.html#Volatile.



Comment at: clang/test/Sema/inline-asm-validate-m68k.c:51
+  asm volatile ("" :: "C0"(IncorrectVal)); // expected-error{{value '1' out of 
range for constraint 'C0'}}
+}

do we need tests for lowercase `a`, `r`, or `d`?



Comment at: llvm/lib/Target/M68k/M68kAsmPrinter.cpp:57-59
+  case MachineOperand::MO_ConstantPoolIndex:
+OS << DL.getPrivateGlobalPrefix() << "CPI" << getFunctionNumber() << '_'
+   << MO.getIndex();

If `DL` is only needed for this lone case, consider using `{}` for the case and 
sinking the def closer to the use.


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

https://reviews.llvm.org/D102585

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


[PATCH] D102614: [index] Add support for type of pointers to class members

2021-05-19 Thread Argyrios Kyrtzidis via Phabricator via cfe-commits
akyrtzi added inline comments.



Comment at: clang/lib/Index/USRGeneration.cpp:897
+if (const MemberPointerType *MPT = T->getAs()) {
+  VisitType(QualType(MPT->getClass(), 0));
+  Out << "::*";

A bit better to do `VisitTagDecl(MPT->getClass())`, what do you think?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102614

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


[PATCH] D102742: [IR] make stack-protector-guard-* flags into module attrs

2021-05-19 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers updated this revision to Diff 346585.
nickdesaulniers added a comment.

- remove spurious comment


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102742

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/test/CodeGen/stack-protector-guard.c
  llvm/include/llvm/CodeGen/CommandFlags.h
  llvm/include/llvm/IR/Module.h
  llvm/include/llvm/Target/TargetOptions.h
  llvm/lib/CodeGen/CommandFlags.cpp
  llvm/lib/CodeGen/StackProtector.cpp
  llvm/lib/IR/Module.cpp
  llvm/lib/Target/AArch64/AArch64InstrInfo.cpp
  llvm/lib/Target/X86/X86ISelLowering.cpp
  llvm/test/CodeGen/AArch64/stack-guard-sysreg.ll
  llvm/test/CodeGen/X86/stack-protector-3.ll

Index: llvm/test/CodeGen/X86/stack-protector-3.ll
===
--- llvm/test/CodeGen/X86/stack-protector-3.ll
+++ llvm/test/CodeGen/X86/stack-protector-3.ll
@@ -1,10 +1,18 @@
-; RUN: llc -mtriple=x86_64-pc-linux-gnu -o - < %s | FileCheck --check-prefix=CHECK-TLS-FS-40 %s
-; RUN: llc -mtriple=x86_64-pc-linux-gnu -stack-protector-guard=tls -o - < %s | FileCheck --check-prefix=CHECK-TLS-FS-40 %s
-; RUN: llc -mtriple=x86_64-pc-linux-gnu -stack-protector-guard=global -o - < %s | FileCheck --check-prefix=CHECK-GLOBAL %s
-; RUN: llc -mtriple=x86_64-pc-linux-gnu -stack-protector-guard-reg=fs -o - < %s | FileCheck --check-prefix=CHECK-TLS-FS-40 %s
-; RUN: llc -mtriple=x86_64-pc-linux-gnu -stack-protector-guard-reg=gs -o - < %s | FileCheck --check-prefix=CHECK-GS %s
-; RUN: llc -mtriple=x86_64-pc-linux-gnu -stack-protector-guard-offset=20 -o - < %s | FileCheck --check-prefix=CHECK-OFFSET %s
-; RUN: llc -mtriple=x86_64-pc-linux-gnu -stack-protector-guard-offset=-20 -o - < %s | FileCheck --check-prefix=CHECK-NEGATIVE-OFFSET %s
+; RUN: split-file %s %t
+; RUN: cat %t/main.ll %t/a.ll > %t/a2.ll
+; RUN: cat %t/main.ll %t/b.ll > %t/b2.ll
+; RUN: cat %t/main.ll %t/c.ll > %t/c2.ll
+; RUN: cat %t/main.ll %t/d.ll > %t/d2.ll
+; RUN: cat %t/main.ll %t/e.ll > %t/e2.ll
+; RUN: cat %t/main.ll %t/f.ll > %t/f2.ll
+; RUN: cat %t/main.ll %t/g.ll > %t/g2.ll
+; RUN: llc -mtriple=x86_64-pc-linux-gnu -o - < %t/a2.ll | FileCheck --check-prefix=CHECK-TLS-FS-40 %s
+; RUN: llc -mtriple=x86_64-pc-linux-gnu -o - < %t/b2.ll | FileCheck --check-prefix=CHECK-TLS-FS-40 %s
+; RUN: llc -mtriple=x86_64-pc-linux-gnu -o - < %t/c2.ll | FileCheck --check-prefix=CHECK-GLOBAL %s
+; RUN: llc -mtriple=x86_64-pc-linux-gnu -o - < %t/d2.ll | FileCheck --check-prefix=CHECK-TLS-FS-40 %s
+; RUN: llc -mtriple=x86_64-pc-linux-gnu -o - < %t/e2.ll | FileCheck --check-prefix=CHECK-GS %s
+; RUN: llc -mtriple=x86_64-pc-linux-gnu -o - < %t/f2.ll | FileCheck --check-prefix=CHECK-OFFSET %s
+; RUN: llc -mtriple=x86_64-pc-linux-gnu -o - < %t/g2.ll | FileCheck --check-prefix=CHECK-NEGATIVE-OFFSET %s
 
 ; CHECK-TLS-FS-40:   movq%fs:40, %rax
 ; CHECK-TLS-FS-40:   movq%fs:40, %rax
@@ -47,6 +55,8 @@
 ; CHECK-GLOBAL-NEXT:  .cfi_def_cfa_offset 32
 ; CHECK-GLOBAL-NEXT:  callq   __stack_chk_fail
 
+;--- main.ll
+
 ; ModuleID = 't.c'
 @.str = private unnamed_addr constant [14 x i8] c"stackoverflow\00", align 1
 @a = dso_local local_unnamed_addr global i8* null, align 8
@@ -75,3 +85,23 @@
 attributes #0 = { nounwind sspreq uwtable writeonly "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "frame-pointer"="none" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" "unsafe-fp-math"="false" "use-soft-float"="false" }
 attributes #1 = { argmemonly nounwind willreturn }
 attributes #2 = { nounwind }
+
+;--- a.ll
+;--- b.ll
+!llvm.module.flags = !{!1}
+!1 = !{i32 2, !"stack-protector-guard", !"tls"}
+;--- c.ll
+!llvm.module.flags = !{!1}
+!1 = !{i32 2, !"stack-protector-guard", !"global"}
+;--- d.ll
+!llvm.module.flags = !{!1}
+!1 = !{i32 2, !"stack-protector-guard-reg", !"fs"}
+;--- e.ll
+!llvm.module.flags = !{!1}
+!1 = !{i32 2, !"stack-protector-guard-reg", !"gs"}
+;--- f.ll
+!llvm.module.flags = !{!1}
+!1 = !{i32 2, !"stack-protector-guard-offset", i32 20}
+;--- g.ll
+!llvm.module.flags = !{!1}
+!1 = !{i32 2, !"stack-protector-guard-offset", i32 -20}
Index: llvm/test/CodeGen/AArch64/stack-guard-sysreg.ll
===
--- llvm/test/CodeGen/AArch64/stack-guard-sysreg.ll
+++ llvm/test/CodeGen/AArch64/stack-guard-sysreg.ll
@@ -1,46 +1,39 @@
-; RUN: llc %s --stack-protector-guard=sysreg \
-; RUN:   --stack-protector-guard-reg=sp_el0 \
-; RUN:   --stack-protector-guard-offset=0 -verify-machineinstrs -o - | \
+; RUN: split-file %s %t
+; RUN: cat %t/main.ll %t/a.ll > 

[PATCH] D102742: [IR] make stack-protector-guard-* flags into module attrs

2021-05-19 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers updated this revision to Diff 346584.
nickdesaulniers added a comment.
Herald added a subscriber: dang.

- add cc1 test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102742

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/test/CodeGen/stack-protector-guard.c
  llvm/include/llvm/CodeGen/CommandFlags.h
  llvm/include/llvm/IR/Module.h
  llvm/include/llvm/Target/TargetOptions.h
  llvm/lib/CodeGen/CommandFlags.cpp
  llvm/lib/CodeGen/StackProtector.cpp
  llvm/lib/IR/Module.cpp
  llvm/lib/Target/AArch64/AArch64InstrInfo.cpp
  llvm/lib/Target/X86/X86ISelLowering.cpp
  llvm/test/CodeGen/AArch64/stack-guard-sysreg.ll
  llvm/test/CodeGen/X86/stack-protector-3.ll

Index: llvm/test/CodeGen/X86/stack-protector-3.ll
===
--- llvm/test/CodeGen/X86/stack-protector-3.ll
+++ llvm/test/CodeGen/X86/stack-protector-3.ll
@@ -1,10 +1,18 @@
-; RUN: llc -mtriple=x86_64-pc-linux-gnu -o - < %s | FileCheck --check-prefix=CHECK-TLS-FS-40 %s
-; RUN: llc -mtriple=x86_64-pc-linux-gnu -stack-protector-guard=tls -o - < %s | FileCheck --check-prefix=CHECK-TLS-FS-40 %s
-; RUN: llc -mtriple=x86_64-pc-linux-gnu -stack-protector-guard=global -o - < %s | FileCheck --check-prefix=CHECK-GLOBAL %s
-; RUN: llc -mtriple=x86_64-pc-linux-gnu -stack-protector-guard-reg=fs -o - < %s | FileCheck --check-prefix=CHECK-TLS-FS-40 %s
-; RUN: llc -mtriple=x86_64-pc-linux-gnu -stack-protector-guard-reg=gs -o - < %s | FileCheck --check-prefix=CHECK-GS %s
-; RUN: llc -mtriple=x86_64-pc-linux-gnu -stack-protector-guard-offset=20 -o - < %s | FileCheck --check-prefix=CHECK-OFFSET %s
-; RUN: llc -mtriple=x86_64-pc-linux-gnu -stack-protector-guard-offset=-20 -o - < %s | FileCheck --check-prefix=CHECK-NEGATIVE-OFFSET %s
+; RUN: split-file %s %t
+; RUN: cat %t/main.ll %t/a.ll > %t/a2.ll
+; RUN: cat %t/main.ll %t/b.ll > %t/b2.ll
+; RUN: cat %t/main.ll %t/c.ll > %t/c2.ll
+; RUN: cat %t/main.ll %t/d.ll > %t/d2.ll
+; RUN: cat %t/main.ll %t/e.ll > %t/e2.ll
+; RUN: cat %t/main.ll %t/f.ll > %t/f2.ll
+; RUN: cat %t/main.ll %t/g.ll > %t/g2.ll
+; RUN: llc -mtriple=x86_64-pc-linux-gnu -o - < %t/a2.ll | FileCheck --check-prefix=CHECK-TLS-FS-40 %s
+; RUN: llc -mtriple=x86_64-pc-linux-gnu -o - < %t/b2.ll | FileCheck --check-prefix=CHECK-TLS-FS-40 %s
+; RUN: llc -mtriple=x86_64-pc-linux-gnu -o - < %t/c2.ll | FileCheck --check-prefix=CHECK-GLOBAL %s
+; RUN: llc -mtriple=x86_64-pc-linux-gnu -o - < %t/d2.ll | FileCheck --check-prefix=CHECK-TLS-FS-40 %s
+; RUN: llc -mtriple=x86_64-pc-linux-gnu -o - < %t/e2.ll | FileCheck --check-prefix=CHECK-GS %s
+; RUN: llc -mtriple=x86_64-pc-linux-gnu -o - < %t/f2.ll | FileCheck --check-prefix=CHECK-OFFSET %s
+; RUN: llc -mtriple=x86_64-pc-linux-gnu -o - < %t/g2.ll | FileCheck --check-prefix=CHECK-NEGATIVE-OFFSET %s
 
 ; CHECK-TLS-FS-40:   movq%fs:40, %rax
 ; CHECK-TLS-FS-40:   movq%fs:40, %rax
@@ -47,6 +55,8 @@
 ; CHECK-GLOBAL-NEXT:  .cfi_def_cfa_offset 32
 ; CHECK-GLOBAL-NEXT:  callq   __stack_chk_fail
 
+;--- main.ll
+
 ; ModuleID = 't.c'
 @.str = private unnamed_addr constant [14 x i8] c"stackoverflow\00", align 1
 @a = dso_local local_unnamed_addr global i8* null, align 8
@@ -75,3 +85,23 @@
 attributes #0 = { nounwind sspreq uwtable writeonly "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "frame-pointer"="none" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" "unsafe-fp-math"="false" "use-soft-float"="false" }
 attributes #1 = { argmemonly nounwind willreturn }
 attributes #2 = { nounwind }
+
+;--- a.ll
+;--- b.ll
+!llvm.module.flags = !{!1}
+!1 = !{i32 2, !"stack-protector-guard", !"tls"}
+;--- c.ll
+!llvm.module.flags = !{!1}
+!1 = !{i32 2, !"stack-protector-guard", !"global"}
+;--- d.ll
+!llvm.module.flags = !{!1}
+!1 = !{i32 2, !"stack-protector-guard-reg", !"fs"}
+;--- e.ll
+!llvm.module.flags = !{!1}
+!1 = !{i32 2, !"stack-protector-guard-reg", !"gs"}
+;--- f.ll
+!llvm.module.flags = !{!1}
+!1 = !{i32 2, !"stack-protector-guard-offset", i32 20}
+;--- g.ll
+!llvm.module.flags = !{!1}
+!1 = !{i32 2, !"stack-protector-guard-offset", i32 -20}
Index: llvm/test/CodeGen/AArch64/stack-guard-sysreg.ll
===
--- llvm/test/CodeGen/AArch64/stack-guard-sysreg.ll
+++ llvm/test/CodeGen/AArch64/stack-guard-sysreg.ll
@@ -1,46 +1,39 @@
-; RUN: llc %s --stack-protector-guard=sysreg \
-; RUN:   --stack-protector-guard-reg=sp_el0 \
-; RUN:   --stack-protector-guard-offset=0 -verify-machineinstrs -o - | \
+; RUN: split-file %s %t
+; RUN: cat 

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

2021-05-19 Thread Ryan Santhirarajan via Phabricator via cfe-commits
rsanthir.quic updated this revision to Diff 346582.
rsanthir.quic added a comment.

Localized changes to Options.td, needed to explicitly add negative
flag for -Wframe-larger-than


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102782

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Frontend/backend-stack-usage-diagnostic.c


Index: clang/test/Frontend/backend-stack-usage-diagnostic.c
===
--- /dev/null
+++ clang/test/Frontend/backend-stack-usage-diagnostic.c
@@ -0,0 +1,17 @@
+// RUN: %clang -Wstack-usage=0 -o /dev/null -c %s 2> %t.err
+// RUN: FileCheck < %t.err %s --check-prefix=WARN
+// RUN: %clang -Wno-stack-usage= -w -o /dev/null -c %s 2> %t.err
+// RUN: FileCheck < %t.err %s --check-prefix=IGNORE --allow-empty
+// RUN: %clang -Wstack-usage=0 -w -o /dev/null -c %s 2> %t.err
+// RUN: FileCheck < %t.err %s --check-prefix=IGNORE --allow-empty
+// RUN: %clang -Wstack-usage=3 -o /dev/null -c %s 2> %t.err
+// RUN: FileCheck < %t.err %s --check-prefix=WARN
+// RUN: %clang -Wstack-usage=100 -o /dev/null -c %s 2> %t.err
+// RUN: FileCheck < %t.err %s --check-prefix=IGNORE --allow-empty
+
+// WARN: warning: stack frame size of {{[0-9]+}} bytes in function 
'test_square'
+// IGNORE-NOT:  stack frame size of {{[0-9]+}} bytes in function 'test_square'
+int test_square(int num) {
+  return num * num;
+}
+
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -4762,12 +4762,14 @@
   D.Diag(diag::err_aix_default_altivec_abi);
   }
 
-  if (Arg *A = Args.getLastArg(options::OPT_Wframe_larger_than_EQ)) {
-StringRef v = A->getValue();
-CmdArgs.push_back("-mllvm");
-CmdArgs.push_back(Args.MakeArgString("-warn-stack-size=" + v));
-A->claim();
-  }
+  if (Args.hasFlag(options::OPT_Wframe_larger_than_EQ,
+   options::OPT_Wno_frame_larger_than_EQ, false))
+if (Arg *A = Args.getLastArg(options::OPT_Wframe_larger_than_EQ)) {
+  StringRef v = A->getValue();
+  CmdArgs.push_back("-mllvm");
+  CmdArgs.push_back(Args.MakeArgString("-warn-stack-size=" + v));
+  A->claim();
+}
 
   if (!Args.hasFlag(options::OPT_fjump_tables, options::OPT_fno_jump_tables,
 true))
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -2500,6 +2500,11 @@
 def Wlarger_than_EQ : Joined<["-"], "Wlarger-than=">, 
Group;
 def Wlarger_than_ : Joined<["-"], "Wlarger-than-">, Alias;
 def Wframe_larger_than_EQ : Joined<["-"], "Wframe-larger-than=">, 
Group, Flags<[NoXarchOption]>;
+def Wno_frame_larger_than_EQ : Joined<["-"], "Wnoframe-larger-than=">, 
Group, Flags<[NoXarchOption]>;
+def Wstack_stack_usage_EQ : Joined<["-"], "Wstack-usage=">, 
Flags<[NoXarchOption]>,
+  Alias;
+def Wno_stack_stack_usage_EQ : Joined<["-"], "Wno-stack-usage=">, 
Flags<[NoXarchOption]>,
+  Alias;
 
 def : Flag<["-"], "fterminated-vtables">, Alias;
 defm threadsafe_statics : BoolFOption<"threadsafe-statics",


Index: clang/test/Frontend/backend-stack-usage-diagnostic.c
===
--- /dev/null
+++ clang/test/Frontend/backend-stack-usage-diagnostic.c
@@ -0,0 +1,17 @@
+// RUN: %clang -Wstack-usage=0 -o /dev/null -c %s 2> %t.err
+// RUN: FileCheck < %t.err %s --check-prefix=WARN
+// RUN: %clang -Wno-stack-usage= -w -o /dev/null -c %s 2> %t.err
+// RUN: FileCheck < %t.err %s --check-prefix=IGNORE --allow-empty
+// RUN: %clang -Wstack-usage=0 -w -o /dev/null -c %s 2> %t.err
+// RUN: FileCheck < %t.err %s --check-prefix=IGNORE --allow-empty
+// RUN: %clang -Wstack-usage=3 -o /dev/null -c %s 2> %t.err
+// RUN: FileCheck < %t.err %s --check-prefix=WARN
+// RUN: %clang -Wstack-usage=100 -o /dev/null -c %s 2> %t.err
+// RUN: FileCheck < %t.err %s --check-prefix=IGNORE --allow-empty
+
+// WARN: warning: stack frame size of {{[0-9]+}} bytes in function 'test_square'
+// IGNORE-NOT:  stack frame size of {{[0-9]+}} bytes in function 'test_square'
+int test_square(int num) {
+  return num * num;
+}
+
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -4762,12 +4762,14 @@
   D.Diag(diag::err_aix_default_altivec_abi);
   }
 
-  if (Arg *A = Args.getLastArg(options::OPT_Wframe_larger_than_EQ)) {
-StringRef v = A->getValue();
-CmdArgs.push_back("-mllvm");
-CmdArgs.push_back(Args.MakeArgString("-warn-stack-size=" + v));
-A->claim();
-  }
+  if (Args.hasFlag(options::OPT_Wframe_larger_than_EQ,
+   

[PATCH] D102592: [sanitizer] Caught global buffer underflow for first variable

2021-05-19 Thread Evgenii Stepanov via Phabricator via cfe-commits
eugenis added a comment.

I think it is too hit-and-miss to add even under a flag. It's just not the 
right approach - but I also don't know what the right approach would be.

Perhaps adding a small left redzone for all globals and reducing the right 
redzone to keep the total size under control? This way when most globals are 
instrumented we get approximately the same amount of redzone between any 2 of 
them, but also a little on the left of the first one.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102592

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


[PATCH] D101973: [OpenMP][NFC] Remove SIMD check lines for non-simd tests

2021-05-19 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert updated this revision to Diff 346579.
jdoerfert added a comment.

Make the script remove leftover `CHECK:` lines that would now trigger given
the absence of a specific check prefix for the -fopenmp-simd invocations.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101973

Files:
  clang/test/OpenMP/cancel_codegen.cpp
  clang/test/OpenMP/cancellation_point_codegen.cpp
  clang/test/OpenMP/debug-info-complex-byval.cpp
  clang/test/OpenMP/debug-info-openmp-array.cpp
  clang/test/OpenMP/distribute_codegen.cpp
  clang/test/OpenMP/distribute_firstprivate_codegen.cpp
  clang/test/OpenMP/distribute_lastprivate_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_firstprivate_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_if_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_lastprivate_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_num_threads_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_private_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_proc_bind_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_reduction_task_codegen.cpp
  clang/test/OpenMP/distribute_private_codegen.cpp
  clang/test/OpenMP/for_firstprivate_codegen.cpp
  clang/test/OpenMP/for_lastprivate_codegen.cpp
  clang/test/OpenMP/for_linear_codegen.cpp
  clang/test/OpenMP/for_private_codegen.cpp
  clang/test/OpenMP/for_reduction_codegen.cpp
  clang/test/OpenMP/for_reduction_task_codegen.cpp
  clang/test/OpenMP/master_taskloop_in_reduction_codegen.cpp
  clang/test/OpenMP/openmp_win_codegen.cpp
  clang/test/OpenMP/parallel_codegen.cpp
  clang/test/OpenMP/parallel_copyin_codegen.cpp
  clang/test/OpenMP/parallel_firstprivate_codegen.cpp
  clang/test/OpenMP/parallel_for_codegen.cpp
  clang/test/OpenMP/parallel_for_lastprivate_conditional.cpp
  clang/test/OpenMP/parallel_for_linear_codegen.cpp
  clang/test/OpenMP/parallel_for_reduction_task_codegen.cpp
  clang/test/OpenMP/parallel_if_codegen.cpp
  clang/test/OpenMP/parallel_master_codegen.cpp
  clang/test/OpenMP/parallel_master_reduction_task_codegen.cpp
  clang/test/OpenMP/parallel_master_taskloop_codegen.cpp
  clang/test/OpenMP/parallel_master_taskloop_lastprivate_codegen.cpp
  clang/test/OpenMP/parallel_private_codegen.cpp
  clang/test/OpenMP/parallel_reduction_codegen.cpp
  clang/test/OpenMP/parallel_reduction_task_codegen.cpp
  clang/test/OpenMP/parallel_sections_codegen.cpp
  clang/test/OpenMP/parallel_sections_reduction_task_codegen.cpp
  clang/test/OpenMP/sections_firstprivate_codegen.cpp
  clang/test/OpenMP/sections_lastprivate_codegen.cpp
  clang/test/OpenMP/sections_private_codegen.cpp
  clang/test/OpenMP/sections_reduction_codegen.cpp
  clang/test/OpenMP/sections_reduction_task_codegen.cpp
  clang/test/OpenMP/single_codegen.cpp
  clang/test/OpenMP/single_firstprivate_codegen.cpp
  clang/test/OpenMP/single_private_codegen.cpp
  clang/test/OpenMP/target_codegen_global_capture.cpp
  clang/test/OpenMP/target_map_codegen_03.cpp
  clang/test/OpenMP/target_parallel_codegen.cpp
  clang/test/OpenMP/target_parallel_for_codegen.cpp
  clang/test/OpenMP/target_parallel_for_reduction_task_codegen.cpp
  clang/test/OpenMP/target_parallel_if_codegen.cpp
  clang/test/OpenMP/target_parallel_num_threads_codegen.cpp
  clang/test/OpenMP/target_parallel_reduction_task_codegen.cpp
  clang/test/OpenMP/target_teams_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_collapse_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_dist_schedule_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_firstprivate_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_lastprivate_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_collapse_codegen.cpp
  
clang/test/OpenMP/target_teams_distribute_parallel_for_dist_schedule_codegen.cpp
  
clang/test/OpenMP/target_teams_distribute_parallel_for_firstprivate_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_if_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_lastprivate_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_order_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_private_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_proc_bind_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_reduction_codegen.cpp
  
clang/test/OpenMP/target_teams_distribute_parallel_for_reduction_task_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_schedule_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_private_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_reduction_codegen.cpp
  clang/test/OpenMP/target_teams_num_teams_codegen.cpp
  clang/test/OpenMP/target_teams_thread_limit_codegen.cpp
  

[PATCH] D102772: [SanitizeCoverage] Add support for NoSanitizeCoverage function attribute

2021-05-19 Thread Marco Elver via Phabricator via cfe-commits
melver updated this revision to Diff 346577.
melver added a comment.
Herald added a subscriber: steven_wu.

Rest of long-tail of IR changes related to introducing a new attributes...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102772

Files:
  clang/docs/SanitizerCoverage.rst
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/CodeGen/sanitize-coverage.c
  llvm/bindings/go/llvm/ir_test.go
  llvm/docs/BitCodeFormat.rst
  llvm/docs/LangRef.rst
  llvm/include/llvm/AsmParser/LLToken.h
  llvm/include/llvm/Bitcode/LLVMBitCodes.h
  llvm/include/llvm/IR/Attributes.td
  llvm/lib/AsmParser/LLLexer.cpp
  llvm/lib/AsmParser/LLParser.cpp
  llvm/lib/Bitcode/Reader/BitcodeReader.cpp
  llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
  llvm/lib/IR/Attributes.cpp
  llvm/lib/IR/Verifier.cpp
  llvm/lib/Transforms/IPO/ForceFunctionAttrs.cpp
  llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
  llvm/lib/Transforms/Utils/CodeExtractor.cpp
  llvm/test/Bitcode/attributes.ll
  llvm/test/Bitcode/compatibility.ll
  llvm/utils/emacs/llvm-mode.el
  llvm/utils/llvm.grm
  llvm/utils/vim/syntax/llvm.vim
  llvm/utils/vscode/llvm/syntaxes/ll.tmLanguage.yaml

Index: llvm/utils/vscode/llvm/syntaxes/ll.tmLanguage.yaml
===
--- llvm/utils/vscode/llvm/syntaxes/ll.tmLanguage.yaml
+++ llvm/utils/vscode/llvm/syntaxes/ll.tmLanguage.yaml
@@ -237,6 +237,7 @@
 \\bnosync\\b|\
 \\bnoundef\\b|\
 \\bnounwind\\b|\
+\\bno_sanitize_coverage\\b|\
 \\bnull_pointer_is_valid\\b|\
 \\boptforfuzzing\\b|\
 \\boptnone\\b|\
Index: llvm/utils/vim/syntax/llvm.vim
===
--- llvm/utils/vim/syntax/llvm.vim
+++ llvm/utils/vim/syntax/llvm.vim
@@ -138,6 +138,7 @@
   \ nosync
   \ noundef
   \ nounwind
+  \ no_sanitize_coverage
   \ null_pointer_is_valid
   \ optforfuzzing
   \ optnone
Index: llvm/utils/llvm.grm
===
--- llvm/utils/llvm.grm
+++ llvm/utils/llvm.grm
@@ -176,6 +176,7 @@
  | sanitize_thread
  | sanitize_memory
  | mustprogress
+ | no_sanitize_coverage
  ;
 
 OptFuncAttrs  ::= + _ | OptFuncAttrs FuncAttr ;
Index: llvm/utils/emacs/llvm-mode.el
===
--- llvm/utils/emacs/llvm-mode.el
+++ llvm/utils/emacs/llvm-mode.el
@@ -25,7 +25,7 @@
'("alwaysinline" "argmemonly" "allocsize" "builtin" "cold" "convergent" "dereferenceable" "dereferenceable_or_null" "hot" "inaccessiblememonly"
  "inaccessiblemem_or_argmemonly" "inalloca" "inlinehint" "jumptable" "minsize" "mustprogress" "naked" "nobuiltin" "nonnull"
  "nocallback" "nocf_check" "noduplicate" "nofree" "noimplicitfloat" "noinline" "nomerge" "nonlazybind" "noprofile" "noredzone" "noreturn"
- "norecurse" "nosync" "noundef" "nounwind" "null_pointer_is_valid" "optforfuzzing" "optnone" "optsize" "preallocated" "readnone" "readonly" "returned" "returns_twice"
+ "norecurse" "nosync" "noundef" "nounwind" "no_sanitize_coverage" "null_pointer_is_valid" "optforfuzzing" "optnone" "optsize" "preallocated" "readnone" "readonly" "returned" "returns_twice"
  "shadowcallstack" "speculatable" "speculative_load_hardening" "ssp" "sspreq" "sspstrong" "safestack" "sanitize_address" "sanitize_hwaddress" "sanitize_memtag"
  "sanitize_thread" "sanitize_memory" "strictfp" "swifterror" "uwtable" "vscale_range" "willreturn" "writeonly" "immarg") 'symbols) . font-lock-constant-face)
;; Variables
Index: llvm/test/Bitcode/compatibility.ll
===
--- llvm/test/Bitcode/compatibility.ll
+++ llvm/test/Bitcode/compatibility.ll
@@ -1510,7 +1510,7 @@
   ; CHECK: select <2 x i1> , <2 x i8> , <2 x i8> 
 
   call void @f.nobuiltin() builtin
-  ; CHECK: call void @f.nobuiltin() #44
+  ; CHECK: call void @f.nobuiltin() #45
 
   call fastcc noalias i32* @f.noalias() noinline
   ; CHECK: call fastcc noalias i32* @f.noalias() #12
@@ -1904,6 +1904,9 @@
   ret void
 }
 
+declare void @f.no_sanitize_coverage() no_sanitize_coverage
+; CHECK: declare void @f.no_sanitize_coverage() #44
+
 ; immarg attribute
 declare void @llvm.test.immarg.intrinsic(i32 immarg)
 ; CHECK: declare void @llvm.test.immarg.intrinsic(i32 immarg)
@@ -1961,7 +1964,8 @@
 ; CHECK: attributes #41 = { writeonly }
 ; CHECK: attributes #42 = { speculatable }
 ; CHECK: attributes #43 = { strictfp }
-; CHECK: attributes #44 = { builtin }
+; CHECK: attributes #44 = { no_sanitize_coverage }
+; CHECK: attributes #45 = { builtin }
 
 ;; Metadata
 
Index: llvm/test/Bitcode/attributes.ll

[PATCH] D102724: Revert "[AIX] Avoid structor alias; die before bad alias codegen"

2021-05-19 Thread Jinsong Ji via Phabricator via cfe-commits
jsji added a comment.

In D102724#2769756 , @jasonliu wrote:

> Good idea, fyi, this is the patch: https://reviews.llvm.org/D83252

Thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102724

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


[PATCH] D102742: [IR] make stack-protector-guard-* flags into module attrs

2021-05-19 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added inline comments.



Comment at: llvm/include/llvm/IR/Module.h:898
 
+  // enum class StackProtectorGuards { None, TLS, Global, SysReg };
+  StringRef getStackProtectorGuard() const;

TODO: delete this comment


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102742

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


[PATCH] D102742: [IR] make stack-protector-guard-* flags into module attrs

2021-05-19 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers planned changes to this revision.
nickdesaulniers added inline comments.



Comment at: clang/lib/CodeGen/CodeGenModule.cpp:776-783
+  if (getCodeGenOpts().StackProtectorGuard != "")
+getModule().setStackProtectorGuard(getCodeGenOpts().StackProtectorGuard);
+  if (getCodeGenOpts().StackProtectorGuardReg != "none")
+getModule().setStackProtectorGuardReg(
+getCodeGenOpts().StackProtectorGuardReg);
+  if (getCodeGenOpts().StackProtectorGuardOffset != INT_MAX)
+getModule().setStackProtectorGuardOffset(

I should add tests for these; that clang emits these module attributes as 
expected.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102742

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


[PATCH] D102633: [clang-scan-deps] Improvements to thread usage

2021-05-19 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added a reviewer: aganea.
arphaman added a comment.

It might be good for @aganea to take a look as well.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102633

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


[PATCH] D102742: [IR] make stack-protector-guard-* flags into module attrs

2021-05-19 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers updated this revision to Diff 346573.
nickdesaulniers added a comment.
Herald added a subscriber: pengfei.

- remove TargetOption members, update tests


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102742

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  llvm/include/llvm/CodeGen/CommandFlags.h
  llvm/include/llvm/IR/Module.h
  llvm/include/llvm/Target/TargetOptions.h
  llvm/lib/CodeGen/CommandFlags.cpp
  llvm/lib/CodeGen/StackProtector.cpp
  llvm/lib/IR/Module.cpp
  llvm/lib/Target/AArch64/AArch64InstrInfo.cpp
  llvm/lib/Target/X86/X86ISelLowering.cpp
  llvm/test/CodeGen/AArch64/stack-guard-sysreg.ll
  llvm/test/CodeGen/X86/stack-protector-3.ll

Index: llvm/test/CodeGen/X86/stack-protector-3.ll
===
--- llvm/test/CodeGen/X86/stack-protector-3.ll
+++ llvm/test/CodeGen/X86/stack-protector-3.ll
@@ -1,10 +1,18 @@
-; RUN: llc -mtriple=x86_64-pc-linux-gnu -o - < %s | FileCheck --check-prefix=CHECK-TLS-FS-40 %s
-; RUN: llc -mtriple=x86_64-pc-linux-gnu -stack-protector-guard=tls -o - < %s | FileCheck --check-prefix=CHECK-TLS-FS-40 %s
-; RUN: llc -mtriple=x86_64-pc-linux-gnu -stack-protector-guard=global -o - < %s | FileCheck --check-prefix=CHECK-GLOBAL %s
-; RUN: llc -mtriple=x86_64-pc-linux-gnu -stack-protector-guard-reg=fs -o - < %s | FileCheck --check-prefix=CHECK-TLS-FS-40 %s
-; RUN: llc -mtriple=x86_64-pc-linux-gnu -stack-protector-guard-reg=gs -o - < %s | FileCheck --check-prefix=CHECK-GS %s
-; RUN: llc -mtriple=x86_64-pc-linux-gnu -stack-protector-guard-offset=20 -o - < %s | FileCheck --check-prefix=CHECK-OFFSET %s
-; RUN: llc -mtriple=x86_64-pc-linux-gnu -stack-protector-guard-offset=-20 -o - < %s | FileCheck --check-prefix=CHECK-NEGATIVE-OFFSET %s
+; RUN: split-file %s %t
+; RUN: cat %t/main.ll %t/a.ll > %t/a2.ll
+; RUN: cat %t/main.ll %t/b.ll > %t/b2.ll
+; RUN: cat %t/main.ll %t/c.ll > %t/c2.ll
+; RUN: cat %t/main.ll %t/d.ll > %t/d2.ll
+; RUN: cat %t/main.ll %t/e.ll > %t/e2.ll
+; RUN: cat %t/main.ll %t/f.ll > %t/f2.ll
+; RUN: cat %t/main.ll %t/g.ll > %t/g2.ll
+; RUN: llc -mtriple=x86_64-pc-linux-gnu -o - < %t/a2.ll | FileCheck --check-prefix=CHECK-TLS-FS-40 %s
+; RUN: llc -mtriple=x86_64-pc-linux-gnu -o - < %t/b2.ll | FileCheck --check-prefix=CHECK-TLS-FS-40 %s
+; RUN: llc -mtriple=x86_64-pc-linux-gnu -o - < %t/c2.ll | FileCheck --check-prefix=CHECK-GLOBAL %s
+; RUN: llc -mtriple=x86_64-pc-linux-gnu -o - < %t/d2.ll | FileCheck --check-prefix=CHECK-TLS-FS-40 %s
+; RUN: llc -mtriple=x86_64-pc-linux-gnu -o - < %t/e2.ll | FileCheck --check-prefix=CHECK-GS %s
+; RUN: llc -mtriple=x86_64-pc-linux-gnu -o - < %t/f2.ll | FileCheck --check-prefix=CHECK-OFFSET %s
+; RUN: llc -mtriple=x86_64-pc-linux-gnu -o - < %t/g2.ll | FileCheck --check-prefix=CHECK-NEGATIVE-OFFSET %s
 
 ; CHECK-TLS-FS-40:   movq%fs:40, %rax
 ; CHECK-TLS-FS-40:   movq%fs:40, %rax
@@ -47,6 +55,8 @@
 ; CHECK-GLOBAL-NEXT:  .cfi_def_cfa_offset 32
 ; CHECK-GLOBAL-NEXT:  callq   __stack_chk_fail
 
+;--- main.ll
+
 ; ModuleID = 't.c'
 @.str = private unnamed_addr constant [14 x i8] c"stackoverflow\00", align 1
 @a = dso_local local_unnamed_addr global i8* null, align 8
@@ -75,3 +85,23 @@
 attributes #0 = { nounwind sspreq uwtable writeonly "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "frame-pointer"="none" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" "unsafe-fp-math"="false" "use-soft-float"="false" }
 attributes #1 = { argmemonly nounwind willreturn }
 attributes #2 = { nounwind }
+
+;--- a.ll
+;--- b.ll
+!llvm.module.flags = !{!1}
+!1 = !{i32 2, !"stack-protector-guard", !"tls"}
+;--- c.ll
+!llvm.module.flags = !{!1}
+!1 = !{i32 2, !"stack-protector-guard", !"global"}
+;--- d.ll
+!llvm.module.flags = !{!1}
+!1 = !{i32 2, !"stack-protector-guard-reg", !"fs"}
+;--- e.ll
+!llvm.module.flags = !{!1}
+!1 = !{i32 2, !"stack-protector-guard-reg", !"gs"}
+;--- f.ll
+!llvm.module.flags = !{!1}
+!1 = !{i32 2, !"stack-protector-guard-offset", i32 20}
+;--- g.ll
+!llvm.module.flags = !{!1}
+!1 = !{i32 2, !"stack-protector-guard-offset", i32 -20}
Index: llvm/test/CodeGen/AArch64/stack-guard-sysreg.ll
===
--- llvm/test/CodeGen/AArch64/stack-guard-sysreg.ll
+++ llvm/test/CodeGen/AArch64/stack-guard-sysreg.ll
@@ -1,46 +1,39 @@
-; RUN: llc %s --stack-protector-guard=sysreg \
-; RUN:   --stack-protector-guard-reg=sp_el0 \
-; RUN:   --stack-protector-guard-offset=0 -verify-machineinstrs -o - | \
+; RUN: split-file %s %t
+; RUN: cat %t/main.ll %t/a.ll > %t/a2.ll
+; RUN: cat %t/main.ll 

[PATCH] D102724: Revert "[AIX] Avoid structor alias; die before bad alias codegen"

2021-05-19 Thread Jason Liu via Phabricator via cfe-commits
jasonliu added a comment.

Good idea, fyi, this is the patch: https://reviews.llvm.org/D83252


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102724

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


[PATCH] D102736: Fix tmp files being left on Windows builds.

2021-05-19 Thread Amy Huang via Phabricator via cfe-commits
akhuang added a comment.

In D102736#2769358 , @amccarth wrote:

> At some point, the duplicate handle must be closed.  I don't see that 
> happening.  I've added an inline comment where I think it should be done.
>
> (I find it weird that duplicating the handle seems necessary.)
>
> At a high level, it seems a shame that `llvm::support::fs` doesn't have 
> create-temporary-file and keep-temporary-file operations to hide all this 
> detail from the frontend.

So, there is a `TempFile` class in `llvm::support::fs` with create temp file 
and keep temp file operations, and it would be nice to use that. The issue I 
was running into is that it uses a file descriptor (`int fd`) to keep track of 
the file, but for some reason, the function to convert the fd to a handle 
(`_get_osfhandle`) was not working (exits the program when called). I haven't 
yet figured out why this is happening


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102736

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


[PATCH] D102814: [AIX] Print printable byte list as quoted string

2021-05-19 Thread Jinsong Ji via Phabricator via cfe-commits
jsji created this revision.
jsji added reviewers: PowerPC, hubert.reinterpretcast, DiggerLin, xingxue, 
shchenz.
Herald added subscribers: hiraditya, nemanjai.
jsji requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

.byte supports string, so if the whole byte list are printable,
we can actually print the string for readability and LIT tests maintainence.

  .byte 'H,'e,'l,'l,'o,',,' ,'w,'o,'r,'l,'d

->

  .byte "Hello, world"


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D102814

Files:
  clang/test/CodeGenCXX/debug-info-byval.cpp
  llvm/lib/MC/MCAsmStreamer.cpp
  llvm/test/CodeGen/PowerPC/aix-emit-tracebacktable-clobber-register.ll
  llvm/test/CodeGen/PowerPC/aix-emit-tracebacktable.ll
  llvm/test/CodeGen/PowerPC/aix-exception.ll
  llvm/test/CodeGen/PowerPC/aix-xcoff-data.ll
  llvm/test/CodeGen/PowerPC/aix-xcoff-rodata.ll
  llvm/test/DebugInfo/XCOFF/empty.ll
  llvm/test/DebugInfo/XCOFF/explicit-section.ll
  llvm/test/DebugInfo/XCOFF/function-sections.ll

Index: llvm/test/DebugInfo/XCOFF/function-sections.ll
===
--- llvm/test/DebugInfo/XCOFF/function-sections.ll
+++ llvm/test/DebugInfo/XCOFF/function-sections.ll
@@ -72,7 +72,7 @@
 ; CHECK-NEXT:  .byte   0x01# NumberOfFPParms = 0, +HasParmsOnStack
 ; CHECK-NEXT:  .vbyte  4, L..foo0-.foo[PR] # Function size
 ; CHECK-NEXT:  .vbyte  2, 0x0003   # Function name len = 3
-; CHECK-NEXT:  .byte   'f,'o,'o# Function Name
+; CHECK-NEXT:  .byte   "foo"   # Function Name
 ; CHECK-NEXT:  L..func_end0:
 ; CHECK-NEXT:  # -- End function
 ; CHECK-NEXT:  .csect .bar[PR],2
@@ -108,7 +108,7 @@
 ; CHECK-NEXT:  .byte   0x01# NumberOfFPParms = 0, +HasParmsOnStack
 ; CHECK-NEXT:  .vbyte  4, L..bar0-.bar[PR] # Function size
 ; CHECK-NEXT:  .vbyte  2, 0x0003   # Function name len = 3
-; CHECK-NEXT:  .byte   'b,'a,'r# Function Name
+; CHECK-NEXT:  .byte   "bar"   # Function Name
 ; CHECK-NEXT:  L..func_end1:
 ; CHECK-NEXT:  # -- End function
 ; CHECK-NEXT:  L..sec_end0:
@@ -258,10 +258,10 @@
 ; CHECK-NEXT:  .byte   0
 ; CHECK-NEXT:  .byte   0
 ; CHECK-NEXT:  .byte   1
-; CHECK-NEXT:  .byte   'd,'e,'b,'u,'g
+; CHECK-NEXT:  .byte   "debug"
 ; CHECK-NEXT:  .byte   0
 ; CHECK-NEXT:  .byte   0
-; CHECK-NEXT:  .byte   '1,'.,'c
+; CHECK-NEXT:  .byte   "1.c"
 ; CHECK-NEXT:  .byte   0
 ; CHECK-NEXT:  .byte   1
 ; CHECK-NEXT:  .byte   0
Index: llvm/test/DebugInfo/XCOFF/explicit-section.ll
===
--- llvm/test/DebugInfo/XCOFF/explicit-section.ll
+++ llvm/test/DebugInfo/XCOFF/explicit-section.ll
@@ -77,7 +77,7 @@
 ; CHECK-NEXT:  .byte   0x01# NumberOfFPParms = 0, +HasParmsOnStack
 ; CHECK-NEXT:  .vbyte  4, L..bar0-.bar # Function size
 ; CHECK-NEXT:  .vbyte  2, 0x0003   # Function name len = 3
-; CHECK-NEXT:  .byte   'b,'a,'r# Function Name
+; CHECK-NEXT:  .byte   "bar"   # Function Name
 ; CHECK-NEXT:  L..func_end0:
 ; CHECK-NEXT:  # -- End function
 ; CHECK-NEXT:  .csect explicit_main_sec[PR],2
@@ -125,7 +125,7 @@
 ; CHECK-NEXT:  .byte   0x01# NumberOfFPParms = 0, +HasParmsOnStack
 ; CHECK-NEXT:  .vbyte  4, L..main0-.main   # Function size
 ; CHECK-NEXT:  .vbyte  2, 0x0004   # Function name len = 4
-; CHECK-NEXT:  .byte   'm,'a,'i,'n # Function Name
+; CHECK-NEXT:  .byte   "main"  # Function Name
 ; CHECK-NEXT:  L..func_end1:
 ; CHECK-NEXT:  # -- End function
 ; CHECK-NEXT:  L..sec_end0:
@@ -271,10 +271,10 @@
 ; CHECK-NEXT:  .byte   0
 ; CHECK-NEXT:  .byte   0
 ; CHECK-NEXT:  .byte   1
-; CHECK-NEXT:  .byte   'd,'e,'b,'u,'g
+; CHECK-NEXT:  .byte   "debug"
 ; CHECK-NEXT:  .byte   0
 ; CHECK-NEXT:  .byte   0
-; CHECK-NEXT:  .byte   '2,'.,'c
+; CHECK-NEXT:  .byte   "2.c"
 ; CHECK-NEXT:  .byte   0
 ; CHECK-NEXT:  .byte   1
 ; CHECK-NEXT:  .byte   0
Index: llvm/test/DebugInfo/XCOFF/empty.ll
===
--- llvm/test/DebugInfo/XCOFF/empty.ll
+++ llvm/test/DebugInfo/XCOFF/empty.ll
@@ 

[PATCH] D102724: Revert "[AIX] Avoid structor alias; die before bad alias codegen"

2021-05-19 Thread Jinsong Ji via Phabricator via cfe-commits
jsji added a comment.

> because AIX now has an alias implementation.

Can we please include the patches or commits that implement the alias?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102724

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


[PATCH] D102812: [clang] Don't pass multiple backend options if mixing -mimplicit-it and -Wa,-mimplicit-it

2021-05-19 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo updated this revision to Diff 346568.
mstorsjo added a comment.

Rebased on top of the revert.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102812

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/arm-target-as-mimplicit-it.s

Index: clang/test/Driver/arm-target-as-mimplicit-it.s
===
--- clang/test/Driver/arm-target-as-mimplicit-it.s
+++ clang/test/Driver/arm-target-as-mimplicit-it.s
@@ -10,22 +10,22 @@
 // RUN: %clang -target arm-linux-gnueabi -### -Xassembler -mimplicit-it=arm %s 2>&1 | FileCheck %s --check-prefix=ARM
 // RUN: %clang -target arm-linux-gnueabi -### -Xassembler -mimplicit-it=thumb %s 2>&1 | FileCheck %s --check-prefix=THUMB
 /// Test space separated -Wa,- arguments (latter wins).
+// RUN: %clang -target arm-linux-gnueabi -### -Wa,-mimplicit-it=always -Wa,-mimplicit-it=always %s 2>&1 | FileCheck %s --check-prefix=ALWAYS
 // RUN: %clang -target arm-linux-gnueabi -### -Wa,-mimplicit-it=never -Wa,-mimplicit-it=always %s 2>&1 | FileCheck %s --check-prefix=ALWAYS
 // RUN: %clang -target arm-linux-gnueabi -### -Wa,-mimplicit-it=always -Wa,-mimplicit-it=never %s 2>&1 | FileCheck %s --check-prefix=NEVER
 // RUN: %clang -target arm-linux-gnueabi -### -Wa,-mimplicit-it=always -Wa,-mimplicit-it=arm %s 2>&1 | FileCheck %s --check-prefix=ARM
 // RUN: %clang -target arm-linux-gnueabi -### -Wa,-mimplicit-it=always -Wa,-mimplicit-it=thumb %s 2>&1 | FileCheck %s --check-prefix=THUMB
 /// Test comma separated -Wa,- arguments (latter wins).
+// RUN: %clang -target arm-linux-gnueabi -### -Wa,-mimplicit-it=always,-mimplicit-it=always %s 2>&1 | FileCheck %s --check-prefix=ALWAYS
 // RUN: %clang -target arm-linux-gnueabi -### -Wa,-mimplicit-it=never,-mimplicit-it=always %s 2>&1 | FileCheck %s --check-prefix=ALWAYS
 // RUN: %clang -target arm-linux-gnueabi -### -Wa,-mimplicit-it=always,-mimplicit-it=never %s 2>&1 | FileCheck %s --check-prefix=NEVER
 // RUN: %clang -target arm-linux-gnueabi -### -Wa,-mimplicit-it=always,-mimplicit-it=arm %s 2>&1 | FileCheck %s --check-prefix=ARM
 // RUN: %clang -target arm-linux-gnueabi -### -Wa,-mimplicit-it=always,-mimplicit-it=thumb %s 2>&1 | FileCheck %s --check-prefix=THUMB
 
-/// Mix -implicit-it= (compiler) with -Wa,-mimplicit-it= (assembler), assembler
-/// takes priority. -mllvm -arm-implicit-it= will be repeated, with the
-/// assembler flag appearing last (latter wins).
-// RUN: %clang -target arm-linux-gnueabi -### -mimplicit-it=never -Wa,-mimplicit-it=always %S/Inputs/wildcard1.c 2>&1 | FileCheck %s --check-prefix=NEVER_ALWAYS
-// RUN: %clang -target arm-linux-gnueabi -### -mimplicit-it=always -Wa,-mimplicit-it=never %S/Inputs/wildcard1.c 2>&1 | FileCheck %s --check-prefix=ALWAYS_NEVER
-// RUN: %clang -target arm-linux-gnueabi -### -Wa,-mimplicit-it=never -mimplicit-it=always %S/Inputs/wildcard1.c 2>&1 | FileCheck %s --check-prefix=ALWAYS_NEVER
+/// Mix -implicit-it= (compiler) with -Wa,-mimplicit-it= (assembler). If
+/// they match, emit only one argument, if mismatch, error out.
+// RUN: %clang -target arm-linux-gnueabi -### -mimplicit-it=always -Wa,-mimplicit-it=always %S/Inputs/wildcard1.c 2>&1 | FileCheck %s --check-prefix=ALWAYS
+// RUN: %clang -target arm-linux-gnueabi -### -mimplicit-it=never -Wa,-mimplicit-it=always %S/Inputs/wildcard1.c 2>&1 | FileCheck %s --check-prefix=MISMATCH
 
 /// Test invalid input.
 // RUN: %clang -target arm-linux-gnueabi -### -Wa,-mimplicit-it=foo %s 2>&1 | FileCheck %s --check-prefix=INVALID
@@ -34,11 +34,13 @@
 // RUN: %clang -target arm-linux-gnueabi -### -Wa,-mimplicit-it=always,-mimplicit-it=foo %s 2>&1 | FileCheck %s --check-prefix=INVALID
 
 
+/// Check that there isn't a second -arm-implicit-it following the matched one.
 // ALWAYS: "-mllvm" "-arm-implicit-it=always"
+// ALWAYS-NOT: "-arm-implicit-it={{.*}}"
 // NEVER: "-mllvm" "-arm-implicit-it=never"
+// NEVER-NOT: "-arm-implicit-it={{.*}}"
 // ARM: "-mllvm" "-arm-implicit-it=arm"
 // THUMB: "-mllvm" "-arm-implicit-it=thumb"
-// NEVER_ALWAYS: "-mllvm" "-arm-implicit-it=never" "-mllvm" "-arm-implicit-it=always"
-// ALWAYS_NEVER: "-mllvm" "-arm-implicit-it=always" "-mllvm" "-arm-implicit-it=never"
+// MISMATCH: error: unsupported argument '{{.*}}' to option '-mimplicit-it'
 // INVALID: error: unsupported argument '-mimplicit-it=foo' to option 'Wa,'
 // XINVALID: error: unsupported argument '-mimplicit-it=foo' to option 'Xassembler'
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -2366,15 +2366,15 @@
   DumpCompilationDatabase(C, "", Target, Output, Input, Args);
 }
 
-static bool AddARMImplicitITArgs(const ArgList , ArgStringList ,
+static bool CheckARMImplicitITArg(StringRef Value) {
+  return Value == "always" || Value == "never" || Value == 

[clang] 688b917 - Revert "[Driver] Delete -mimplicit-it="

2021-05-19 Thread Martin Storsjö via cfe-commits

Author: Martin Storsjö
Date: 2021-05-20T00:17:50+03:00
New Revision: 688b917b4b3cbe09bf4954b2c10b01ef57386c0a

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

LOG: Revert "[Driver] Delete -mimplicit-it="

This reverts commit 2919222d8017f2425a85765b95e4b7c6f8e70ca4.

That commit broke backwards compatibility. Additionally, the
replacement, -Wa,-mimplicit-it, isn't yet supported by any stable
release of Clang.

See D102812 for a fix for the error cases when callers specify both
-mimplicit-it and -Wa,-mimplicit-it.

Added: 
clang/test/Driver/arm-implicit-it.s

Modified: 
clang/include/clang/Driver/Options.td
clang/lib/Driver/ToolChains/Clang.cpp
clang/test/Driver/arm-target-as-mimplicit-it.s
clang/test/Driver/as-options.s

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 1b78810bf352..1274f7a0af2e 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -3017,6 +3017,7 @@ def mtls_size_EQ : Joined<["-"], "mtls-size=">, 
Group, Flags<[NoXarchOp
   HelpText<"Specify bit size of immediate TLS offsets (AArch64 ELF only): "
"12 (for 4KB) | 24 (for 16MB, default) | 32 (for 4GB) | 48 (for 
256TB, needs -mcmodel=large)">,
   MarshallingInfoInt>;
+def mimplicit_it_EQ : Joined<["-"], "mimplicit-it=">, Group;
 def mdefault_build_attributes : Joined<["-"], "mdefault-build-attributes">, 
Group;
 def mno_default_build_attributes : Joined<["-"], 
"mno-default-build-attributes">, Group;
 def mconstant_cfstrings : Flag<["-"], "mconstant-cfstrings">, 
Group;

diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index add62e3ab4ab..2ef635469df0 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -2393,6 +2393,22 @@ static void 
CollectArgsForIntegratedAssembler(Compilation ,
DefaultIncrementalLinkerCompatible))
 CmdArgs.push_back("-mincremental-linker-compatible");
 
+  switch (C.getDefaultToolChain().getArch()) {
+  case llvm::Triple::arm:
+  case llvm::Triple::armeb:
+  case llvm::Triple::thumb:
+  case llvm::Triple::thumbeb:
+if (Arg *A = Args.getLastArg(options::OPT_mimplicit_it_EQ)) {
+  StringRef Value = A->getValue();
+  if (!AddARMImplicitITArgs(Args, CmdArgs, Value))
+D.Diag(diag::err_drv_unsupported_option_argument)
+<< A->getOption().getName() << Value;
+}
+break;
+  default:
+break;
+  }
+
   // If you add more args here, also add them to the block below that
   // starts with "// If CollectArgsForIntegratedAssembler() isn't called 
below".
 
@@ -4337,6 +4353,16 @@ void Clang::ConstructJob(Compilation , const JobAction 
,
   Args.ClaimAllArgs(options::OPT_mno_relax_all);
   Args.ClaimAllArgs(options::OPT_mincremental_linker_compatible);
   Args.ClaimAllArgs(options::OPT_mno_incremental_linker_compatible);
+  switch (C.getDefaultToolChain().getArch()) {
+  case llvm::Triple::arm:
+  case llvm::Triple::armeb:
+  case llvm::Triple::thumb:
+  case llvm::Triple::thumbeb:
+Args.ClaimAllArgs(options::OPT_mimplicit_it_EQ);
+break;
+  default:
+break;
+  }
 }
 Args.ClaimAllArgs(options::OPT_Wa_COMMA);
 Args.ClaimAllArgs(options::OPT_Xassembler);

diff  --git a/clang/test/Driver/arm-implicit-it.s 
b/clang/test/Driver/arm-implicit-it.s
new file mode 100644
index ..48e4bdbe8c95
--- /dev/null
+++ b/clang/test/Driver/arm-implicit-it.s
@@ -0,0 +1,24 @@
+// RUN: %clang -target armv7--none-eabi -### %s 2>&1 \
+// RUN:| FileCheck %s -check-prefix CHECK-DEFAULT
+
+// RUN: %clang -target armv7--none-eabi -mimplicit-it=arm -### %s 2>&1 \
+// RUN:| FileCheck %s -check-prefix CHECK-ARM
+
+// RUN: %clang -target armv7--none-eabi -mimplicit-it=thumb -### %s 2>&1 \
+// RUN:| FileCheck %s -check-prefix CHECK-THUMB
+
+// RUN: %clang -target armv7--none-eabi -mimplicit-it=never -### %s 2>&1 \
+// RUN:| FileCheck %s -check-prefix CHECK-NEVER
+
+// RUN: %clang -target armv7--none-eabi -mimplicit-it=always -### %s 2>&1 \
+// RUN:| FileCheck %s -check-prefix CHECK-ALWAYS
+
+// RUN: %clang -target armv7--none-eabi -mimplicit-it=thisisnotavalidoption 
-### %s 2>&1 \
+// RUN:| FileCheck %s -check-prefix CHECK-INVALID
+
+// CHECK-DEFAULT-NOT: "-arm-implicit-it
+// CHECK-ARM: "-arm-implicit-it=arm"
+// CHECK-THUMB: "-arm-implicit-it=thumb"
+// CHECK-NEVER: "-arm-implicit-it=never"
+// CHECK-ALWAYS: "-arm-implicit-it=always"
+// CHECK-INVALID: error: unsupported argument 'thisisnotavalidoption' to 
option 'mimplicit-it='

diff  --git a/clang/test/Driver/arm-target-as-mimplicit-it.s 
b/clang/test/Driver/arm-target-as-mimplicit-it.s

[PATCH] D102812: [clang] Don't pass multiple backend options if mixing -mimplicit-it and -Wa,-mimplicit-it

2021-05-19 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo created this revision.
mstorsjo added reviewers: MaskRay, nickdesaulniers, raj.khem.
Herald added a subscriber: kristof.beyls.
mstorsjo requested review of this revision.
Herald added a project: clang.

If multiple instances of the -arm-implicit-it option is passed to
the backend, it errors out.

Also fix cases where there are multiple -Wa,-mimplicit-it; the existing
tests indicate that the last one specified takes effect, while in
practice it passed double options, which didn't work as intended.

This goes on top of a reverted 2919222d8017f2425a85765b95e4b7c6f8e70ca4 
.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D102812

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/arm-target-as-mimplicit-it.s

Index: clang/test/Driver/arm-target-as-mimplicit-it.s
===
--- clang/test/Driver/arm-target-as-mimplicit-it.s
+++ clang/test/Driver/arm-target-as-mimplicit-it.s
@@ -10,22 +10,22 @@
 // RUN: %clang -target arm-linux-gnueabi -### -Xassembler -mimplicit-it=arm %s 2>&1 | FileCheck %s --check-prefix=ARM
 // RUN: %clang -target arm-linux-gnueabi -### -Xassembler -mimplicit-it=thumb %s 2>&1 | FileCheck %s --check-prefix=THUMB
 /// Test space separated -Wa,- arguments (latter wins).
+// RUN: %clang -target arm-linux-gnueabi -### -Wa,-mimplicit-it=always -Wa,-mimplicit-it=always %s 2>&1 | FileCheck %s --check-prefix=ALWAYS
 // RUN: %clang -target arm-linux-gnueabi -### -Wa,-mimplicit-it=never -Wa,-mimplicit-it=always %s 2>&1 | FileCheck %s --check-prefix=ALWAYS
 // RUN: %clang -target arm-linux-gnueabi -### -Wa,-mimplicit-it=always -Wa,-mimplicit-it=never %s 2>&1 | FileCheck %s --check-prefix=NEVER
 // RUN: %clang -target arm-linux-gnueabi -### -Wa,-mimplicit-it=always -Wa,-mimplicit-it=arm %s 2>&1 | FileCheck %s --check-prefix=ARM
 // RUN: %clang -target arm-linux-gnueabi -### -Wa,-mimplicit-it=always -Wa,-mimplicit-it=thumb %s 2>&1 | FileCheck %s --check-prefix=THUMB
 /// Test comma separated -Wa,- arguments (latter wins).
+// RUN: %clang -target arm-linux-gnueabi -### -Wa,-mimplicit-it=always,-mimplicit-it=always %s 2>&1 | FileCheck %s --check-prefix=ALWAYS
 // RUN: %clang -target arm-linux-gnueabi -### -Wa,-mimplicit-it=never,-mimplicit-it=always %s 2>&1 | FileCheck %s --check-prefix=ALWAYS
 // RUN: %clang -target arm-linux-gnueabi -### -Wa,-mimplicit-it=always,-mimplicit-it=never %s 2>&1 | FileCheck %s --check-prefix=NEVER
 // RUN: %clang -target arm-linux-gnueabi -### -Wa,-mimplicit-it=always,-mimplicit-it=arm %s 2>&1 | FileCheck %s --check-prefix=ARM
 // RUN: %clang -target arm-linux-gnueabi -### -Wa,-mimplicit-it=always,-mimplicit-it=thumb %s 2>&1 | FileCheck %s --check-prefix=THUMB
 
-/// Mix -implicit-it= (compiler) with -Wa,-mimplicit-it= (assembler), assembler
-/// takes priority. -mllvm -arm-implicit-it= will be repeated, with the
-/// assembler flag appearing last (latter wins).
-// RUN: %clang -target arm-linux-gnueabi -### -mimplicit-it=never -Wa,-mimplicit-it=always %S/Inputs/wildcard1.c 2>&1 | FileCheck %s --check-prefix=NEVER_ALWAYS
-// RUN: %clang -target arm-linux-gnueabi -### -mimplicit-it=always -Wa,-mimplicit-it=never %S/Inputs/wildcard1.c 2>&1 | FileCheck %s --check-prefix=ALWAYS_NEVER
-// RUN: %clang -target arm-linux-gnueabi -### -Wa,-mimplicit-it=never -mimplicit-it=always %S/Inputs/wildcard1.c 2>&1 | FileCheck %s --check-prefix=ALWAYS_NEVER
+/// Mix -implicit-it= (compiler) with -Wa,-mimplicit-it= (assembler). If
+/// they match, emit only one argument, if mismatch, error out.
+// RUN: %clang -target arm-linux-gnueabi -### -mimplicit-it=always -Wa,-mimplicit-it=always %S/Inputs/wildcard1.c 2>&1 | FileCheck %s --check-prefix=ALWAYS
+// RUN: %clang -target arm-linux-gnueabi -### -mimplicit-it=never -Wa,-mimplicit-it=always %S/Inputs/wildcard1.c 2>&1 | FileCheck %s --check-prefix=MISMATCH
 
 /// Test invalid input.
 // RUN: %clang -target arm-linux-gnueabi -### -Wa,-mimplicit-it=foo %s 2>&1 | FileCheck %s --check-prefix=INVALID
@@ -34,11 +34,13 @@
 // RUN: %clang -target arm-linux-gnueabi -### -Wa,-mimplicit-it=always,-mimplicit-it=foo %s 2>&1 | FileCheck %s --check-prefix=INVALID
 
 
+/// Check that there isn't a second -arm-implicit-it following the matched one.
 // ALWAYS: "-mllvm" "-arm-implicit-it=always"
+// ALWAYS-NOT: "-arm-implicit-it={{.*}}"
 // NEVER: "-mllvm" "-arm-implicit-it=never"
+// NEVER-NOT: "-arm-implicit-it={{.*}}"
 // ARM: "-mllvm" "-arm-implicit-it=arm"
 // THUMB: "-mllvm" "-arm-implicit-it=thumb"
-// NEVER_ALWAYS: "-mllvm" "-arm-implicit-it=never" "-mllvm" "-arm-implicit-it=always"
-// ALWAYS_NEVER: "-mllvm" "-arm-implicit-it=always" "-mllvm" "-arm-implicit-it=never"
+// MISMATCH: error: unsupported argument '{{.*}}' to option '-mimplicit-it'
 // INVALID: error: unsupported argument '-mimplicit-it=foo' to option 'Wa,'
 // XINVALID: error: unsupported argument '-mimplicit-it=foo' to option 

[PATCH] D102469: [sanitizer] Reduce redzone size for small size global objects

2021-05-19 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added a comment.

Do you need help with landing thin?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102469

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


[PATCH] D102469: [sanitizer] Reduce redzone size for small size global objects

2021-05-19 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added inline comments.



Comment at: llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp:2556
+  uint64_t RZ = 0;
+  if (SizeInBytes < MinRZ / 2) {
+// Reduce redzone size for small size objects, e.g. int, char[1]. MinRZ is

MaskRay wrote:
> I wonder whether 16-byte array should use this optimization as well (i.e. `<` 
> => `<=`)
> 
> @vitalybuka 
Agree, <= cutoff looks better here


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102469

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


[PATCH] D102724: Revert "[AIX] Avoid structor alias; die before bad alias codegen"

2021-05-19 Thread Jason Liu via Phabricator via cfe-commits
jasonliu accepted this revision.
jasonliu 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/D102724/new/

https://reviews.llvm.org/D102724

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


[PATCH] D102568: [Driver] Delete -mimplicit-it=

2021-05-19 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added inline comments.



Comment at: clang/test/Driver/arm-target-as-mimplicit-it.s:18
 /// Test comma separated -Wa,- arguments (latter wins).
 // RUN: %clang -target arm-linux-gnueabi -### 
-Wa,-mimplicit-it=never,-mimplicit-it=always %s 2>&1 | FileCheck %s 
--check-prefix=ALWAYS
 // RUN: %clang -target arm-linux-gnueabi -### 
-Wa,-mimplicit-it=always,-mimplicit-it=never %s 2>&1 | FileCheck %s 
--check-prefix=NEVER

I noted another discrepancy here; the tests seem to suggest that you can pass 
multiple `-Wa,-mimplicit-it=` and only the last one will take effect, while in 
practice this will cause backend errors. I'll fix that at the same time.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102568

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


[PATCH] D102807: Revert "[AIX] Avoid structor alias; die before bad alias codegen"

2021-05-19 Thread Jake Egan via Phabricator via cfe-commits
Jake-Egan abandoned this revision.
Jake-Egan added a comment.

Duplicate.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102807

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


[PATCH] D102724: Revert "[AIX] Avoid structor alias; die before bad alias codegen"

2021-05-19 Thread Jake Egan via Phabricator via cfe-commits
Jake-Egan updated this revision to Diff 346560.
Jake-Egan added a comment.

Added the changes jasonliu asked for.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102724

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/aix-constructor-alias.c


Index: clang/test/Driver/aix-constructor-alias.c
===
--- clang/test/Driver/aix-constructor-alias.c
+++ clang/test/Driver/aix-constructor-alias.c
@@ -1,7 +1,7 @@
-// Check that we don't pass -mconstructor-aliases when compiling for AIX.
+// Check that we pass -mconstructor-aliases when compiling for AIX.
 
 // RUN: %clang -### -target powerpc-ibm-aix7.1.0.0 %s -c -o %t.o 2>&1 \
 // RUN:   | FileCheck %s
 // RUN: %clang -### -target powerpc64-ibm-aix7.1.0.0 %s -c -o %t.o 2>&1 \
 // RUN:   | FileCheck %s
-// CHECK-NOT: "-mconstructor-aliases"
+// CHECK: "-mconstructor-aliases"
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -4973,10 +4973,8 @@
 
   // 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. Similarly, aliases aren't yet supported
-  // for AIX.
-  if (!RawTriple.isOSDarwin() && !RawTriple.isNVPTX() &&
-  !RawTriple.isAMDGPU() && !RawTriple.isOSAIX())
+  // where aliases aren't supported.
+  if (!RawTriple.isOSDarwin() && !RawTriple.isNVPTX() && !RawTriple.isAMDGPU())
 CmdArgs.push_back("-mconstructor-aliases");
 
   // Darwin's kernel doesn't support guard variables; just die if we


Index: clang/test/Driver/aix-constructor-alias.c
===
--- clang/test/Driver/aix-constructor-alias.c
+++ clang/test/Driver/aix-constructor-alias.c
@@ -1,7 +1,7 @@
-// Check that we don't pass -mconstructor-aliases when compiling for AIX.
+// Check that we pass -mconstructor-aliases when compiling for AIX.
 
 // RUN: %clang -### -target powerpc-ibm-aix7.1.0.0 %s -c -o %t.o 2>&1 \
 // RUN:   | FileCheck %s
 // RUN: %clang -### -target powerpc64-ibm-aix7.1.0.0 %s -c -o %t.o 2>&1 \
 // RUN:   | FileCheck %s
-// CHECK-NOT: "-mconstructor-aliases"
+// CHECK: "-mconstructor-aliases"
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -4973,10 +4973,8 @@
 
   // 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. Similarly, aliases aren't yet supported
-  // for AIX.
-  if (!RawTriple.isOSDarwin() && !RawTriple.isNVPTX() &&
-  !RawTriple.isAMDGPU() && !RawTriple.isOSAIX())
+  // where aliases aren't supported.
+  if (!RawTriple.isOSDarwin() && !RawTriple.isNVPTX() && !RawTriple.isAMDGPU())
 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] D102801: [CUDA][HIP] Fix implicit constant variable

2021-05-19 Thread Artem Belevich via Phabricator via cfe-commits
tra added a reviewer: rsmith.
tra added a subscriber: rsmith.
tra added a comment.

Tentative LGTM as we need it to fix the regression soon.

Summoning @rsmith for the 'big picture' opinion. 
While the patch may fix this particular regression, I wonder if there's a 
better way to deal with this. We're growing a bit too many nuances that would 
be hard to explain and may cause more corner cases to appear.




Comment at: clang/lib/CodeGen/CodeGenModule.cpp:2386
+  };
+  if (!HasImplicitConstantAttr(V))
+DeferredDeclsToEmit.push_back(V);

IIUIC, The idea here is that we do not want to emit `constexpr int foo;` on 
device, even if we happen to ODR-use it there.
And the way we detect this is by checking for implicit `__constant__` we happen 
to add to constexpr variables.

I think this may be relying on the implementation details too much. It also 
makes compiler's behavior somewhat surprising -- we would potentially emit 
other variables that do not get any device attributes attribute, but would not 
emit the variables with implicit `__constant__`, which is a device attribute.

I'm not sure if we have any good options here. This may be an acceptable 
compromise, but I wonder if there's a better way to deal with this.

That said, this patch is OK to fix the regression we have now, but we may need 
to revisit this.




Comment at: clang/test/CodeGenCUDA/host-used-device-var.cu:103-131
+// Check implicit constant variable ODR-used by host code is not emitted.
+// DEV-NEG-NOT: _ZN16TestConstexprVar1oE
+namespace TestConstexprVar {
+char o;
+class ou {
+public:
+  ou(char) { __builtin_strlen(); }

This definitely needs some comments. Otherwise this is nearly incomprehensible 
and it's impossible to tell what's going on.


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

https://reviews.llvm.org/D102801

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


[PATCH] D102807: Revert "[AIX] Avoid structor alias; die before bad alias codegen"

2021-05-19 Thread Jake Egan via Phabricator via cfe-commits
Jake-Egan created this revision.
Herald added a subscriber: jeroen.dobbelaere.
Jake-Egan requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This reverts commit b116ded57da3530e661f871f4191c59cd9e091cd 
.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D102807

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/aix-constructor-alias.c


Index: clang/test/Driver/aix-constructor-alias.c
===
--- clang/test/Driver/aix-constructor-alias.c
+++ clang/test/Driver/aix-constructor-alias.c
@@ -1,7 +1,7 @@
-// Check that we don't pass -mconstructor-aliases when compiling for AIX.
+// Check that we pass -mconstructor-aliases when compiling for AIX.
 
 // RUN: %clang -### -target powerpc-ibm-aix7.1.0.0 %s -c -o %t.o 2>&1 \
 // RUN:   | FileCheck %s
 // RUN: %clang -### -target powerpc64-ibm-aix7.1.0.0 %s -c -o %t.o 2>&1 \
 // RUN:   | FileCheck %s
-// CHECK-NOT: "-mconstructor-aliases"
+// CHECK: "-mconstructor-aliases"
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -4973,10 +4973,8 @@
 
   // 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. Similarly, aliases aren't yet supported
-  // for AIX.
-  if (!RawTriple.isOSDarwin() && !RawTriple.isNVPTX() &&
-  !RawTriple.isAMDGPU() && !RawTriple.isOSAIX())
+  // where aliases aren't supported.
+  if (!RawTriple.isOSDarwin() && !RawTriple.isNVPTX() && !RawTriple.isAMDGPU())
 CmdArgs.push_back("-mconstructor-aliases");
 
   // Darwin's kernel doesn't support guard variables; just die if we


Index: clang/test/Driver/aix-constructor-alias.c
===
--- clang/test/Driver/aix-constructor-alias.c
+++ clang/test/Driver/aix-constructor-alias.c
@@ -1,7 +1,7 @@
-// Check that we don't pass -mconstructor-aliases when compiling for AIX.
+// Check that we pass -mconstructor-aliases when compiling for AIX.
 
 // RUN: %clang -### -target powerpc-ibm-aix7.1.0.0 %s -c -o %t.o 2>&1 \
 // RUN:   | FileCheck %s
 // RUN: %clang -### -target powerpc64-ibm-aix7.1.0.0 %s -c -o %t.o 2>&1 \
 // RUN:   | FileCheck %s
-// CHECK-NOT: "-mconstructor-aliases"
+// CHECK: "-mconstructor-aliases"
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -4973,10 +4973,8 @@
 
   // 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. Similarly, aliases aren't yet supported
-  // for AIX.
-  if (!RawTriple.isOSDarwin() && !RawTriple.isNVPTX() &&
-  !RawTriple.isAMDGPU() && !RawTriple.isOSAIX())
+  // where aliases aren't supported.
+  if (!RawTriple.isOSDarwin() && !RawTriple.isNVPTX() && !RawTriple.isAMDGPU())
 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] D102782: Add support for Warning Flag "-Wstack-usage="

2021-05-19 Thread Ana Pazos via Phabricator via cfe-commits
apazos added inline comments.



Comment at: clang/lib/Basic/Warnings.cpp:101
+Opt = "no-frame-larger-than=";
+
   // Check to see if this warning starts with "no-", if so, this is a

Since GCC supports the negative option -Wno-stack-usage, I think it is best to 
add the negative option Wno-frame-larger-than in the td file and alias it too, 
to avoid this C code in here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102782

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


[PATCH] D102805: [M68k] Allow user to preserve certain registers

2021-05-19 Thread Min-Yih Hsu via Phabricator via cfe-commits
myhsu created this revision.
myhsu added reviewers: nickdesaulniers, simoncook.
Herald added subscribers: dang, s.egerton, hiraditya.
myhsu requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

Add `-ffixed-a[0-6]` and `-ffixed-d[0-7]` driver flags and the corresponding 
subtarget features to prevent certain register from being allocated.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D102805

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Arch/M68k.cpp
  clang/test/Driver/m68k-fixed-register.c
  llvm/lib/Target/M68k/M68k.td
  llvm/lib/Target/M68k/M68kRegisterInfo.cpp
  llvm/lib/Target/M68k/M68kSubtarget.cpp
  llvm/lib/Target/M68k/M68kSubtarget.h
  llvm/test/CodeGen/M68k/reserved-regs.ll

Index: llvm/test/CodeGen/M68k/reserved-regs.ll
===
--- /dev/null
+++ llvm/test/CodeGen/M68k/reserved-regs.ll
@@ -0,0 +1,70 @@
+; RUN: llc -mtriple=m68k -mattr="+reserve-a0" < %s | FileCheck --check-prefix=A0 %s
+; RUN: llc -mtriple=m68k -mattr="+reserve-a1" < %s | FileCheck --check-prefix=A1 %s
+; RUN: llc -mtriple=m68k -mattr="+reserve-a2" < %s | FileCheck --check-prefix=A2 %s
+; RUN: llc -mtriple=m68k -mattr="+reserve-a3" < %s | FileCheck --check-prefix=A3 %s
+; RUN: llc -mtriple=m68k -mattr="+reserve-a4" < %s | FileCheck --check-prefix=A4 %s
+; RUN: llc -mtriple=m68k -mattr="+reserve-a5" < %s | FileCheck --check-prefix=A5 %s
+; RUN: llc -mtriple=m68k -mattr="+reserve-a6" < %s | FileCheck --check-prefix=A6 %s
+; RUN: llc -mtriple=m68k -mattr="+reserve-d0" < %s | FileCheck --check-prefix=D0 %s
+; RUN: llc -mtriple=m68k -mattr="+reserve-d1" < %s | FileCheck --check-prefix=D1 %s
+; RUN: llc -mtriple=m68k -mattr="+reserve-d2" < %s | FileCheck --check-prefix=D2 %s
+; RUN: llc -mtriple=m68k -mattr="+reserve-d3" < %s | FileCheck --check-prefix=D3 %s
+; RUN: llc -mtriple=m68k -mattr="+reserve-d4" < %s | FileCheck --check-prefix=D4 %s
+; RUN: llc -mtriple=m68k -mattr="+reserve-d5" < %s | FileCheck --check-prefix=D5 %s
+; RUN: llc -mtriple=m68k -mattr="+reserve-d6" < %s | FileCheck --check-prefix=D6 %s
+; RUN: llc -mtriple=m68k -mattr="+reserve-d7" < %s | FileCheck --check-prefix=D7 %s
+
+; Used to exhaust all registers
+;
+; A better way to do this might be:
+; ```
+; @var = global [16 x i32] zeroinitializer
+; ...
+; %tmp = load load volatile [16 x i32], [16 x i32]* @var
+; store volatile [16 x i32] %tmp, [16 x i32]* @var
+; ```
+; Which is copied from `test/CodeGen/RISCV/reserved-regs.ll`.
+; But currently we have problem doing codegen for the above snippet
+; (https://bugs.llvm.org/show_bug.cgi?id=50377).
+define void @foo(i32* nocapture readonly %a, i32* nocapture readonly %b, i32* nocapture readonly %c, i32* nocapture readonly %d,
+ i32* nocapture readonly %a1, i32* nocapture readonly %b1, i32* nocapture readonly %c1, i32* nocapture readonly %d1,
+ i32* nocapture readonly %a2, i32* nocapture readonly %b2, i32* nocapture readonly %c2, i32* nocapture readonly %d2,
+ i32* nocapture readonly %a3, i32* nocapture readonly %b3, i32* nocapture readonly %c3, i32* nocapture readonly %d3) {
+entry:
+  %0 = load i32, i32* %a, align 4
+  %1 = load i32, i32* %b, align 4
+  %2 = load i32, i32* %c, align 4
+  %3 = load i32, i32* %d, align 4
+  %4 = load i32, i32* %a1, align 4
+  %5 = load i32, i32* %b1, align 4
+  %6 = load i32, i32* %c1, align 4
+  %7 = load i32, i32* %d1, align 4
+  %8 = load i32, i32* %a2, align 4
+  %9 = load i32, i32* %b2, align 4
+  %10 = load i32, i32* %c2, align 4
+  %11 = load i32, i32* %d2, align 4
+  %12 = load i32, i32* %a3, align 4
+  %13 = load i32, i32* %b3, align 4
+  %14 = load i32, i32* %c3, align 4
+  %15 = load i32, i32* %d3, align 4
+  ; A0-NOT: %a0
+  ; A1-NOT: %a1
+  ; A2-NOT: %a2
+  ; A3-NOT: %a3
+  ; A4-NOT: %a4
+  ; A5-NOT: %a5
+  ; A6-NOT: %a6
+  ; D0-NOT: %d0
+  ; D1-NOT: %d1
+  ; D2-NOT: %d2
+  ; D3-NOT: %d3
+  ; D4-NOT: %d4
+  ; D5-NOT: %d5
+  ; D6-NOT: %d6
+  ; D7-NOT: %d7
+  tail call void @bar(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4, i32 %5, i32 %6, i32 %7, i32 %8, i32 %9, i32 %10, i32 %11, i32 %12, i32 %13, i32 %14, i32 %15)
+  ret void
+}
+
+declare void @bar(i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32)
+
Index: llvm/lib/Target/M68k/M68kSubtarget.h
===
--- llvm/lib/Target/M68k/M68kSubtarget.h
+++ llvm/lib/Target/M68k/M68kSubtarget.h
@@ -18,6 +18,7 @@
 #include "M68kISelLowering.h"
 #include "M68kInstrInfo.h"
 
+#include "llvm/ADT/BitVector.h"
 #include "llvm/CodeGen/SelectionDAGTargetInfo.h"
 #include "llvm/CodeGen/TargetSubtargetInfo.h"
 #include "llvm/IR/DataLayout.h"
@@ -47,6 +48,8 @@
   enum SubtargetEnum { M00, M10, M20, M30, M40, M60 };
   SubtargetEnum SubtargetKind = M00;
 
+  BitVector UserReservedRegister;
+
   InstrItineraryData InstrItins;
 
   /// 

[PATCH] D100991: Fix parsing of vector keyword in presence of conflicting uses.

2021-05-19 Thread Jamie Schmeiser via Phabricator via cfe-commits
jamieschmeiser updated this revision to Diff 346548.
jamieschmeiser added a comment.

Expand testing.


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

https://reviews.llvm.org/D100991

Files:
  clang/lib/Parse/Parser.cpp
  clang/test/Parser/altivec-non-type-vector.c
  clang/test/Parser/altivec-template-vector.cpp
  clang/test/Parser/altivec-typedef-vector.c

Index: clang/test/Parser/altivec-typedef-vector.c
===
--- /dev/null
+++ clang/test/Parser/altivec-typedef-vector.c
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s -triple powerpc64-ibm-aix
+// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s -triple powerpc64-ibm-aix-xcoff
+// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s -triple powerpc64le-ibm-linux-gnu
+// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s -triple powerpc64le-linux-unknown
+// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s -triple powerpc64le-unknown-linux
+// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s -triple powerpc64le-unknown-linux-gnu
+// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s -triple powerpc64le-unknown-unknown
+// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s -triple powerpc64-linux
+// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s -triple powerpc64-linux-gnu
+// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s -triple powerpc64-linux-musl
+// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s -triple powerpc64-montavista-linux-gnu
+// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s -triple powerpc64-none-none
+// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s -triple powerpc64-unknown-aix
+// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s -triple powerpc64-unknown-aix-xcoff
+// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s -triple powerpc64-unknown-linux-gnu
+// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s -triple powerpc64-unknown-unknown
+// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s -triple powerpc-ibm-aix
+// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s -triple powerpc-ibm-aix-xcoff
+// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s -triple powerpc-linux-gnu
+// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s -triple powerpc-unknown-aix
+// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s -triple powerpc-unknown-aix-xcoff
+// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s -triple powerpc-unknown-linux-gnu
+// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s -triple powerpc-unknown-openbsd
+// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s -triple powerpc-unknown-unknown
+
+typedef int vector;
+
+void test() {
+  vector unsigned int v = {0};
+}
Index: clang/test/Parser/altivec-template-vector.cpp
===
--- /dev/null
+++ clang/test/Parser/altivec-template-vector.cpp
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s -triple powerpc64-ibm-aix
+// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s -triple powerpc64-ibm-aix-xcoff
+// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s -triple powerpc64le-ibm-linux-gnu
+// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s -triple powerpc64le-linux-unknown
+// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s -triple powerpc64le-unknown-linux
+// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s -triple powerpc64le-unknown-linux-gnu
+// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s -triple powerpc64le-unknown-unknown
+// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s -triple powerpc64-linux
+// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s -triple powerpc64-linux-gnu
+// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s -triple powerpc64-linux-musl
+// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s -triple powerpc64-montavista-linux-gnu
+// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s -triple powerpc64-none-none
+// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s -triple powerpc64-unknown-aix
+// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s -triple powerpc64-unknown-aix-xcoff
+// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s -triple powerpc64-unknown-linux-gnu
+// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s -triple powerpc64-unknown-unknown
+// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s -triple powerpc-ibm-aix
+// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s -triple powerpc-ibm-aix-xcoff
+// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s -triple powerpc-linux-gnu
+// RUN: %clang_cc1 -target-feature +altivec -fsyntax-only %s -triple powerpc-unknown-aix
+// RUN: %clang_cc1 

[clang] d38057f - Treat implicit deduction guides as being equivalent to their

2021-05-19 Thread Richard Smith via cfe-commits

Author: Richard Smith
Date: 2021-05-19T13:31:53-07:00
New Revision: d38057f3ecb080e0ae4aba367a737226221327f2

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

LOG: Treat implicit deduction guides as being equivalent to their
corresponding constructor for access checking purposes.

Added: 


Modified: 
clang/include/clang/AST/DeclCXX.h
clang/lib/AST/ASTImporter.cpp
clang/lib/AST/DeclCXX.cpp
clang/lib/Sema/SemaAccess.cpp
clang/lib/Sema/SemaTemplate.cpp
clang/lib/Serialization/ASTReaderDecl.cpp
clang/lib/Serialization/ASTWriterDecl.cpp
clang/test/SemaTemplate/ctad.cpp

Removed: 




diff  --git a/clang/include/clang/AST/DeclCXX.h 
b/clang/include/clang/AST/DeclCXX.h
index d90732b1d0ca9..c3c326b50397e 100644
--- a/clang/include/clang/AST/DeclCXX.h
+++ b/clang/include/clang/AST/DeclCXX.h
@@ -1852,15 +1852,17 @@ class CXXDeductionGuideDecl : public FunctionDecl {
   CXXDeductionGuideDecl(ASTContext , DeclContext *DC, SourceLocation 
StartLoc,
 ExplicitSpecifier ES,
 const DeclarationNameInfo , QualType T,
-TypeSourceInfo *TInfo, SourceLocation EndLocation)
+TypeSourceInfo *TInfo, SourceLocation EndLocation,
+CXXConstructorDecl *Ctor)
   : FunctionDecl(CXXDeductionGuide, C, DC, StartLoc, NameInfo, T, TInfo,
  SC_None, false, ConstexprSpecKind::Unspecified),
-ExplicitSpec(ES) {
+Ctor(Ctor), ExplicitSpec(ES) {
 if (EndLocation.isValid())
   setRangeEnd(EndLocation);
 setIsCopyDeductionCandidate(false);
   }
 
+  CXXConstructorDecl *Ctor;
   ExplicitSpecifier ExplicitSpec;
   void setExplicitSpecifier(ExplicitSpecifier ES) { ExplicitSpec = ES; }
 
@@ -1871,7 +1873,8 @@ class CXXDeductionGuideDecl : public FunctionDecl {
   static CXXDeductionGuideDecl *
   Create(ASTContext , DeclContext *DC, SourceLocation StartLoc,
  ExplicitSpecifier ES, const DeclarationNameInfo , QualType T,
- TypeSourceInfo *TInfo, SourceLocation EndLocation);
+ TypeSourceInfo *TInfo, SourceLocation EndLocation,
+ CXXConstructorDecl *Ctor = nullptr);
 
   static CXXDeductionGuideDecl *CreateDeserialized(ASTContext , unsigned ID);
 
@@ -1886,6 +1889,12 @@ class CXXDeductionGuideDecl : public FunctionDecl {
 return getDeclName().getCXXDeductionGuideTemplate();
   }
 
+  /// Get the constructor from which this deduction guide was generated, if
+  /// this is an implicit deduction guide.
+  CXXConstructorDecl *getCorrespondingConstructor() const {
+return Ctor;
+  }
+
   void setIsCopyDeductionCandidate(bool isCDC = true) {
 FunctionDeclBits.IsCopyDeductionCandidate = isCDC;
   }

diff  --git a/clang/lib/AST/ASTImporter.cpp b/clang/lib/AST/ASTImporter.cpp
index 9caa1178c0b7b..c0fc376157d2a 100644
--- a/clang/lib/AST/ASTImporter.cpp
+++ b/clang/lib/AST/ASTImporter.cpp
@@ -3457,11 +3457,13 @@ ExpectedDecl 
ASTNodeImporter::VisitFunctionDecl(FunctionDecl *D) {
   } else if (auto *Guide = dyn_cast(D)) {
 ExplicitSpecifier ESpec =
 importExplicitSpecifier(Err, Guide->getExplicitSpecifier());
+CXXConstructorDecl *Ctor =
+importChecked(Err, Guide->getCorrespondingConstructor());
 if (Err)
   return std::move(Err);
 if (GetImportedOrCreateDecl(
 ToFunction, D, Importer.getToContext(), DC, ToInnerLocStart, ESpec,
-NameInfo, T, TInfo, ToEndLoc))
+NameInfo, T, TInfo, ToEndLoc, Ctor))
   return ToFunction;
 cast(ToFunction)
 ->setIsCopyDeductionCandidate(Guide->isCopyDeductionCandidate());

diff  --git a/clang/lib/AST/DeclCXX.cpp b/clang/lib/AST/DeclCXX.cpp
index 081c9ebf8622d..3d1faee0ab113 100644
--- a/clang/lib/AST/DeclCXX.cpp
+++ b/clang/lib/AST/DeclCXX.cpp
@@ -2073,19 +2073,21 @@ ExplicitSpecifier 
ExplicitSpecifier::getFromDecl(FunctionDecl *Function) {
   }
 }
 
-CXXDeductionGuideDecl *CXXDeductionGuideDecl::Create(
-ASTContext , DeclContext *DC, SourceLocation StartLoc,
-ExplicitSpecifier ES, const DeclarationNameInfo , QualType T,
-TypeSourceInfo *TInfo, SourceLocation EndLocation) {
+CXXDeductionGuideDecl *
+CXXDeductionGuideDecl::Create(ASTContext , DeclContext *DC,
+  SourceLocation StartLoc, ExplicitSpecifier ES,
+  const DeclarationNameInfo , QualType T,
+  TypeSourceInfo *TInfo, SourceLocation 
EndLocation,
+  CXXConstructorDecl *Ctor) {
   return new (C, DC) CXXDeductionGuideDecl(C, DC, StartLoc, ES, NameInfo, T,
-   TInfo, EndLocation);
+   TInfo, EndLocation, Ctor);
 }
 
 

[PATCH] D102469: [sanitizer] Reduce redzone size for small size global objects

2021-05-19 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay accepted this revision.
MaskRay added inline comments.



Comment at: llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp:2556
+  uint64_t RZ = 0;
+  if (SizeInBytes < MinRZ / 2) {
+// Reduce redzone size for small size objects, e.g. int, char[1]. MinRZ is

I wonder whether 16-byte array should use this optimization as well (i.e. `<` 
=> `<=`)

@vitalybuka 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102469

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


[PATCH] D102583: -fno-semantic-interposition: Don't set dso_local on GlobalVariable

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

lgtm


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102583

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


[PATCH] D102237: [CUDA][HIP] Fix non-ODR-use of static device variable

2021-05-19 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

In D102237#2767538 , @tra wrote:

> Here's a slightly simpler reproducer: https://godbolt.org/z/rW6P9e37s

I have a fix for this: https://reviews.llvm.org/D102801

It seems the issue was due to clang emits the implicit constant variable 
`aw::c` but it is invalid to be emitted on device side since it is 
initialized with a host function pointer. The fix is not to force emit implicit 
constant variables in device compilation. This basically limits our previous 
fix to explicit device variables.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102237

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


[PATCH] D102696: [Analyzer] Find constraints that are directly attached to a BinOp

2021-05-19 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

In D102696#2767894 , @martong wrote:

>> In this case the equations are $y == 0 and $x + 0 == 0 which is much easier 
>> to solve.
>
> Yes, you are right.
>
>> This happens for the same reason that your patch is needed in the first 
>> place: we're eagerly substituting a constant.
>
> Absolutely, that's the point. On the other hand, it is very important to 
> emphasize that we cannot solve this problem with a stronger solver, see my 
> example with 3 variables and two equations above.

Well, in that other example, we should be asking about `$x + $y + 0 == 0` at 
some point. And then the solver should be able to deduce it from `$x + $y + $z 
== 0` and `$z == 0`. If we're not asking this question, that's obviously the 
first problem to get out of our way.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102696

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


[PATCH] D102801: [CUDA][HIP] Fix implicit constant variable

2021-05-19 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl created this revision.
yaxunl added a reviewer: tra.
Herald added a reviewer: aaron.ballman.
yaxunl requested review of this revision.

constexpr variables are implicit constant variables in device compilation.
Not all constexpr variables are valid to be emitted on device side, therefore
we should not force emit implicit constant variables even if they are
ODR-used by host code.

This fixes the regression caused by https://reviews.llvm.org/D102237


https://reviews.llvm.org/D102801

Files:
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Sema/SemaCUDA.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/AST/ast-dump-constant-var.cu
  clang/test/CodeGenCUDA/host-used-device-var.cu

Index: clang/test/CodeGenCUDA/host-used-device-var.cu
===
--- clang/test/CodeGenCUDA/host-used-device-var.cu
+++ clang/test/CodeGenCUDA/host-used-device-var.cu
@@ -66,8 +66,22 @@
 template 
 __device__ func_t p_add_func = add_func;
 
+// Check non-constant constexpr variables ODR-used by host code only is not emitted.
+// DEV-NEG-NOT: constexpr_var1a
+// DEV-NEG-NOT: constexpr_var1b
+constexpr int constexpr_var1a = 1;
+inline constexpr int constexpr_var1b = 1;
+
+// Check constant constexpr variables ODR-used by host code only.
+// Non-inline constexpr variable has internal linkage, therefore it is not accessible by host and not kept.
+// Inline constexpr variable has linkonce_ord linkage, therefore it can be accessed by host and kept.
+// DEV-NEG-NOT: constexpr_var2a
+// DEV-DAG: @constexpr_var2b = linkonce_odr addrspace(4) externally_initialized constant i32 2
+__constant__ constexpr int constexpr_var2a = 2;
+inline __constant__ constexpr int constexpr_var2b = 2;
+
 void use(func_t p);
-void use(int *p);
+void use(const int *p);
 
 void fun1() {
   use();
@@ -76,20 +90,58 @@
   use(_var);
   use(_var);
   use(p_add_func);
+  use(_var1a);
+  use(_var1b);
+  use(_var2a);
+  use(_var2b);
 }
 
 __global__ void kern1(int **x) {
   *x = 
 }
 
+// Check implicit constant variable ODR-used by host code is not emitted.
+// DEV-NEG-NOT: _ZN16TestConstexprVar1oE
+namespace TestConstexprVar {
+char o;
+class ou {
+public:
+  ou(char) { __builtin_strlen(); }
+};
+template < typename ao > struct aw { static constexpr ao c; };
+class x {
+protected:
+  typedef ou (*y)(const x *);
+  constexpr x(y ag) : ah(ag) {}
+  template < bool * > struct ak;
+  template < typename > struct al {
+static bool am;
+static ak<  > an;
+  };
+  template < typename ao > static x ap() { (void)aw< ao >::c; return x(nullptr); }
+  y ah;
+};
+template < typename ao > bool x::al< ao >::am(< ao >);
+class ar : x {
+public:
+  constexpr ar() : x(as) {}
+  static ou as(const x *) { return 0; }
+  al< ar > av;
+};
+}
+
 // Check the exact list of variables to ensure @_ZL2u4 is not among them.
-// DEV: @llvm.compiler.used = {{[^@]*}} @_Z10p_add_funcIiE {{[^@]*}} @_ZL2u3 {{[^@]*}} @inline_var {{[^@]*}} @u1 {{[^@]*}} @u2 {{[^@]*}} @u5
+// DEV: @llvm.compiler.used = {{[^@]*}} @_Z10p_add_funcIiE {{[^@]*}} @_ZL2u3 {{[^@]*}} @constexpr_var2b {{[^@]*}} @inline_var {{[^@]*}} @u1 {{[^@]*}} @u2 {{[^@]*}} @u5
 
 // HOST-DAG: hipRegisterVar{{.*}}@u1
 // HOST-DAG: hipRegisterVar{{.*}}@u2
 // HOST-DAG: hipRegisterVar{{.*}}@_ZL2u3
+// HOST-DAG: hipRegisterVar{{.*}}@constexpr_var2b
 // HOST-DAG: hipRegisterVar{{.*}}@u5
 // HOST-DAG: hipRegisterVar{{.*}}@inline_var
 // HOST-DAG: hipRegisterVar{{.*}}@_Z10p_add_funcIiE
 // HOST-NEG-NOT: hipRegisterVar{{.*}}@ext_var
 // HOST-NEG-NOT: hipRegisterVar{{.*}}@_ZL2u4
+// HOST-NEG-NOT: hipRegisterVar{{.*}}@constexpr_var1a
+// HOST-NEG-NOT: hipRegisterVar{{.*}}@constexpr_var1b
+// HOST-NEG-NOT: hipRegisterVar{{.*}}@constexpr_var2a
Index: clang/test/AST/ast-dump-constant-var.cu
===
--- /dev/null
+++ clang/test/AST/ast-dump-constant-var.cu
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 -std=c++14 -ast-dump -x hip %s | FileCheck -check-prefixes=CHECK,HOST %s
+// RUN: %clang_cc1 -std=c++14 -ast-dump -fcuda-is-device -x hip %s | FileCheck -check-prefixes=CHECK,DEV %s
+
+#include "Inputs/cuda.h"
+
+// CHECK-LABEL: VarDecl {{.*}} m1 'int'
+// CHECK-NEXT: CUDAConstantAttr {{.*}}cuda.h
+__constant__ int m1;
+
+// CHECK-LABEL: VarDecl {{.*}} m2 'int'
+// CHECK-NEXT: CUDAConstantAttr {{.*}}cuda.h
+// CHECK-NOT: CUDAConstantAttr
+__constant__ __constant__ int m2;
+
+// CHECK-LABEL: VarDecl {{.*}} m3 'const int'
+// HOST-NOT: CUDAConstantAttr
+// DEV-NOT: CUDAConstantAttr {{.*}}cuda.h
+// DEV: CUDAConstantAttr {{.*}}Implicit
+// DEV-NOT: CUDAConstantAttr {{.*}}cuda.h
+constexpr int m3 = 1;
+
+// CHECK-LABEL: VarDecl {{.*}} m3a 'const int'
+// CHECK-NOT: CUDAConstantAttr {{.*}}Implicit
+// CHECK: CUDAConstantAttr {{.*}}cuda.h
+// CHECK-NOT: CUDAConstantAttr {{.*}}Implicit
+constexpr __constant__ int m3a = 2;
+
+// CHECK-LABEL: VarDecl {{.*}} m3b 'const int'
+// CHECK-NOT: CUDAConstantAttr {{.*}}Implicit
+// CHECK: CUDAConstantAttr 

[PATCH] D102568: [Driver] Delete -mimplicit-it=

2021-05-19 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

In D102568#2769401 , @dblaikie wrote:

> Ah, thanks for the history. Yeah, still not sure those bugs are on equal 
> footing - if the patch had been in for a few months before musl was fixed (If 
> they're interested in building from LLVM head - wonder why it took so long & 
> if they aren't, then it doesn't seem like we need to rush to fix this/keep 
> the fix in tree if backing it out and considering how to support both new-ish 
> (self-imposed due to the -mimplicit-it= change) and existing (mingw arm) use 
> cases can be handled gracefully and have it in the next LLVM release or the 
> like).

The original driver option was added in 2016-07. Some projects may accrue some 
-mimplicit-it usage singe then.

The option -Wa,-mimplicit-it was added in 2021-02. @raj.khem noticed the issue 
in 2021-05. Perhaps that's not too long ? :)

> But sounds like there's some possible both-use-cases-work path forward, which 
> is good to see.

Yes. Seems that @mstorsjo has started working on making all the use cases work.
With this, I am certainly happy that we can retain the options for a couple of 
releases.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102568

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


[PATCH] D102568: [Driver] Delete -mimplicit-it=

2021-05-19 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added a comment.

In D102568#2769390 , @MaskRay wrote:

> In D102568#2769340 , @mstorsjo 
> wrote:
>
>> In the meantime, wouldn't it be possible to detect the presence of the other 
>> one and check if they match or not, to avoid passing duplicate options to 
>> the backend? I can give that a try.
>
> Should be possible! Thanks for offering the help. I think it is too much to 
> test contradicting values like `// NEVER_ALWAYS: "-mllvm" 
> "-arm-implicit-it=never" "-mllvm" "-arm-implicit-it=always"`.
> We can just assume having different values is undefined behavior. (No project 
> should specify different values.)

Yep, that sounds good to me. The old tests seem to be written under the 
assumption that it's ok to specify multiple values and the last one take 
effect, but that doesn't seem to be the case, not even when that patch was 
applied in February.

I'll get started at making duplicate options with the same value work in one 
way or another.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102568

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


[PATCH] D102568: [Driver] Delete -mimplicit-it=

2021-05-19 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

In D102568#2769395 , @MaskRay wrote:

> In D102568#2769389 , @dblaikie 
> wrote:
>
>> In D102568#2769341 , @MaskRay 
>> wrote:
>>
>>> I think libvpx's ASFLAGS usage is about GNU as, not the driver option.
>>>
>>> In D102568#2769296 , @dblaikie 
>>> wrote:
>>>
> I think "waiting for a few releases" is too much and doesn't improve 
> things (they will notice issues until you remove the option). I can 
> accept "waiting for one major release".

 Having fairly broad windows of not breaking backwards compatibility is a 
 fairly reasonable request. Take LLVM itself, for instance - which supports 
 building with Clang back as far as 3.5. (not suggesting we need to have a 
 window that large for every feature/piece of surface area - but that there 
 is scope for fairly wide windows)
>>>
>>> I understand the broad Windows and I also strive for this portability.
>>>
>>> However, reverting this patch is now a trade-off. It would make 
>>> x264/openh264's mingw build happy but break musl's arm build (2018-09 ~ ).
>>> There can be other projects doing detection on both -mimplicit-it and 
>>> -Wa,-mimplicit-it and will be broken by reverting this patch.
>>
>> Not sure I follow - presumably musl's arm build wasn't working with clang 
>> before this patch? Or something changed there after this patch landed?
>
> musl's arm build has always been working with clang. It stopped working after 
> the driver option -mimplicit-it= was added earlier this year.
> This patch dropped the driver option/fixed the musl build but broke some 
> mingw arm projects.

Ah, thanks for the history. Yeah, still not sure those bugs are on equal 
footing - if the patch had been in for a few months before musl was fixed (If 
they're interested in building from LLVM head - wonder why it took so long & if 
they aren't, then it doesn't seem like we need to rush to fix this/keep the fix 
in tree if backing it out and considering how to support both new-ish 
(self-imposed due to the -mimplicit-it= change) and existing (mingw arm) use 
cases can be handled gracefully and have it in the next LLVM release or the 
like).

But sounds like there's some possible both-use-cases-work path forward, which 
is good to see.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102568

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


[PATCH] D102568: [Driver] Delete -mimplicit-it=

2021-05-19 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

In D102568#2769389 , @dblaikie wrote:

> In D102568#2769341 , @MaskRay wrote:
>
>> I think libvpx's ASFLAGS usage is about GNU as, not the driver option.
>>
>> In D102568#2769296 , @dblaikie 
>> wrote:
>>
 I think "waiting for a few releases" is too much and doesn't improve 
 things (they will notice issues until you remove the option). I can accept 
 "waiting for one major release".
>>>
>>> Having fairly broad windows of not breaking backwards compatibility is a 
>>> fairly reasonable request. Take LLVM itself, for instance - which supports 
>>> building with Clang back as far as 3.5. (not suggesting we need to have a 
>>> window that large for every feature/piece of surface area - but that there 
>>> is scope for fairly wide windows)
>>
>> I understand the broad Windows and I also strive for this portability.
>>
>> However, reverting this patch is now a trade-off. It would make 
>> x264/openh264's mingw build happy but break musl's arm build (2018-09 ~ ).
>> There can be other projects doing detection on both -mimplicit-it and 
>> -Wa,-mimplicit-it and will be broken by reverting this patch.
>
> Not sure I follow - presumably musl's arm build wasn't working with clang 
> before this patch? Or something changed there after this patch landed?

musl's arm build has always been working with clang. It stopped working after 
the driver option -mimplicit-it= was added earlier this year.
This patch dropped the driver option/fixed the musl build but broke some mingw 
arm projects.

> It's not OK to say "this patch fixed a bug for someone, so now reverting it 
> is on equal footing with the regressions the patch caused" - if a patch broke 
> an existing use case that's different from fixing a use case that wasn't 
> working to begin with & reverting to the known/existing failures would be 
> where things tend to lean (not absolute by any means - there are cases where 
> we tradeoff adding a new bug to fix an existing bug) if all other things are 
> equal.




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102568

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


[PATCH] D102459: [clang][ObjC] Allow different availability annotation on a method when implementing an optional protocol requirement

2021-05-19 Thread Alex Lorenz via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG50be48b0f3c8: [clang][ObjC] Allow different availability 
annotation on a method (authored by arphaman).
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102459

Files:
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/SemaObjC/attr-availability.m
  clang/test/SemaObjC/override-opt-prop-availability.m

Index: clang/test/SemaObjC/override-opt-prop-availability.m
===
--- /dev/null
+++ clang/test/SemaObjC/override-opt-prop-availability.m
@@ -0,0 +1,47 @@
+// RUN: %clang_cc1 -triple arm64-apple-ios11 -fsyntax-only -verify %s
+
+@protocol P
+
+@property (nonatomic) int reqProp __attribute__((availability(ios, introduced=12.0))); // expected-note 2 {{is here}}
+
+
+
+@optional
+@property (nonatomic) int myProp __attribute__((availability(ios, introduced=12.0))); // expected-note {{has been marked as being introduced in}}
+
+@optional
+@property (nonatomic, readonly) int depProp __attribute__((availability(ios, introduced=8.0, deprecated=12.0))); // expected-note {{protocol method is here}}
+
+@optional
+@property (nonatomic) int obsProp __attribute__((availability(ios, introduced=8.0, obsoleted=12.0)));
+
+@optional
+- (void) unavaibleInClass __attribute__((availability(ios, introduced=12.0))); // expected-note {{method is here}}
+
+@end
+
+@interface X 
+
+@property (nonatomic) int myProp __attribute__((availability(ios, introduced=13.0))); // expected-note 2 {{has been marked as being introduced in}}
+
+@property (nonatomic) int reqProp __attribute__((availability(ios, introduced=13.0))); // expected-warning 2 {{method introduced after the protocol method it implements on iOS}}
+
+@property (nonatomic, readonly) int depProp __attribute__((availability(ios, introduced=8.0, deprecated=10.0))); // expected-warning {{method deprecated before the protocol method it implements on iOS (12.0 vs. 10.0)}} expected-note {{been explicitly marked deprecated here}}
+
+@property (nonatomic) int obsProp __attribute__((availability(ios, introduced=8.0, obsoleted=10.0))); // expected-note {{been explicitly marked unavailable here}}
+
+- (void) unavaibleInClass __attribute__((availability(ios, unavailable))); // expected-warning {{method cannot be unavailable on iOS when the protocol method it implements is available}}
+
+@end
+
+
+void test(X *x) {
+  int i =  x.myProp;  // expected-warning {{'myProp' is only available on iOS 13.0 or newer}} expected-note {{enclose}}
+  x.myProp = i;   // expected-warning {{'setMyProp:' is only available on iOS 13.0 or newer}} expected-note {{enclose}}
+  int i2 = x.depProp; // expected-warning {{'depProp' is deprecated: first deprecated in iOS 10.0}}
+  int i3 = x.obsProp; // expected-error {{'obsProp' is unavailable: obsoleted in iOS 10.0}}
+}
+
+void testProto(id x) {
+  int i = x.myProp; // expected-warning {{'myProp' is only available on iOS 12.0 or newer}} expected-note {{enclose}}
+}
Index: clang/test/SemaObjC/attr-availability.m
===
--- clang/test/SemaObjC/attr-availability.m
+++ clang/test/SemaObjC/attr-availability.m
@@ -229,8 +229,7 @@
 // inherited be implementations of those protocol methods.
 @protocol AvailabilityP2
 @optional
--(void)methodA __attribute__((availability(macosx,introduced=10.1,deprecated=10.2))); // expected-note 4{{'methodA' has been explicitly marked deprecated here}} \
-// expected-note 2{{protocol method is here}}
+-(void)methodA __attribute__((availability(macosx,introduced=10.1,deprecated=10.2))); // expected-note 4{{'methodA' has been explicitly marked deprecated here}}
 -(void)methodB __attribute__((unavailable)); // expected-note 4{{'methodB' has been explicitly marked unavailable here}}
 -(void)methodC;
 @end
@@ -279,7 +278,7 @@
 
 __attribute__((objc_root_class))
 @interface ImplementsAvailabilityP2c 
--(void)methodA __attribute__((availability(macosx,introduced=10.2))); // expected-warning{{method introduced after the protocol method it implements on macOS (10.2 vs. 10.1)}}
+-(void)methodA __attribute__((availability(macosx,introduced=10.2)));
 -(void)methodB __attribute__((unavailable));
 @end
 
@@ -288,7 +287,7 @@
 @end
 
 @implementation ImplementsAvailabilityP2d
--(void)methodA __attribute__((availability(macosx,introduced=10.2))) // expected-warning{{method introduced after the protocol method it implements on macOS (10.2 vs. 10.1)}}
+-(void)methodA __attribute__((availability(macosx,introduced=10.2)))
 {
 }
 -(void)methodB __attribute__((unavailable)) {
Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -2300,6 +2300,7 @@
 

[clang] 50be48b - [clang][ObjC] Allow different availability annotation on a method

2021-05-19 Thread Alex Lorenz via cfe-commits

Author: Alex Lorenz
Date: 2021-05-19T12:13:57-07:00
New Revision: 50be48b0f3c884a87ddf19c7c51abcab035c1efb

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

LOG: [clang][ObjC] Allow different availability annotation on a method
when implementing an optional protocol requirement

When an Objective-C method implements an optional protocol requirement,
allow the method to use a newer introduced or older obsoleted
availability version than what's specified on the method in the protocol
itself. This allows SDK adopters to adopt an optional method from a
protocol later than when the method is introduced in the protocol. The users
that call an optional method on an object that conforms to this protocol
are supposed to check whether the object implements the method or not,
so a lack of appropriate `if (@available)` check for a new OS version
is not a cause of concern as there's already another runtime check that's 
required.

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

Added: 
clang/test/SemaObjC/override-opt-prop-availability.m

Modified: 
clang/include/clang/Sema/Sema.h
clang/lib/Sema/SemaDecl.cpp
clang/lib/Sema/SemaDeclAttr.cpp
clang/test/SemaObjC/attr-availability.m

Removed: 




diff  --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index b6143d1d31789..9c459a95a6916 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -3255,6 +3255,9 @@ class Sema final {
 /// Merge availability attributes for an implementation of
 /// a protocol requirement.
 AMK_ProtocolImplementation,
+/// Merge availability attributes for an implementation of
+/// an optional protocol requirement.
+AMK_OptionalProtocolImplementation
   };
 
   /// Describes the kind of priority given to an availability attribute.

diff  --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index c4db147e7efde..90fae1d9c9286 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -2608,7 +2608,8 @@ static bool mergeDeclAttribute(Sema , NamedDecl *D,
 NewAttr = nullptr;
   else if ((isa(Attr) || isa(Attr)) &&
(AMK == Sema::AMK_Override ||
-AMK == Sema::AMK_ProtocolImplementation))
+AMK == Sema::AMK_ProtocolImplementation ||
+AMK == Sema::AMK_OptionalProtocolImplementation))
 NewAttr = nullptr;
   else if (const auto *UA = dyn_cast(Attr))
 NewAttr = S.mergeUuidAttr(D, *UA, UA->getGuid(), UA->getGuidDecl());
@@ -2956,6 +2957,7 @@ void Sema::mergeDeclAttributes(NamedDecl *New, Decl *Old,
   case AMK_Redeclaration:
   case AMK_Override:
   case AMK_ProtocolImplementation:
+  case AMK_OptionalProtocolImplementation:
 LocalAMK = AMK;
 break;
   }
@@ -3861,10 +3863,11 @@ void Sema::mergeObjCMethodDecls(ObjCMethodDecl 
*newMethod,
 ObjCMethodDecl *oldMethod) {
   // Merge the attributes, including deprecated/unavailable
   AvailabilityMergeKind MergeKind =
-isa(oldMethod->getDeclContext())
-  ? AMK_ProtocolImplementation
-  : isa(newMethod->getDeclContext()) ? AMK_Redeclaration
-   : AMK_Override;
+  isa(oldMethod->getDeclContext())
+  ? (oldMethod->isOptional() ? AMK_OptionalProtocolImplementation
+ : AMK_ProtocolImplementation)
+  : isa(newMethod->getDeclContext()) ? AMK_Redeclaration
+   : AMK_Override;
 
   mergeDeclAttributes(newMethod, oldMethod, MergeKind);
 

diff  --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index c470598ef4f84..4bbbcf985cbd3 100644
--- a/clang/lib/Sema/SemaDeclAttr.cpp
+++ b/clang/lib/Sema/SemaDeclAttr.cpp
@@ -2300,6 +2300,7 @@ AvailabilityAttr *Sema::mergeAvailabilityAttr(
 
   case AMK_Override:
   case AMK_ProtocolImplementation:
+  case AMK_OptionalProtocolImplementation:
 OverrideOrImpl = true;
 break;
   }
@@ -2368,6 +2369,14 @@ AvailabilityAttr *Sema::mergeAvailabilityAttr(
  diag::warn_mismatched_availability_override_unavail)
   << AvailabilityAttr::getPrettyPlatformName(Platform->getName())
   << (AMK == AMK_Override);
+  } else if (Which != 1 && AMK == AMK_OptionalProtocolImplementation) {
+// Allow 
diff erent 'introduced' / 'obsoleted' availability versions
+// on a method that implements an optional protocol requirement. It
+// makes less sense to allow this for 'deprecated' as the user 
can't
+// see if the method is 'deprecated' as 'respondsToSelector' will
+// still return true when the method is deprecated.
+   

[PATCH] D102568: [Driver] Delete -mimplicit-it=

2021-05-19 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

In D102568#2769340 , @mstorsjo wrote:

> In the meantime, wouldn't it be possible to detect the presence of the other 
> one and check if they match or not, to avoid passing duplicate options to the 
> backend? I can give that a try.

Should be possible! Thanks for offering the help. I think it is too much to 
test contradicting values like `// NEVER_ALWAYS: "-mllvm" 
"-arm-implicit-it=never" "-mllvm" "-arm-implicit-it=always"`.
We can just assume having different values is undefined behavior. (No project 
should specify different values.)

>> I think "waiting for a few releases" is too much and doesn't improve things 
>> (they will notice issues until you remove the option). I can accept "waiting 
>> for one major release".

I said this because this would break musl arm build.

> Ok, that's at least some sort of middle ground. Would fixing the duplicate 
> option issue (as long as they have matching values) open up for keeping both 
> a little bit longer?

If you can make -mimplicit-it= -Wa,-mimplicit-it= work, keeping the driver 
option bit longer LG.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102568

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


[PATCH] D102568: [Driver] Delete -mimplicit-it=

2021-05-19 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

In D102568#2769341 , @MaskRay wrote:

> I think libvpx's ASFLAGS usage is about GNU as, not the driver option.
>
> In D102568#2769296 , @dblaikie 
> wrote:
>
>>> I think "waiting for a few releases" is too much and doesn't improve things 
>>> (they will notice issues until you remove the option). I can accept 
>>> "waiting for one major release".
>>
>> Having fairly broad windows of not breaking backwards compatibility is a 
>> fairly reasonable request. Take LLVM itself, for instance - which supports 
>> building with Clang back as far as 3.5. (not suggesting we need to have a 
>> window that large for every feature/piece of surface area - but that there 
>> is scope for fairly wide windows)
>
> I understand the broad Windows and I also strive for this portability.
>
> However, reverting this patch is now a trade-off. It would make 
> x264/openh264's mingw build happy but break musl's arm build (2018-09 ~ ).
> There can be other projects doing detection on both -mimplicit-it and 
> -Wa,-mimplicit-it and will be broken by reverting this patch.

Not sure I follow - presumably musl's arm build wasn't working with clang 
before this patch? Or something changed there after this patch landed?

It's not OK to say "this patch fixed a bug for someone, so now reverting it is 
on equal footing with the regressions the patch caused" - if a patch broke an 
existing use case that's different from fixing a use case that wasn't working 
to begin with & reverting to the known/existing failures would be where things 
tend to lean (not absolute by any means - there are cases where we tradeoff 
adding a new bug to fix an existing bug) if all other things are equal.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102568

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


[PATCH] D102784: [Diagnostics] Allow emitting analysis and missed remarks on functions

2021-05-19 Thread Joseph Huber via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG2db182ff8d0c: [Diagnostics] Allow emitting analysis and 
missed remarks on functions (authored by jhuber6).

Changed prior to commit:
  https://reviews.llvm.org/D102784?vs=346516=346531#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102784

Files:
  clang/test/OpenMP/remarks_parallel_in_multiple_target_state_machines.c
  clang/test/OpenMP/remarks_parallel_in_target_state_machine.c
  llvm/include/llvm/IR/DiagnosticInfo.h
  llvm/lib/IR/DiagnosticInfo.cpp
  llvm/lib/Transforms/IPO/OpenMPOpt.cpp
  llvm/test/Transforms/OpenMP/deduplication_remarks.ll
  llvm/test/Transforms/OpenMP/gpu_kernel_detection_remarks.ll
  llvm/test/Transforms/OpenMP/icv_remarks.ll

Index: llvm/test/Transforms/OpenMP/icv_remarks.ll
===
--- llvm/test/Transforms/OpenMP/icv_remarks.ll
+++ llvm/test/Transforms/OpenMP/icv_remarks.ll
@@ -1,5 +1,5 @@
-; RUN: opt -passes=openmp-opt-cgscc -pass-remarks=openmp-opt -openmp-print-icv-values -disable-output < %s 2>&1 | FileCheck %s
-; RUN: opt -openmp-opt-cgscc -pass-remarks=openmp-opt -openmp-print-icv-values -disable-output < %s 2>&1 | FileCheck %s
+; RUN: opt -passes=openmp-opt-cgscc -pass-remarks-analysis=openmp-opt -openmp-print-icv-values -disable-output < %s 2>&1 | FileCheck %s
+; RUN: opt -openmp-opt-cgscc -pass-remarks-analysis=openmp-opt -openmp-print-icv-values -disable-output < %s 2>&1 | FileCheck %s
 
 ; ModuleID = 'icv_remarks.c'
 source_filename = "icv_remarks.c"
Index: llvm/test/Transforms/OpenMP/gpu_kernel_detection_remarks.ll
===
--- llvm/test/Transforms/OpenMP/gpu_kernel_detection_remarks.ll
+++ llvm/test/Transforms/OpenMP/gpu_kernel_detection_remarks.ll
@@ -1,5 +1,5 @@
-; RUN: opt -passes=openmp-opt-cgscc -pass-remarks=openmp-opt -openmp-print-gpu-kernels -disable-output < %s 2>&1 | FileCheck %s --implicit-check-not=non_kernel
-; RUN: opt-openmp-opt-cgscc -pass-remarks=openmp-opt -openmp-print-gpu-kernels -disable-output < %s 2>&1 | FileCheck %s --implicit-check-not=non_kernel
+; RUN: opt -passes=openmp-opt-cgscc -pass-remarks-analysis=openmp-opt -openmp-print-gpu-kernels -disable-output < %s 2>&1 | FileCheck %s --implicit-check-not=non_kernel
+; RUN: opt-openmp-opt-cgscc -pass-remarks-analysis=openmp-opt -openmp-print-gpu-kernels -disable-output < %s 2>&1 | FileCheck %s --implicit-check-not=non_kernel
 
 ; CHECK-DAG: remark: :0:0: OpenMP GPU kernel kernel1
 ; CHECK-DAG: remark: :0:0: OpenMP GPU kernel kernel2
Index: llvm/test/Transforms/OpenMP/deduplication_remarks.ll
===
--- llvm/test/Transforms/OpenMP/deduplication_remarks.ll
+++ llvm/test/Transforms/OpenMP/deduplication_remarks.ll
@@ -10,9 +10,9 @@
 @0 = private unnamed_addr global %struct.ident_t { i32 0, i32 34, i32 0, i32 0, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str0, i32 0, i32 0) }, align 8
 @.str0 = private unnamed_addr constant [23 x i8] c";unknown;unknown;0;0;;\00", align 1
 
-; CHECK: remark: deduplication_remarks.c:9:10: OpenMP runtime call __kmpc_global_thread_num moved to deduplication_remarks.c:5:10
-; CHECK: remark: deduplication_remarks.c:7:10: OpenMP runtime call __kmpc_global_thread_num deduplicated
-; CHECK: remark: deduplication_remarks.c:5:10: OpenMP runtime call __kmpc_global_thread_num deduplicated
+; CHECK: remark: deduplication_remarks.c:4:0: OpenMP runtime call __kmpc_global_thread_num moved to beginning of OpenMP region
+; CHECK: remark: deduplication_remarks.c:4:0: OpenMP runtime call __kmpc_global_thread_num deduplicated
+; CHECK: remark: deduplication_remarks.c:4:0: OpenMP runtime call __kmpc_global_thread_num deduplicated
 define dso_local void @deduplicate() local_unnamed_addr !dbg !14 {
   %1 = tail call i32 @__kmpc_global_thread_num(%struct.ident_t* nonnull @0), !dbg !21
   call void @useI32(i32 %1), !dbg !23
Index: llvm/lib/Transforms/IPO/OpenMPOpt.cpp
===
--- llvm/lib/Transforms/IPO/OpenMPOpt.cpp
+++ llvm/lib/Transforms/IPO/OpenMPOpt.cpp
@@ -581,15 +581,15 @@
 for (Function *F : OMPInfoCache.ModuleSlice) {
   for (auto ICV : ICVs) {
 auto ICVInfo = OMPInfoCache.ICVs[ICV];
-auto Remark = [&](OptimizationRemark OR) {
-  return OR << "OpenMP ICV " << ore::NV("OpenMPICV", ICVInfo.Name)
-<< " Value: "
-<< (ICVInfo.InitValue
-? ICVInfo.InitValue->getValue().toString(10, true)
-: "IMPLEMENTATION_DEFINED");
+auto Remark = [&](OptimizationRemarkAnalysis ORA) {
+  return ORA << "OpenMP ICV " << ore::NV("OpenMPICV", ICVInfo.Name)
+ << " Value: "
+ << 

[clang] 2db182f - [Diagnostics] Allow emitting analysis and missed remarks on functions

2021-05-19 Thread Joseph Huber via cfe-commits

Author: Joseph Huber
Date: 2021-05-19T15:10:20-04:00
New Revision: 2db182ff8d0c0d50155bf70d1db60b4e78c348ca

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

LOG: [Diagnostics] Allow emitting analysis and missed remarks on functions

Summary:
Currently, only `OptimizationRemarks` can be emitted using a Function.
Add constructors to allow this for `OptimizationRemarksAnalysis` and
`OptimizationRemarkMissed` as well.

Reviewed By: jdoerfert thegameg

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

Added: 


Modified: 
clang/test/OpenMP/remarks_parallel_in_multiple_target_state_machines.c
clang/test/OpenMP/remarks_parallel_in_target_state_machine.c
llvm/include/llvm/IR/DiagnosticInfo.h
llvm/lib/IR/DiagnosticInfo.cpp
llvm/lib/Transforms/IPO/OpenMPOpt.cpp
llvm/test/Transforms/OpenMP/deduplication_remarks.ll
llvm/test/Transforms/OpenMP/gpu_kernel_detection_remarks.ll
llvm/test/Transforms/OpenMP/icv_remarks.ll

Removed: 




diff  --git 
a/clang/test/OpenMP/remarks_parallel_in_multiple_target_state_machines.c 
b/clang/test/OpenMP/remarks_parallel_in_multiple_target_state_machines.c
index 8a8b55686d4c3..72593b96bd1ba 100644
--- a/clang/test/OpenMP/remarks_parallel_in_multiple_target_state_machines.c
+++ b/clang/test/OpenMP/remarks_parallel_in_multiple_target_state_machines.c
@@ -1,6 +1,6 @@
-// RUN: %clang_cc1 -verify=host
  -Rpass=openmp -fopenmp -x c++ 
-triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda 
-emit-llvm-bc %s -o %t-ppc-host.bc
-// RUN: %clang_cc1 -verify=all,safe
  -Rpass=openmp -fopenmp -O2 -x c++ 
-triple nvptx64-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm 
%s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o %t.out
-// RUN: %clang_cc1 -fexperimental-new-pass-manager -verify=all,safe
  -Rpass=openmp -fopenmp -O2 -x c++ 
-triple nvptx64-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm 
%s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o %t.out
+// RUN: %clang_cc1 -verify=host  
-Rpass=openmp-opt -Rpass-analysis=openmp -fopenmp -x c++ -triple 
powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc 
%s -o %t-ppc-host.bc
+// RUN: %clang_cc1 -verify=all,safe  
-Rpass=openmp-opt -Rpass-analysis=openmp -fopenmp -O2 -x c++ -triple 
nvptx64-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s 
-fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o %t.out
+// RUN: %clang_cc1 -fexperimental-new-pass-manager -verify=all,safe  
-Rpass=openmp-opt -Rpass-analysis=openmp -fopenmp -O2 -x c++ -triple 
nvptx64-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s 
-fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o %t.out
 
 // host-no-diagnostics
 
@@ -96,5 +96,5 @@ void spmd(void) {
   }
 }
 
-// all-remark@* 5 {{OpenMP runtime call __kmpc_global_thread_num moved to}}
+// all-remark@* 5 {{OpenMP runtime call __kmpc_global_thread_num moved to 
beginning of OpenMP region}}
 // all-remark@* 12 {{OpenMP runtime call __kmpc_global_thread_num 
deduplicated}}

diff  --git a/clang/test/OpenMP/remarks_parallel_in_target_state_machine.c 
b/clang/test/OpenMP/remarks_parallel_in_target_state_machine.c
index 3d0d527dc42fd..604c2f2abfc25 100644
--- a/clang/test/OpenMP/remarks_parallel_in_target_state_machine.c
+++ b/clang/test/OpenMP/remarks_parallel_in_target_state_machine.c
@@ -1,6 +1,6 @@
-// RUN: %clang_cc1 -verify=host -Rpass=openmp 
-fopenmp -x c++ -triple powerpc64le-unknown-unknown 
-fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc
-// RUN: %clang_cc1 -verify  -Rpass=openmp 
-fopenmp -O2 -x c++ -triple nvptx64-unknown-unknown 
-fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device 
-fopenmp-host-ir-file-path %t-ppc-host.bc -o %t.out
-// RUN: %clang_cc1 -fexperimental-new-pass-manager -verify  -Rpass=openmp 
-fopenmp -O2 -x c++ -triple nvptx64-unknown-unknown 
-fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device 
-fopenmp-host-ir-file-path %t-ppc-host.bc -o %t.out
+// RUN: %clang_cc1 -verify=host -Rpass=openmp 
-Rpass-analysis=openmp-opt -fopenmp -x c++ -triple powerpc64le-unknown-unknown 
-fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc
+// RUN: %clang_cc1 -verify  -Rpass=openmp 

[PATCH] D102736: Fix tmp files being left on Windows builds.

2021-05-19 Thread Adrian McCarthy via Phabricator via cfe-commits
amccarth requested changes to this revision.
amccarth added a comment.
This revision now requires changes to proceed.

Sorry, forgot to Request Changes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102736

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


[PATCH] D102736: Fix tmp files being left on Windows builds.

2021-05-19 Thread Adrian McCarthy via Phabricator via cfe-commits
amccarth added a comment.

At some point, the duplicate handle must be closed.  I don't see that 
happening.  I've added an inline comment where I think it should be done.

(I find it weird that duplicating the handle seems necessary.)

At a high level, it seems a shame that `llvm::support::fs` doesn't have 
create-temporary-file and keep-temporary-file operations to hide all this 
detail from the frontend.




Comment at: clang/lib/Frontend/CompilerInstance.cpp:721
+llvm::sys::fs::UnmarkFileForDeletion(OF.Handle);
+
 // If '-working-directory' was passed, the output filename should be

IIUC, OF.Handle is the duplicate handle, and we're done with it at this point.  
It should be closed, before doing things like trying to rename/move the file.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102736

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


[PATCH] D102568: [Driver] Delete -mimplicit-it=

2021-05-19 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added a comment.

In D102568#2769341 , @MaskRay wrote:

> I think libvpx's ASFLAGS usage is about GNU as, not the driver option.

It is indeed for calling a GNU as-like tool, but at 
https://chromium.googlesource.com/webm/libvpx/+/66c1ff6850fd53bcf5c17247569bea1d700d6247/build/make/configure.sh#1003
 it sets `AS="$CC -c"`, which is for cases when using clang-based tools where 
there's no standalone `as`-like tool to use.

My initial patch for that case looked like this:

  diff --git a/build/make/configure.sh b/build/make/configure.sh 
  index 81d30a16c..526c08d3a 100644 
  --- a/build/make/configure.sh 
  +++ b/build/make/configure.sh 
  @@ -1009,7 +1009,16 @@ EOF 
 if enabled thumb; then 
   asm_conversion_cmd="$asm_conversion_cmd -thumb" 
   check_add_cflags -mthumb 
  -check_add_asflags -mthumb -mimplicit-it=always 
  +check_add_asflags -mthumb 
  +case ${tgt_os} in 
  +  win*) 
  +# If $AS is $CC, this flag needs to be passed with -Wa. 
  +check_add_asflags -Wa,-mimplicit-it=always 
  +;; 
  +  *) 
  +check_add_asflags -mimplicit-it=always 
  +;; 
  +esac 
 fi 
 ;; 
   vs*) 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102568

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


[PATCH] D102568: [Driver] Delete -mimplicit-it=

2021-05-19 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

I think libvpx's ASFLAGS usage is about GNU as, not the driver option.

In D102568#2769296 , @dblaikie wrote:

>> I think "waiting for a few releases" is too much and doesn't improve things 
>> (they will notice issues until you remove the option). I can accept "waiting 
>> for one major release".
>
> Having fairly broad windows of not breaking backwards compatibility is a 
> fairly reasonable request. Take LLVM itself, for instance - which supports 
> building with Clang back as far as 3.5. (not suggesting we need to have a 
> window that large for every feature/piece of surface area - but that there is 
> scope for fairly wide windows)

I understand the broad Windows and I also strive for this portability.

However, reverting this patch is now a trade-off. It would make x264/openh264's 
mingw build happy but break musl's arm build (2018-09 ~ 2021-02).
There can be other projects doing detection on both -mimplicit-it and 
-Wa,-mimplicit-it and will be broken by reverting this patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102568

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


[PATCH] D102568: [Driver] Delete -mimplicit-it=

2021-05-19 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added a comment.

In D102568#2769267 , @MaskRay wrote:

> I don't mind reverting this temporarily.
> However, reverting this would break musl build.
> musl (since 2018-09) detects both options and will add both if available: 
> `-Wa,-mimplicit-it=never -mimplicit-it=always` will cause a duplicate option 
> failure.
> Can't there be other projects which do similar detection and be broken by 
> having both options?

I'm curious - if it detects both forms and adds both options, why does it add 
them with contradicting option values? If I understand things correctly, adding 
both options with matching values isn't an error?

Ok, so now I checked, and it does seem to error out even if they have matching 
values - that sounds like the real issue to me.

In the meantime, wouldn't it be possible to detect the presence of the other 
one and check if they match or not, to avoid passing duplicate options to the 
backend? I can give that a try.

> I think "waiting for a few releases" is too much and doesn't improve things 
> (they will notice issues until you remove the option). I can accept "waiting 
> for one major release".

Ok, that's at least some sort of middle ground. Would fixing the duplicate 
option issue (as long as they have matching values) open up for keeping both a 
little bit longer?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102568

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


[PATCH] D101793: [clang][AST] Improve AST Reader/Writer memory footprint

2021-05-19 Thread Wei Wang via Phabricator via cfe-commits
weiwang added a comment.

Tried to make `Sema::DeclsToCheckForDeferredDiags` `llvm::SmallSetVector`. The 
heap RSS did drop significantly (from peak 100GB to 59GB) , but not as good as 
the current fix (peak 26GB), which makes 
`ASTReader::DeclsToCheckForDeferredDiags` `llvm::SmallSetVector`.

I think the reason is that the duplicated decls are read from multiple module 
file sources (`ASTReader::ReadAST()` -> `ASTReader::ReadASTBlock()`), then 
stored into `ASTReader::DeclsToCheckForDeferredDiags`, then goes into 
`Sema::DeclsToCheckForDeferredDiags` in 
`ASTReader::ReadDeclsToCheckForDeferredDiags()`. Doing dedup at the early stage 
when the decls were just read in `ASTReader` is more effective at reducing RSS.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101793

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


[PATCH] D102568: [Driver] Delete -mimplicit-it=

2021-05-19 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

> I think "waiting for a few releases" is too much and doesn't improve things 
> (they will notice issues until you remove the option). I can accept "waiting 
> for one major release".

Having fairly broad windows of not breaking backwards compatibility is a fairly 
reasonable request. Take LLVM itself, for instance - which supports building 
with Clang back as far as 3.5. (not suggesting we need to have a window that 
large for every feature/piece of surface area - but that there is scope for 
fairly wide windows)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102568

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


[PATCH] D102568: [Driver] Delete -mimplicit-it=

2021-05-19 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

In D102568#2769237 , @mstorsjo wrote:

> In D102568#2769053 , 
> @nickdesaulniers wrote:
>
>>> But this change did break my build in these places:
>>> https://code.videolan.org/videolan/x264/-/blob/b684ebe04a6f80f8207a57940a1fa00e25274f81/configure#L855
>>> https://chromium.googlesource.com/webm/libvpx/+/66c1ff6850fd53bcf5c17247569bea1d700d6247/build/make/configure.sh#1012
>>> https://github.com/cisco/openh264/blob/089d6c6d83ab6e5d451ef18808bb6c46faf553a2/build/platform-mingw_nt.mk#L23
>>
>> Thanks for the links; @MaskRay I think you should file some issues in those 
>> projects to help them move to the assembler option before we try to remove 
>> it again.
>
> Well I already started doing that, I had made one PR, when CI tests there 
> informed me that the new form of the option didn't work out with the version 
> of Clang in use there (10.0 fwiw).

Thanks for noticing the teams.

 Should be an easy fix either way (replace `-mimplicit-it=always` with 
 `-Wa,-wmimplicit-it=always`).
>>>
>>> No, it's not an easy fix as no existing releases of Clang support it.
>>
>> Well, these projects linked above will need to implement either feature 
>> detection for the command line flag options before hard coding them, or 
>> compiler version checks.
>
> I really think it's silly to demand multiple projects to implement detection 
> for this option. Just let's revert this change, let both option forms coexist 
> in a couple public stable releases, until it's acceptable to raise the 
> minimum required tool version for those build configurations to Clang 13 
> (it's a quite niche configuration, but upgrading CI systems always takes some 
> time), and then after that drop the old form (e.g. in Clang 15). Maybe we 
> could add a deprecation warning to the one that we're going to remove in the 
> future?

I don't mind reverting this temporarily.
However, reverting this would break musl build.
musl detects both options and will add both if available: 
`-Wa,-mimplicit-it=never -mimplicit-it=always` will cause a duplicate option 
failure.
Can't there be other projects which do similar detection and be broken by 
having both options?

I think "waiting for a few releases" is too much and doesn't improve things. I 
can accept "waiting for one major release".


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102568

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


[PATCH] D102715: Fix LIT failure on native aix

2021-05-19 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.

LGTM!




Comment at: clang/test/Sema/struct-packed-align.c:170
+#elif defined(_AIX)
+// On AIX, [bool, char, short] bitfields have the same alignment as unsigned
+// int.

hubert.reinterpretcast wrote:
> Xiangling_L wrote:
> > aaron.ballman wrote:
> > > Xiangling_L wrote:
> > > > aaron.ballman wrote:
> > > > > We're not really testing the behavior of `bool` or `short` anywhere 
> > > > > and it'd be nice to verify that. Perhaps instead of modifying an 
> > > > > existing test to add more fields, it'd make sense to make a new test 
> > > > > structure?
> > > > > 
> > > > > While thinking of other potentially smaller-than-int types, I 
> > > > > wondered whether `wchar_t` has special behavior here as well (I have 
> > > > > no idea how that type is defined for AIX, so it's entirely possible 
> > > > > it's size and alignment already match `int`).
> > > > > We're not really testing the behavior of bool or short anywhere and 
> > > > > it'd be nice to verify that. 
> > > > 
> > > > The comment is to explain why char has 4-byte alignment mainly. And the 
> > > > testcase here is, as comments mentioned, to test `Packed attribute 
> > > > shouldn't be ignored for bit-field of char types`.  Perhaps I should 
> > > > remove `bool` and `short` so that people wouldn't be confused.  
> > > > 
> > > > And the special alignment regarding bool, short etc. has been tested 
> > > > when the special rule introduced on aix here: 
> > > > https://reviews.llvm.org/D87029.
> > > > 
> > > > 
> > > > 
> > > > > Perhaps instead of modifying an existing test to add more fields, 
> > > > > it'd make sense to make a new test structure?
> > > > 
> > > > I don't think it's necessary to make a new test structure. The modified 
> > > > testcase test the same property as the original one. And it is more 
> > > > capable as it can also test the property for AIX target.
> > > > 
> > > > 
> > > > 
> > > > 
> > > > > I wondered whether wchar_t has special behavior here as well 
> > > > 
> > > > I think `wchar_t` has the same special behavior. Basically any type 
> > > > smaller than 4 bytes will be aligned to 4 when it comes to bitfield. 
> > > > Please correct me if I am wrong @hubert.reinterpretcast 
> > > > 
> > > > 
> > > > Perhaps I should remove bool and short so that people wouldn't be 
> > > > confused.
> > > 
> > > That might not be a bad idea. I saw the comment and went to look for the 
> > > declarations of `bool` and `short` type to verify they were behaving the 
> > > same way, hence the confusion.
> > > 
> > > > The modified testcase test the same property as the original one.
> > > 
> > > The part that worries me is that it shifts the offset for `e`. Before, 
> > > the packed field could be packed into the previous allocation unit (4 
> > > bits + 8 bits fit comfortably within a 32-bit allocation unit), but now 
> > > the packed field is in an awkward spot (28 bits + 8 bits no longer fits 
> > > into a 32-bit allocation unit). So I think it could be subtly changing 
> > > the behavior of the test, but perhaps not in an observable way that 
> > > matters (I admit that I don't know all the ins and outs of our packing 
> > > strategies).
> > > but now the packed field is in an awkward spot (28 bits + 8 bits no 
> > > longer fits into a 32-bit allocation unit)
> > 
> > 
> > I think this is exactly the purpose of the test. We'd like to tell if the 
> > `packed` attribute has effect or not.
> > 
> > Before the modification, on AIX, no matter the packed works or not, you 
> > will see the size = 4, align = 4 since char has 4-byte alignment.
> My understanding is that the "awkward spot" was always the intention of the 
> test. It's just that the assumption around "allocation unit" size being 1 for 
> `char` was encoded into the test.
Ah, thank you both for pointing that out to me. This just shifts the awkward 
spot to make the test scenario more obvious. That makes a lot more sense to me.


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

https://reviews.llvm.org/D102715

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


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

2021-05-19 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

Generally looks reasonable to me - but I'll leave signoff to some other folks 
who have been more involved in the discussion so far.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102782

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


[PATCH] D102568: [Driver] Delete -mimplicit-it=

2021-05-19 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added a comment.

In D102568#2769053 , @nickdesaulniers 
wrote:

>> But this change did break my build in these places:
>> https://code.videolan.org/videolan/x264/-/blob/b684ebe04a6f80f8207a57940a1fa00e25274f81/configure#L855
>> https://chromium.googlesource.com/webm/libvpx/+/66c1ff6850fd53bcf5c17247569bea1d700d6247/build/make/configure.sh#1012
>> https://github.com/cisco/openh264/blob/089d6c6d83ab6e5d451ef18808bb6c46faf553a2/build/platform-mingw_nt.mk#L23
>
> Thanks for the links; @MaskRay I think you should file some issues in those 
> projects to help them move to the assembler option before we try to remove it 
> again.

Well I already started doing that, I had made one PR, when CI tests there 
informed me that the new form of the option didn't work out with the version of 
Clang in use there (10.0 fwiw).

>>> Should be an easy fix either way (replace `-mimplicit-it=always` with 
>>> `-Wa,-wmimplicit-it=always`).
>>
>> No, it's not an easy fix as no existing releases of Clang support it.
>
> Well, these projects linked above will need to implement either feature 
> detection for the command line flag options before hard coding them, or 
> compiler version checks.

I really think it's silly to demand multiple projects to implement detection 
for this option. Just let's revert this change, let both option forms coexist 
in a couple public stable releases, until it's acceptable to raise the minimum 
required tool version for those build configurations to Clang 13 (it's a quite 
niche configuration, but upgrading CI systems always takes some time), and then 
after that drop the old form (e.g. in Clang 15). Maybe we could add a 
deprecation warning to the one that we're going to remove in the future?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102568

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


[PATCH] D102791: [WebAssembly] Warn on exception spec for Emscripten EH

2021-05-19 Thread Heejin Ahn via Phabricator via cfe-commits
aheejin created this revision.
aheejin added a reviewer: dschuff.
Herald added subscribers: wingo, ecnelises, sunfish, jgravelle-google, sbc100.
aheejin requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

It turns out we have not correctly supported exception spec all along in
Emscripten EH. Emscripten EH supports `throw()` but not `throw` with
types. See https://bugs.llvm.org/show_bug.cgi?id=50396.

Wasm EH also only supports `throw()` but not `throw` with types, and we
have been printing a warning message for the latter. This prints the
same warning message for `throw` with types when Emscripten EH is used,
or more precisely, when Wasm EH is not used. (So this will print the
warning messsage even when `-fno-exceptions` is used but I think that
should be fine. It's cumbersome to do a complilcated option checking in
CGException.cpp and options checkings are mostly done in elsewhere.)


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D102791

Files:
  clang/lib/CodeGen/CGException.cpp
  clang/test/CodeGenCXX/wasm-eh.cpp


Index: clang/test/CodeGenCXX/wasm-eh.cpp
===
--- clang/test/CodeGenCXX/wasm-eh.cpp
+++ clang/test/CodeGenCXX/wasm-eh.cpp
@@ -381,7 +381,7 @@
 // RUN: %clang_cc1 %s -triple wasm32-unknown-unknown -fms-extensions 
-fexceptions -fcxx-exceptions -exception-model=wasm -target-feature 
+exception-handling -emit-llvm -o - -std=c++11 2>&1 | FileCheck %s 
--check-prefix=WARNING-DEFAULT
 // RUN: %clang_cc1 %s -triple wasm32-unknown-unknown -fms-extensions 
-fexceptions -fcxx-exceptions -exception-model=wasm -target-feature 
+exception-handling -Wwasm-exception-spec -emit-llvm -o - -std=c++11 2>&1 | 
FileCheck %s --check-prefix=WARNING-ON
 // RUN: %clang_cc1 %s -triple wasm32-unknown-unknown -fms-extensions 
-fexceptions -fcxx-exceptions -exception-model=wasm -target-feature 
+exception-handling -Wno-wasm-exception-spec -emit-llvm -o - -std=c++11 2>&1 | 
FileCheck %s --check-prefix=WARNING-OFF
-// RUN: %clang_cc1 %s -triple wasm32-unknown-unknown -fexceptions 
-fcxx-exceptions -emit-llvm -o - -std=c++11 2>&1 | FileCheck %s 
--check-prefix=NOT-WASM-EH
+// RUN: %clang_cc1 %s -triple wasm32-unknown-unknown -fexceptions 
-fcxx-exceptions -emit-llvm -o - -std=c++11 2>&1 | FileCheck %s 
--check-prefix=EM-EH-WARNING
 
 // Wasm EH ignores dynamic exception specifications with types at the moment.
 // This is controlled by -Wwasm-exception-spec, which is on by default. This
@@ -392,7 +392,7 @@
 // WARNING-DEFAULT: warning: dynamic exception specifications with types are 
currently ignored in wasm
 // WARNING-ON: warning: dynamic exception specifications with types are 
currently ignored in wasm
 // WARNING-OFF-NOT: warning: dynamic exception specifications with types are 
currently ignored in wasm
-// NOT-WASM-EH-NOT: warning: dynamic exception specifications with types are 
currently ignored in wasm
+// EM-EH-WARNING: warning: dynamic exception specifications with types are 
currently ignored in wasm
 
 // Wasm curremtly treats 'throw()' in the same way as 'noexept'. Check if the
 // same warning message is printed as if when a 'noexcept' function throws.
Index: clang/lib/CodeGen/CGException.cpp
===
--- clang/lib/CodeGen/CGException.cpp
+++ clang/lib/CodeGen/CGException.cpp
@@ -473,9 +473,9 @@
 // encode these in an object file but MSVC doesn't do anything with it.
 if (getTarget().getCXXABI().isMicrosoft())
   return;
-// In wasm we currently treat 'throw()' in the same way as 'noexcept'. In
+// In Wasm EH we currently treat 'throw()' in the same way as 'noexcept'. 
In
 // case of throw with types, we ignore it and print a warning for now.
-// TODO Correctly handle exception specification in wasm
+// TODO Correctly handle exception specification in Wasm EH
 if (CGM.getLangOpts().hasWasmExceptions()) {
   if (EST == EST_DynamicNone)
 EHStack.pushTerminate();
@@ -485,6 +485,19 @@
 << FD->getExceptionSpecSourceRange();
   return;
 }
+// Currently Emscripten EH only handles 'throw()' but not 'throw' with
+// types. 'throw()' handling will be done in JS glue code so we don't need
+// to do anything in that case. Just print a warning message in case of
+// throw with types.
+// TODO Correctly handle exception specification in Emscripten EH
+if (getTarget().getCXXABI() == TargetCXXABI::WebAssembly &&
+CGM.getLangOpts().getExceptionHandling() ==
+LangOptions::ExceptionHandlingKind::None &&
+EST == EST_Dynamic)
+  CGM.getDiags().Report(D->getLocation(),
+diag::warn_wasm_dynamic_exception_spec_ignored)
+  << FD->getExceptionSpecSourceRange();
+
 unsigned NumExceptions = Proto->getNumExceptions();
 EHFilterScope *Filter = EHStack.pushFilter(NumExceptions);
 

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

2021-05-19 Thread Jamie Schmeiser via Phabricator via cfe-commits
jamieschmeiser requested review of this revision.
jamieschmeiser added a comment.

Significant changes made since previously accepted.


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

https://reviews.llvm.org/D98798

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


  1   2   >