[PATCH] D108421: Mark openmp internal global dso_local

2021-09-07 Thread kamlesh kumar via Phabricator via cfe-commits
kamleshbhalui added a comment.

ping?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108421

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


[PATCH] D108753: [analyzer] MallocChecker: Add notes from NoOwnershipChangeVisitor only when a function "intents", but doesn't change ownership, enable by default

2021-09-07 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ accepted this revision.
NoQ added a comment.

This looks good!

I guess one way to make this //even more// conservative would be to match the 
variable inside the delete-expression to the one we expect to get deallocated.


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

https://reviews.llvm.org/D108753

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


[PATCH] D105092: [RISCV] (1/2) Add the tail policy argument to builtins/intrinsics.

2021-09-07 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td:2292
+   (op2_type op2_reg_class:$rs2),
+   (mask_type V0), GPR:$vl, sew, (XLenVT GPR:$policy))>;
+

Does timm:$policy work down here too?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105092

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


[PATCH] D108881: [clang][driver] Honor the last -flto(=.*)? argument

2021-09-07 Thread Usman Nadeem via Phabricator via cfe-commits
mnadeem updated this revision to Diff 371245.

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

https://reviews.llvm.org/D108881

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/Driver/amdgpu-toolchain.c
  clang/test/Driver/lto.c

Index: clang/test/Driver/lto.c
===
--- clang/test/Driver/lto.c
+++ clang/test/Driver/lto.c
@@ -85,3 +85,23 @@
 // FLTO-AUTO: -flto=full
 // FLTO-JOBSERVER: -flto=full
 //
+
+// Pass the last -flto argument.
+// RUN: %clang -target x86_64-unknown-linux -### %s -flto=thin -flto 2>&1 | \
+// RUN: FileCheck --check-prefix=FLTO-FULL %s
+// RUN: %clang -target x86_64-unknown-linux -### %s -flto=thin -flto=full \
+// RUN: 2>&1 | FileCheck --check-prefix=FLTO-FULL %s
+// RUN: %clang -target x86_64-unknown-linux -### %s -flto=full -flto=thin  \
+// RUN: 2>&1 | FileCheck --check-prefix=FLTO-THIN %s
+// RUN: %clang -target x86_64-unknown-linux -### %s -flto -flto=thin 2>&1 | \
+// RUN: FileCheck --check-prefix=FLTO-THIN %s
+//
+// FLTO-FULL-NOT: -flto=thin
+// FLTO-FULL: -flto=full
+// FLTO-FULL-NOT: -flto=thin
+//
+// FLTO-THIN-NOT: -flto=full
+// FLTO-THIN-NOT: "-flto"
+// FLTO-THIN: -flto=thin
+// FLTO-THIN-NOT: "-flto"
+// FLTO-THIN-NOT: -flto=full
\ No newline at end of file
Index: clang/test/Driver/amdgpu-toolchain.c
===
--- clang/test/Driver/amdgpu-toolchain.c
+++ clang/test/Driver/amdgpu-toolchain.c
@@ -12,5 +12,5 @@
 
 // RUN: %clang -### -target amdgcn-amd-amdhsa -mcpu=gfx906 -nogpulib \
 // RUN:   -flto %s 2>&1 | FileCheck -check-prefix=LTO %s
-// LTO: clang{{.*}} "-flto"
+// LTO: clang{{.*}} "-flto=full"
 // LTO: ld.lld{{.*}}
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -1419,7 +1419,7 @@
   }
 
   if (Opts.PrepareForLTO && !Opts.PrepareForThinLTO)
-GenerateArg(Args, OPT_flto, SA);
+GenerateArg(Args, OPT_flto_EQ, "full", SA);
 
   if (Opts.PrepareForThinLTO)
 GenerateArg(Args, OPT_flto_EQ, "thin", SA);
@@ -1706,9 +1706,10 @@
 }
   }
 
-  Opts.PrepareForLTO = Args.hasArg(OPT_flto, OPT_flto_EQ);
+  Opts.PrepareForLTO = false;
   Opts.PrepareForThinLTO = false;
   if (Arg *A = Args.getLastArg(OPT_flto_EQ)) {
+Opts.PrepareForLTO = true;
 StringRef S = A->getValue();
 if (S == "thin")
   Opts.PrepareForThinLTO = true;
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -4474,28 +4474,18 @@
   CmdArgs.push_back("-emit-llvm-uselists");
 
 if (IsUsingLTO) {
-  if (!IsDeviceOffloadAction) {
-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");
-  } else if (Triple.isAMDGPU()) {
-// Only AMDGPU supports device-side LTO
-assert(LTOMode == LTOK_Full || LTOMode == LTOK_Thin);
-CmdArgs.push_back(Args.MakeArgString(
-Twine("-flto=") + (LTOMode == LTOK_Thin ? "thin" : "full")));
-CmdArgs.push_back("-flto-unit");
-  } else {
+  // Only AMDGPU supports device-side LTO.
+  if (IsDeviceOffloadAction && !Triple.isAMDGPU()) {
 D.Diag(diag::err_drv_unsupported_opt_for_target)
 << Args.getLastArg(options::OPT_foffload_lto,
options::OPT_foffload_lto_EQ)
->getAsString(Args)
 << Triple.getTriple();
+  } else {
+assert(LTOMode == LTOK_Full || LTOMode == LTOK_Thin);
+CmdArgs.push_back(Args.MakeArgString(
+Twine("-flto=") + (LTOMode == LTOK_Thin ? "thin" : "full")));
+CmdArgs.push_back("-flto-unit");
   }
 }
   }
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -585,53 +585,34 @@
 // Parse the LTO options and record the type of LTO compilation
 // based on which -f(no-)?lto(=.*)? or -f(no-)?offload-lto(=.*)?
 // option occurs last.
-static llvm::Optional
-parseLTOMode(Driver , const llvm::opt::ArgList , OptSpecifier OptPos,
- OptSpecifier OptNeg, OptSpecifier OptEq, bool IsOffload) {
-  driver::LTOKind LTOMode = LTOK_None;
-  // Non-offload LTO allows -flto=auto and -flto=jobserver. Offload LTO does
-  // not support those options.
-  if (!Args.hasFlag(OptPos, OptEq, OptNeg, false) &&
-  (IsOffload ||
-   

[PATCH] D108881: [clang][driver] Honor the last -flto(=.*)? argument

2021-09-07 Thread Usman Nadeem via Phabricator via cfe-commits
mnadeem added inline comments.



Comment at: clang/lib/Driver/Driver.cpp:596-598
-   (!Args.hasFlag(options::OPT_flto_EQ_auto, options::OPT_fno_lto, false) 
&&
-!Args.hasFlag(options::OPT_flto_EQ_jobserver, options::OPT_fno_lto,
-  false

These were removed because the options now alias with flto=full.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108881

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


[PATCH] D108881: [clang][driver] Honor the last -flto(=.*)? argument

2021-09-07 Thread Usman Nadeem via Phabricator via cfe-commits
mnadeem updated this revision to Diff 371241.
mnadeem added a comment.

- - Make flto an alias of flto=full.
- - Make foffload-lto an alias of foffload-lto=full.
- - Make flto_EQ_jobserver, flto_EQ_auto aliases of flto=full, since they are  
being treated as full lto right now.
- - Clean up the code for parseLTOMode and setLTOMode.
- - Replace uses of OPT_flto with OPT_flto_EQ.

I'm not very familiar with driver code so let me know if I made any mistake or 
left anything out.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108881

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/Driver/amdgpu-toolchain.c
  clang/test/Driver/lto.c

Index: clang/test/Driver/lto.c
===
--- clang/test/Driver/lto.c
+++ clang/test/Driver/lto.c
@@ -85,3 +85,23 @@
 // FLTO-AUTO: -flto=full
 // FLTO-JOBSERVER: -flto=full
 //
+
+// Pass the last -flto argument.
+// RUN: %clang -target x86_64-unknown-linux -### %s -flto=thin -flto 2>&1 | \
+// RUN: FileCheck --check-prefix=FLTO-FULL %s
+// RUN: %clang -target x86_64-unknown-linux -### %s -flto=thin -flto=full \
+// 2>&1 | RUN: FileCheck --check-prefix=FLTO-FULL %s
+// RUN: %clang -target x86_64-unknown-linux -### %s -flto=full -flto=thin  \
+// 2>&1 | RUN: FileCheck --check-prefix=FLTO-THIN %s
+// RUN: %clang -target x86_64-unknown-linux -### %s -flto -flto=thin 2>&1 | \
+// RUN: FileCheck --check-prefix=FLTO-THIN %s
+//
+// FLTO-FULL-NOT: -flto=thin
+// FLTO-FULL: -flto=full
+// FLTO-FULL-NOT: -flto=thin
+//
+// FLTO-THIN-NOT: -flto=full
+// FLTO-THIN-NOT: "-flto"
+// FLTO-THIN: -flto=thin
+// FLTO-THIN-NOT: "-flto"
+// FLTO-THIN-NOT: -flto=full
\ No newline at end of file
Index: clang/test/Driver/amdgpu-toolchain.c
===
--- clang/test/Driver/amdgpu-toolchain.c
+++ clang/test/Driver/amdgpu-toolchain.c
@@ -12,5 +12,5 @@
 
 // RUN: %clang -### -target amdgcn-amd-amdhsa -mcpu=gfx906 -nogpulib \
 // RUN:   -flto %s 2>&1 | FileCheck -check-prefix=LTO %s
-// LTO: clang{{.*}} "-flto"
+// LTO: clang{{.*}} "-flto=full"
 // LTO: ld.lld{{.*}}
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -1419,7 +1419,7 @@
   }
 
   if (Opts.PrepareForLTO && !Opts.PrepareForThinLTO)
-GenerateArg(Args, OPT_flto, SA);
+GenerateArg(Args, OPT_flto_EQ, "full", SA);
 
   if (Opts.PrepareForThinLTO)
 GenerateArg(Args, OPT_flto_EQ, "thin", SA);
@@ -1706,9 +1706,10 @@
 }
   }
 
-  Opts.PrepareForLTO = Args.hasArg(OPT_flto, OPT_flto_EQ);
+  Opts.PrepareForLTO = false;
   Opts.PrepareForThinLTO = false;
   if (Arg *A = Args.getLastArg(OPT_flto_EQ)) {
+Opts.PrepareForLTO = true;
 StringRef S = A->getValue();
 if (S == "thin")
   Opts.PrepareForThinLTO = true;
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -4474,28 +4474,18 @@
   CmdArgs.push_back("-emit-llvm-uselists");
 
 if (IsUsingLTO) {
-  if (!IsDeviceOffloadAction) {
-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");
-  } else if (Triple.isAMDGPU()) {
-// Only AMDGPU supports device-side LTO
-assert(LTOMode == LTOK_Full || LTOMode == LTOK_Thin);
-CmdArgs.push_back(Args.MakeArgString(
-Twine("-flto=") + (LTOMode == LTOK_Thin ? "thin" : "full")));
-CmdArgs.push_back("-flto-unit");
-  } else {
+  // Only AMDGPU supports device-side LTO.
+  if (IsDeviceOffloadAction && !Triple.isAMDGPU()) {
 D.Diag(diag::err_drv_unsupported_opt_for_target)
 << Args.getLastArg(options::OPT_foffload_lto,
options::OPT_foffload_lto_EQ)
->getAsString(Args)
 << Triple.getTriple();
+  } else {
+assert(LTOMode == LTOK_Full || LTOMode == LTOK_Thin);
+CmdArgs.push_back(Args.MakeArgString(
+Twine("-flto=") + (LTOMode == LTOK_Thin ? "thin" : "full")));
+CmdArgs.push_back("-flto-unit");
   }
 }
   }
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -585,53 +585,34 @@
 // Parse the LTO options and record the type of LTO compilation
 // based on which 

[clang] b0d4d96 - [AVR] Add support for the tinyAVR 0-series and tinyAVR 1-series

2021-09-07 Thread Ben Shi via cfe-commits

Author: Justin Latimer
Date: 2021-09-08T02:35:26Z
New Revision: b0d4d969e22efd282047e51b7927c1ab53eccf32

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

LOG: [AVR] Add support for the tinyAVR 0-series and tinyAVR 1-series

Reviewed By: Dylan McKay, Ben Shi

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

Added: 


Modified: 
clang/lib/Basic/Targets/AVR.cpp
clang/test/Misc/target-invalid-cpu-note.c
llvm/lib/Target/AVR/AVRDevices.td

Removed: 




diff  --git a/clang/lib/Basic/Targets/AVR.cpp b/clang/lib/Basic/Targets/AVR.cpp
index e87b7338c4d6e..3d163dc897a49 100644
--- a/clang/lib/Basic/Targets/AVR.cpp
+++ b/clang/lib/Basic/Targets/AVR.cpp
@@ -274,6 +274,31 @@ static MCUInfo AVRMcus[] = {
 {"attiny40", "__AVR_ATtiny40__"},
 {"attiny102", "__AVR_ATtiny102__"},
 {"attiny104", "__AVR_ATtiny104__"},
+{"attiny202", "__AVR_ATtiny202__"},
+{"attiny402", "__AVR_ATtiny402__"},
+{"attiny204", "__AVR_ATtiny204__"},
+{"attiny404", "__AVR_ATtiny404__"},
+{"attiny804", "__AVR_ATtiny804__"},
+{"attiny1604", "__AVR_ATtiny1604__"},
+{"attiny406", "__AVR_ATtiny406__"},
+{"attiny806", "__AVR_ATtiny806__"},
+{"attiny1606", "__AVR_ATtiny1606__"},
+{"attiny807", "__AVR_ATtiny807__"},
+{"attiny1607", "__AVR_ATtiny1607__"},
+{"attiny212", "__AVR_ATtiny212__"},
+{"attiny412", "__AVR_ATtiny412__"},
+{"attiny214", "__AVR_ATtiny214__"},
+{"attiny414", "__AVR_ATtiny414__"},
+{"attiny814", "__AVR_ATtiny814__"},
+{"attiny1614", "__AVR_ATtiny1614__"},
+{"attiny416", "__AVR_ATtiny416__"},
+{"attiny816", "__AVR_ATtiny816__"},
+{"attiny1616", "__AVR_ATtiny1616__"},
+{"attiny3216", "__AVR_ATtiny3216__"},
+{"attiny417", "__AVR_ATtiny417__"},
+{"attiny817", "__AVR_ATtiny817__"},
+{"attiny1617", "__AVR_ATtiny1617__"},
+{"attiny3217", "__AVR_ATtiny3217__"},
 };
 
 } // namespace targets

diff  --git a/clang/test/Misc/target-invalid-cpu-note.c 
b/clang/test/Misc/target-invalid-cpu-note.c
index 8963c309e6dbe..4c3cd5e01df8a 100644
--- a/clang/test/Misc/target-invalid-cpu-note.c
+++ b/clang/test/Misc/target-invalid-cpu-note.c
@@ -188,7 +188,11 @@
 // AVR-SAME: atxmega256a3, atxmega256a3u, atxmega256a3b, atxmega256a3bu, 
atxmega256c3,
 // AVR-SAME: atxmega256d3, atxmega384c3, atxmega384d3, atxmega128a1, 
atxmega128a1u,
 // AVR-SAME: atxmega128a4u, attiny4, attiny5, attiny9, attiny10, attiny20, 
attiny40,
-// AVR-SAME: attiny102, attiny104
+// AVR-SAME: attiny102, attiny104, attiny202, attiny402, attiny204, attiny404, 
attiny804,
+// AVR-SAME: attiny1604, attiny406, attiny806, attiny1606, attiny807, 
attiny1607,
+// AVR-SAME: attiny212, attiny412, attiny214, attiny414, attiny814, attiny1614,
+// AVR-SAME: attiny416, attiny816, attiny1616, attiny3216, attiny417, 
attiny817,
+// AVR-SAME: attiny1617, attiny3217
 
 // RUN: not %clang_cc1 -triple riscv32 -target-cpu not-a-cpu -fsyntax-only %s 
2>&1 | FileCheck %s --check-prefix RISCV32
 // RISCV32: error: unknown target CPU 'not-a-cpu'

diff  --git a/llvm/lib/Target/AVR/AVRDevices.td 
b/llvm/lib/Target/AVR/AVRDevices.td
index e3cfdbcbc2a76..7ad0fe904a819 100644
--- a/llvm/lib/Target/AVR/AVRDevices.td
+++ b/llvm/lib/Target/AVR/AVRDevices.td
@@ -498,3 +498,28 @@ def : Device<"attiny20", FamilyTiny, ELFArchTiny>;
 def : Device<"attiny40", FamilyTiny, ELFArchTiny>;
 def : Device<"attiny102", FamilyTiny, ELFArchTiny>;
 def : Device<"attiny104", FamilyTiny, ELFArchTiny>;
+def : Device<"attiny202", FamilyXMEGA, ELFArchXMEGA3>;
+def : Device<"attiny402", FamilyXMEGA, ELFArchXMEGA3>;
+def : Device<"attiny204", FamilyXMEGA, ELFArchXMEGA3>;
+def : Device<"attiny404", FamilyXMEGA, ELFArchXMEGA3>;
+def : Device<"attiny804", FamilyXMEGA, ELFArchXMEGA3>;
+def : Device<"attiny1604", FamilyXMEGA, ELFArchXMEGA3>;
+def : Device<"attiny406", FamilyXMEGA, ELFArchXMEGA3>;
+def : Device<"attiny806", FamilyXMEGA, ELFArchXMEGA3>;
+def : Device<"attiny1606", FamilyXMEGA, ELFArchXMEGA3>;
+def : Device<"attiny807", FamilyXMEGA, ELFArchXMEGA3>;
+def : Device<"attiny1607", FamilyXMEGA, ELFArchXMEGA3>;
+def : Device<"attiny212", FamilyXMEGA, ELFArchXMEGA3>;
+def : Device<"attiny412", FamilyXMEGA, ELFArchXMEGA3>;
+def : Device<"attiny214", FamilyXMEGA, ELFArchXMEGA3>;
+def : Device<"attiny414", FamilyXMEGA, ELFArchXMEGA3>;
+def : Device<"attiny814", FamilyXMEGA, ELFArchXMEGA3>;
+def : Device<"attiny1614", FamilyXMEGA, ELFArchXMEGA3>;
+def : Device<"attiny416", FamilyXMEGA, ELFArchXMEGA3>;
+def : Device<"attiny816", FamilyXMEGA, ELFArchXMEGA3>;
+def : Device<"attiny1616", FamilyXMEGA, ELFArchXMEGA3>;
+def : Device<"attiny3216", FamilyXMEGA, ELFArchXMEGA3>;
+def : Device<"attiny417", FamilyXMEGA, ELFArchXMEGA3>;
+def : Device<"attiny817", FamilyXMEGA, ELFArchXMEGA3>;
+def : 

[PATCH] D103136: [AVR] Add support for the tinyAVR 0-series and tinyAVR 1-seriesø

2021-09-07 Thread Ben Shi 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 rGb0d4d969e22e: [AVR] Add support for the tinyAVR 0-series and 
tinyAVR 1-series (authored by justinlatimer, committed by benshi001).

Changed prior to commit:
  https://reviews.llvm.org/D103136?vs=371176=371237#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103136

Files:
  clang/lib/Basic/Targets/AVR.cpp
  clang/test/Misc/target-invalid-cpu-note.c
  llvm/lib/Target/AVR/AVRDevices.td


Index: llvm/lib/Target/AVR/AVRDevices.td
===
--- llvm/lib/Target/AVR/AVRDevices.td
+++ llvm/lib/Target/AVR/AVRDevices.td
@@ -498,3 +498,28 @@
 def : Device<"attiny40", FamilyTiny, ELFArchTiny>;
 def : Device<"attiny102", FamilyTiny, ELFArchTiny>;
 def : Device<"attiny104", FamilyTiny, ELFArchTiny>;
+def : Device<"attiny202", FamilyXMEGA, ELFArchXMEGA3>;
+def : Device<"attiny402", FamilyXMEGA, ELFArchXMEGA3>;
+def : Device<"attiny204", FamilyXMEGA, ELFArchXMEGA3>;
+def : Device<"attiny404", FamilyXMEGA, ELFArchXMEGA3>;
+def : Device<"attiny804", FamilyXMEGA, ELFArchXMEGA3>;
+def : Device<"attiny1604", FamilyXMEGA, ELFArchXMEGA3>;
+def : Device<"attiny406", FamilyXMEGA, ELFArchXMEGA3>;
+def : Device<"attiny806", FamilyXMEGA, ELFArchXMEGA3>;
+def : Device<"attiny1606", FamilyXMEGA, ELFArchXMEGA3>;
+def : Device<"attiny807", FamilyXMEGA, ELFArchXMEGA3>;
+def : Device<"attiny1607", FamilyXMEGA, ELFArchXMEGA3>;
+def : Device<"attiny212", FamilyXMEGA, ELFArchXMEGA3>;
+def : Device<"attiny412", FamilyXMEGA, ELFArchXMEGA3>;
+def : Device<"attiny214", FamilyXMEGA, ELFArchXMEGA3>;
+def : Device<"attiny414", FamilyXMEGA, ELFArchXMEGA3>;
+def : Device<"attiny814", FamilyXMEGA, ELFArchXMEGA3>;
+def : Device<"attiny1614", FamilyXMEGA, ELFArchXMEGA3>;
+def : Device<"attiny416", FamilyXMEGA, ELFArchXMEGA3>;
+def : Device<"attiny816", FamilyXMEGA, ELFArchXMEGA3>;
+def : Device<"attiny1616", FamilyXMEGA, ELFArchXMEGA3>;
+def : Device<"attiny3216", FamilyXMEGA, ELFArchXMEGA3>;
+def : Device<"attiny417", FamilyXMEGA, ELFArchXMEGA3>;
+def : Device<"attiny817", FamilyXMEGA, ELFArchXMEGA3>;
+def : Device<"attiny1617", FamilyXMEGA, ELFArchXMEGA3>;
+def : Device<"attiny3217", FamilyXMEGA, ELFArchXMEGA3>;
Index: clang/test/Misc/target-invalid-cpu-note.c
===
--- clang/test/Misc/target-invalid-cpu-note.c
+++ clang/test/Misc/target-invalid-cpu-note.c
@@ -188,7 +188,11 @@
 // AVR-SAME: atxmega256a3, atxmega256a3u, atxmega256a3b, atxmega256a3bu, 
atxmega256c3,
 // AVR-SAME: atxmega256d3, atxmega384c3, atxmega384d3, atxmega128a1, 
atxmega128a1u,
 // AVR-SAME: atxmega128a4u, attiny4, attiny5, attiny9, attiny10, attiny20, 
attiny40,
-// AVR-SAME: attiny102, attiny104
+// AVR-SAME: attiny102, attiny104, attiny202, attiny402, attiny204, attiny404, 
attiny804,
+// AVR-SAME: attiny1604, attiny406, attiny806, attiny1606, attiny807, 
attiny1607,
+// AVR-SAME: attiny212, attiny412, attiny214, attiny414, attiny814, attiny1614,
+// AVR-SAME: attiny416, attiny816, attiny1616, attiny3216, attiny417, 
attiny817,
+// AVR-SAME: attiny1617, attiny3217
 
 // RUN: not %clang_cc1 -triple riscv32 -target-cpu not-a-cpu -fsyntax-only %s 
2>&1 | FileCheck %s --check-prefix RISCV32
 // RISCV32: error: unknown target CPU 'not-a-cpu'
Index: clang/lib/Basic/Targets/AVR.cpp
===
--- clang/lib/Basic/Targets/AVR.cpp
+++ clang/lib/Basic/Targets/AVR.cpp
@@ -274,6 +274,31 @@
 {"attiny40", "__AVR_ATtiny40__"},
 {"attiny102", "__AVR_ATtiny102__"},
 {"attiny104", "__AVR_ATtiny104__"},
+{"attiny202", "__AVR_ATtiny202__"},
+{"attiny402", "__AVR_ATtiny402__"},
+{"attiny204", "__AVR_ATtiny204__"},
+{"attiny404", "__AVR_ATtiny404__"},
+{"attiny804", "__AVR_ATtiny804__"},
+{"attiny1604", "__AVR_ATtiny1604__"},
+{"attiny406", "__AVR_ATtiny406__"},
+{"attiny806", "__AVR_ATtiny806__"},
+{"attiny1606", "__AVR_ATtiny1606__"},
+{"attiny807", "__AVR_ATtiny807__"},
+{"attiny1607", "__AVR_ATtiny1607__"},
+{"attiny212", "__AVR_ATtiny212__"},
+{"attiny412", "__AVR_ATtiny412__"},
+{"attiny214", "__AVR_ATtiny214__"},
+{"attiny414", "__AVR_ATtiny414__"},
+{"attiny814", "__AVR_ATtiny814__"},
+{"attiny1614", "__AVR_ATtiny1614__"},
+{"attiny416", "__AVR_ATtiny416__"},
+{"attiny816", "__AVR_ATtiny816__"},
+{"attiny1616", "__AVR_ATtiny1616__"},
+{"attiny3216", "__AVR_ATtiny3216__"},
+{"attiny417", "__AVR_ATtiny417__"},
+{"attiny817", "__AVR_ATtiny817__"},
+{"attiny1617", "__AVR_ATtiny1617__"},
+{"attiny3217", "__AVR_ATtiny3217__"},
 };
 
 } // namespace targets


Index: llvm/lib/Target/AVR/AVRDevices.td
===
--- 

[PATCH] D109411: [clang] Enable the special enable_if_t diagnostics for libc++'s _EnableIf as well.

2021-09-07 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone created this revision.
Quuxplusone added reviewers: ldionne, doug.gregor, rsmith, dblaikie, courbet, 
saar.raz.
Quuxplusone added a project: clang.
Quuxplusone requested review of this revision.
Herald added a subscriber: cfe-commits.

This comes from lengthy discussion between @Quuxplusone and @ldionne over on 
D108216 .
Right now, libc++ uses a "SCARY metaprogramming" version of `_EnableIf` that 
bypasses all of Clang's clever diagnostic stuff and produces bad diagnostics. 
My recent benchmarks ( 
https://quuxplusone.github.io/blog/2021/09/04/enable-if-benchmark/ ) have 
determined that the SCARYness is not buying us any speedup; therefore we are 
happy to drop it and go back to using the standard `std::enable_if` for all our 
SFINAE needs. //However//, we don't want to type out `typename 
std::enable_if::type` all over the library; we want to use an alias 
template. And we can't use `std::enable_if_t` because we need a solution that 
works in C++11, and we do not provide `std::enable_if_t` in C++11.
Therefore, the name `_EnableIf` might persist for a while longer, but as merely 
a thin veneer over `std::enable_if` (instead of a whole other weird SCARY 
thing). Therefore, to get the good diagnostics, can we just make Clang treat 
`_EnableIf` as a synonym of `enable_if_t` from now on?

(Btw, this existing code is all sorts of broken, theoretically speaking. I 
filed https://bugs.llvm.org/show_bug.cgi?id=51696 about it last week. So if 
someone wants to use this PR as an excuse to go down the rabbit hole and fix it 
for real, that would be cool too.)


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D109411

Files:
  clang/lib/Sema/SemaTemplate.cpp


Index: clang/lib/Sema/SemaTemplate.cpp
===
--- clang/lib/Sema/SemaTemplate.cpp
+++ clang/lib/Sema/SemaTemplate.cpp
@@ -3511,8 +3511,10 @@
 }
 
 /// Determine whether this alias template is "enable_if_t".
+/// libc++ sometimes uses "_EnableIf".
 static bool isEnableIfAliasTemplate(TypeAliasTemplateDecl *AliasTemplate) {
-  return AliasTemplate->getName().equals("enable_if_t");
+  return AliasTemplate->getName().equals("enable_if_t") ||
+ AliasTemplate->getName().equals("_EnableIf");
 }
 
 /// Collect all of the separable terms in the given condition, which


Index: clang/lib/Sema/SemaTemplate.cpp
===
--- clang/lib/Sema/SemaTemplate.cpp
+++ clang/lib/Sema/SemaTemplate.cpp
@@ -3511,8 +3511,10 @@
 }
 
 /// Determine whether this alias template is "enable_if_t".
+/// libc++ sometimes uses "_EnableIf".
 static bool isEnableIfAliasTemplate(TypeAliasTemplateDecl *AliasTemplate) {
-  return AliasTemplate->getName().equals("enable_if_t");
+  return AliasTemplate->getName().equals("enable_if_t") ||
+ AliasTemplate->getName().equals("_EnableIf");
 }
 
 /// Collect all of the separable terms in the given condition, which
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D109408: [libcxxabi] NFC: fix incorrect indentation of braces

2021-09-07 Thread zhouyizhou via Phabricator via cfe-commits
zhouyizhou added a comment.

In D109408#2988417 , @ldionne wrote:

> FWIW, I dislike that we don't indent stuff at all inside namespaces -- often 
> I find it useful to indent things inside short-lived namespaces. But let's go 
> for simplicity and consistency.
>
> Did you look into clang-formatting other files in libc++abi? What would the 
> diff look like?

Thanks for reviewing,
I will look into other files in libc++abi one by one, and report what I have 
found ;-)
Thanks again
Zhouyi




Comment at: libcxxabi/src/cxa_exception_storage.cpp:102
 }
 }
+} // namespace __cxxabiv1

Quuxplusone wrote:
> LGTM, FWIW.
> 
> It's surprising that clang-format adds `} // namespace foo` closing comments, 
> but doesn't add `} // extern "C"` closing comments: this lonely brace is a 
> bit confusing and I think it //would// benefit from an `// extern "C"` 
> comment.
Thanks for reviewing, 
clang-format do behave a little strange to me. The result of invoking 
clang-format in git cloned directory is diffent from invoking clang-format in 
other directory ( for example /tmp).
By the way, I have not write access to LLVM, so I need someone to commit for me.

Thanks again ;-)
Zhouyi


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109408

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


[PATCH] D108696: [Coroutines] [Frontend] Lookup in std namespace first

2021-09-07 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu planned changes to this revision.
ChuanqiXu added a comment.

We should proceed after D108697  accepted.


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

https://reviews.llvm.org/D108696

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


[PATCH] D109408: [libcxxabi] NFC: fix incorrect indentation of braces

2021-09-07 Thread Louis Dionne via Phabricator via cfe-commits
ldionne accepted this revision.
ldionne added a comment.
This revision is now accepted and ready to land.

FWIW, I dislike that we don't indent stuff at all inside namespaces -- often I 
find it useful to indent things inside short-lived namespaces. But let's go for 
simplicity and consistency.

Did you look into clang-formatting other files in libc++abi? What would the 
diff look like?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109408

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


[PATCH] D109408: [libcxxabi] NFC: fix incorrect indentation of braces

2021-09-07 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone added inline comments.



Comment at: libcxxabi/src/cxa_exception_storage.cpp:102
 }
 }
+} // namespace __cxxabiv1

LGTM, FWIW.

It's surprising that clang-format adds `} // namespace foo` closing comments, 
but doesn't add `} // extern "C"` closing comments: this lonely brace is a bit 
confusing and I think it //would// benefit from an `// extern "C"` comment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109408

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


[PATCH] D109386: Fix use-after-free from GlobalCtors associated data

2021-09-07 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

This seems like a good use for a ValueHandle, even if it is slightly more code.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109386

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


[PATCH] D109406: [clang] fix transformation of template arguments of 'auto' type constraints

2021-09-07 Thread Matheus Izvekov 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 rG68b9d8ed7abe: [clang] fix transformation of template 
arguments of auto type constraints (authored by mizvekov).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109406

Files:
  clang/lib/Sema/TreeTransform.h
  clang/test/CXX/dcl/dcl.spec/dcl.type/dcl.spec.auto/p6.cpp


Index: clang/test/CXX/dcl/dcl.spec/dcl.type/dcl.spec.auto/p6.cpp
===
--- clang/test/CXX/dcl/dcl.spec/dcl.type/dcl.spec.auto/p6.cpp
+++ clang/test/CXX/dcl/dcl.spec/dcl.type/dcl.spec.auto/p6.cpp
@@ -76,3 +76,25 @@
   template concept d = true;
   d<,> auto e = 0; // expected-error{{expected expression}}
 }
+
+namespace PR48617 {
+  template  concept C = true;
+  template  class A {};
+
+  template  C auto e(A) { return 0; }
+
+  // FIXME: The error here does not make sense.
+  template auto e<>(A<>);
+  // expected-error@-1 {{explicit instantiation of 'e' does not refer to a 
function template}}
+  // expected-note@-5  {{candidate template ignored: failed template argument 
deduction}}
+
+  // FIXME: Should be able to instantiate this with no errors.
+  template C auto e(A);
+  // expected-error@-1 {{explicit instantiation of 'e' does not refer to a 
function template}}
+  // expected-note@-10 {{candidate template ignored: could not match 'C auto' against 'C auto'}}
+  
+  template C<> auto e<>(A<>);
+
+  template  A c(Ts...);
+  int f = e(c(1, 2));
+}
Index: clang/lib/Sema/TreeTransform.h
===
--- clang/lib/Sema/TreeTransform.h
+++ clang/lib/Sema/TreeTransform.h
@@ -6578,7 +6578,7 @@
   NewTL.setFoundDecl(TL.getFoundDecl());
   NewTL.setLAngleLoc(TL.getLAngleLoc());
   NewTL.setRAngleLoc(TL.getRAngleLoc());
-  for (unsigned I = 0; I < TL.getNumArgs(); ++I)
+  for (unsigned I = 0; I < NewTL.getNumArgs(); ++I)
 NewTL.setArgLocInfo(I, NewTemplateArgs.arguments()[I].getLocInfo());
 
   return Result;


Index: clang/test/CXX/dcl/dcl.spec/dcl.type/dcl.spec.auto/p6.cpp
===
--- clang/test/CXX/dcl/dcl.spec/dcl.type/dcl.spec.auto/p6.cpp
+++ clang/test/CXX/dcl/dcl.spec/dcl.type/dcl.spec.auto/p6.cpp
@@ -76,3 +76,25 @@
   template concept d = true;
   d<,> auto e = 0; // expected-error{{expected expression}}
 }
+
+namespace PR48617 {
+  template  concept C = true;
+  template  class A {};
+
+  template  C auto e(A) { return 0; }
+
+  // FIXME: The error here does not make sense.
+  template auto e<>(A<>);
+  // expected-error@-1 {{explicit instantiation of 'e' does not refer to a function template}}
+  // expected-note@-5  {{candidate template ignored: failed template argument deduction}}
+
+  // FIXME: Should be able to instantiate this with no errors.
+  template C auto e(A);
+  // expected-error@-1 {{explicit instantiation of 'e' does not refer to a function template}}
+  // expected-note@-10 {{candidate template ignored: could not match 'C auto' against 'C auto'}}
+  
+  template C<> auto e<>(A<>);
+
+  template  A c(Ts...);
+  int f = e(c(1, 2));
+}
Index: clang/lib/Sema/TreeTransform.h
===
--- clang/lib/Sema/TreeTransform.h
+++ clang/lib/Sema/TreeTransform.h
@@ -6578,7 +6578,7 @@
   NewTL.setFoundDecl(TL.getFoundDecl());
   NewTL.setLAngleLoc(TL.getLAngleLoc());
   NewTL.setRAngleLoc(TL.getRAngleLoc());
-  for (unsigned I = 0; I < TL.getNumArgs(); ++I)
+  for (unsigned I = 0; I < NewTL.getNumArgs(); ++I)
 NewTL.setArgLocInfo(I, NewTemplateArgs.arguments()[I].getLocInfo());
 
   return Result;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 68b9d8e - [clang] fix transformation of template arguments of 'auto' type constraints

2021-09-07 Thread Matheus Izvekov via cfe-commits

Author: Matheus Izvekov
Date: 2021-09-08T03:22:34+02:00
New Revision: 68b9d8ed7abe4046992ae1557990edfbb3a772bc

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

LOG: [clang] fix transformation of template arguments of 'auto' type constraints

See PR48617.

When assigning the new template arguments to the new TypeLoc, we were looping
on the argument count of the original TypeLoc instead of the new one,
which can be different when packs are present.

Signed-off-by: Matheus Izvekov 

Reviewed By: rsmith

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

Added: 


Modified: 
clang/lib/Sema/TreeTransform.h
clang/test/CXX/dcl/dcl.spec/dcl.type/dcl.spec.auto/p6.cpp

Removed: 




diff  --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h
index 8841b2e00d40f..2a7ceaf6425ee 100644
--- a/clang/lib/Sema/TreeTransform.h
+++ b/clang/lib/Sema/TreeTransform.h
@@ -6578,7 +6578,7 @@ QualType 
TreeTransform::TransformAutoType(TypeLocBuilder ,
   NewTL.setFoundDecl(TL.getFoundDecl());
   NewTL.setLAngleLoc(TL.getLAngleLoc());
   NewTL.setRAngleLoc(TL.getRAngleLoc());
-  for (unsigned I = 0; I < TL.getNumArgs(); ++I)
+  for (unsigned I = 0; I < NewTL.getNumArgs(); ++I)
 NewTL.setArgLocInfo(I, NewTemplateArgs.arguments()[I].getLocInfo());
 
   return Result;

diff  --git a/clang/test/CXX/dcl/dcl.spec/dcl.type/dcl.spec.auto/p6.cpp 
b/clang/test/CXX/dcl/dcl.spec/dcl.type/dcl.spec.auto/p6.cpp
index 7830d1f435262..4941027423217 100644
--- a/clang/test/CXX/dcl/dcl.spec/dcl.type/dcl.spec.auto/p6.cpp
+++ b/clang/test/CXX/dcl/dcl.spec/dcl.type/dcl.spec.auto/p6.cpp
@@ -76,3 +76,25 @@ namespace PR48593 {
   template concept d = true;
   d<,> auto e = 0; // expected-error{{expected expression}}
 }
+
+namespace PR48617 {
+  template  concept C = true;
+  template  class A {};
+
+  template  C auto e(A) { return 0; }
+
+  // FIXME: The error here does not make sense.
+  template auto e<>(A<>);
+  // expected-error@-1 {{explicit instantiation of 'e' does not refer to a 
function template}}
+  // expected-note@-5  {{candidate template ignored: failed template argument 
deduction}}
+
+  // FIXME: Should be able to instantiate this with no errors.
+  template C auto e(A);
+  // expected-error@-1 {{explicit instantiation of 'e' does not refer to a 
function template}}
+  // expected-note@-10 {{candidate template ignored: could not match 'C auto' against 'C auto'}}
+  
+  template C<> auto e<>(A<>);
+
+  template  A c(Ts...);
+  int f = e(c(1, 2));
+}



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


[PATCH] D109408: [libcxxabi] NFC: fix incorrect indentation of braces

2021-09-07 Thread zhouyizhou via Phabricator via cfe-commits
zhouyizhou created this revision.
zhouyizhou added a reviewer: libcxx-commits.
zhouyizhou requested review of this revision.
Herald added projects: clang, libc++abi.
Herald added a subscriber: cfe-commits.
Herald added a reviewer: libc++abi.

Some functions in cxa_exception_storage.cpp have incorrect indentation of 
braces,
use clang-format to fix them

Signed-off-by: Zhouyi Zhou 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D109408

Files:
  clang/test/SemaCXX/cxx1z-lambda-star-this.cpp
  clang/test/SemaCXX/cxx20-lambda-decltype-this.cpp
  libcxxabi/src/cxa_exception_storage.cpp

Index: libcxxabi/src/cxa_exception_storage.cpp
===
--- libcxxabi/src/cxa_exception_storage.cpp
+++ libcxxabi/src/cxa_exception_storage.cpp
@@ -18,28 +18,28 @@
 
 namespace __cxxabiv1 {
 extern "C" {
-static __cxa_eh_globals eh_globals;
-__cxa_eh_globals *__cxa_get_globals() { return _globals; }
-__cxa_eh_globals *__cxa_get_globals_fast() { return _globals; }
-}
+static __cxa_eh_globals eh_globals;
+__cxa_eh_globals *__cxa_get_globals() { return _globals; }
+__cxa_eh_globals *__cxa_get_globals_fast() { return _globals; }
 }
+} // namespace __cxxabiv1
 
 #elif defined(HAS_THREAD_LOCAL)
 
 namespace __cxxabiv1 {
 
 namespace {
-__cxa_eh_globals * __globals () {
-static thread_local __cxa_eh_globals eh_globals;
-return _globals;
-}
-}
+__cxa_eh_globals *__globals() {
+  static thread_local __cxa_eh_globals eh_globals;
+  return _globals;
+}
+} // namespace
 
 extern "C" {
-__cxa_eh_globals * __cxa_get_globals  () { return __globals (); }
-__cxa_eh_globals * __cxa_get_globals_fast () { return __globals (); }
-}
+__cxa_eh_globals *__cxa_get_globals() { return __globals(); }
+__cxa_eh_globals *__cxa_get_globals_fast() { return __globals(); }
 }
+} // namespace __cxxabiv1
 
 #else
 
@@ -56,50 +56,49 @@
 
 namespace __cxxabiv1 {
 namespace {
-std::__libcpp_tls_key key_;
-std::__libcpp_exec_once_flag flag_ = _LIBCPP_EXEC_ONCE_INITIALIZER;
-
-void _LIBCPP_TLS_DESTRUCTOR_CC destruct_ (void *p) {
-__free_with_fallback ( p );
-if ( 0 != std::__libcpp_tls_set ( key_, NULL ) )
-abort_message("cannot zero out thread value for __cxa_get_globals()");
-}
-
-void construct_ () {
-if ( 0 != std::__libcpp_tls_create ( _, destruct_ ) )
-abort_message("cannot create thread specific key for __cxa_get_globals()");
-}
+std::__libcpp_tls_key key_;
+std::__libcpp_exec_once_flag flag_ = _LIBCPP_EXEC_ONCE_INITIALIZER;
+
+void _LIBCPP_TLS_DESTRUCTOR_CC destruct_(void *p) {
+  __free_with_fallback(p);
+  if (0 != std::__libcpp_tls_set(key_, NULL))
+abort_message("cannot zero out thread value for __cxa_get_globals()");
 }
 
+void construct_() {
+  if (0 != std::__libcpp_tls_create(_, destruct_))
+abort_message("cannot create thread specific key for __cxa_get_globals()");
+}
+} // namespace
+
 extern "C" {
-__cxa_eh_globals * __cxa_get_globals () {
-//  Try to get the globals for this thread
-__cxa_eh_globals* retVal = __cxa_get_globals_fast ();
-
-//  If this is the first time we've been asked for these globals, create them
-if ( NULL == retVal ) {
-retVal = static_cast<__cxa_eh_globals*>
-(__calloc_with_fallback (1, sizeof (__cxa_eh_globals)));
-if ( NULL == retVal )
-abort_message("cannot allocate __cxa_eh_globals");
-if ( 0 != std::__libcpp_tls_set ( key_, retVal ) )
-   abort_message("std::__libcpp_tls_set failure in __cxa_get_globals()");
-   }
-return retVal;
-}
-
-// Note that this implementation will reliably return NULL if not
-// preceded by a call to __cxa_get_globals().  This is an extension
-// to the Itanium ABI and is taken advantage of in several places in
-// libc++abi.
-__cxa_eh_globals * __cxa_get_globals_fast () {
-//  First time through, create the key.
-if (0 != std::__libcpp_execute_once(_, construct_))
-abort_message("execute once failure in __cxa_get_globals_fast()");
-//static int init = construct_();
-return static_cast<__cxa_eh_globals*>(std::__libcpp_tls_get(key_));
-}
+__cxa_eh_globals *__cxa_get_globals() {
+  //  Try to get the globals for this thread
+  __cxa_eh_globals *retVal = __cxa_get_globals_fast();
+
+  //  If this is the first time we've been asked for these globals, create them
+  if (NULL == retVal) {
+retVal = static_cast<__cxa_eh_globals *>(
+__calloc_with_fallback(1, sizeof(__cxa_eh_globals)));
+if (NULL == retVal)
+  abort_message("cannot allocate __cxa_eh_globals");
+if (0 != std::__libcpp_tls_set(key_, retVal))
+  abort_message("std::__libcpp_tls_set failure in __cxa_get_globals()");
+  }
+  return retVal;
+}
 
+// Note that this implementation will 

[PATCH] D109406: [clang] fix transformation of template arguments of 'auto' type constraints

2021-09-07 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov created this revision.
mizvekov published this revision for review.
mizvekov added a reviewer: rsmith.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

See PR48617.

When assigning the new template arguments to the new TypeLoc, we were looping
on the argument count of the original TypeLoc instead of the new one,
which can be different when packs are present.

Signed-off-by: Matheus Izvekov 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D109406

Files:
  clang/lib/Sema/TreeTransform.h
  clang/test/CXX/dcl/dcl.spec/dcl.type/dcl.spec.auto/p6.cpp


Index: clang/test/CXX/dcl/dcl.spec/dcl.type/dcl.spec.auto/p6.cpp
===
--- clang/test/CXX/dcl/dcl.spec/dcl.type/dcl.spec.auto/p6.cpp
+++ clang/test/CXX/dcl/dcl.spec/dcl.type/dcl.spec.auto/p6.cpp
@@ -76,3 +76,25 @@
   template concept d = true;
   d<,> auto e = 0; // expected-error{{expected expression}}
 }
+
+namespace PR48617 {
+  template  concept C = true;
+  template  class A {};
+
+  template  C auto e(A) { return 0; }
+
+  // FIXME: The error here does not make sense.
+  template auto e<>(A<>);
+  // expected-error@-1 {{explicit instantiation of 'e' does not refer to a 
function template}}
+  // expected-note@-5  {{candidate template ignored: failed template argument 
deduction}}
+
+  // FIXME: Should be able to instantiate this with no errors.
+  template C auto e(A);
+  // expected-error@-1 {{explicit instantiation of 'e' does not refer to a 
function template}}
+  // expected-note@-10 {{candidate template ignored: could not match 'C auto' against 'C auto'}}
+  
+  template C<> auto e<>(A<>);
+
+  template  A c(Ts...);
+  int f = e(c(1, 2));
+}
Index: clang/lib/Sema/TreeTransform.h
===
--- clang/lib/Sema/TreeTransform.h
+++ clang/lib/Sema/TreeTransform.h
@@ -6578,7 +6578,7 @@
   NewTL.setFoundDecl(TL.getFoundDecl());
   NewTL.setLAngleLoc(TL.getLAngleLoc());
   NewTL.setRAngleLoc(TL.getRAngleLoc());
-  for (unsigned I = 0; I < TL.getNumArgs(); ++I)
+  for (unsigned I = 0; I < NewTL.getNumArgs(); ++I)
 NewTL.setArgLocInfo(I, NewTemplateArgs.arguments()[I].getLocInfo());
 
   return Result;


Index: clang/test/CXX/dcl/dcl.spec/dcl.type/dcl.spec.auto/p6.cpp
===
--- clang/test/CXX/dcl/dcl.spec/dcl.type/dcl.spec.auto/p6.cpp
+++ clang/test/CXX/dcl/dcl.spec/dcl.type/dcl.spec.auto/p6.cpp
@@ -76,3 +76,25 @@
   template concept d = true;
   d<,> auto e = 0; // expected-error{{expected expression}}
 }
+
+namespace PR48617 {
+  template  concept C = true;
+  template  class A {};
+
+  template  C auto e(A) { return 0; }
+
+  // FIXME: The error here does not make sense.
+  template auto e<>(A<>);
+  // expected-error@-1 {{explicit instantiation of 'e' does not refer to a function template}}
+  // expected-note@-5  {{candidate template ignored: failed template argument deduction}}
+
+  // FIXME: Should be able to instantiate this with no errors.
+  template C auto e(A);
+  // expected-error@-1 {{explicit instantiation of 'e' does not refer to a function template}}
+  // expected-note@-10 {{candidate template ignored: could not match 'C auto' against 'C auto'}}
+  
+  template C<> auto e<>(A<>);
+
+  template  A c(Ts...);
+  int f = e(c(1, 2));
+}
Index: clang/lib/Sema/TreeTransform.h
===
--- clang/lib/Sema/TreeTransform.h
+++ clang/lib/Sema/TreeTransform.h
@@ -6578,7 +6578,7 @@
   NewTL.setFoundDecl(TL.getFoundDecl());
   NewTL.setLAngleLoc(TL.getLAngleLoc());
   NewTL.setRAngleLoc(TL.getRAngleLoc());
-  for (unsigned I = 0; I < TL.getNumArgs(); ++I)
+  for (unsigned I = 0; I < NewTL.getNumArgs(); ++I)
 NewTL.setArgLocInfo(I, NewTemplateArgs.arguments()[I].getLocInfo());
 
   return Result;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D103938: Diagnose -Wunused-value in constant evaluation context

2021-09-07 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added inline comments.



Comment at: clang/test/Sema/i-c-e.c:77-78
+  // expected-warning {{expression result unused}}
+int comma3[(1, 2)];   // expected-warning {{variable length array folded to 
constant array as an extension}} \
+  // expected-warning {{expression result unused}}
 

aaron.ballman wrote:
> ychen wrote:
> > aaron.ballman wrote:
> > > I think this diagnostic is kind of unfortunate because it increases my 
> > > confusion -- the expression result is most assuredly *not* unused in 
> > > these cases because it's used in the definition of the type.
> > > the expression result is most assuredly *not* unused in these cases 
> > > because it's used in the definition of the type.
> >  
> > Do you mean "1" is used in the definition of the type? The warning is for 
> > "1" in this case. If I change `1` to any other number, the type of `comma3` 
> > should not change, I think that means `1` is not used.
> > Do you mean "1" is used in the definition of the type? The warning is for 
> > "1" in this case. If I change 1 to any other number, the type of comma3 
> > should not change, I think that means 1 is not used.
> 
> I agree that the `1` is unused.
> 
> The trouble is that the diagnostic doesn't make that clear -- it just says 
> the expression result is unused, which makes it sound like the entire comma 
> expression result value is unused (which is not the case). I think the 
> diagnostic should more clearly specify *what* is unused in this case, 
> otherwise users may think the diagnostic is a false positive.
Sounds good to me. I've used "left operand of comma operator has no effect" 
which is what GCC uses for this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103938

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


[PATCH] D103938: Diagnose -Wunused-value in constant evaluation context

2021-09-07 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen updated this revision to Diff 371221.
ychen added a comment.
Herald added a subscriber: jdoerfert.

- Use more specific diagnoses "left operand of comma operator has no effect" 
when left operand of comma operator has no effect  instead of "expression 
result is unused".


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103938

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaStmt.cpp
  clang/test/Analysis/dead-stores.c
  clang/test/CXX/basic/basic.link/p8.cpp
  clang/test/CXX/drs/dr14xx.cpp
  clang/test/CXX/drs/dr20xx.cpp
  clang/test/CXX/drs/dr7xx.cpp
  clang/test/CXX/temp/temp.constr/temp.constr.constr/partial-specializations.cpp
  clang/test/CodeCompletion/pragma-macro-token-caching.c
  clang/test/Frontend/fixed_point_crash.c
  clang/test/PCH/cxx-explicit-specifier.cpp
  clang/test/Parser/cxx-ambig-decl-expr.cpp
  clang/test/Parser/cxx0x-ambig.cpp
  clang/test/Parser/cxx1z-init-statement.cpp
  clang/test/Parser/objc-messaging-1.m
  clang/test/Parser/objc-try-catch-1.m
  clang/test/Parser/objcxx11-attributes.mm
  clang/test/Sema/const-eval.c
  clang/test/Sema/exprs.c
  clang/test/Sema/i-c-e.c
  clang/test/Sema/sizeless-1.c
  clang/test/Sema/switch-1.c
  clang/test/Sema/vla-2.c
  clang/test/Sema/warn-type-safety.c
  clang/test/Sema/warn-unused-value.c
  clang/test/SemaCXX/attr-annotate.cpp
  clang/test/SemaCXX/builtin-constant-p.cpp
  clang/test/SemaCXX/constant-expression-cxx2a.cpp
  clang/test/SemaCXX/constant-expression.cpp
  clang/test/SemaCXX/expression-traits.cpp
  clang/test/SemaCXX/matrix-type-operators.cpp
  clang/test/SemaCXX/overloaded-operator.cpp
  clang/test/SemaCXX/sizeless-1.cpp
  clang/test/SemaCXX/vector.cpp
  clang/test/SemaCXX/warn-comma-operator.cpp
  clang/test/SemaCXX/warn-unused-value.cpp
  clang/test/SemaTemplate/derived.cpp
  clang/test/SemaTemplate/lambda-capture-pack.cpp

Index: clang/test/SemaTemplate/lambda-capture-pack.cpp
===
--- clang/test/SemaTemplate/lambda-capture-pack.cpp
+++ clang/test/SemaTemplate/lambda-capture-pack.cpp
@@ -18,7 +18,7 @@
 namespace PR41576 {
   template  constexpr int f(Xs ...xs) {
 return [&](auto ...ys) { // expected-note {{instantiation}}
-  return ((xs + ys), ...); // expected-warning {{unused}}
+  return ((xs + ys), ...); // expected-warning {{left operand of comma operator has no effect}}
 }(1, 2);
   }
   static_assert(f(3, 4) == 6); // expected-note {{instantiation}}
Index: clang/test/SemaTemplate/derived.cpp
===
--- clang/test/SemaTemplate/derived.cpp
+++ clang/test/SemaTemplate/derived.cpp
@@ -49,6 +49,6 @@
 
   class A {
 TFP m_p;
-void Enable() { 0, A(); } // expected-warning {{unused}}
+void Enable() { 0, A(); } // expected-warning {{left operand of comma operator has no effect}}
   };
 }
Index: clang/test/SemaCXX/warn-unused-value.cpp
===
--- clang/test/SemaCXX/warn-unused-value.cpp
+++ clang/test/SemaCXX/warn-unused-value.cpp
@@ -1,6 +1,7 @@
 // RUN: %clang_cc1 -fsyntax-only -verify -Wunused-value %s
 // RUN: %clang_cc1 -fsyntax-only -verify -Wunused-value -std=c++98 %s
 // RUN: %clang_cc1 -fsyntax-only -verify -Wunused-value -std=c++11 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wunused-value -std=c++17 %s
 
 // PR4806
 namespace test0 {
@@ -138,3 +139,26 @@
   (void)arr3;
   (void)arr4;
 }
+
+#if __cplusplus >= 201103L // C++11 or later
+namespace test5 {
+int v[(5, 6)]; // expected-warning {{left operand of comma operator has no effect}}
+void foo() {
+  new double[false ? (1, 2) : 3]
+// FIXME: We shouldn't diagnose the unreachable constant expression
+// here.
+[false ? (1, 2) : 3]; // expected-warning {{left operand of comma operator has no effect}}
+}
+} // namespace test5
+#endif
+
+#if __cplusplus >= 201703L // C++11 or later
+namespace test6 {
+auto b() {
+  if constexpr (false)
+return (1,0);
+  else
+return (1.0,0.0); // expected-warning {{left operand of comma operator has no effect}}
+}
+} // namespace test6
+#endif
Index: clang/test/SemaCXX/warn-comma-operator.cpp
===
--- clang/test/SemaCXX/warn-comma-operator.cpp
+++ clang/test/SemaCXX/warn-comma-operator.cpp
@@ -242,8 +242,8 @@
 
 template 
 class Foo {
-  typedef bool_seq<(xs::value, true)...> all_true;
-  typedef bool_seq<(xs::value, false)...> all_false;
+  typedef bool_seq<((void)xs::value, true)...> all_true;
+  typedef bool_seq<((void)xs::value, false)...> all_false;
   typedef bool_seq seq;
 };
 
Index: clang/test/SemaCXX/vector.cpp
===
--- 

[PATCH] D102531: PR45881: Properly use CXXThisOverride for templated lambda

2021-09-07 Thread Yuanfang Chen via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG61d1cce2f835: PR45881: Properly use CXXThisOverride for 
templated lambda (authored by ychen).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102531

Files:
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/test/SemaCXX/cxx1z-lambda-star-this.cpp
  clang/test/SemaCXX/cxx20-lambda-decltype-this.cpp

Index: clang/test/SemaCXX/cxx20-lambda-decltype-this.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/cxx20-lambda-decltype-this.cpp
@@ -0,0 +1,31 @@
+// RUN: %clang_cc1 -std=c++2a -fsyntax-only -emit-llvm-only %s
+// RUN: %clang_cc1 -std=c++2a -fsyntax-only -fdelayed-template-parsing %s
+// RUN: %clang_cc1 -std=c++2a -fsyntax-only -fms-extensions %s
+// RUN: %clang_cc1 -std=c++2a -fsyntax-only -fdelayed-template-parsing -fms-extensions %s
+
+namespace PR45881 {
+struct A {
+void f();
+};
+int id(A*);
+void A::f() {
+auto z = [*this](auto z2, decltype(z2(this)) z3){};
+z(id,3);
+}
+
+struct B {
+void f();
+};
+void B::f() {
+auto z = [](){return 0;};
+z.template operator()();
+}
+
+struct C {
+void f();
+};
+void C::f() {
+auto z = [](){return 0;};
+z.template operator()();
+}
+} // namespace PR45881
Index: clang/test/SemaCXX/cxx1z-lambda-star-this.cpp
===
--- clang/test/SemaCXX/cxx1z-lambda-star-this.cpp
+++ clang/test/SemaCXX/cxx1z-lambda-star-this.cpp
@@ -298,3 +298,13 @@
 
 } // namespace PR32831
 
+namespace PR45881 {
+struct A {
+void f();
+};
+int id(A*);
+void A::f() {
+auto z = [*this](auto z2, decltype(z2(this)) z3){};
+z(id,3);
+}
+} // namespace PR45881
Index: clang/lib/Sema/SemaTemplateDeduction.cpp
===
--- clang/lib/Sema/SemaTemplateDeduction.cpp
+++ clang/lib/Sema/SemaTemplateDeduction.cpp
@@ -2858,9 +2858,24 @@
   return Sema::TDK_Incomplete;
 }
 
-TemplateArgumentLoc DefArg = S.SubstDefaultTemplateArgumentIfAvailable(
-TD, TD->getLocation(), TD->getSourceRange().getEnd(), Param, Builder,
-HasDefaultArg);
+TemplateArgumentLoc DefArg;
+{
+  Qualifiers ThisTypeQuals;
+  CXXRecordDecl *ThisContext = nullptr;
+  if (auto *Rec = dyn_cast(TD->getDeclContext()))
+if (Rec->isLambda())
+  if (auto *Method = dyn_cast(Rec->getDeclContext())) {
+ThisContext = Method->getParent();
+ThisTypeQuals = Method->getMethodQualifiers();
+  }
+
+  Sema::CXXThisScopeRAII ThisScope(S, ThisContext, ThisTypeQuals,
+   S.getLangOpts().CPlusPlus17);
+
+  DefArg = S.SubstDefaultTemplateArgumentIfAvailable(
+  TD, TD->getLocation(), TD->getSourceRange().getEnd(), Param, Builder,
+  HasDefaultArg);
+}
 
 // If there was no default argument, deduction is incomplete.
 if (DefArg.getArgument().isNull()) {
Index: clang/lib/Sema/SemaTemplate.cpp
===
--- clang/lib/Sema/SemaTemplate.cpp
+++ clang/lib/Sema/SemaTemplate.cpp
@@ -5110,7 +5110,11 @@
 for (unsigned i = 0, e = Param->getDepth(); i != e; ++i)
   TemplateArgLists.addOuterTemplateArguments(None);
 
-Sema::ContextRAII SavedContext(SemaRef, Template->getDeclContext());
+bool ForLambdaCallOperator = false;
+if (const auto *Rec = dyn_cast(Template->getDeclContext()))
+  ForLambdaCallOperator = Rec->isLambda();
+Sema::ContextRAII SavedContext(SemaRef, Template->getDeclContext(),
+   !ForLambdaCallOperator);
 ArgType =
 SemaRef.SubstType(ArgType, TemplateArgLists,
   Param->getDefaultArgumentLoc(), Param->getDeclName());
Index: clang/lib/Sema/SemaExprCXX.cpp
===
--- clang/lib/Sema/SemaExprCXX.cpp
+++ clang/lib/Sema/SemaExprCXX.cpp
@@ -1137,11 +1137,10 @@
 }
   }
 
-  // 2) We've run out of ScopeInfos but check if CurDC is a lambda (which can
-  // happen during instantiation of its nested generic lambda call operator)
-  if (isLambdaCallOperator(CurDC)) {
-assert(CurLSI && "While computing 'this' capture-type for a generic "
- "lambda, we must have a corresponding LambdaScopeInfo");
+  // 2) We've run out of ScopeInfos but check 1. if CurDC is a lambda (which
+  //can happen during instantiation of its nested generic lambda call
+  //operator); 2. if we're in a lambda scope (lambda body).
+  if (CurLSI && isLambdaCallOperator(CurDC)) {
 assert(isGenericLambdaCallOperatorSpecialization(CurLSI->CallOperator) &&
"While computing 'this' capture-type for a generic lambda, when 

[clang] 61d1cce - PR45881: Properly use CXXThisOverride for templated lambda

2021-09-07 Thread Yuanfang Chen via cfe-commits

Author: Yuanfang Chen
Date: 2021-09-07T17:02:24-07:00
New Revision: 61d1cce2f83571c00f76144d42a2dea2cb3ab1ca

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

LOG: PR45881: Properly use CXXThisOverride for templated lambda

- `this` used in lambda expression parameter declarations needs no capture.
- Set up CXXThisOverride for default template arguments of a lambda.

A similar fix to this is c3d2ebb60f604.

Reviewed By: aaron.ballman

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

Added: 
clang/test/SemaCXX/cxx20-lambda-decltype-this.cpp

Modified: 
clang/lib/Sema/SemaExprCXX.cpp
clang/lib/Sema/SemaTemplate.cpp
clang/lib/Sema/SemaTemplateDeduction.cpp
clang/test/SemaCXX/cxx1z-lambda-star-this.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp
index ba2e17c4a6313..e30e1bb7df786 100644
--- a/clang/lib/Sema/SemaExprCXX.cpp
+++ b/clang/lib/Sema/SemaExprCXX.cpp
@@ -1137,11 +1137,10 @@ static QualType 
adjustCVQualifiersForCXXThisWithinLambda(
 }
   }
 
-  // 2) We've run out of ScopeInfos but check if CurDC is a lambda (which can
-  // happen during instantiation of its nested generic lambda call operator)
-  if (isLambdaCallOperator(CurDC)) {
-assert(CurLSI && "While computing 'this' capture-type for a generic "
- "lambda, we must have a corresponding LambdaScopeInfo");
+  // 2) We've run out of ScopeInfos but check 1. if CurDC is a lambda (which
+  //can happen during instantiation of its nested generic lambda call
+  //operator); 2. if we're in a lambda scope (lambda body).
+  if (CurLSI && isLambdaCallOperator(CurDC)) {
 assert(isGenericLambdaCallOperatorSpecialization(CurLSI->CallOperator) &&
"While computing 'this' capture-type for a generic lambda, when we "
"run out of enclosing LSI's, yet the enclosing DC is a "

diff  --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp
index 5d26f2d2c11a5..6682b17f4e146 100644
--- a/clang/lib/Sema/SemaTemplate.cpp
+++ b/clang/lib/Sema/SemaTemplate.cpp
@@ -5110,7 +5110,11 @@ SubstDefaultTemplateArgument(Sema ,
 for (unsigned i = 0, e = Param->getDepth(); i != e; ++i)
   TemplateArgLists.addOuterTemplateArguments(None);
 
-Sema::ContextRAII SavedContext(SemaRef, Template->getDeclContext());
+bool ForLambdaCallOperator = false;
+if (const auto *Rec = dyn_cast(Template->getDeclContext()))
+  ForLambdaCallOperator = Rec->isLambda();
+Sema::ContextRAII SavedContext(SemaRef, Template->getDeclContext(),
+   !ForLambdaCallOperator);
 ArgType =
 SemaRef.SubstType(ArgType, TemplateArgLists,
   Param->getDefaultArgumentLoc(), 
Param->getDeclName());

diff  --git a/clang/lib/Sema/SemaTemplateDeduction.cpp 
b/clang/lib/Sema/SemaTemplateDeduction.cpp
index 5d93a17922269..f0a9e820c028c 100644
--- a/clang/lib/Sema/SemaTemplateDeduction.cpp
+++ b/clang/lib/Sema/SemaTemplateDeduction.cpp
@@ -2858,9 +2858,24 @@ static Sema::TemplateDeductionResult 
ConvertDeducedTemplateArguments(
   return Sema::TDK_Incomplete;
 }
 
-TemplateArgumentLoc DefArg = S.SubstDefaultTemplateArgumentIfAvailable(
-TD, TD->getLocation(), TD->getSourceRange().getEnd(), Param, Builder,
-HasDefaultArg);
+TemplateArgumentLoc DefArg;
+{
+  Qualifiers ThisTypeQuals;
+  CXXRecordDecl *ThisContext = nullptr;
+  if (auto *Rec = dyn_cast(TD->getDeclContext()))
+if (Rec->isLambda())
+  if (auto *Method = dyn_cast(Rec->getDeclContext())) {
+ThisContext = Method->getParent();
+ThisTypeQuals = Method->getMethodQualifiers();
+  }
+
+  Sema::CXXThisScopeRAII ThisScope(S, ThisContext, ThisTypeQuals,
+   S.getLangOpts().CPlusPlus17);
+
+  DefArg = S.SubstDefaultTemplateArgumentIfAvailable(
+  TD, TD->getLocation(), TD->getSourceRange().getEnd(), Param, Builder,
+  HasDefaultArg);
+}
 
 // If there was no default argument, deduction is incomplete.
 if (DefArg.getArgument().isNull()) {

diff  --git a/clang/test/SemaCXX/cxx1z-lambda-star-this.cpp 
b/clang/test/SemaCXX/cxx1z-lambda-star-this.cpp
index 2426e8f5a207f..5a471fd6b6940 100644
--- a/clang/test/SemaCXX/cxx1z-lambda-star-this.cpp
+++ b/clang/test/SemaCXX/cxx1z-lambda-star-this.cpp
@@ -298,3 +298,13 @@ class A {
 
 } // namespace PR32831
 
+namespace PR45881 {
+struct A {
+void f();
+};
+int id(A*);
+void A::f() {
+auto z = [*this](auto z2, decltype(z2(this)) z3){};
+z(id,3);
+}
+} // namespace PR45881

diff  --git a/clang/test/SemaCXX/cxx20-lambda-decltype-this.cpp 
b/clang/test/SemaCXX/cxx20-lambda-decltype-this.cpp
new file 

[PATCH] D109402: Make 'align-mismatch' warning work without an associated function declaration

2021-09-07 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman created this revision.
arphaman added reviewers: tmatheson, ravikandhadai.
Herald added a subscriber: ributzka.
arphaman requested review of this revision.

This change fixes a crash where a NULL fd was used to emit a diagnostic.
Instead of crashing, just avoid printing the declaration name when there's no
associated function declaration.

The crash was introduced in https://reviews.llvm.org/D97187.


https://reviews.llvm.org/D109402

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/typedef_alignment_mismatch_warning.cpp


Index: clang/test/CodeGen/typedef_alignment_mismatch_warning.cpp
===
--- clang/test/CodeGen/typedef_alignment_mismatch_warning.cpp
+++ clang/test/CodeGen/typedef_alignment_mismatch_warning.cpp
@@ -282,3 +282,7 @@
   auto *UA4ptr = new UsingAligned4(11);
   new (UA4ptr) UsingAligned4(12);
 }
+
+void testFunctionPointerArray(void (*fptr[10])(Aligned8Int *), Aligned2Int* 
src) {
+  fptr[0](src); // expected-warning {{passing 2-byte aligned argument to 
8-byte aligned parameter 1 may result in an unaligned pointer access}}
+}
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -4956,7 +4956,7 @@
   if (ArgAlign < ParamAlign)
 Diag(Loc, diag::warn_param_mismatched_alignment)
 << (int)ArgAlign.getQuantity() << (int)ParamAlign.getQuantity()
-<< ParamName << FDecl;
+<< ParamName << (FDecl != nullptr) << FDecl;
 }
 
 /// Handles the checks for format strings, non-POD arguments to vararg
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -6781,7 +6781,7 @@
   "taking address of packed member %0 of class or structure %q1 may result in 
an unaligned pointer value">,
   InGroup>;
 def warn_param_mismatched_alignment : Warning<
-  "passing %0-byte aligned argument to %1-byte aligned parameter %2 of %3 may 
result in an unaligned pointer access">,
+  "passing %0-byte aligned argument to %1-byte aligned parameter %2%select{| 
of %4}3 may result in an unaligned pointer access">,
   InGroup>;
 
 def err_objc_object_assignment : Error<


Index: clang/test/CodeGen/typedef_alignment_mismatch_warning.cpp
===
--- clang/test/CodeGen/typedef_alignment_mismatch_warning.cpp
+++ clang/test/CodeGen/typedef_alignment_mismatch_warning.cpp
@@ -282,3 +282,7 @@
   auto *UA4ptr = new UsingAligned4(11);
   new (UA4ptr) UsingAligned4(12);
 }
+
+void testFunctionPointerArray(void (*fptr[10])(Aligned8Int *), Aligned2Int* src) {
+  fptr[0](src); // expected-warning {{passing 2-byte aligned argument to 8-byte aligned parameter 1 may result in an unaligned pointer access}}
+}
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -4956,7 +4956,7 @@
   if (ArgAlign < ParamAlign)
 Diag(Loc, diag::warn_param_mismatched_alignment)
 << (int)ArgAlign.getQuantity() << (int)ParamAlign.getQuantity()
-<< ParamName << FDecl;
+<< ParamName << (FDecl != nullptr) << FDecl;
 }
 
 /// Handles the checks for format strings, non-POD arguments to vararg
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -6781,7 +6781,7 @@
   "taking address of packed member %0 of class or structure %q1 may result in an unaligned pointer value">,
   InGroup>;
 def warn_param_mismatched_alignment : Warning<
-  "passing %0-byte aligned argument to %1-byte aligned parameter %2 of %3 may result in an unaligned pointer access">,
+  "passing %0-byte aligned argument to %1-byte aligned parameter %2%select{| of %4}3 may result in an unaligned pointer access">,
   InGroup>;
 
 def err_objc_object_assignment : Error<
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

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



Comment at: clang/test/CodeGen/pgo-sample-thinlto-summary.c:1
-// RUN: %clang_cc1 -O2 
-fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm -o 
- 2>&1 | FileCheck %s -check-prefix=SAMPLEPGO
-// RUN: %clang_cc1 -O2 
-fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm 
-flto=thin -o - 2>&1 | FileCheck %s -check-prefix=THINLTO
-// RUN: %clang_cc1 -O2 -fexperimental-new-pass-manager 
-fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm -o 
- 2>&1 | FileCheck %s -check-prefix=SAMPLEPGO
-// RUN: %clang_cc1 -O2 -fexperimental-new-pass-manager 
-fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm 
-flto=thin -o - 2>&1 | FileCheck %s -check-prefix=THINLTO
-// Checks if hot call is inlined by normal compile, but not inlined by
-// thinlto compile.
+// RUN: %clang_cc1 -mllvm -opt-bisect-limit=-1 -O2 
-fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm -o 
- 2>&1 | FileCheck %s -check-prefix=SAMPLEPGO
+// RUN: %clang_cc1 -mllvm -opt-bisect-limit=-1 -O2 
-fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm 
-flto=thin -o - 2>&1 | FileCheck %s -check-prefix=THINLTO

-opt-bisect-limit seems like a roundabout way to get the pass invocations 
printed. How about just -mllvm -debug-pass=Structure?



Comment at: clang/test/CodeGen/pgo-sample-thinlto-summary.c:16
 // Checks if loop unroll is invoked by normal compile, but not thinlto compile.
-// SAMPLEPGO-LABEL: define {{(dso_local )?}}void @unroll
-// THINLTO-LABEL: define {{(dso_local )?}}void @unroll
-// SAMPLEPGO: call{{.*}}baz
-// SAMPLEPGO: call{{.*}}baz
-// THINLTO: call{{.*}}baz
-// THINLTO-NOT: call{{.*}}baz
+// Checks that icp is not invoked for ThinLTO, but invoked for normal 
samplepgo.
+// SAMPLEPGO-LABEL: running pass ({{[0-9]+}}) {{[a-zA-Z0-9]+}} on

Nit, consolidate this and the prior sentence.



Comment at: clang/test/CodeGen/pgo-sample-thinlto-summary.c:28
 
-// Checks that icp is not invoked for ThinLTO, but invoked for normal 
samplepgo.
-// SAMPLEPGO-LABEL: define {{(dso_local )?}}void @icp
-// THINLTO-LABEL: define {{(dso_local )?}}void @icp
-// SAMPLEPGO: if.true.direct_targ
-// FIXME: the following condition needs to be reversed once
-//LTOPreLinkDefaultPipeline is customized.
-// THINLTO-NOT: if.true.direct_targ
 void icp(void (*p)()) {
   p();

No need for 2 functions named "unroll" and "icp" anymore, since we are just 
checking the passes. Why not remove both of these, and just use bar below for 
checking the passes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109234

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


[PATCH] D108808: [clang-tidy] bugprone-infinite-loop: Fix false positives with volatile addresses.

2021-09-07 Thread Artem Dergachev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGdcde8fdeeb3e: [clang-tidy] bugprone-infinite-loop: Fix false 
positives with volatile… (authored by dergachev.a).

Changed prior to commit:
  https://reviews.llvm.org/D108808?vs=369040=371202#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108808

Files:
  clang-tools-extra/clang-tidy/bugprone/InfiniteLoopCheck.cpp
  clang-tools-extra/test/clang-tidy/checkers/bugprone-infinite-loop.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-redundant-branch-condition.cpp


Index: 
clang-tools-extra/test/clang-tidy/checkers/bugprone-redundant-branch-condition.cpp
===
--- 
clang-tools-extra/test/clang-tidy/checkers/bugprone-redundant-branch-condition.cpp
+++ 
clang-tools-extra/test/clang-tidy/checkers/bugprone-redundant-branch-condition.cpp
@@ -1387,3 +1387,13 @@
 }
   }
 }
+
+void volatile_concrete_address() {
+  // No warning. The value behind the volatile concrete address
+  // is beyond our control. It may change at any time.
+  if (*(volatile int *)0x1234) {
+if (*(volatile int *)0x1234) {
+  doSomething();
+}
+  }
+}
Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-infinite-loop.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/bugprone-infinite-loop.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-infinite-loop.cpp
@@ -591,3 +591,34 @@
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: this loop is infinite; none 
of its condition variables (x) are updated in the loop body 
[bugprone-infinite-loop]
   }
 }
+
+void test_volatile_cast() {
+  // This is a no-op cast. Clang ignores the qualifier, we should too.
+  for (int i = 0; (volatile int)i < 10;) {
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: this loop is infinite; none of 
its condition variables (i) are updated in the loop body 
[bugprone-infinite-loop]
+  }
+}
+
+void test_volatile_concrete_address(int i, int size) {
+  // No warning. The value behind the volatile concrete address
+  // is beyond our control. It may change at any time.
+  for (; *((volatile int *)0x1234) < size;) {
+  }
+
+  for (; *((volatile int *)(0x1234 + i)) < size;) {
+  }
+
+  for (; **((volatile int **)0x1234) < size;) {
+  }
+
+  volatile int *x = (volatile int *)0x1234;
+  for (; *x < 10;) {
+  }
+
+  // FIXME: This one should probably also be suppressed.
+  // Whatever the developer is doing here, they can do that again anywhere else
+  // which basically makes it a global.
+  for (; *(int *)0x1234 < size;) {
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: this loop is infinite; none of 
its condition variables (size) are updated in the loop body 
[bugprone-infinite-loop]
+  }
+}
Index: clang-tools-extra/clang-tidy/bugprone/InfiniteLoopCheck.cpp
===
--- clang-tools-extra/clang-tidy/bugprone/InfiniteLoopCheck.cpp
+++ clang-tools-extra/clang-tidy/bugprone/InfiniteLoopCheck.cpp
@@ -65,6 +65,17 @@
  ObjCIvarRefExpr, ObjCPropertyRefExpr, ObjCMessageExpr>(Cond)) 
{
 // FIXME: Handle MemberExpr.
 return true;
+  } else if (const auto *CE = dyn_cast(Cond)) {
+QualType T = CE->getType();
+while (true) {
+  if (T.isVolatileQualified())
+return true;
+
+  if (!T->isAnyPointerType() && !T->isReferenceType())
+break;
+
+  T = T->getPointeeType();
+}
   }
 
   return false;


Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-redundant-branch-condition.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/bugprone-redundant-branch-condition.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-redundant-branch-condition.cpp
@@ -1387,3 +1387,13 @@
 }
   }
 }
+
+void volatile_concrete_address() {
+  // No warning. The value behind the volatile concrete address
+  // is beyond our control. It may change at any time.
+  if (*(volatile int *)0x1234) {
+if (*(volatile int *)0x1234) {
+  doSomething();
+}
+  }
+}
Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-infinite-loop.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/bugprone-infinite-loop.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-infinite-loop.cpp
@@ -591,3 +591,34 @@
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: this loop is infinite; none of its condition variables (x) are updated in the loop body [bugprone-infinite-loop]
   }
 }
+
+void test_volatile_cast() {
+  // This is a no-op cast. Clang ignores the qualifier, we should too.
+  for (int i = 0; (volatile int)i < 10;) {
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: this loop is infinite; none of its 

[clang-tools-extra] dcde8fd - [clang-tidy] bugprone-infinite-loop: Fix false positives with volatile addresses.

2021-09-07 Thread Artem Dergachev via cfe-commits

Author: Artem Dergachev
Date: 2021-09-07T15:10:46-07:00
New Revision: dcde8fdeeb3ebda6fe6a23d933fbe5caee01c088

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

LOG: [clang-tidy] bugprone-infinite-loop: Fix false positives with volatile 
addresses.

Low-level code may occasionally deal with direct access by concrete addresses
such as 0x1234. Values at these addresses act like globals: they can change
at any time. They typically wear volatile qualifiers.

Suppress all warnings on loops with conditions that involve casting anything to
a pointer-to-...-pointer-to-volatile type.

The closely related bugprone-redundant-branch-condition check
doesn't seem to be affected. Add a test just in case.

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

Added: 


Modified: 
clang-tools-extra/clang-tidy/bugprone/InfiniteLoopCheck.cpp
clang-tools-extra/test/clang-tidy/checkers/bugprone-infinite-loop.cpp

clang-tools-extra/test/clang-tidy/checkers/bugprone-redundant-branch-condition.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/bugprone/InfiniteLoopCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/InfiniteLoopCheck.cpp
index 8ac7f8eb28aee..99775b2400458 100644
--- a/clang-tools-extra/clang-tidy/bugprone/InfiniteLoopCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/InfiniteLoopCheck.cpp
@@ -65,6 +65,17 @@ static bool isVarThatIsPossiblyChanged(const Decl *Func, 
const Stmt *LoopStmt,
  ObjCIvarRefExpr, ObjCPropertyRefExpr, ObjCMessageExpr>(Cond)) 
{
 // FIXME: Handle MemberExpr.
 return true;
+  } else if (const auto *CE = dyn_cast(Cond)) {
+QualType T = CE->getType();
+while (true) {
+  if (T.isVolatileQualified())
+return true;
+
+  if (!T->isAnyPointerType() && !T->isReferenceType())
+break;
+
+  T = T->getPointeeType();
+}
   }
 
   return false;

diff  --git 
a/clang-tools-extra/test/clang-tidy/checkers/bugprone-infinite-loop.cpp 
b/clang-tools-extra/test/clang-tidy/checkers/bugprone-infinite-loop.cpp
index 6afde606481c1..ed50b5c7d74ea 100644
--- a/clang-tools-extra/test/clang-tidy/checkers/bugprone-infinite-loop.cpp
+++ b/clang-tools-extra/test/clang-tidy/checkers/bugprone-infinite-loop.cpp
@@ -591,3 +591,34 @@ void test_structured_bindings_bad() {
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: this loop is infinite; none 
of its condition variables (x) are updated in the loop body 
[bugprone-infinite-loop]
   }
 }
+
+void test_volatile_cast() {
+  // This is a no-op cast. Clang ignores the qualifier, we should too.
+  for (int i = 0; (volatile int)i < 10;) {
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: this loop is infinite; none of 
its condition variables (i) are updated in the loop body 
[bugprone-infinite-loop]
+  }
+}
+
+void test_volatile_concrete_address(int i, int size) {
+  // No warning. The value behind the volatile concrete address
+  // is beyond our control. It may change at any time.
+  for (; *((volatile int *)0x1234) < size;) {
+  }
+
+  for (; *((volatile int *)(0x1234 + i)) < size;) {
+  }
+
+  for (; **((volatile int **)0x1234) < size;) {
+  }
+
+  volatile int *x = (volatile int *)0x1234;
+  for (; *x < 10;) {
+  }
+
+  // FIXME: This one should probably also be suppressed.
+  // Whatever the developer is doing here, they can do that again anywhere else
+  // which basically makes it a global.
+  for (; *(int *)0x1234 < size;) {
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: this loop is infinite; none of 
its condition variables (size) are updated in the loop body 
[bugprone-infinite-loop]
+  }
+}

diff  --git 
a/clang-tools-extra/test/clang-tidy/checkers/bugprone-redundant-branch-condition.cpp
 
b/clang-tools-extra/test/clang-tidy/checkers/bugprone-redundant-branch-condition.cpp
index 9b84406e70e03..40994b0ff884e 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/bugprone-redundant-branch-condition.cpp
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/bugprone-redundant-branch-condition.cpp
@@ -1387,3 +1387,13 @@ void relational_operator_reversed() {
 }
   }
 }
+
+void volatile_concrete_address() {
+  // No warning. The value behind the volatile concrete address
+  // is beyond our control. It may change at any time.
+  if (*(volatile int *)0x1234) {
+if (*(volatile int *)0x1234) {
+  doSomething();
+}
+  }
+}



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


[PATCH] D108881: [clang][driver] Honor the last -flto(=.*)? argument

2021-09-07 Thread Steven Wu via Phabricator via cfe-commits
steven_wu added a comment.

In D108881#2988026 , @tejohnson wrote:

> In D108881#2988016 , @steven_wu 
> wrote:
>
>> In D108881#2987990 , @mnadeem 
>> wrote:
>>
>>> In D108881#2973735 , @steven_wu 
>>> wrote:
>>>
 In D108881#2973719 , @mnadeem 
 wrote:

> In D108881#2973516 , @steven_wu 
> wrote:
>
>> I will do a cleanup of `parseLTOMode` function since we don't need a 
>> `OptPos` parameter anymore. There are few minor places references 
>> `OPT_flto` or `OPT_foffload_lto` can be cleaned up too.
>
> Will you incorporate the functional changes in this patch? Or is there 
> still a need for this change?

 The current change set in this review is functional change while the 
 cleanup I want is not functional after the rewrite the old option as 
 Alias. Once flto is the alias, there is no need to handle that in the 
 driver and those might actually become source of bug in the future.

 I think it would be good to do the cleanup in the same commit unless you 
 have compelling reason not to.
>>>
>>> Hi @steven_wu any idea about the timeline?
>>>
>>> This issue is blocking some internal work, and assuming that it will take 
>>> longer to get a full fix, I would prefer it if this change could go in on 
>>> its own.
>>> Otherwise I am good with doing everything in the same commit.
>>
>> I expect the cleanup is very very simple and that is why I am suggested to 
>> do in the same commit. I am ok with a followup fix as well.
>
> I think there might be some high level confusion. @steven_wu earlier in the 
> thread you said "I will do a cleanup", but I think you were asking @mnadeem 
> to do the cleanup here in this patch.

Ah, I see. I probably type the reply from my phone do I didn't double check. I 
really mean "I would suggest @mnadeem to do a cleanup in the same commit". 
Sorry about the confusion.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108881

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


[PATCH] D108881: [clang][driver] Honor the last -flto(=.*)? argument

2021-09-07 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson added a comment.

In D108881#2988016 , @steven_wu wrote:

> In D108881#2987990 , @mnadeem wrote:
>
>> In D108881#2973735 , @steven_wu 
>> wrote:
>>
>>> In D108881#2973719 , @mnadeem 
>>> wrote:
>>>
 In D108881#2973516 , @steven_wu 
 wrote:

> I will do a cleanup of `parseLTOMode` function since we don't need a 
> `OptPos` parameter anymore. There are few minor places references 
> `OPT_flto` or `OPT_foffload_lto` can be cleaned up too.

 Will you incorporate the functional changes in this patch? Or is there 
 still a need for this change?
>>>
>>> The current change set in this review is functional change while the 
>>> cleanup I want is not functional after the rewrite the old option as Alias. 
>>> Once flto is the alias, there is no need to handle that in the driver and 
>>> those might actually become source of bug in the future.
>>>
>>> I think it would be good to do the cleanup in the same commit unless you 
>>> have compelling reason not to.
>>
>> Hi @steven_wu any idea about the timeline?
>>
>> This issue is blocking some internal work, and assuming that it will take 
>> longer to get a full fix, I would prefer it if this change could go in on 
>> its own.
>> Otherwise I am good with doing everything in the same commit.
>
> I expect the cleanup is very very simple and that is why I am suggested to do 
> in the same commit. I am ok with a followup fix as well.

I think there might be some high level confusion. @steven_wu earlier in the 
thread you said "I will do a cleanup", but I think you were asking @mnadeem to 
do the cleanup here in this patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108881

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


[PATCH] D108881: [clang][driver] Honor the last -flto(=.*)? argument

2021-09-07 Thread Steven Wu via Phabricator via cfe-commits
steven_wu added a comment.

If you didn't quite get what I mean, I am suggesting to cleanup all the 
reference to the old flag. Since `-flto` is rewrite by the driver to 
`-flto=full`, clang should not query `OPT_flto` anymore. All references to the 
old flag needs to be audited and removed while preserving the correct behavior.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108881

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


[PATCH] D105756: [clang] C++98 implicit moves are back with a vengeance

2021-09-07 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

It looks like this commit causes unexpected changes in non-C++ code. Eg., in 
this tiny reproducer (that uses the non-standard "blocks" feature but is 
otherwise plain C):

  typedef struct {
int x;
  } S;
  
  void foo() {
^{
  S s;
  return s;
};
  }

I'm suddenly seeing C++-specific items in the AST that shouldn't show up in C 
(xvalues, NRVO, etc.):

`$ clang -x c -Xclang -ast-dump test.c`

  ...
  `-FunctionDecl 0x7fc55288aa88  line:5:6 foo 'void ()'
`-CompoundStmt 0x7fc55288aec0 
  `-BlockExpr 0x7fc55288aea8  'S (^)(void)'
`-BlockDecl 0x7fc55288ab70  line:6:3
  |-CompoundStmt 0x7fc55288adc8 
  | |-DeclStmt 0x7fc55288acd8 
  | | `-VarDecl 0x7fc55288ac70  col:7 used s 'S':'S' nrvo
  | `-ReturnStmt 0x7fc55288adb0 
  |   `-ImplicitCastExpr 0x7fc55288ad98  'S':'S' 

  | `-ImplicitCastExpr 0x7fc55288ad80  'S':'S' xvalue 
  |   `-ImplicitCastExpr 0x7fc55288ad68  'S':'S' 

  | `-DeclRefExpr 0x7fc55288acf0  'S':'S' lvalue Var 
0x7fc55288ac70 's' 'S':'S'
  `-VarDecl 0x7fc55288ac70  col:7 used s 'S':'S' nrvo

The double implicit lvalue-to-rvalue cast looks incorrect as well (there isn't 
an extra dereference here).

Here's how the old AST looks like:

  ...
  `-FunctionDecl 0x7fb594079e88  line:5:6 foo 'void ()'
`-CompoundStmt 0x7fb59407a230 
  `-BlockExpr 0x7fb59407a218  'S (^)(void)'
`-BlockDecl 0x7fb594079f70  line:6:3
  |-CompoundStmt 0x7fb59407a138 
  | |-DeclStmt 0x7fb59407a0d8 
  | | `-VarDecl 0x7fb59407a070  col:7 used s 'S':'S'
  | `-ReturnStmt 0x7fb59407a128 
  |   `-ImplicitCastExpr 0x7fb59407a110  'S':'S' 

  | `-DeclRefExpr 0x7fb59407a0f0  'S':'S' lvalue Var 
0x7fb59407a070 's' 'S':'S'
  `-VarDecl 0x7fb59407a070  col:7 used s 'S':'S'

I don't think this is intended. @mizvekov, do you think you can add more hard 
checks to make sure it's constrained to C++? (Or maybe there's another, more 
precise solution?)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105756

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


[PATCH] D108881: [clang][driver] Honor the last -flto(=.*)? argument

2021-09-07 Thread Steven Wu via Phabricator via cfe-commits
steven_wu added a comment.

In D108881#2987990 , @mnadeem wrote:

> In D108881#2973735 , @steven_wu 
> wrote:
>
>> In D108881#2973719 , @mnadeem 
>> wrote:
>>
>>> In D108881#2973516 , @steven_wu 
>>> wrote:
>>>
 I will do a cleanup of `parseLTOMode` function since we don't need a 
 `OptPos` parameter anymore. There are few minor places references 
 `OPT_flto` or `OPT_foffload_lto` can be cleaned up too.
>>>
>>> Will you incorporate the functional changes in this patch? Or is there 
>>> still a need for this change?
>>
>> The current change set in this review is functional change while the cleanup 
>> I want is not functional after the rewrite the old option as Alias. Once 
>> flto is the alias, there is no need to handle that in the driver and those 
>> might actually become source of bug in the future.
>>
>> I think it would be good to do the cleanup in the same commit unless you 
>> have compelling reason not to.
>
> Hi @steven_wu any idea about the timeline?
>
> This issue is blocking some internal work, and assuming that it will take 
> longer to get a full fix, I would prefer it if this change could go in on its 
> own.
> Otherwise I am good with doing everything in the same commit.

I expect the cleanup is very very simple and that is why I am suggested to do 
in the same commit. I am ok with a followup fix as well.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108881

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


[PATCH] D108881: [clang][driver] Honor the last -flto(=.*)? argument

2021-09-07 Thread Usman Nadeem via Phabricator via cfe-commits
mnadeem added a comment.

In D108881#2973735 , @steven_wu wrote:

> In D108881#2973719 , @mnadeem wrote:
>
>> In D108881#2973516 , @steven_wu 
>> wrote:
>>
>>> I will do a cleanup of `parseLTOMode` function since we don't need a 
>>> `OptPos` parameter anymore. There are few minor places references 
>>> `OPT_flto` or `OPT_foffload_lto` can be cleaned up too.
>>
>> Will you incorporate the functional changes in this patch? Or is there still 
>> a need for this change?
>
> The current change set in this review is functional change while the cleanup 
> I want is not functional after the rewrite the old option as Alias. Once flto 
> is the alias, there is no need to handle that in the driver and those might 
> actually become source of bug in the future.
>
> I think it would be good to do the cleanup in the same commit unless you have 
> compelling reason not to.

Hi @steven_wu any idea about the timeline?

This issue is blocking some internal work, and assuming that it will take 
longer to get a full fix, I would prefer it if this change could go in on its 
own.
Otherwise I am good with doing everything in the same commit.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108881

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


[PATCH] D109345: MemoryBuffer: Migrate to Expected/llvm::Error from ErrorOr/std::error_code

2021-09-07 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay accepted this revision.
MaskRay added a comment.
This revision is now accepted and ready to land.

`ninja clang` on Windows works. `check-llvm-tools` has a few `REQUIRES: 
system-windows` tests and I am running them. Test invocation is bit slow.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109345

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


[PATCH] D109060: [AIX][ZOS] Disable LIT tests on AIX and z/OS due to lack of Objective-C support

2021-09-07 Thread Jinsong Ji via Phabricator via cfe-commits
jsji added inline comments.



Comment at: clang/test/Modules/ExtDebugInfo.cpp:208
 
-
-// CHECK: !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: 
!{{[0-9]+}}, entity: ![[STRUCT]], file: ![[CPP]], line: 27)
+// CHECK: !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: 
!{{[0-9]+}}, entity: ![[STRUCT]], file: ![[CPP]], line: 28)
 

Why this change? If this is needed, this should be in another patch. Thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109060

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


[PATCH] D109387: [NFC][AIX] Check for typedef properly when getting preferred type align

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

Oh, no, I don't think this is NFC.  It seems very likely that there's some case 
where the behavior is distinguishable.  Maybe a typedef of a record with an 
alignment attribute?

  __attribute__((aligned(2), packed)) struct float4 { float x, y, z, w; };
  typedef struct float4 float4typedef;
  
  struct {
float4typedef field; // presumably still eligible for alignment upgrade
  };


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109387

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


[PATCH] D109387: [AIX] Check for typedef properly when getting preferred type align

2021-09-07 Thread Steven Wan via Phabricator via cfe-commits
stevewan added a comment.

In D109387#2987780 , @rjmccall wrote:

> LGTM, except it's missing tests.

Thanks. This is an NFC patch, the tests added in 
https://reviews.llvm.org/D107598 should still suffice IMHO.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109387

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


[PATCH] D103136: [AVR] Add support for the tinyAVR 0-series and tinyAVR 1-seriesø

2021-09-07 Thread Justin Latimer via Phabricator via cfe-commits
justinlatimer added a comment.

For the commit message, my name is Justin Latimer and my email is 
justinlati...@gmail.com. Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103136

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


[PATCH] D103136: [AVR] Add support for the tinyAVR 0-series and tinyAVR 1-seriesø

2021-09-07 Thread Justin Latimer via Phabricator via cfe-commits
justinlatimer updated this revision to Diff 371176.
justinlatimer added a comment.

Update target-invalid-cpu-note.c test.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103136

Files:
  clang/lib/Basic/Targets/AVR.cpp
  clang/test/Misc/target-invalid-cpu-note.c
  llvm/lib/Target/AVR/AVRDevices.td


Index: llvm/lib/Target/AVR/AVRDevices.td
===
--- llvm/lib/Target/AVR/AVRDevices.td
+++ llvm/lib/Target/AVR/AVRDevices.td
@@ -495,4 +495,28 @@
 def : Device<"attiny40",   FamilyTiny, ELFArchTiny>;
 def : Device<"attiny102",  FamilyTiny, ELFArchTiny>;
 def : Device<"attiny104",  FamilyTiny, ELFArchTiny>;
-
+def : Device<"attiny202",  FamilyXMEGA, ELFArchXMEGA3>;
+def : Device<"attiny402",  FamilyXMEGA, ELFArchXMEGA3>;
+def : Device<"attiny204",  FamilyXMEGA, ELFArchXMEGA3>;
+def : Device<"attiny404",  FamilyXMEGA, ELFArchXMEGA3>;
+def : Device<"attiny804",  FamilyXMEGA, ELFArchXMEGA3>;
+def : Device<"attiny1604", FamilyXMEGA, ELFArchXMEGA3>;
+def : Device<"attiny406",  FamilyXMEGA, ELFArchXMEGA3>;
+def : Device<"attiny806",  FamilyXMEGA, ELFArchXMEGA3>;
+def : Device<"attiny1606", FamilyXMEGA, ELFArchXMEGA3>;
+def : Device<"attiny807",  FamilyXMEGA, ELFArchXMEGA3>;
+def : Device<"attiny1607", FamilyXMEGA, ELFArchXMEGA3>;
+def : Device<"attiny212",  FamilyXMEGA, ELFArchXMEGA3>;
+def : Device<"attiny412",  FamilyXMEGA, ELFArchXMEGA3>;
+def : Device<"attiny214",  FamilyXMEGA, ELFArchXMEGA3>;
+def : Device<"attiny414",  FamilyXMEGA, ELFArchXMEGA3>;
+def : Device<"attiny814",  FamilyXMEGA, ELFArchXMEGA3>;
+def : Device<"attiny1614", FamilyXMEGA, ELFArchXMEGA3>;
+def : Device<"attiny416",  FamilyXMEGA, ELFArchXMEGA3>;
+def : Device<"attiny816",  FamilyXMEGA, ELFArchXMEGA3>;
+def : Device<"attiny1616", FamilyXMEGA, ELFArchXMEGA3>;
+def : Device<"attiny3216", FamilyXMEGA, ELFArchXMEGA3>;
+def : Device<"attiny417",  FamilyXMEGA, ELFArchXMEGA3>;
+def : Device<"attiny817",  FamilyXMEGA, ELFArchXMEGA3>;
+def : Device<"attiny1617", FamilyXMEGA, ELFArchXMEGA3>;
+def : Device<"attiny3217", FamilyXMEGA, ELFArchXMEGA3>;
Index: clang/test/Misc/target-invalid-cpu-note.c
===
--- clang/test/Misc/target-invalid-cpu-note.c
+++ clang/test/Misc/target-invalid-cpu-note.c
@@ -154,7 +154,11 @@
 // AVR-SAME: txmega256a3bu, atxmega256c3, atxmega256d3, atxmega384c3,
 // AVR-SAME: txmega384d3, atxmega128a1, atxmega128a1u, atxmega128a4u,
 // AVR-SAME: ttiny4, attiny5, attiny9, attiny10, attiny20, attiny40, attiny102,
-// AVR-SAME: attiny104
+// AVR-SAME: attiny104, attiny202, attiny402, attiny204, attiny404, attiny804,
+// AVR-SAME: attiny1604, attiny406, attiny806, attiny1606, attiny807, 
attiny1607,
+// AVR-SAME: attiny212, attiny412, attiny214, attiny414, attiny814, attiny1614,
+// AVR-SAME: attiny416, attiny816, attiny1616, attiny3216, attiny417, 
attiny817,
+// AVR-SAME: attiny1617, attiny3217
 
 // RUN: not %clang_cc1 -triple riscv32 -target-cpu not-a-cpu -fsyntax-only %s 
2>&1 | FileCheck %s --check-prefix RISCV32
 // RISCV32: error: unknown target CPU 'not-a-cpu'
Index: clang/lib/Basic/Targets/AVR.cpp
===
--- clang/lib/Basic/Targets/AVR.cpp
+++ clang/lib/Basic/Targets/AVR.cpp
@@ -267,6 +267,31 @@
 {"attiny40", "__AVR_ATtiny40__"},
 {"attiny102", "__AVR_ATtiny102__"},
 {"attiny104", "__AVR_ATtiny104__"},
+{"attiny202", "__AVR_ATtiny202__"},
+{"attiny402", "__AVR_ATtiny402__"},
+{"attiny204", "__AVR_ATtiny204__"},
+{"attiny404", "__AVR_ATtiny404__"},
+{"attiny804", "__AVR_ATtiny804__"},
+{"attiny1604", "__AVR_ATtiny1604__"},
+{"attiny406", "__AVR_ATtiny406__"},
+{"attiny806", "__AVR_ATtiny806__"},
+{"attiny1606", "__AVR_ATtiny1606__"},
+{"attiny807", "__AVR_ATtiny807__"},
+{"attiny1607", "__AVR_ATtiny1607__"},
+{"attiny212", "__AVR_ATtiny212__"},
+{"attiny412", "__AVR_ATtiny412__"},
+{"attiny214", "__AVR_ATtiny214__"},
+{"attiny414", "__AVR_ATtiny414__"},
+{"attiny814", "__AVR_ATtiny814__"},
+{"attiny1614", "__AVR_ATtiny1614__"},
+{"attiny416", "__AVR_ATtiny416__"},
+{"attiny816", "__AVR_ATtiny816__"},
+{"attiny1616", "__AVR_ATtiny1616__"},
+{"attiny3216", "__AVR_ATtiny3216__"},
+{"attiny417", "__AVR_ATtiny417__"},
+{"attiny817", "__AVR_ATtiny817__"},
+{"attiny1617", "__AVR_ATtiny1617__"},
+{"attiny3217", "__AVR_ATtiny3217__"},
 };
 
 } // namespace targets


Index: llvm/lib/Target/AVR/AVRDevices.td
===
--- llvm/lib/Target/AVR/AVRDevices.td
+++ 

[PATCH] D109321: [clang][OpenMP] Fix the bug in codegen for ordered directive

2021-09-07 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 added a comment.

In D109321#2986678 , @peixin wrote:

>   $ clang++ -fopenmp simd.cpp -O1 -Xclang -disable-llvm-passes && ./a.out
>   0 1  2  3  4  5  6  7  8  9
>   $ clang++ -fopenmp simd.cpp -O2 && ./a.out
>   0 1  2  3  4  5  6  7  8  9
>   $ clang++ -fopenmp simd.cpp -O3 && ./a.out
>   0 1  2  3  4  5  6  7  8  9
>
> This bug is not in clang frontend. I will post it in bugzilla.
>
> Another question is why not add `llvm::Attribute::AlwaysInline` when 
> `CGM.getCodeGenOpts().OptimizationLevel` is 0? @jhuber6 I think it is correct 
> to add the attribute when `CGM.getCodeGenOpts().OptimizationLevel` is 0.

Just to prevent the IR from changing when optimizations aren't enabled.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109321

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


[PATCH] D109321: [clang][OpenMP] Fix the bug in codegen for ordered directive

2021-09-07 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert requested changes to this revision.
jdoerfert added a comment.

As noted before, this is not the right fix. Not inlining should not cause a 
semantic difference here, the problem is something else.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109321

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


[PATCH] D109387: [AIX] Check for typedef properly when getting preferred type align

2021-09-07 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall added a comment.
This revision is now accepted and ready to land.

LGTM, except it's missing tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109387

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


[PATCH] D109126: [PowerPC] [NFC] Add Big-Endian checks for existing MMA tests

2021-09-07 Thread Ahsan Saghir via Phabricator via cfe-commits
saghir marked an inline comment as done.
saghir added inline comments.



Comment at: clang/test/CodeGen/builtins-ppc-pair-mma.c:5
+// RUN: %clang_cc1 -O3 -triple powerpc64-unknown-unknown -target-cpu pwr10 \
+// RUN: -emit-llvm %s -o - | FileCheck %s --check-prefix=CHECK-BE
 

nemanjai wrote:
> qiucf wrote:
> > Seems just adding `%clang_cc1 -O3 -triple powerpc64-unknown-unknown 
> > -target-cpu pwr10 -emit-llvm %s -o - | FileCheck %s` also makes the test 
> > pass. `CHECK` and `CHECK-BE` contents are the same.
> The existing builtins produce the same IR but I think this is done in 
> preparation for https://reviews.llvm.org/D107647 which will add builtins very 
> similar to these but that produce different IR on LE and BE. The description 
> of the patch should probably mention that.
Since all the builtins in this file produce the same output for LE and BE, it's 
probably better to add checks for the new builtins (having different output for 
LE/BE) in a separate file.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109126

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


[PATCH] D109060: [AIX][ZOS] Disable LIT tests on AIX and z/OS due to lack of Objective-C support

2021-09-07 Thread Jake Egan via Phabricator via cfe-commits
Jake-Egan updated this revision to Diff 371165.
Jake-Egan added a comment.

Fixed ExtDebugInfo.cpp


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109060

Files:
  clang/test/CodeGenObjC/lit.local.cfg
  clang/test/CodeGenObjCXX/lit.local.cfg
  clang/test/Import/forward-declared-objc-class/test.m
  clang/test/Import/objc-arc/test-cleanup-object.m
  clang/test/Import/objc-autoreleasepool/test.m
  clang/test/Import/objc-definitions-in-expression/test.m
  clang/test/Import/objc-method/test.m
  clang/test/Import/objc-param-decl/test.m
  clang/test/Import/objc-try-catch/test.m
  clang/test/Modules/DebugInfoNamespace.cpp
  clang/test/Modules/DebugInfoTransitiveImport.m
  clang/test/Modules/ExtDebugInfo.cpp
  clang/test/Modules/ExtDebugInfo.m
  clang/test/Modules/ModuleModuleDebugInfo.cpp
  clang/test/Modules/autolink.m
  clang/test/Modules/autolinkTBD.m
  clang/test/Modules/cxx-irgen.cpp
  clang/test/Modules/debug-info-moduleimport.m
  clang/test/Modules/direct-module-import.m
  clang/test/Modules/merge-record-definition-nonmodular.m
  clang/test/Modules/merge-record-definition-visibility.m
  clang/test/Modules/merge-record-definition.m
  clang/test/Modules/module_file_info.m
  clang/test/Modules/objc-initializer.m
  clang/test/Modules/pch-used.m
  clang/test/Modules/use-exportas-for-link.m
  clang/test/PCH/irgen-rdar13114142.mm
  clang/test/PCH/objc_container.m
  clang/test/PCH/objc_literals.m
  clang/test/PCH/objc_literals.mm
  clang/test/PCH/objcxx-ivar-class.mm

Index: clang/test/PCH/objcxx-ivar-class.mm
===
--- clang/test/PCH/objcxx-ivar-class.mm
+++ clang/test/PCH/objcxx-ivar-class.mm
@@ -1,3 +1,4 @@
+// UNSUPPORTED: -zos, -aix
 // Test this without pch.
 // RUN: %clang_cc1 -include %S/objcxx-ivar-class.h -triple %itanium_abi_triple %s -emit-llvm -o - | FileCheck %s
 
Index: clang/test/PCH/objc_literals.mm
===
--- clang/test/PCH/objc_literals.mm
+++ clang/test/PCH/objc_literals.mm
@@ -1,3 +1,4 @@
+// UNSUPPORTED: -zos, -aix
 // RUN: %clang_cc1 -triple %itanium_abi_triple -emit-pch -x objective-c++ -std=c++0x -o %t %s
 // RUN: %clang_cc1 -triple %itanium_abi_triple -include-pch %t -x objective-c++ -std=c++0x -verify %s
 // RUN: %clang_cc1 -triple %itanium_abi_triple -include-pch %t -x objective-c++ -std=c++0x -ast-print %s | FileCheck -check-prefix=CHECK-PRINT %s
Index: clang/test/PCH/objc_literals.m
===
--- clang/test/PCH/objc_literals.m
+++ clang/test/PCH/objc_literals.m
@@ -1,3 +1,4 @@
+// UNSUPPORTED: -zos, -aix
 // RUN: %clang_cc1 -emit-pch -o %t %s
 // RUN: %clang_cc1 -include-pch %t -verify %s
 // RUN: %clang_cc1 -include-pch %t -ast-print %s | FileCheck -check-prefix=CHECK-PRINT %s
Index: clang/test/PCH/objc_container.m
===
--- clang/test/PCH/objc_container.m
+++ clang/test/PCH/objc_container.m
@@ -1,3 +1,4 @@
+// UNSUPPORTED: -zos, -aix
 // Test this without pch.
 // RUN: %clang_cc1 -include %S/objc_container.h -fsyntax-only -verify %s
 
Index: clang/test/PCH/irgen-rdar13114142.mm
===
--- clang/test/PCH/irgen-rdar13114142.mm
+++ clang/test/PCH/irgen-rdar13114142.mm
@@ -1,3 +1,4 @@
+// UNSUPPORTED: -zos, -aix
 // RUN: %clang_cc1 %s -triple %itanium_abi_triple -emit-pch -o %t.pch
 // RUN: %clang_cc1 %s -triple %itanium_abi_triple -emit-llvm -include-pch %t.pch -o - | FileCheck %s
 
Index: clang/test/Modules/use-exportas-for-link.m
===
--- clang/test/Modules/use-exportas-for-link.m
+++ clang/test/Modules/use-exportas-for-link.m
@@ -1,3 +1,4 @@
+// UNSUPPORTED: -zos, -aix
 // RUN: rm -rf %t
 // RUN: %clang_cc1 -emit-llvm -o - -fmodules-cache-path=%t -DA -fmodules -fimplicit-module-maps -F %S/Inputs/exportas-link %s | FileCheck --check-prefix=CHECK_A %s
 // CHECK_A: !llvm.linker.options = !{![[MODULE:[0-9]+]]}
Index: clang/test/Modules/pch-used.m
===
--- clang/test/Modules/pch-used.m
+++ clang/test/Modules/pch-used.m
@@ -1,3 +1,4 @@
+// UNSUPPORTED: -zos, -aix
 // RUN: rm -rf %t
 // RUN: mkdir %t
 // RUN: %clang_cc1 -x objective-c-header -emit-pch %S/Inputs/pch-used.h -o %t/pch-used.h.pch -fmodules -fimplicit-module-maps -fmodules-cache-path=%t/cache -O0 -isystem %S/Inputs/System/usr/include
Index: clang/test/Modules/objc-initializer.m
===
--- clang/test/Modules/objc-initializer.m
+++ clang/test/Modules/objc-initializer.m
@@ -1,3 +1,4 @@
+// UNSUPPORTED: -zos, -aix
 // RUN: rm -rf %t
 // RUN: %clang_cc1 -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -I %S/Inputs/objc-initializer %s -emit-llvm -o - 

[PATCH] D109126: [PowerPC] [NFC] Add Big-Endian checks for existing MMA tests

2021-09-07 Thread Ahsan Saghir via Phabricator via cfe-commits
saghir updated this revision to Diff 371164.
saghir added a comment.

Addressed review comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109126

Files:
  clang/test/CodeGen/builtins-ppc-pair-mma.c
  clang/test/Sema/ppc-pair-mma-types.c
  clang/test/SemaCXX/ppc-pair-mma-types.cpp


Index: clang/test/SemaCXX/ppc-pair-mma-types.cpp
===
--- clang/test/SemaCXX/ppc-pair-mma-types.cpp
+++ clang/test/SemaCXX/ppc-pair-mma-types.cpp
@@ -1,5 +1,7 @@
 // RUN: %clang_cc1 -triple powerpc64le-unknown-unknown -fsyntax-only \
-// RUN:   -fcxx-exceptions -target-cpu future %s -verify
+// RUN:   -fcxx-exceptions -target-cpu pwr10 %s -verify
+// RUN: %clang_cc1 -triple powerpc64-unknown-unknown -fsyntax-only \
+// RUN:   -fcxx-exceptions -target-cpu pwr10 %s -verify
 
 // vector quad
 
Index: clang/test/Sema/ppc-pair-mma-types.c
===
--- clang/test/Sema/ppc-pair-mma-types.c
+++ clang/test/Sema/ppc-pair-mma-types.c
@@ -1,5 +1,7 @@
 // RUN: %clang_cc1 -triple powerpc64le-unknown-unknown -fsyntax-only \
-// RUN:   -target-cpu future %s -verify
+// RUN:   -target-cpu pwr10 %s -verify
+// RUN: %clang_cc1 -triple powerpc64-unknown-unknown -fsyntax-only \
+// RUN:   -target-cpu pwr10 %s -verify
 
 // The use of PPC MMA types is strongly restricted. Non-pointer MMA variables
 // can only be declared in functions and a limited number of operations are
Index: clang/test/CodeGen/builtins-ppc-pair-mma.c
===
--- clang/test/CodeGen/builtins-ppc-pair-mma.c
+++ clang/test/CodeGen/builtins-ppc-pair-mma.c
@@ -1,5 +1,8 @@
 // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
-// RUN: %clang_cc1 -O3 -triple powerpc64le-unknown-unknown -target-cpu future 
-emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -O3 -triple powerpc64le-unknown-unknown -target-cpu pwr10 \
+// RUN:  -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -O3 -triple powerpc64-unknown-unknown -target-cpu pwr10 \
+// RUN: -emit-llvm %s -o - | FileCheck %s
 
 // CHECK-LABEL: @test1(
 // CHECK-NEXT:  entry:


Index: clang/test/SemaCXX/ppc-pair-mma-types.cpp
===
--- clang/test/SemaCXX/ppc-pair-mma-types.cpp
+++ clang/test/SemaCXX/ppc-pair-mma-types.cpp
@@ -1,5 +1,7 @@
 // RUN: %clang_cc1 -triple powerpc64le-unknown-unknown -fsyntax-only \
-// RUN:   -fcxx-exceptions -target-cpu future %s -verify
+// RUN:   -fcxx-exceptions -target-cpu pwr10 %s -verify
+// RUN: %clang_cc1 -triple powerpc64-unknown-unknown -fsyntax-only \
+// RUN:   -fcxx-exceptions -target-cpu pwr10 %s -verify
 
 // vector quad
 
Index: clang/test/Sema/ppc-pair-mma-types.c
===
--- clang/test/Sema/ppc-pair-mma-types.c
+++ clang/test/Sema/ppc-pair-mma-types.c
@@ -1,5 +1,7 @@
 // RUN: %clang_cc1 -triple powerpc64le-unknown-unknown -fsyntax-only \
-// RUN:   -target-cpu future %s -verify
+// RUN:   -target-cpu pwr10 %s -verify
+// RUN: %clang_cc1 -triple powerpc64-unknown-unknown -fsyntax-only \
+// RUN:   -target-cpu pwr10 %s -verify
 
 // The use of PPC MMA types is strongly restricted. Non-pointer MMA variables
 // can only be declared in functions and a limited number of operations are
Index: clang/test/CodeGen/builtins-ppc-pair-mma.c
===
--- clang/test/CodeGen/builtins-ppc-pair-mma.c
+++ clang/test/CodeGen/builtins-ppc-pair-mma.c
@@ -1,5 +1,8 @@
 // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
-// RUN: %clang_cc1 -O3 -triple powerpc64le-unknown-unknown -target-cpu future -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -O3 -triple powerpc64le-unknown-unknown -target-cpu pwr10 \
+// RUN:  -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -O3 -triple powerpc64-unknown-unknown -target-cpu pwr10 \
+// RUN: -emit-llvm %s -o - | FileCheck %s
 
 // CHECK-LABEL: @test1(
 // CHECK-NEXT:  entry:
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D109199: [compiler-rt][Fuchsia] Support building + running compiler-rt tests on fuchsia's host toolchain

2021-09-07 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan added inline comments.



Comment at: clang/cmake/caches/Fuchsia-stage2.cmake:123
 set(RUNTIMES_${target}_COMPILER_RT_USE_BUILTINS_LIBRARY ON CACHE BOOL "")
+set(RUNTIMES_${target}_COMPILER_RT_BUILD_BUILTINS ON CACHE BOOL "")
+set(RUNTIMES_${target}_COMPILER_RT_CAN_EXECUTE_TESTS ON CACHE BOOL "")

phosek wrote:
> leonardchan wrote:
> > phosek wrote:
> > > This shouldn't be needed.
> > So while we do build builtins, this is actually needed to run builtins 
> > tests: 
> > https://github.com/llvm/llvm-project/blob/ad7e12226f6b1ebf91511899016cdfb29aa8919e/compiler-rt/test/CMakeLists.txt#L59
> We are already build builtins in a separate build so I think we should be 
> running the tests there rather than building the twice.
Ah, I didn't know that. Removed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109199

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


[PATCH] D109199: [compiler-rt][Fuchsia] Support building + running compiler-rt tests on fuchsia's host toolchain

2021-09-07 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan updated this revision to Diff 371163.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109199

Files:
  clang/cmake/caches/Fuchsia-stage2.cmake


Index: clang/cmake/caches/Fuchsia-stage2.cmake
===
--- clang/cmake/caches/Fuchsia-stage2.cmake
+++ clang/cmake/caches/Fuchsia-stage2.cmake
@@ -60,7 +60,6 @@
   set(COMPILER_RT_USE_BUILTINS_LIBRARY ON CACHE BOOL "")
 
   set(LIBUNWIND_ENABLE_SHARED OFF CACHE BOOL "")
-  set(LIBUNWIND_INSTALL_LIBRARY OFF CACHE BOOL "")
   set(LIBUNWIND_USE_COMPILER_RT ON CACHE BOOL "")
   set(LIBCXXABI_ENABLE_SHARED OFF CACHE BOOL "")
   set(LIBCXXABI_ENABLE_STATIC_UNWINDER ON CACHE BOOL "")
@@ -121,9 +120,9 @@
 set(RUNTIMES_${target}_CMAKE_MODULE_LINKER_FLAGS "-fuse-ld=lld" CACHE 
STRING "")
 set(RUNTIMES_${target}_CMAKE_EXE_LINKER_FLAGS "-fuse-ld=lld" CACHE STRING 
"")
 set(RUNTIMES_${target}_COMPILER_RT_USE_BUILTINS_LIBRARY ON CACHE BOOL "")
+set(RUNTIMES_${target}_COMPILER_RT_CAN_EXECUTE_TESTS ON CACHE BOOL "")
 set(RUNTIMES_${target}_LIBUNWIND_ENABLE_SHARED OFF CACHE BOOL "")
 set(RUNTIMES_${target}_LIBUNWIND_USE_COMPILER_RT ON CACHE BOOL "")
-set(RUNTIMES_${target}_LIBUNWIND_INSTALL_LIBRARY OFF CACHE BOOL "")
 set(RUNTIMES_${target}_LIBCXXABI_USE_COMPILER_RT ON CACHE BOOL "")
 set(RUNTIMES_${target}_LIBCXXABI_ENABLE_SHARED OFF CACHE BOOL "")
 set(RUNTIMES_${target}_LIBCXXABI_USE_LLVM_UNWINDER ON CACHE BOOL "")
@@ -136,6 +135,10 @@
 set(RUNTIMES_${target}_LLVM_ENABLE_ASSERTIONS OFF CACHE BOOL "")
 set(RUNTIMES_${target}_SANITIZER_CXX_ABI "libc++" CACHE STRING "")
 set(RUNTIMES_${target}_SANITIZER_CXX_ABI_INTREE ON CACHE BOOL "")
+set(RUNTIMES_${target}_COMPILER_RT_TEST_COMPILER_CFLAGS 
"--unwindlib=libunwind -static-libgcc" CACHE STRING "")
+set(RUNTIMES_${target}_SANITIZER_COMMON_TEST_TARGET_CFLAGS 
"--unwindlib=libunwind -static-libgcc" CACHE STRING "")
+set(RUNTIMES_${target}_TSAN_TEST_TARGET_CFLAGS "--unwindlib=libunwind" 
CACHE STRING "")
+set(RUNTIMES_${target}_LLVM_TOOLS_DIR "${CMAKE_BINARY_DIR}/bin" CACHE BOOL 
"")
 set(RUNTIMES_${target}_LLVM_ENABLE_RUNTIMES 
"compiler-rt;libcxx;libcxxabi;libunwind" CACHE STRING "")
 
 # Use .build-id link.


Index: clang/cmake/caches/Fuchsia-stage2.cmake
===
--- clang/cmake/caches/Fuchsia-stage2.cmake
+++ clang/cmake/caches/Fuchsia-stage2.cmake
@@ -60,7 +60,6 @@
   set(COMPILER_RT_USE_BUILTINS_LIBRARY ON CACHE BOOL "")
 
   set(LIBUNWIND_ENABLE_SHARED OFF CACHE BOOL "")
-  set(LIBUNWIND_INSTALL_LIBRARY OFF CACHE BOOL "")
   set(LIBUNWIND_USE_COMPILER_RT ON CACHE BOOL "")
   set(LIBCXXABI_ENABLE_SHARED OFF CACHE BOOL "")
   set(LIBCXXABI_ENABLE_STATIC_UNWINDER ON CACHE BOOL "")
@@ -121,9 +120,9 @@
 set(RUNTIMES_${target}_CMAKE_MODULE_LINKER_FLAGS "-fuse-ld=lld" CACHE STRING "")
 set(RUNTIMES_${target}_CMAKE_EXE_LINKER_FLAGS "-fuse-ld=lld" CACHE STRING "")
 set(RUNTIMES_${target}_COMPILER_RT_USE_BUILTINS_LIBRARY ON CACHE BOOL "")
+set(RUNTIMES_${target}_COMPILER_RT_CAN_EXECUTE_TESTS ON CACHE BOOL "")
 set(RUNTIMES_${target}_LIBUNWIND_ENABLE_SHARED OFF CACHE BOOL "")
 set(RUNTIMES_${target}_LIBUNWIND_USE_COMPILER_RT ON CACHE BOOL "")
-set(RUNTIMES_${target}_LIBUNWIND_INSTALL_LIBRARY OFF CACHE BOOL "")
 set(RUNTIMES_${target}_LIBCXXABI_USE_COMPILER_RT ON CACHE BOOL "")
 set(RUNTIMES_${target}_LIBCXXABI_ENABLE_SHARED OFF CACHE BOOL "")
 set(RUNTIMES_${target}_LIBCXXABI_USE_LLVM_UNWINDER ON CACHE BOOL "")
@@ -136,6 +135,10 @@
 set(RUNTIMES_${target}_LLVM_ENABLE_ASSERTIONS OFF CACHE BOOL "")
 set(RUNTIMES_${target}_SANITIZER_CXX_ABI "libc++" CACHE STRING "")
 set(RUNTIMES_${target}_SANITIZER_CXX_ABI_INTREE ON CACHE BOOL "")
+set(RUNTIMES_${target}_COMPILER_RT_TEST_COMPILER_CFLAGS "--unwindlib=libunwind -static-libgcc" CACHE STRING "")
+set(RUNTIMES_${target}_SANITIZER_COMMON_TEST_TARGET_CFLAGS "--unwindlib=libunwind -static-libgcc" CACHE STRING "")
+set(RUNTIMES_${target}_TSAN_TEST_TARGET_CFLAGS "--unwindlib=libunwind" CACHE STRING "")
+set(RUNTIMES_${target}_LLVM_TOOLS_DIR "${CMAKE_BINARY_DIR}/bin" CACHE BOOL "")
 set(RUNTIMES_${target}_LLVM_ENABLE_RUNTIMES "compiler-rt;libcxx;libcxxabi;libunwind" CACHE STRING "")
 
 # Use .build-id link.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D108958: [OpenMP] Make CUDA math library functions SPMD amenable

2021-09-07 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 updated this revision to Diff 371162.
jhuber6 added a comment.

Fixing end assumes using wrong syntax.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108958

Files:
  clang/lib/Headers/__clang_cuda_libdevice_declares.h


Index: clang/lib/Headers/__clang_cuda_libdevice_declares.h
===
--- clang/lib/Headers/__clang_cuda_libdevice_declares.h
+++ clang/lib/Headers/__clang_cuda_libdevice_declares.h
@@ -16,6 +16,7 @@
 
 #if defined(__OPENMP_NVPTX__)
 #define __DEVICE__
+#pragma omp begin assumes ext_spmd_amenable no_openmp
 #elif defined(__CUDA__)
 #define __DEVICE__ __device__
 #endif
@@ -456,6 +457,11 @@
 __DEVICE__ float __nv_y1f(float __a);
 __DEVICE__ float __nv_ynf(int __a, float __b);
 __DEVICE__ double __nv_yn(int __a, double __b);
+
+#if defined(__OPENMP_NVPTX__)
+#pragma omp end assumes ext_spmd_amenable no_openmp
+#endif
+
 #if defined(__cplusplus)
 } // extern "C"
 #endif


Index: clang/lib/Headers/__clang_cuda_libdevice_declares.h
===
--- clang/lib/Headers/__clang_cuda_libdevice_declares.h
+++ clang/lib/Headers/__clang_cuda_libdevice_declares.h
@@ -16,6 +16,7 @@
 
 #if defined(__OPENMP_NVPTX__)
 #define __DEVICE__
+#pragma omp begin assumes ext_spmd_amenable no_openmp
 #elif defined(__CUDA__)
 #define __DEVICE__ __device__
 #endif
@@ -456,6 +457,11 @@
 __DEVICE__ float __nv_y1f(float __a);
 __DEVICE__ float __nv_ynf(int __a, float __b);
 __DEVICE__ double __nv_yn(int __a, double __b);
+
+#if defined(__OPENMP_NVPTX__)
+#pragma omp end assumes ext_spmd_amenable no_openmp
+#endif
+
 #if defined(__cplusplus)
 } // extern "C"
 #endif
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D106809: [clang-offload-bundler] Make Bundle Entry ID backward compatible

2021-09-07 Thread George Rokos via Phabricator via cfe-commits
grokos accepted this revision.
grokos added a comment.

LGTM as well.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106809

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


[PATCH] D106809: [clang-offload-bundler] Make Bundle Entry ID backward compatible

2021-09-07 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl accepted this revision.
yaxunl added a comment.
This revision is now accepted and ready to land.

Ideally, we probably need something like isValidOffloadArch(Triple, 
OffloadArch) or getTargetTriple(OffloadArch). However, I think the current 
patch is good enough for its own purpose.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106809

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


[PATCH] D109060: [AIX][ZOS] Disable LIT tests on AIX and z/OS due to lack of Objective-C support

2021-09-07 Thread Jinsong Ji via Phabricator via cfe-commits
jsji accepted this revision as: jsji.
jsji added a comment.
This revision is now accepted and ready to land.

LGTM. Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109060

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


[PATCH] D109387: [AIX] Check for typedef properly when getting preferred type align

2021-09-07 Thread Steven Wan via Phabricator via cfe-commits
stevewan created this revision.
stevewan requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

The current check for typedef is naive and doesn't deal with any convoluted 
cases. This patch makes use of the new 'AlignRequirement' enum field from 
'TypeInfo' to determine whether or not this is an 'aligned' attribute on a 
typedef.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D109387

Files:
  clang/lib/AST/ASTContext.cpp


Index: clang/lib/AST/ASTContext.cpp
===
--- clang/lib/AST/ASTContext.cpp
+++ clang/lib/AST/ASTContext.cpp
@@ -2497,8 +2497,10 @@
 const RecordDecl *RD = RT->getDecl();
 
 // When used as part of a typedef, or together with a 'packed' attribute,
-// the 'aligned' attribute can be used to decrease alignment.
-if ((TI.isAlignRequired() && T->getAs() != nullptr) ||
+// the 'aligned' attribute can be used to decrease alignment. Note that the
+// 'packed' case is already taken into consideration when computing the
+// alignment, we only need to handle the typedef case here.
+if (TI.AlignRequirement == AlignRequirementKind::RequiredByTypedef ||
 RD->isInvalidDecl())
   return ABIAlign;
 


Index: clang/lib/AST/ASTContext.cpp
===
--- clang/lib/AST/ASTContext.cpp
+++ clang/lib/AST/ASTContext.cpp
@@ -2497,8 +2497,10 @@
 const RecordDecl *RD = RT->getDecl();
 
 // When used as part of a typedef, or together with a 'packed' attribute,
-// the 'aligned' attribute can be used to decrease alignment.
-if ((TI.isAlignRequired() && T->getAs() != nullptr) ||
+// the 'aligned' attribute can be used to decrease alignment. Note that the
+// 'packed' case is already taken into consideration when computing the
+// alignment, we only need to handle the typedef case here.
+if (TI.AlignRequirement == AlignRequirementKind::RequiredByTypedef ||
 RD->isInvalidDecl())
   return ABIAlign;
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D109386: Fix use-after-free from GlobalCtors associated data

2021-09-07 Thread Lei Wang via Phabricator via cfe-commits
wlei created this revision.
Herald added subscribers: hoy, wenlei, lxfind.
wlei requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D109386

Files:
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/CodeGenModule.h


Index: clang/lib/CodeGen/CodeGenModule.h
===
--- clang/lib/CodeGen/CodeGenModule.h
+++ clang/lib/CodeGen/CodeGenModule.h
@@ -1526,6 +1526,8 @@
   void EmitPointerToInitFunc(const VarDecl *VD, llvm::GlobalVariable *Addr,
  llvm::Function *InitFunc, InitSegAttr *ISA);
 
+  void UpdateADOfGlobalCtors(llvm::Constant *Old, llvm::Constant *New);
+
   // FIXME: Hardcoding priority here is gross.
   void AddGlobalCtor(llvm::Function *Ctor, int Priority = 65535,
  llvm::Constant *AssociatedData = nullptr);
Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -1421,6 +1421,14 @@
   return getModule().getNamedValue(Name);
 }
 
+void CodeGenModule::UpdateADOfGlobalCtors(llvm::Constant *Old, llvm::Constant 
*New) {
+  for(auto  : GlobalCtors) {
+if(S.AssociatedData == Old) {
+  S.AssociatedData = New;
+}
+  }
+}
+
 /// AddGlobalCtor - Add a function to the list that will be called before
 /// main() runs.
 void CodeGenModule::AddGlobalCtor(llvm::Function *Ctor, int Priority,
@@ -3901,6 +3909,8 @@
   llvm::Constant *NewPtrForOldDecl =
   llvm::ConstantExpr::getBitCast(GV, Entry->getType());
   Entry->replaceAllUsesWith(NewPtrForOldDecl);
+
+  UpdateADOfGlobalCtors(Entry, GV);
 }
 
 Entry->eraseFromParent();


Index: clang/lib/CodeGen/CodeGenModule.h
===
--- clang/lib/CodeGen/CodeGenModule.h
+++ clang/lib/CodeGen/CodeGenModule.h
@@ -1526,6 +1526,8 @@
   void EmitPointerToInitFunc(const VarDecl *VD, llvm::GlobalVariable *Addr,
  llvm::Function *InitFunc, InitSegAttr *ISA);
 
+  void UpdateADOfGlobalCtors(llvm::Constant *Old, llvm::Constant *New);
+
   // FIXME: Hardcoding priority here is gross.
   void AddGlobalCtor(llvm::Function *Ctor, int Priority = 65535,
  llvm::Constant *AssociatedData = nullptr);
Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -1421,6 +1421,14 @@
   return getModule().getNamedValue(Name);
 }
 
+void CodeGenModule::UpdateADOfGlobalCtors(llvm::Constant *Old, llvm::Constant *New) {
+  for(auto  : GlobalCtors) {
+if(S.AssociatedData == Old) {
+  S.AssociatedData = New;
+}
+  }
+}
+
 /// AddGlobalCtor - Add a function to the list that will be called before
 /// main() runs.
 void CodeGenModule::AddGlobalCtor(llvm::Function *Ctor, int Priority,
@@ -3901,6 +3909,8 @@
   llvm::Constant *NewPtrForOldDecl =
   llvm::ConstantExpr::getBitCast(GV, Entry->getType());
   Entry->replaceAllUsesWith(NewPtrForOldDecl);
+
+  UpdateADOfGlobalCtors(Entry, GV);
 }
 
 Entry->eraseFromParent();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D108958: [OpenMP] Make CUDA math library functions SPMD amenable

2021-09-07 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 updated this revision to Diff 371153.
jhuber6 added a comment.

Adding `no_openmp` assumption as well.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108958

Files:
  clang/lib/Headers/__clang_cuda_libdevice_declares.h


Index: clang/lib/Headers/__clang_cuda_libdevice_declares.h
===
--- clang/lib/Headers/__clang_cuda_libdevice_declares.h
+++ clang/lib/Headers/__clang_cuda_libdevice_declares.h
@@ -16,6 +16,7 @@
 
 #if defined(__OPENMP_NVPTX__)
 #define __DEVICE__
+#pragma omp begin assumes ext_spmd_amenable no_openmp
 #elif defined(__CUDA__)
 #define __DEVICE__ __device__
 #endif
@@ -456,6 +457,11 @@
 __DEVICE__ float __nv_y1f(float __a);
 __DEVICE__ float __nv_ynf(int __a, float __b);
 __DEVICE__ double __nv_yn(int __a, double __b);
+
+#if defined(__OPENMP_NVPTX__)
+#pragma omp end assumes ext_spmd_amenable, omp_no_openmp
+#endif
+
 #if defined(__cplusplus)
 } // extern "C"
 #endif


Index: clang/lib/Headers/__clang_cuda_libdevice_declares.h
===
--- clang/lib/Headers/__clang_cuda_libdevice_declares.h
+++ clang/lib/Headers/__clang_cuda_libdevice_declares.h
@@ -16,6 +16,7 @@
 
 #if defined(__OPENMP_NVPTX__)
 #define __DEVICE__
+#pragma omp begin assumes ext_spmd_amenable no_openmp
 #elif defined(__CUDA__)
 #define __DEVICE__ __device__
 #endif
@@ -456,6 +457,11 @@
 __DEVICE__ float __nv_y1f(float __a);
 __DEVICE__ float __nv_ynf(int __a, float __b);
 __DEVICE__ double __nv_yn(int __a, double __b);
+
+#if defined(__OPENMP_NVPTX__)
+#pragma omp end assumes ext_spmd_amenable, omp_no_openmp
+#endif
+
 #if defined(__cplusplus)
 } // extern "C"
 #endif
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D109345: MemoryBuffer: Migrate to Expected/llvm::Error from ErrorOr/std::error_code

2021-09-07 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith added a comment.

This seems like the right direction to me! Especially like the 
look-through-the-ErrorInfo change for `FileError` -- I hit this before and 
found it annoying.

IMO, it'd be valuable to split out the consequential functional changes:

- Improvements/changes you made to FileError could be committed ahead of time
- Other improvements you discussed to avoid regressions in (e.g.) 
llvm-symbolizer (seems potentially important?)

I agree the other changes are mostly mechanical and don't all need careful 
review-by-subcomponents.

That said, it looks very painful for downstream clients of the LLVM C++ API 
since it's structured as an all-or-nothing change. Especially for managing 
cherry-picks to long-lived stable branches. It's painful because clients will 
have code like this:

  if (auto MaybeFile = MemoryBuffer::getFileOrSTDIN()) {
// Do something with MaybeFile
  }
  // Else path doesn't care about the specific error code.

that will suddenly start crashing at runtime. I even wonder if there like that 
introduced in-tree by your current all-in-one patch, since I think our 
filesystem-error paths are often missing test coverage. (It'd be difficult to 
do a thorough audit.)

I thought through a potential staging that could mitigate the pain:

1. Add `using MemoryBufferCompat = MemoryBuffer` and search/replace all static 
`MemoryBuffer::` API calls over to `MemoryBufferCompat::`. No direct impact on 
downstreams.
2. Change `MemoryBuffer` to use `Error` and `Expected`, leaving behind 
`std::error_code` and `ErrorOr` wrappers in a no-longer-just-a-typedef 
`MemoryBufferCompat`. Easy for downstreams to temporarily revert, and 
cherry-pick once they've finished adapting in the example of (1).
3. Update all code to use the new APIs. Could be done all at once since it's 
mostly mechanical, as you said. Also an option to split up by component (e.g., 
maybe the llvm-symbolizer regression is okay, but it could be nice to get that 
reviewed separately / in isolation).
4. Delete `MemoryBufferCompat`. Downstreams can temporarily revert while they 
follow the example of on (3).

(Given that (1) and (2) are easy to write, you already have `tree` state for 
(4), and (3) is easy to create from (4), then I //think// you could construct 
the above commit sequence without having to redo all the work... then if you 
wanted to split (3) up from there it'd be easy enough.)

(2) seems like the commit mostly likely to cause functional regressions, and 
it'd be isolated and easy to revert/reapply (downstream and/or upstream) 
without much churn.

WDYT?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109345

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


[PATCH] D109060: [AIX] Disable LIT tests on AIX due to lack of Objective-C support

2021-09-07 Thread Jake Egan via Phabricator via cfe-commits
Jake-Egan updated this revision to Diff 371137.
Jake-Egan edited the summary of this revision.
Jake-Egan added a comment.

Added lit.local.cfg and unsupported z/OS as well.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109060

Files:
  clang/test/CodeGenObjC/lit.local.cfg
  clang/test/CodeGenObjCXX/lit.local.cfg
  clang/test/Import/forward-declared-objc-class/test.m
  clang/test/Import/objc-arc/test-cleanup-object.m
  clang/test/Import/objc-autoreleasepool/test.m
  clang/test/Import/objc-definitions-in-expression/test.m
  clang/test/Import/objc-method/test.m
  clang/test/Import/objc-param-decl/test.m
  clang/test/Import/objc-try-catch/test.m
  clang/test/Modules/DebugInfoNamespace.cpp
  clang/test/Modules/DebugInfoTransitiveImport.m
  clang/test/Modules/ExtDebugInfo.cpp
  clang/test/Modules/ExtDebugInfo.m
  clang/test/Modules/ModuleModuleDebugInfo.cpp
  clang/test/Modules/autolink.m
  clang/test/Modules/autolinkTBD.m
  clang/test/Modules/cxx-irgen.cpp
  clang/test/Modules/debug-info-moduleimport.m
  clang/test/Modules/direct-module-import.m
  clang/test/Modules/merge-record-definition-nonmodular.m
  clang/test/Modules/merge-record-definition-visibility.m
  clang/test/Modules/merge-record-definition.m
  clang/test/Modules/module_file_info.m
  clang/test/Modules/objc-initializer.m
  clang/test/Modules/pch-used.m
  clang/test/Modules/use-exportas-for-link.m
  clang/test/PCH/irgen-rdar13114142.mm
  clang/test/PCH/objc_container.m
  clang/test/PCH/objc_literals.m
  clang/test/PCH/objc_literals.mm
  clang/test/PCH/objcxx-ivar-class.mm

Index: clang/test/PCH/objcxx-ivar-class.mm
===
--- clang/test/PCH/objcxx-ivar-class.mm
+++ clang/test/PCH/objcxx-ivar-class.mm
@@ -1,3 +1,4 @@
+// UNSUPPORTED: -zos, -aix
 // Test this without pch.
 // RUN: %clang_cc1 -include %S/objcxx-ivar-class.h -triple %itanium_abi_triple %s -emit-llvm -o - | FileCheck %s
 
Index: clang/test/PCH/objc_literals.mm
===
--- clang/test/PCH/objc_literals.mm
+++ clang/test/PCH/objc_literals.mm
@@ -1,3 +1,4 @@
+// UNSUPPORTED: -zos, -aix
 // RUN: %clang_cc1 -triple %itanium_abi_triple -emit-pch -x objective-c++ -std=c++0x -o %t %s
 // RUN: %clang_cc1 -triple %itanium_abi_triple -include-pch %t -x objective-c++ -std=c++0x -verify %s
 // RUN: %clang_cc1 -triple %itanium_abi_triple -include-pch %t -x objective-c++ -std=c++0x -ast-print %s | FileCheck -check-prefix=CHECK-PRINT %s
Index: clang/test/PCH/objc_literals.m
===
--- clang/test/PCH/objc_literals.m
+++ clang/test/PCH/objc_literals.m
@@ -1,3 +1,4 @@
+// UNSUPPORTED: -zos, -aix
 // RUN: %clang_cc1 -emit-pch -o %t %s
 // RUN: %clang_cc1 -include-pch %t -verify %s
 // RUN: %clang_cc1 -include-pch %t -ast-print %s | FileCheck -check-prefix=CHECK-PRINT %s
Index: clang/test/PCH/objc_container.m
===
--- clang/test/PCH/objc_container.m
+++ clang/test/PCH/objc_container.m
@@ -1,3 +1,4 @@
+// UNSUPPORTED: -zos, -aix
 // Test this without pch.
 // RUN: %clang_cc1 -include %S/objc_container.h -fsyntax-only -verify %s
 
Index: clang/test/PCH/irgen-rdar13114142.mm
===
--- clang/test/PCH/irgen-rdar13114142.mm
+++ clang/test/PCH/irgen-rdar13114142.mm
@@ -1,3 +1,4 @@
+// UNSUPPORTED: -zos, -aix
 // RUN: %clang_cc1 %s -triple %itanium_abi_triple -emit-pch -o %t.pch
 // RUN: %clang_cc1 %s -triple %itanium_abi_triple -emit-llvm -include-pch %t.pch -o - | FileCheck %s
 
Index: clang/test/Modules/use-exportas-for-link.m
===
--- clang/test/Modules/use-exportas-for-link.m
+++ clang/test/Modules/use-exportas-for-link.m
@@ -1,3 +1,4 @@
+// UNSUPPORTED: -zos, -aix
 // RUN: rm -rf %t
 // RUN: %clang_cc1 -emit-llvm -o - -fmodules-cache-path=%t -DA -fmodules -fimplicit-module-maps -F %S/Inputs/exportas-link %s | FileCheck --check-prefix=CHECK_A %s
 // CHECK_A: !llvm.linker.options = !{![[MODULE:[0-9]+]]}
Index: clang/test/Modules/pch-used.m
===
--- clang/test/Modules/pch-used.m
+++ clang/test/Modules/pch-used.m
@@ -1,3 +1,4 @@
+// UNSUPPORTED: -zos, -aix
 // RUN: rm -rf %t
 // RUN: mkdir %t
 // RUN: %clang_cc1 -x objective-c-header -emit-pch %S/Inputs/pch-used.h -o %t/pch-used.h.pch -fmodules -fimplicit-module-maps -fmodules-cache-path=%t/cache -O0 -isystem %S/Inputs/System/usr/include
Index: clang/test/Modules/objc-initializer.m
===
--- clang/test/Modules/objc-initializer.m
+++ clang/test/Modules/objc-initializer.m
@@ -1,3 +1,4 @@
+// UNSUPPORTED: -zos, -aix
 // RUN: rm -rf %t
 // RUN: %clang_cc1 -fmodules-cache-path=%t -fmodules 

[PATCH] D106809: [clang-offload-bundler] Make Bundle Entry ID backward compatible

2021-09-07 Thread Saiyedul Islam via Phabricator via cfe-commits
saiislam updated this revision to Diff 371133.
saiislam marked 2 inline comments as done.
saiislam added a comment.

1. Added tests for empty and incompatible archives.
2. Improved identification of GPUArch in Bundle Entry ID using CudaArch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106809

Files:
  clang/docs/ClangOffloadBundler.rst
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/clang-offload-bundler.c
  clang/test/Driver/hip-rdc-device-only.hip
  clang/test/Driver/hip-toolchain-rdc-separate.hip
  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
@@ -14,6 +14,7 @@
 ///
 //===--===//
 
+#include "clang/Basic/Cuda.h"
 #include "clang/Basic/Version.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/SmallString.h"
@@ -134,21 +135,28 @@
 ///  * Offload Kind - Host, OpenMP, or HIP
 ///  * Triple - Standard LLVM Triple
 ///  * GPUArch (Optional) - Processor name, like gfx906 or sm_30
-/// In presence of Proc, the Triple should contain separator "-" for all
-/// standard four components, even if they are empty.
+
 struct OffloadTargetInfo {
   StringRef OffloadKind;
   llvm::Triple Triple;
   StringRef GPUArch;
 
   OffloadTargetInfo(const StringRef Target) {
-SmallVector Components;
-Target.split(Components, '-', 5);
-Components.resize(6);
-this->OffloadKind = Components[0];
-this->Triple = llvm::Triple(Components[1], Components[2], Components[3],
-Components[4]);
-this->GPUArch = Components[5];
+auto TargetFeatures = Target.split(':');
+auto TripleOrGPU = TargetFeatures.first.rsplit('-');
+
+if (clang::StringToCudaArch(TripleOrGPU.second) !=
+clang::CudaArch::UNKNOWN) {
+  auto KindTriple = TripleOrGPU.first.split('-');
+  this->OffloadKind = KindTriple.first;
+  this->Triple = llvm::Triple(KindTriple.second);
+  this->GPUArch = Target.substr(Target.find(TripleOrGPU.second));
+} else {
+  auto KindTriple = TargetFeatures.first.split('-');
+  this->OffloadKind = KindTriple.first;
+  this->Triple = llvm::Triple(KindTriple.second);
+  this->GPUArch = "";
+}
   }
 
   bool hasHostKind() const { return this->OffloadKind == "host"; }
@@ -1063,9 +1071,10 @@
 
   // Compatible in case of exact match.
   if (CodeObjectInfo == TargetInfo) {
-DEBUG_WITH_TYPE(
-"CodeObjectCompatibility",
-dbgs() << "Compatible: Exact match: " << CodeObjectInfo.str() << "\n");
+DEBUG_WITH_TYPE("CodeObjectCompatibility",
+dbgs() << "Compatible: Exact match: \t[CodeObject: "
+   << CodeObjectInfo.str()
+   << "]\t:\t[Target: " << TargetInfo.str() << "]\n");
 return true;
   }
 
@@ -1276,9 +1285,19 @@
 } else if (!AllowMissingBundles) {
   std::string ErrMsg =
   Twine("no compatible code object found for the target '" + Target +
-"' in heterogenous archive library: " + IFName)
+"' in heterogeneous archive library: " + IFName)
   .str();
   return createStringError(inconvertibleErrorCode(), ErrMsg);
+} else { // Create an empty archive file if no compatible code object is
+ // found and "allow-missing-bundles" is enabled. It ensures that
+ // the linker using output of this step doesn't complain about
+ // the missing input file.
+  std::vector EmptyArchive;
+  EmptyArchive.clear();
+  if (Error WriteErr = writeArchive(FileName, EmptyArchive, true,
+getDefaultArchiveKindForHost(), true,
+false, nullptr))
+return WriteErr;
 }
   }
 
Index: clang/test/Driver/hip-toolchain-rdc-separate.hip
===
--- clang/test/Driver/hip-toolchain-rdc-separate.hip
+++ clang/test/Driver/hip-toolchain-rdc-separate.hip
@@ -44,7 +44,7 @@
 // CHECK-SAME: {{.*}} [[A_SRC]]
 
 // CHECK: [[BUNDLER:".*clang-offload-bundler"]] "-type=o"
-// CHECK-SAME: "-targets=hip-amdgcn-amd-amdhsa--gfx803,hip-amdgcn-amd-amdhsa--gfx900,host-x86_64-unknown-linux-gnu"
+// CHECK-SAME: "-targets=hip-amdgcn-amd-amdhsa-gfx803,hip-amdgcn-amd-amdhsa-gfx900,host-x86_64-unknown-linux-gnu"
 // CHECK-SAME: "-outputs=[[A_O:.*a.o]]" "-inputs=[[A_BC1]],[[A_BC2]],[[A_OBJ_HOST]]"
 
 // CHECK: [[CLANG]] "-cc1" "-triple" "amdgcn-amd-amdhsa"
@@ -79,7 +79,7 @@
 // CHECK-SAME: {{.*}} [[B_SRC]]
 
 // CHECK: [[BUNDLER:".*clang-offload-bundler"]] "-type=o"
-// CHECK-SAME: 

[PATCH] D109372: [RISCV][RFC] Add Clang support for RISC-V overlay system

2021-09-07 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/include/clang/Basic/Attr.td:1793-1795
+// This is not marked as a TargetSpecificAttr because that would trigger
+// an 'attribute ignored' warning, but we want to check it explicitly and
+// trigger an error.

This is not typical attribute behavior -- if the target architecture doesn't 
support the attribute, are the semantics such that an error is 
appropriate/required? Put another way, why do we want to trigger an error for 
this attribute while not triggering errors for other target-specific attributes 
(like calling conventions)?



Comment at: clang/include/clang/Basic/Attr.td:1797
+def RISCVOverlayCall : InheritableAttr {
+  let Spellings = [GCC<"overlaycall">];
+  let Subjects = SubjectList<[Function]>;

Does GCC support this attribute? If not, this should be using the `Clang` 
spelling (same below).

Also, `overlaycall` is pretty hard to read; why not `overlay_call` and 
`overlay_data`?



Comment at: clang/include/clang/Basic/Attr.td:1798
+  let Spellings = [GCC<"overlaycall">];
+  let Subjects = SubjectList<[Function]>;
+  let LangOpts = [RISCVOverlayFunctions];

What about Objective-C methods?



Comment at: clang/include/clang/Basic/DiagnosticDriverKinds.td:36
+def err_drv_invalid_riscv_abi_fcomrv : Error<
+  "invalid ABI '%0' when using -fcomrv">;
 def warn_drv_avr_mcu_not_specified : Warning<





Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:314
+  "RISC-V 'overlaycall' attribute requires support to be enabled with "
+  "the -fcomrv option">;
+def err_overlaycall_static : Error<





Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:321
+  "RISC-V 'overlaydata' attribute requires support to be enabled with "
+  "the -fcomrv option">;
 def warn_unused_parameter : Warning<"unused parameter %0">,





Comment at: clang/lib/Driver/ToolChains/Arch/RISCV.cpp:496
+  // Handle features corresponding to custom language feature
+  // "RISCVOverlayFunctions"
+  if (Args.hasArg(options::OPT_fcomrv)) {





Comment at: clang/lib/Driver/ToolChains/Clang.cpp:2100
+  // If comrv mode is requested, pass on this flag, and produce an error if an
+  // invalid ABI has been requested
+  if (Args.getLastArg(options::OPT_fcomrv)) {





Comment at: clang/lib/Frontend/CompilerInvocation.cpp:4066
 
+  // RISC-V overlay functions support
+  Opts.RISCVOverlayFunctions = Args.hasArg(OPT_fcomrv);





Comment at: clang/lib/Frontend/CompilerInvocation.cpp:4461
 
+  // RISC-V overlay functions support
+  LangOpts.RISCVOverlayFunctions = Args.hasArg(OPT_fcomrv);





Comment at: clang/lib/Sema/SemaDecl.cpp:3365
+Diag(New->getLocation(), diag::err_overlaycall_mismatch)
+  << New << OldIsOverlayCall;
+notePreviousDefinition(Old, New->getLocation());

You should fix this formatting nit.



Comment at: clang/lib/Sema/SemaDeclAttr.cpp:2043-2047
+  if (!isFunctionOrMethod(D)) {
+S.Diag(D->getLocation(), diag::warn_attribute_wrong_decl_type)
+<< AL << ExpectedFunctionOrMethod;
+return;
+  }

This shouldn't be necessary, the automated checking should handle it 
automatically.



Comment at: clang/lib/Sema/SemaDeclAttr.cpp:2056-2058
+  // overlaycall implies noinline
+  Attr *A = ::new(S.Context) NoInlineAttr(S.Context, AL);
+  A->setImplicit(true);

Please use `NoInlineAttr::CreateImplicit()` instead.



Comment at: clang/lib/Sema/SemaDeclAttr.cpp:8512-8517
+if (!S.getLangOpts().RISCVOverlayFunctions) {
+  AL.setInvalid();
+  S.Diag(AL.getLoc(), diag::err_overlaydata_unsupported);
+  break;
+}
+D->addAttr(::new (S.Context) RISCVOverlayDataAttr(S.Context, AL));

Please write a `handle` function for this as with all the other attributes (we 
have hopes to someday do more tablegen in this area, so sticking with the same 
pattern in this `switch` is strongly preferred).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109372

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


[PATCH] D109372: [RISCV][RFC] Add Clang support for RISC-V overlay system

2021-09-07 Thread Jessica Clarke via Phabricator via cfe-commits
jrtc27 added a comment.

In D109372#2987405 , @MaskRay wrote:

> The name "overlay" is ambiguous. Even after I ruled out Gentoo Overlay and 
> overlayfs, I am thinking whether this has anything to do with `OVERLAY` 
> description in a linker script: 
> https://sourceware.org/binutils/docs/ld/Overlay-Description.html#Overlay-Description
>
>> which are used to mark functions or global data as only accessible through 
>> the overlay engine
>
> Can you give more descriptions for folks who don't follow the RISC-V side 
> proposal but need to review your changes? :)

Basically hardware-assisted code+rodata banking (I guess either by actually 
banking ROMs or just paging stuff in and out) that's mostly transparent to 
software. Functions at the boundary of components (don't know what the 
granularity is) use a weird indirect calling convention where you instead call 
into some magic runtime with a unique ID for the callee, it ensures 
everything's loaded and then tail calls it for you.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109372

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


[PATCH] D102531: PR45881: Properly use CXXThisOverride for templated lambda

2021-09-07 Thread Gulfem Savrun Yeniceri via Phabricator via cfe-commits
gulfem added a comment.

> I'll commit this by the end of the day if @rsmith wasn't able to take a look.

Sounds good, thank you very much!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102531

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


[PATCH] D109372: [RISCV][RFC] Add Clang support for RISC-V overlay system

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

The name "overlay" is ambiguous. Even after I ruled out Gentoo Overlay and 
overlayfs, I am thinking whether this has anything to do with `OVERLAY` 
description in a linker script: 
https://sourceware.org/binutils/docs/ld/Overlay-Description.html#Overlay-Description

> which are used to mark functions or global data as only accessible through 
> the overlay engine

Can you give more descriptions for folks who don't follow the RISC-V side 
proposal but need to review your changes? :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109372

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


[PATCH] D109372: [RISCV][RFC] Add Clang support for RISC-V overlay system

2021-09-07 Thread Jessica Clarke via Phabricator via cfe-commits
jrtc27 added a comment.

I don't see anything giving an error if you try and use the new badly-named 
option for an architecture other than RISC-V (beyond the usual unused argument 
warning that's only an error with -Werror)?




Comment at: clang/include/clang/Basic/Attr.td:348
+// Language option for Overlay functions
+def RISCVOverlayFunctions : LangOpt<"RISCVOverlayFunctions">;
+

I thought the idea for this proposal was to come up with something that wasn't 
RISC-V specific (an architecture-independent specification and a 
RISC-V-specific supplement for how that is mapped to RISC-V) to get industry 
buy-in?



Comment at: clang/include/clang/Basic/Attr.td:1796
+// trigger an error.
+def RISCVOverlayCall : InheritableAttr {
+  let Spellings = [GCC<"overlaycall">];

If you want this to be portable to non-GNU compilers you should consider using 
a keyword instead (which can still map to an attribute internally). That also 
tends to get you better errors (there are places where type attributes can get 
silently ignored currently).



Comment at: clang/include/clang/Basic/AttrDocs.td:2149
+  let Content = [{
+``__attribute__((overlaycall))`` indicates that a function resides in an
+overlay and therefore any calls to or from that function must be handled

Why not just a single attribute that DTRT based on the type?



Comment at: clang/include/clang/Driver/Options.td:3232
   HelpText<"Enable use of experimental RISC-V extensions.">;
+def fcomrv : Flag<["-"], "fcomrv">, Group,
+  Flags<[CC1Option]>,

What on earth is this name?



Comment at: clang/test/CodeGen/riscv-overlaycall.c:1
+// RUN: %clang_cc1 %s -triple=riscv64 -fcomrv -emit-llvm -o - \
+// RUN:| FileCheck %s

Use update_cc_test_checks.py



Comment at: clang/test/Driver/riscv-comrv.c:3
+//
+// REQUIRES: riscv-registered-target
+//

Don't write a driver test that requires the backend, you don't need that to 
test this



Comment at: clang/test/Sema/riscv-overlaycall-namespace.cpp:7
+public:
+  static int X() __attribute__((overlaycall)) { return 0; } // expected-error 
{{RISC-V 'overlaycall' attribute not supported on static functions}}
+};

This error message is misleading. The semantics also don't seem great to me.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109372

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


[PATCH] D102531: PR45881: Properly use CXXThisOverride for templated lambda

2021-09-07 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added a comment.

In D102531#2987367 , @gulfem wrote:

> Any update on this review? Our builds are still broken.

I'll commit this by the end of the day if @rsmith wasn't able to take a look.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102531

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


[PATCH] D102531: PR45881: Properly use CXXThisOverride for templated lambda

2021-09-07 Thread Gulfem Savrun Yeniceri via Phabricator via cfe-commits
gulfem added a comment.

Any update on this review? Our builds are still broken.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102531

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


[PATCH] D109372: [RISCV][RFC] Add Clang support for RISC-V overlay system

2021-09-07 Thread Edward Jones via Phabricator via cfe-commits
edward-jones created this revision.
Herald added subscribers: vkmr, frasercrmck, dexonsmith, dang, jdoerfert, 
evandro, luismarques, apazos, sameer.abuasal, simoncook, s.egerton, Jim, benna, 
psnobl, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, zzheng, 
jrtc27, shiva0217, kito-cheng, niosHD, sabuasal, johnrusso, rbar, asb.
Herald added a reviewer: aaron.ballman.
edward-jones requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay.
Herald added a project: clang.

This is the Clang component of a change to add support for a proposed 'overlay' 
system for RISC-V to LLVM.

This adds two new attributes, __attribute__((overlaydata)), and 
__attribute__((overlaycall)), which are used to mark functions or global data 
as only accessible through the overlay engine. Internally they are converted to 
'overlay-data' and 'overlay-call' attributes in LLVM IR.

This change also adds the option `-fcomrv` to enable use of the overlay system. 
This has the effect of reserving registers x28, x29, x30 and x31 for exclusive 
used by the overlay engine.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D109372

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/AST/TypePrinter.cpp
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Driver/ToolChains/Arch/RISCV.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/lib/Driver/ToolChains/RISCVToolchain.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/CodeGen/riscv-overlaycall.c
  clang/test/Driver/riscv-comrv.c
  clang/test/Misc/pragma-attribute-supported-attributes-list.test
  clang/test/Sema/attr-overlaycall.c
  clang/test/Sema/riscv-overlaycall-namespace.cpp

Index: clang/test/Sema/riscv-overlaycall-namespace.cpp
===
--- /dev/null
+++ clang/test/Sema/riscv-overlaycall-namespace.cpp
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 %s -triple riscv32-unknown-elf -verify -fsyntax-only -fcomrv
+// RUN: %clang_cc1 %s -triple riscv64-unknown-elf -verify -fsyntax-only -fcomrv
+
+namespace {
+class foo {
+public:
+  static int X() __attribute__((overlaycall)) { return 0; } // expected-error {{RISC-V 'overlaycall' attribute not supported on static functions}}
+};
+} // end of anonymous namespace
+
+namespace X {
+  class bar {
+  public:
+static int X() __attribute__((overlaycall)) { return 1; }
+  };
+} // end of namespace X
+
+extern "C" {
+int main(void) { return foo::X() + X::bar::X(); }
+}
Index: clang/test/Sema/attr-overlaycall.c
===
--- /dev/null
+++ clang/test/Sema/attr-overlaycall.c
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -triple riscv32 -fcomrv -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple riscv64 -fcomrv -fsyntax-only -verify %s
+
+int notAFunction __attribute__((overlaycall));
+// expected-warning@-1 {{'overlaycall' attribute only applies to functions}}
+
+void incompatForwardDecl(int x);
+void __attribute__((overlaycall)) incompatForwardDecl(int x) {}
+// expected-error@-1 {{redeclaration of 'incompatForwardDecl' must not have the RISC-V 'overlaycall' attribute}}
+// expected-note@-3 {{previous definition is here}}
+
+static void staticcall() __attribute__((overlaycall)) {}
+// expected-error@-1 {{attribute not supported on static functions}}
+// expected-warning@-2 {{GCC does not allow 'overlaycall' attribute in this position on a function definition}}
+
+static void __attribute__((overlaycall)) staticcall2(){}
+// expected-error@-1 {{attribute not supported on static functions}}
Index: clang/test/Misc/pragma-attribute-supported-attributes-list.test
===
--- clang/test/Misc/pragma-attribute-supported-attributes-list.test
+++ clang/test/Misc/pragma-attribute-supported-attributes-list.test
@@ -147,6 +147,7 @@
 // CHECK-NEXT: PassObjectSize (SubjectMatchRule_variable_is_parameter)
 // CHECK-NEXT: PatchableFunctionEntry (SubjectMatchRule_function, SubjectMatchRule_objc_method)
 // CHECK-NEXT: Pointer (SubjectMatchRule_record_not_is_union)
+// CHECK-NEXT: RISCVOverlayCall (SubjectMatchRule_function)
 // CHECK-NEXT: ReleaseHandle (SubjectMatchRule_variable_is_parameter)
 // CHECK-NEXT: RenderScriptKernel (SubjectMatchRule_function)
 // CHECK-NEXT: ReqdWorkGroupSize (SubjectMatchRule_function)
Index: clang/test/Driver/riscv-comrv.c
===
--- /dev/null
+++ clang/test/Driver/riscv-comrv.c
@@ -0,0 +1,8 @@
+// Check ComRV Driver Arguments
+//
+// REQUIRES: riscv-registered-target
+//
+// RUN: %clang -target 

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

2021-09-07 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan accepted this revision.
abhina.sreeskantharajan added a comment.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109362

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


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

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

LGTM. Thanks for the documentation update.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109362

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


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

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

- Condensed the lit test a bit.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109362

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

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

[PATCH] D109345: MemoryBuffer: Migrate to Expected/llvm::Error from ErrorOr/std::error_code

2021-09-07 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

In D109345#2986297 , @thopre wrote:

> Is there no way to split this patch further? It's going to be hard finding 
> someone who can review something so big. If there's no way to split it in 
> incremental changes, you could perhaps split per subsystem only for review 
> and refer to this diff for CI as well as when landing.

The long migration path would be to do this one function at. time (I did a 
whole cluster of functions in MemoryBuffer for consistency - this does reduce 
total code changes somewhat, since some of those APIs are used in similar 
contexts (eg: branches of a conditional operator - so having them differ means 
more revisions to those call sites)) and probably introducing separate names 
for the Expected versions of the functions, migrating call sites incrementally, 
then doing a mechanical rename at the end of all that.

I don't think it's probably worth that level of granularity - it's a fairly 
mechanical patch as it is.

Mostly I sent this out as an FYI and to get feedback on the general direction - 
whether folks thought it was worth doing at all, and if they feel strongly it 
should be done another way (like the incremental ones above) - but I don't 
think it needs a /huge/ amount of scrutiny, review by separate code owners, 
etc. I'd generally be comfortable committing this as other cross-project 
cleanup/refactoring like function renaming, etc.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109345

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


[PATCH] D108556: [clangd] Don't highlight ObjC `id` and `instancetype`

2021-09-07 Thread David Goldman via Phabricator via cfe-commits
dgoldman marked 2 inline comments as done.
dgoldman added inline comments.



Comment at: clang-tools-extra/clangd/FindTarget.cpp:188
 if (const TypedefNameDecl *TND = dyn_cast(D)) {
+  if (shouldSkipTypedef(TND))
+return;

kadircet wrote:
> why do we need this despite bailing out in the visitor?
Removed, not necessary


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108556

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


[PATCH] D108556: [clangd] Don't highlight ObjC `id` and `instancetype`

2021-09-07 Thread David Goldman via Phabricator via cfe-commits
dgoldman updated this revision to Diff 371103.
dgoldman added a comment.

Update comment + remove un-needed code


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108556

Files:
  clang-tools-extra/clangd/FindTarget.cpp
  clang-tools-extra/clangd/unittests/FindTargetTests.cpp
  clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp


Index: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
===
--- clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
+++ clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
@@ -661,13 +661,15 @@
 @interface $Class_decl[[Foo]]
 @end
 @interface $Class_decl[[Bar]] : $Class[[Foo]]
--($Class[[id]]) $Method_decl[[x]]:(int)$Parameter_decl[[a]] 
$Method_decl[[y]]:(int)$Parameter_decl[[b]];
+-(id) $Method_decl[[x]]:(int)$Parameter_decl[[a]] 
$Method_decl[[y]]:(int)$Parameter_decl[[b]];
++(instancetype)$StaticMethod_decl_static[[sharedInstance]];
 +(void) $StaticMethod_decl_static[[explode]];
 @end
 @implementation $Class_decl[[Bar]]
--($Class[[id]]) $Method_decl[[x]]:(int)$Parameter_decl[[a]] 
$Method_decl[[y]]:(int)$Parameter_decl[[b]] {
+-(id) $Method_decl[[x]]:(int)$Parameter_decl[[a]] 
$Method_decl[[y]]:(int)$Parameter_decl[[b]] {
   return self;
 }
++(instancetype)$StaticMethod_decl_static[[sharedInstance]] { return 0; 
}
 +(void) $StaticMethod_decl_static[[explode]] {}
 @end
 
Index: clang-tools-extra/clangd/unittests/FindTargetTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -995,6 +995,20 @@
 }
   )cpp";
   EXPECT_DECLS("ObjCPropertyRefExpr", "+ (id)sharedInstance");
+
+  Code = R"cpp(
+@interface Foo
++ ([[id]])sharedInstance;
+@end
+  )cpp";
+  EXPECT_DECLS("TypedefTypeLoc");
+
+  Code = R"cpp(
+@interface Foo
++ ([[instancetype]])sharedInstance;
+@end
+  )cpp";
+  EXPECT_DECLS("TypedefTypeLoc");
 }
 
 class FindExplicitReferencesTest : public ::testing::Test {
Index: clang-tools-extra/clangd/FindTarget.cpp
===
--- clang-tools-extra/clangd/FindTarget.cpp
+++ clang-tools-extra/clangd/FindTarget.cpp
@@ -94,6 +94,16 @@
   return nullptr;
 }
 
+// Returns true if the `TypedefNameDecl` should not be reported.
+bool shouldSkipTypedef(const TypedefNameDecl *TD) {
+  // These should be treated as keywords rather than decls - the typedef is an
+  // odd implementation detail.
+  if (TD == TD->getASTContext().getObjCInstanceTypeDecl() ||
+  TD == TD->getASTContext().getObjCIdDecl())
+return true;
+  return false;
+}
+
 // TargetFinder locates the entities that an AST node refers to.
 //
 // Typically this is (possibly) one declaration and (possibly) one type, but
@@ -395,6 +405,8 @@
 }
   }
   void VisitTypedefType(const TypedefType *TT) {
+if (shouldSkipTypedef(TT->getDecl()))
+  return;
 Outer.add(TT->getDecl(), Flags);
   }
   void
@@ -903,6 +915,8 @@
 }
 
 void VisitTypedefTypeLoc(TypedefTypeLoc L) {
+  if (shouldSkipTypedef(L.getTypedefNameDecl()))
+return;
   Refs.push_back(ReferenceLoc{NestedNameSpecifierLoc(),
   L.getNameLoc(),
   /*IsDecl=*/false,


Index: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
===
--- clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
+++ clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
@@ -661,13 +661,15 @@
 @interface $Class_decl[[Foo]]
 @end
 @interface $Class_decl[[Bar]] : $Class[[Foo]]
--($Class[[id]]) $Method_decl[[x]]:(int)$Parameter_decl[[a]] $Method_decl[[y]]:(int)$Parameter_decl[[b]];
+-(id) $Method_decl[[x]]:(int)$Parameter_decl[[a]] $Method_decl[[y]]:(int)$Parameter_decl[[b]];
++(instancetype)$StaticMethod_decl_static[[sharedInstance]];
 +(void) $StaticMethod_decl_static[[explode]];
 @end
 @implementation $Class_decl[[Bar]]
--($Class[[id]]) $Method_decl[[x]]:(int)$Parameter_decl[[a]] $Method_decl[[y]]:(int)$Parameter_decl[[b]] {
+-(id) $Method_decl[[x]]:(int)$Parameter_decl[[a]] $Method_decl[[y]]:(int)$Parameter_decl[[b]] {
   return self;
 }
++(instancetype)$StaticMethod_decl_static[[sharedInstance]] { return 0; }
 +(void) $StaticMethod_decl_static[[explode]] {}
 @end
 
Index: clang-tools-extra/clangd/unittests/FindTargetTests.cpp
===
--- 

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

2021-09-07 Thread Sjoerd Meijer via Phabricator via cfe-commits
SjoerdMeijer added a comment.

The driver part looks good to me. I will let Oli do the approval as he also 
looked at the codegen (and I didn't).




Comment at: clang/include/clang/Driver/Options.td:3274
+  Group,
+  HelpText<"Work around VLLDM erratum CVE-2021-35465 (Arm only)">;
+def mno_fix_cmse_cve_2021_35465 : Flag<["-"], "mno-fix-cmse-cve-2021-35465">,

Nit: I think `Arm` -> `ARM` is better as we we're talking about the ARM backend 
here.


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

https://reviews.llvm.org/D109157

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


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

2021-09-07 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

In D109175#2986782 , @yaxunl wrote:

> I agree with Johannes and Alexey that deferred diags are only needed when 
> LangOpts.OMPTargetTriples.empty(). However, I am not sure whether it is only 
> needed in device compilation.
>
> For other offloading languages like CUDA/HIP it is needed in both device and 
> host compilation.

Technically, we might even want to delay in host only mode for OpenMP, but that 
is something we can revisit (e.g., by dynamically setting a flag based on the 
directives we've seen).
@yaxunl Should we for now check if there is any associated offload job?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109175

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


[PATCH] D109370: [OpenCL] Enables .rgba vector extension in C++ for OpenCL 2021

2021-09-07 Thread Justas Janickas via Phabricator via cfe-commits
Topotuna created this revision.
Topotuna added a reviewer: Anastasia.
Herald added subscribers: ldrumm, yaxunl.
Topotuna requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

`.rgba` vector extension setting in C++ for OpenCL 2021 is now
performed analogously to OpenCL C 3.0. Test case added.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D109370

Files:
  clang/lib/Sema/SemaExprMember.cpp
  clang/test/SemaOpenCL/ext_vectors.cl


Index: clang/test/SemaOpenCL/ext_vectors.cl
===
--- clang/test/SemaOpenCL/ext_vectors.cl
+++ clang/test/SemaOpenCL/ext_vectors.cl
@@ -2,6 +2,7 @@
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL2.0
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL3.0
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=clc++1.0
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=clc++2021
 
 typedef float float4 __attribute__((ext_vector_type(4)));
 
@@ -9,13 +10,13 @@
   V = V.wzyx;
 
   V = V.abgr;
-#if (__OPENCL_C_VERSION__ < 300)
+#if ((defined(__OPENCL_C_VERSION__) && __OPENCL_C_VERSION__ < 300) || 
(defined(__OPENCL_CPP_VERSION__) && __OPENCL_CPP_VERSION__ < 202100))
   // expected-warning@-2 {{vector component name 'a' is a feature from OpenCL 
version 3.0 onwards}}
 #endif
 
   V = V.xyzr;
   // expected-error@-1 {{illegal vector component name 'r'}}
-#if (__OPENCL_C_VERSION__ < 300)
+#if ((defined(__OPENCL_C_VERSION__) && __OPENCL_C_VERSION__ < 300) || 
(defined(__OPENCL_CPP_VERSION__) && __OPENCL_CPP_VERSION__ < 202100))
   // expected-warning@-3 {{vector component name 'r' is a feature from OpenCL 
version 3.0 onwards}}
 #endif
 }
Index: clang/lib/Sema/SemaExprMember.cpp
===
--- clang/lib/Sema/SemaExprMember.cpp
+++ clang/lib/Sema/SemaExprMember.cpp
@@ -340,7 +340,8 @@
 
 // Emit a warning if an rgba selector is used earlier than OpenCL C 3.0.
 if (HasRGBA || (*compStr && IsRGBA(*compStr))) {
-  if (S.getLangOpts().OpenCL && S.getLangOpts().OpenCLVersion < 300) {
+  if (S.getLangOpts().OpenCL &&
+  S.getLangOpts().getOpenCLCompatibleVersion() < 300) {
 const char *DiagBegin = HasRGBA ? CompName->getNameStart() : compStr;
 S.Diag(OpLoc, diag::ext_opencl_ext_vector_type_rgba_selector)
 << StringRef(DiagBegin, 1) << SourceRange(CompLoc);


Index: clang/test/SemaOpenCL/ext_vectors.cl
===
--- clang/test/SemaOpenCL/ext_vectors.cl
+++ clang/test/SemaOpenCL/ext_vectors.cl
@@ -2,6 +2,7 @@
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL2.0
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL3.0
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=clc++1.0
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=clc++2021
 
 typedef float float4 __attribute__((ext_vector_type(4)));
 
@@ -9,13 +10,13 @@
   V = V.wzyx;
 
   V = V.abgr;
-#if (__OPENCL_C_VERSION__ < 300)
+#if ((defined(__OPENCL_C_VERSION__) && __OPENCL_C_VERSION__ < 300) || (defined(__OPENCL_CPP_VERSION__) && __OPENCL_CPP_VERSION__ < 202100))
   // expected-warning@-2 {{vector component name 'a' is a feature from OpenCL version 3.0 onwards}}
 #endif
 
   V = V.xyzr;
   // expected-error@-1 {{illegal vector component name 'r'}}
-#if (__OPENCL_C_VERSION__ < 300)
+#if ((defined(__OPENCL_C_VERSION__) && __OPENCL_C_VERSION__ < 300) || (defined(__OPENCL_CPP_VERSION__) && __OPENCL_CPP_VERSION__ < 202100))
   // expected-warning@-3 {{vector component name 'r' is a feature from OpenCL version 3.0 onwards}}
 #endif
 }
Index: clang/lib/Sema/SemaExprMember.cpp
===
--- clang/lib/Sema/SemaExprMember.cpp
+++ clang/lib/Sema/SemaExprMember.cpp
@@ -340,7 +340,8 @@
 
 // Emit a warning if an rgba selector is used earlier than OpenCL C 3.0.
 if (HasRGBA || (*compStr && IsRGBA(*compStr))) {
-  if (S.getLangOpts().OpenCL && S.getLangOpts().OpenCLVersion < 300) {
+  if (S.getLangOpts().OpenCL &&
+  S.getLangOpts().getOpenCLCompatibleVersion() < 300) {
 const char *DiagBegin = HasRGBA ? CompName->getNameStart() : compStr;
 S.Diag(OpLoc, diag::ext_opencl_ext_vector_type_rgba_selector)
 << StringRef(DiagBegin, 1) << SourceRange(CompLoc);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D108302: [PowerPC] Fixed the crash due to early if conversion with fixed CR fields.

2021-09-07 Thread Victor Huang 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 rG4a226529e2cf: [PowerPC] Fixed the crash due to early if 
conversion with fixed CR fields (authored by NeHuang).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108302

Files:
  llvm/lib/Target/PowerPC/PPCInstrInfo.cpp
  llvm/test/CodeGen/PowerPC/ifcvt_cr_field.ll


Index: llvm/test/CodeGen/PowerPC/ifcvt_cr_field.ll
===
--- /dev/null
+++ llvm/test/CodeGen/PowerPC/ifcvt_cr_field.ll
@@ -0,0 +1,64 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc < %s -mtriple=powerpc64-unknown-linux-gnu -mcpu=pwr9 
-verify-machineinstrs | FileCheck %s
+; RUN: llc < %s -mtriple=powerpc64le-unknown-linux-gnu -mcpu=pwr9 
-verify-machineinstrs | FileCheck %s
+; RUN: llc < %s -mtriple=powerpc64-unknown-aix -mcpu=pwr9 
-verify-machineinstrs | FileCheck %s --check-prefix=CHECK-AIX-64
+; RUN: llc < %s -mtriple=powerpc-unknown-aix -mcpu=pwr9 -verify-machineinstrs 
| FileCheck %s --check-prefix=CHECK-AIX-32
+
+define dso_local signext i32 @test(<4 x i32> %a, <4 x i32> %b, <4 x i32> %c) 
local_unnamed_addr {
+; CHECK-LABEL: test:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:vcmpgtsw. 2, 2, 3
+; CHECK-NEXT:bge 6, .LBB0_2
+; CHECK-NEXT:  # %bb.1: # %land.rhs
+; CHECK-NEXT:vcmpgtsw. 2, 4, 3
+; CHECK-NEXT:mfocrf 3, 2
+; CHECK-NEXT:rlwinm 3, 3, 25, 31, 31
+; CHECK-NEXT:clrldi 3, 3, 32
+; CHECK-NEXT:blr
+; CHECK-NEXT:  .LBB0_2:
+; CHECK-NEXT:li 3, 0
+; CHECK-NEXT:blr
+;
+; CHECK-AIX-64-LABEL: test:
+; CHECK-AIX-64:   # %bb.0: # %entry
+; CHECK-AIX-64-NEXT:vcmpgtsw. 2, 2, 3
+; CHECK-AIX-64-NEXT:bge 6, L..BB0_2
+; CHECK-AIX-64-NEXT:  # %bb.1: # %land.rhs
+; CHECK-AIX-64-NEXT:vcmpgtsw. 2, 4, 3
+; CHECK-AIX-64-NEXT:mfocrf 3, 2
+; CHECK-AIX-64-NEXT:rlwinm 3, 3, 25, 31, 31
+; CHECK-AIX-64-NEXT:clrldi 3, 3, 32
+; CHECK-AIX-64-NEXT:blr
+; CHECK-AIX-64-NEXT:  L..BB0_2:
+; CHECK-AIX-64-NEXT:li 3, 0
+; CHECK-AIX-64-NEXT:blr
+;
+; CHECK-AIX-32-LABEL: test:
+; CHECK-AIX-32:   # %bb.0: # %entry
+; CHECK-AIX-32-NEXT:vcmpgtsw. 2, 2, 3
+; CHECK-AIX-32-NEXT:bge 6, L..BB0_2
+; CHECK-AIX-32-NEXT:  # %bb.1: # %land.rhs
+; CHECK-AIX-32-NEXT:vcmpgtsw. 2, 4, 3
+; CHECK-AIX-32-NEXT:mfocrf 3, 2
+; CHECK-AIX-32-NEXT:rlwinm 3, 3, 25, 31, 31
+; CHECK-AIX-32-NEXT:blr
+; CHECK-AIX-32-NEXT:  L..BB0_2:
+; CHECK-AIX-32-NEXT:li 3, 0
+; CHECK-AIX-32-NEXT:blr
+entry:
+  %0 = tail call i32 @llvm.ppc.altivec.vcmpgtsw.p(i32 2, <4 x i32> %a, <4 x 
i32> %b)
+  %tobool.not = icmp eq i32 %0, 0
+  br i1 %tobool.not, label %land.end, label %land.rhs
+
+land.rhs: ; preds = %entry
+  %1 = tail call i32 @llvm.ppc.altivec.vcmpgtsw.p(i32 2, <4 x i32> %c, <4 x 
i32> %b)
+  %tobool1 = icmp ne i32 %1, 0
+  %phi.cast = zext i1 %tobool1 to i32
+  br label %land.end
+
+land.end: ; preds = %land.rhs, %entry
+  %2 = phi i32 [ 0, %entry ], [ %phi.cast, %land.rhs ]
+  ret i32 %2
+}
+
+declare i32 @llvm.ppc.altivec.vcmpgtsw.p(i32, <4 x i32>, <4 x i32>)
Index: llvm/lib/Target/PowerPC/PPCInstrInfo.cpp
===
--- llvm/lib/Target/PowerPC/PPCInstrInfo.cpp
+++ llvm/lib/Target/PowerPC/PPCInstrInfo.cpp
@@ -1541,6 +1541,11 @@
   if (Cond[1].getReg() == PPC::CTR || Cond[1].getReg() == PPC::CTR8)
 return false;
 
+  // If the conditional branch uses a physical register, then it cannot be
+  // turned into a select.
+  if (Register::isPhysicalRegister(Cond[1].getReg()))
+return false;
+
   // Check register classes.
   const MachineRegisterInfo  = MBB.getParent()->getRegInfo();
   const TargetRegisterClass *RC =


Index: llvm/test/CodeGen/PowerPC/ifcvt_cr_field.ll
===
--- /dev/null
+++ llvm/test/CodeGen/PowerPC/ifcvt_cr_field.ll
@@ -0,0 +1,64 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc < %s -mtriple=powerpc64-unknown-linux-gnu -mcpu=pwr9 -verify-machineinstrs | FileCheck %s
+; RUN: llc < %s -mtriple=powerpc64le-unknown-linux-gnu -mcpu=pwr9 -verify-machineinstrs | FileCheck %s
+; RUN: llc < %s -mtriple=powerpc64-unknown-aix -mcpu=pwr9 -verify-machineinstrs | FileCheck %s --check-prefix=CHECK-AIX-64
+; RUN: llc < %s -mtriple=powerpc-unknown-aix -mcpu=pwr9 -verify-machineinstrs | FileCheck %s --check-prefix=CHECK-AIX-32
+
+define dso_local signext i32 @test(<4 x i32> %a, <4 x i32> %b, <4 x i32> %c) local_unnamed_addr {
+; CHECK-LABEL: test:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:vcmpgtsw. 2, 2, 3
+; CHECK-NEXT:bge 6, .LBB0_2
+; CHECK-NEXT:  # %bb.1: # %land.rhs
+; CHECK-NEXT:vcmpgtsw. 2, 4, 

[PATCH] D109366: [OpenCL] Tests C++ for OpenCL 2021 version macros

2021-09-07 Thread Justas Janickas via Phabricator via cfe-commits
Topotuna created this revision.
Topotuna added a reviewer: Anastasia.
Herald added subscribers: ldrumm, yaxunl.
Topotuna requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Version macro definitions are tested for C++ for OpenCL 2021.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D109366

Files:
  clang/test/Preprocessor/predefined-macros.c


Index: clang/test/Preprocessor/predefined-macros.c
===
--- clang/test/Preprocessor/predefined-macros.c
+++ clang/test/Preprocessor/predefined-macros.c
@@ -135,8 +135,10 @@
 // RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-CL30
 // RUN: %clang_cc1 %s -E -dM -o - -x cl -cl-fast-relaxed-math \
 // RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-FRM
-// RUN: %clang_cc1 %s -E -dM -o - -x cl -cl-std=clc++ \
+// RUN: %clang_cc1 %s -E -dM -o - -x cl -cl-std=clc++1.0 \
 // RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-CLCPP10
+// RUN: %clang_cc1 %s -E -dM -o - -x cl -cl-std=clc++2021 \
+// RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-CLCPP2021
 // CHECK-CL10: #define CL_VERSION_1_0 100
 // CHECK-CL10: #define CL_VERSION_1_1 110
 // CHECK-CL10: #define CL_VERSION_1_2 120
@@ -174,9 +176,15 @@
 // CHECK-CL30-NOT: #define __FAST_RELAXED_MATH__ 1
 // CHECK-FRM: #define __FAST_RELAXED_MATH__ 1
 // CHECK-CLCPP10: #define __CL_CPP_VERSION_1_0__ 100
+// CHECK-CLCPP10: #define __CL_CPP_VERSION_2021__ 202100
 // CHECK-CLCPP10: #define __OPENCL_CPP_VERSION__ 100
 // CHECK-CLCPP10-NOT: #define __FAST_RELAXED_MATH__ 1
 // CHECK-CLCPP10-NOT: #define __ENDIAN_LITTLE__ 1
+// CHECK-CLCPP2021: #define __CL_CPP_VERSION_1_0__ 100
+// CHECK-CLCPP2021: #define __CL_CPP_VERSION_2021__ 202100
+// CHECK-CLCPP2021: #define __OPENCL_CPP_VERSION__ 202100
+// CHECK-CLCPP2021-NOT: #define __FAST_RELAXED_MATH__ 1
+// CHECK-CLCPP2021-NOT: #define __ENDIAN_LITTLE__ 1
 
 // RUN: %clang_cc1 %s -E -dM -o - -x cl \
 // RUN:   | FileCheck %s --check-prefix=MSCOPE


Index: clang/test/Preprocessor/predefined-macros.c
===
--- clang/test/Preprocessor/predefined-macros.c
+++ clang/test/Preprocessor/predefined-macros.c
@@ -135,8 +135,10 @@
 // RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-CL30
 // RUN: %clang_cc1 %s -E -dM -o - -x cl -cl-fast-relaxed-math \
 // RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-FRM
-// RUN: %clang_cc1 %s -E -dM -o - -x cl -cl-std=clc++ \
+// RUN: %clang_cc1 %s -E -dM -o - -x cl -cl-std=clc++1.0 \
 // RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-CLCPP10
+// RUN: %clang_cc1 %s -E -dM -o - -x cl -cl-std=clc++2021 \
+// RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-CLCPP2021
 // CHECK-CL10: #define CL_VERSION_1_0 100
 // CHECK-CL10: #define CL_VERSION_1_1 110
 // CHECK-CL10: #define CL_VERSION_1_2 120
@@ -174,9 +176,15 @@
 // CHECK-CL30-NOT: #define __FAST_RELAXED_MATH__ 1
 // CHECK-FRM: #define __FAST_RELAXED_MATH__ 1
 // CHECK-CLCPP10: #define __CL_CPP_VERSION_1_0__ 100
+// CHECK-CLCPP10: #define __CL_CPP_VERSION_2021__ 202100
 // CHECK-CLCPP10: #define __OPENCL_CPP_VERSION__ 100
 // CHECK-CLCPP10-NOT: #define __FAST_RELAXED_MATH__ 1
 // CHECK-CLCPP10-NOT: #define __ENDIAN_LITTLE__ 1
+// CHECK-CLCPP2021: #define __CL_CPP_VERSION_1_0__ 100
+// CHECK-CLCPP2021: #define __CL_CPP_VERSION_2021__ 202100
+// CHECK-CLCPP2021: #define __OPENCL_CPP_VERSION__ 202100
+// CHECK-CLCPP2021-NOT: #define __FAST_RELAXED_MATH__ 1
+// CHECK-CLCPP2021-NOT: #define __ENDIAN_LITTLE__ 1
 
 // RUN: %clang_cc1 %s -E -dM -o - -x cl \
 // RUN:   | FileCheck %s --check-prefix=MSCOPE
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

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

Changes in this revision:

- renamed fix_cve_2021_35465 to Fix_CVE_2021_35465
- added more Driver tests to cover the use of -mfix-cmse-cve-2021-35465 with 
-mno-fix-cmse-cve-2021-35465
- fixed code indentation


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

https://reviews.llvm.org/D109157

Files:
  clang/docs/ClangCommandLineReference.rst
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/arm-cmse-cve-2021-35465.c
  llvm/lib/Target/ARM/ARMExpandPseudoInsts.cpp
  llvm/test/CodeGen/ARM/cmse-cve-2021-35465-return.ll
  llvm/test/CodeGen/ARM/cmse-cve-2021-35465.ll

Index: llvm/test/CodeGen/ARM/cmse-cve-2021-35465.ll
===
--- /dev/null
+++ llvm/test/CodeGen/ARM/cmse-cve-2021-35465.ll
@@ -0,0 +1,101 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+;
+; RUN: llc %s -o - -mtriple=thumbv8m.main -mattr=+fp-armv8d16sp \
+; RUN:   -arm-fix-cmse-cve-2021-35465=1 | \
+; RUN:   FileCheck %s --check-prefix=CHECK-8M-FP-CVE-2021-35465
+;
+; RUN: llc %s -o - -mtriple=thumbv8m.main -mattr=-fpregs \
+; RUN:   -arm-fix-cmse-cve-2021-35465=1 | \
+; RUN:   FileCheck %s --check-prefix=CHECK-8M-NOFP-CVE-2021-35465
+;
+; RUN: llc %s -o - -mtriple=thumbv8.1m.main -mattr=+fp-armv8d16sp \
+; RUN:   -arm-fix-cmse-cve-2021-35465=1 | \
+; RUN:   FileCheck %s --check-prefix=CHECK-81M-CVE-2021-35465
+;
+; RUN: llc %s -o - -mtriple=thumbv8.1m.main -mattr=-fpregs \
+; RUN:   -arm-fix-cmse-cve-2021-35465=1 | \
+; RUN:   FileCheck %s --check-prefix=CHECK-81M-CVE-2021-35465
+
+
+define void @non_secure_call(void ()* %fptr) {
+; CHECK-8M-FP-CVE-2021-35465-LABEL: non_secure_call:
+; CHECK-8M-FP-CVE-2021-35465:   @ %bb.0:
+; CHECK-8M-FP-CVE-2021-35465-NEXT:push {r7, lr}
+; CHECK-8M-FP-CVE-2021-35465-NEXT:push.w {r4, r5, r6, r7, r8, r9, r10, r11}
+; CHECK-8M-FP-CVE-2021-35465-NEXT:bic r0, r0, #1
+; CHECK-8M-FP-CVE-2021-35465-NEXT:sub sp, #136
+; CHECK-8M-FP-CVE-2021-35465-NEXT:vlstm sp
+; CHECK-8M-FP-CVE-2021-35465-NEXT:mov r1, r0
+; CHECK-8M-FP-CVE-2021-35465-NEXT:mov r2, r0
+; CHECK-8M-FP-CVE-2021-35465-NEXT:mov r3, r0
+; CHECK-8M-FP-CVE-2021-35465-NEXT:mov r4, r0
+; CHECK-8M-FP-CVE-2021-35465-NEXT:mov r5, r0
+; CHECK-8M-FP-CVE-2021-35465-NEXT:mov r6, r0
+; CHECK-8M-FP-CVE-2021-35465-NEXT:mov r7, r0
+; CHECK-8M-FP-CVE-2021-35465-NEXT:mov r8, r0
+; CHECK-8M-FP-CVE-2021-35465-NEXT:mov r9, r0
+; CHECK-8M-FP-CVE-2021-35465-NEXT:mov r10, r0
+; CHECK-8M-FP-CVE-2021-35465-NEXT:mov r11, r0
+; CHECK-8M-FP-CVE-2021-35465-NEXT:mov r12, r0
+; CHECK-8M-FP-CVE-2021-35465-NEXT:msr apsr_nzcvq, r0
+; CHECK-8M-FP-CVE-2021-35465-NEXT:blxns r0
+; CHECK-8M-FP-CVE-2021-35465-NEXT:mrs r12, control
+; CHECK-8M-FP-CVE-2021-35465-NEXT:tst.w r12, #8
+; CHECK-8M-FP-CVE-2021-35465-NEXT:it ne
+; CHECK-8M-FP-CVE-2021-35465-NEXT:vmovne.f32 s0, s0
+; CHECK-8M-FP-CVE-2021-35465-NEXT:vlldm sp
+; CHECK-8M-FP-CVE-2021-35465-NEXT:add sp, #136
+; CHECK-8M-FP-CVE-2021-35465-NEXT:pop.w {r4, r5, r6, r7, r8, r9, r10, r11}
+; CHECK-8M-FP-CVE-2021-35465-NEXT:pop {r7, pc}
+;
+; CHECK-8M-NOFP-CVE-2021-35465-LABEL: non_secure_call:
+; CHECK-8M-NOFP-CVE-2021-35465:   @ %bb.0:
+; CHECK-8M-NOFP-CVE-2021-35465-NEXT:push {r7, lr}
+; CHECK-8M-NOFP-CVE-2021-35465-NEXT:push.w {r4, r5, r6, r7, r8, r9, r10, r11}
+; CHECK-8M-NOFP-CVE-2021-35465-NEXT:bic r0, r0, #1
+; CHECK-8M-NOFP-CVE-2021-35465-NEXT:sub sp, #136
+; CHECK-8M-NOFP-CVE-2021-35465-NEXT:vlstm sp
+; CHECK-8M-NOFP-CVE-2021-35465-NEXT:mov r1, r0
+; CHECK-8M-NOFP-CVE-2021-35465-NEXT:mov r2, r0
+; CHECK-8M-NOFP-CVE-2021-35465-NEXT:mov r3, r0
+; CHECK-8M-NOFP-CVE-2021-35465-NEXT:mov r4, r0
+; CHECK-8M-NOFP-CVE-2021-35465-NEXT:mov r5, r0
+; CHECK-8M-NOFP-CVE-2021-35465-NEXT:mov r6, r0
+; CHECK-8M-NOFP-CVE-2021-35465-NEXT:mov r7, r0
+; CHECK-8M-NOFP-CVE-2021-35465-NEXT:mov r8, r0
+; CHECK-8M-NOFP-CVE-2021-35465-NEXT:mov r9, r0
+; CHECK-8M-NOFP-CVE-2021-35465-NEXT:mov r10, r0
+; CHECK-8M-NOFP-CVE-2021-35465-NEXT:mov r11, r0
+; CHECK-8M-NOFP-CVE-2021-35465-NEXT:mov r12, r0
+; CHECK-8M-NOFP-CVE-2021-35465-NEXT:msr apsr_nzcvq, r0
+; CHECK-8M-NOFP-CVE-2021-35465-NEXT:blxns r0
+; CHECK-8M-NOFP-CVE-2021-35465-NEXT:mrs r12, control
+; CHECK-8M-NOFP-CVE-2021-35465-NEXT:tst.w r12, #8
+; CHECK-8M-NOFP-CVE-2021-35465-NEXT:it ne
+; CHECK-8M-NOFP-CVE-2021-35465-NEXT:@APP
+; CHECK-8M-NOFP-CVE-2021-35465-NEXT:.inst.w 0xeeb00a40
+; CHECK-8M-NOFP-CVE-2021-35465-NEXT:@NO_APP
+; CHECK-8M-NOFP-CVE-2021-35465-NEXT:vlldm sp
+; CHECK-8M-NOFP-CVE-2021-35465-NEXT:add sp, #136
+; CHECK-8M-NOFP-CVE-2021-35465-NEXT:pop.w {r4, r5, r6, r7, r8, r9, r10, r11}
+; CHECK-8M-NOFP-CVE-2021-35465-NEXT:pop {r7, pc}
+;
+; 

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

2021-09-07 Thread David Tenty via Phabricator via cfe-commits
daltenty updated this revision to Diff 371078.
daltenty added a comment.

- Address review comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109078

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

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

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

2021-09-07 Thread David Tenty via Phabricator via cfe-commits
daltenty added inline comments.



Comment at: clang/lib/Driver/ToolChains/AIX.cpp:240-242
+  case ToolChain::CST_Libstdcxx:
+llvm::report_fatal_error(
+"picking up libstdc++ headers is unimplemented on AIX");

ZarkoCA wrote:
> nit: it would be my preference to have the error case first but I also that 
> `AIX::AddCXXStdlibLibArgs` is set up the same way so keeping them consistent 
> may be more important.
Flipping the cases in both places for consistency should be fairly straight 
forward, so I think that's ok.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109078

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


[PATCH] D45961: [MC] Add MCSubtargetInfo to MCAlignFragment

2021-09-07 Thread Peter Smith 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 rG5e71839f7793: [MC] Add MCSubtargetInfo to MCAlignFragment 
(authored by psmith).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Changed prior to commit:
  https://reviews.llvm.org/D45961?vs=370923=371074#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D45961

Files:
  clang/tools/driver/cc1as_main.cpp
  llvm/include/llvm/MC/MCELFStreamer.h
  llvm/include/llvm/MC/MCFragment.h
  llvm/include/llvm/MC/MCObjectStreamer.h
  llvm/include/llvm/MC/MCStreamer.h
  llvm/include/llvm/MC/MCWinCOFFStreamer.h
  llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
  llvm/lib/MC/ConstantPools.cpp
  llvm/lib/MC/MCAsmStreamer.cpp
  llvm/lib/MC/MCELFStreamer.cpp
  llvm/lib/MC/MCObjectStreamer.cpp
  llvm/lib/MC/MCParser/AsmParser.cpp
  llvm/lib/MC/MCParser/MasmParser.cpp
  llvm/lib/MC/MCStreamer.cpp
  llvm/lib/MC/MCWinCOFFStreamer.cpp
  llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
  llvm/lib/Target/ARM/ARMAsmPrinter.cpp
  llvm/lib/Target/ARM/ARMMCInstLower.cpp
  llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
  llvm/lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp
  llvm/lib/Target/Hexagon/AsmParser/HexagonAsmParser.cpp
  llvm/lib/Target/Hexagon/HexagonAsmPrinter.cpp
  llvm/lib/Target/Hexagon/HexagonTargetStreamer.h
  llvm/lib/Target/Mips/MCTargetDesc/MipsTargetStreamer.cpp
  llvm/lib/Target/Mips/MipsAsmPrinter.cpp
  llvm/lib/Target/PowerPC/MCTargetDesc/PPCELFStreamer.cpp
  llvm/lib/Target/PowerPC/MCTargetDesc/PPCXCOFFStreamer.cpp
  llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
  llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
  llvm/lib/Target/X86/X86MCInstLower.cpp
  llvm/tools/llvm-mc/Disassembler.cpp
  llvm/tools/llvm-mc/llvm-mc.cpp
  llvm/tools/llvm-ml/Disassembler.cpp
  llvm/unittests/DebugInfo/DWARF/DWARFExpressionCopyBytesTest.cpp

Index: llvm/unittests/DebugInfo/DWARF/DWARFExpressionCopyBytesTest.cpp
===
--- llvm/unittests/DebugInfo/DWARF/DWARFExpressionCopyBytesTest.cpp
+++ llvm/unittests/DebugInfo/DWARF/DWARFExpressionCopyBytesTest.cpp
@@ -128,7 +128,7 @@
   SmallString<0> Storage;
   raw_svector_ostream VecOS(Storage);
   StreamerContext C = createStreamer(VecOS);
-  C.Streamer->InitSections(false);
+  C.Streamer->initSections(false, *STI);
   MCSection *Section = C.MOFI->getTextSection();
   Section->setHasInstructions(true);
   C.Streamer->SwitchSection(Section);
Index: llvm/tools/llvm-ml/Disassembler.cpp
===
--- llvm/tools/llvm-ml/Disassembler.cpp
+++ llvm/tools/llvm-ml/Disassembler.cpp
@@ -152,7 +152,7 @@
   }
 
   // Set up initial section manually here
-  Streamer.InitSections(false);
+  Streamer.initSections(false, STI);
 
   bool ErrorOccurred = false;
 
Index: llvm/tools/llvm-mc/llvm-mc.cpp
===
--- llvm/tools/llvm-mc/llvm-mc.cpp
+++ llvm/tools/llvm-mc/llvm-mc.cpp
@@ -571,7 +571,7 @@
 MCOptions.MCIncrementalLinkerCompatible,
 /*DWARFMustBeAtTheEnd*/ false));
 if (NoExecStack)
-  Str->InitSections(true);
+  Str->initSections(true, *STI);
   }
 
   // Use Assembler information for parsing.
Index: llvm/tools/llvm-mc/Disassembler.cpp
===
--- llvm/tools/llvm-mc/Disassembler.cpp
+++ llvm/tools/llvm-mc/Disassembler.cpp
@@ -156,7 +156,7 @@
   }
 
   // Set up initial section manually here
-  Streamer.InitSections(false);
+  Streamer.initSections(false, STI);
 
   bool ErrorOccurred = false;
 
Index: llvm/lib/Target/X86/X86MCInstLower.cpp
===
--- llvm/lib/Target/X86/X86MCInstLower.cpp
+++ llvm/lib/Target/X86/X86MCInstLower.cpp
@@ -1718,7 +1718,7 @@
   // First we emit the label and the jump.
   auto CurSled = OutContext.createTempSymbol("xray_event_sled_", true);
   OutStreamer->AddComment("# XRay Custom Event Log");
-  OutStreamer->emitCodeAlignment(2);
+  OutStreamer->emitCodeAlignment(2, ());
   OutStreamer->emitLabel(CurSled);
 
   // Use a two-byte `jmp`. This version of JMP takes an 8-bit relative offset as
@@ -1814,7 +1814,7 @@
   // First we emit the label and the jump.
   auto CurSled = OutContext.createTempSymbol("xray_typed_event_sled_", true);
   OutStreamer->AddComment("# XRay Typed Event Log");
-  OutStreamer->emitCodeAlignment(2);
+  OutStreamer->emitCodeAlignment(2, ());
   OutStreamer->emitLabel(CurSled);
 
   // Use a two-byte `jmp`. This version of JMP takes an 8-bit relative offset as
@@ -1916,7 +1916,7 @@
   //   call// 5 bytes
   //
   auto CurSled = OutContext.createTempSymbol("xray_sled_", true);
-  OutStreamer->emitCodeAlignment(2);
+  OutStreamer->emitCodeAlignment(2, ());
   

[clang] 5e71839 - [MC] Add MCSubtargetInfo to MCAlignFragment

2021-09-07 Thread Peter Smith via cfe-commits

Author: Peter Smith
Date: 2021-09-07T15:46:19+01:00
New Revision: 5e71839f7793b3ab94e928654a493cb3d7216176

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

LOG: [MC] Add MCSubtargetInfo to MCAlignFragment

In preparation for passing the MCSubtargetInfo (STI) through to writeNops
so that it can use the STI in operation at the time, we need to record the
STI in operation when a MCAlignFragment may write nops as padding. The
STI is currently unused, a further patch will pass it through to
writeNops.

There are many places that can create an MCAlignFragment, in most cases
we can find out the STI in operation at the time. In a few places this
isn't possible as we are in initialisation or finalisation, or are
emitting constant pools. When possible I've tried to find the most
appropriate existing fragment to obtain the STI from, when none is
available use the per module STI.

For constant pools we don't actually need to use EmitCodeAlign as the
constant pools are data anyway so falling through into it via an
executable NOP is no better than falling through into data padding.

This is a prerequisite for D45962 which uses the STI to emit the
appropriate NOP for the STI. Which can differ per fragment.

Note that involves an interface change to InitSections. It is now
called initSections and requires a SubtargetInfo as a parameter.

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

Added: 


Modified: 
clang/tools/driver/cc1as_main.cpp
llvm/include/llvm/MC/MCELFStreamer.h
llvm/include/llvm/MC/MCFragment.h
llvm/include/llvm/MC/MCObjectStreamer.h
llvm/include/llvm/MC/MCStreamer.h
llvm/include/llvm/MC/MCWinCOFFStreamer.h
llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
llvm/lib/MC/ConstantPools.cpp
llvm/lib/MC/MCAsmStreamer.cpp
llvm/lib/MC/MCELFStreamer.cpp
llvm/lib/MC/MCObjectStreamer.cpp
llvm/lib/MC/MCParser/AsmParser.cpp
llvm/lib/MC/MCParser/MasmParser.cpp
llvm/lib/MC/MCStreamer.cpp
llvm/lib/MC/MCWinCOFFStreamer.cpp
llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
llvm/lib/Target/ARM/ARMAsmPrinter.cpp
llvm/lib/Target/ARM/ARMMCInstLower.cpp
llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
llvm/lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp
llvm/lib/Target/Hexagon/AsmParser/HexagonAsmParser.cpp
llvm/lib/Target/Hexagon/HexagonAsmPrinter.cpp
llvm/lib/Target/Hexagon/HexagonTargetStreamer.h
llvm/lib/Target/Mips/MCTargetDesc/MipsTargetStreamer.cpp
llvm/lib/Target/Mips/MipsAsmPrinter.cpp
llvm/lib/Target/PowerPC/MCTargetDesc/PPCELFStreamer.cpp
llvm/lib/Target/PowerPC/MCTargetDesc/PPCXCOFFStreamer.cpp
llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
llvm/lib/Target/X86/X86MCInstLower.cpp
llvm/tools/llvm-mc/Disassembler.cpp
llvm/tools/llvm-mc/llvm-mc.cpp
llvm/tools/llvm-ml/Disassembler.cpp
llvm/unittests/DebugInfo/DWARF/DWARFExpressionCopyBytesTest.cpp

Removed: 




diff  --git a/clang/tools/driver/cc1as_main.cpp 
b/clang/tools/driver/cc1as_main.cpp
index 086ce0ea77875..6549b132f6166 100644
--- a/clang/tools/driver/cc1as_main.cpp
+++ b/clang/tools/driver/cc1as_main.cpp
@@ -490,7 +490,7 @@ static bool ExecuteAssemblerImpl(AssemblerInvocation ,
 T, Ctx, std::move(MAB), std::move(OW), std::move(CE), *STI,
 Opts.RelaxAll, Opts.IncrementalLinkerCompatible,
 /*DWARFMustBeAtTheEnd*/ true));
-Str.get()->InitSections(Opts.NoExecStack);
+Str.get()->initSections(Opts.NoExecStack, *STI);
   }
 
   // When -fembed-bitcode is passed to clang_as, a 1-byte marker

diff  --git a/llvm/include/llvm/MC/MCELFStreamer.h 
b/llvm/include/llvm/MC/MCELFStreamer.h
index 8c1e22a147025..8f2b176862c85 100644
--- a/llvm/include/llvm/MC/MCELFStreamer.h
+++ b/llvm/include/llvm/MC/MCELFStreamer.h
@@ -39,7 +39,7 @@ class MCELFStreamer : public MCObjectStreamer {
   /// \name MCStreamer Interface
   /// @{
 
-  void InitSections(bool NoExecStack) override;
+  void initSections(bool NoExecStack, const MCSubtargetInfo ) override;
   void changeSection(MCSection *Section, const MCExpr *Subsection) override;
   void emitLabel(MCSymbol *Symbol, SMLoc Loc = SMLoc()) override;
   void emitLabelAtPos(MCSymbol *Symbol, SMLoc Loc, MCFragment *F,

diff  --git a/llvm/include/llvm/MC/MCFragment.h 
b/llvm/include/llvm/MC/MCFragment.h
index f3a785fb09b7f..d415e10ab2779 100644
--- a/llvm/include/llvm/MC/MCFragment.h
+++ b/llvm/include/llvm/MC/MCFragment.h
@@ -311,6 +311,9 @@ class MCAlignFragment : public MCFragment {
   /// cannot be satisfied in this width then this fragment is ignored.
   unsigned MaxBytesToEmit;
 
+  /// When emitting Nops some subtargets have specific nop encodings.
+  const MCSubtargetInfo *STI;
+
 public:
   

[PATCH] D108560: [clang-tidy] Add support for NOLINTBEGIN ... NOLINTEND comments to suppress clang-tidy warnings over multiple lines

2021-09-07 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: 
clang-tools-extra/test/clang-tidy/infrastructure/nolintbeginend.cpp:82
+
+// CHECK-MESSAGES: Suppressed 12 warnings (12 NOLINT)

I'd like to see some additional test coverage that shows improper use and what 
happens.

e.g., what happens if there's a `NOLINTBEGIN` and no `NOLINTEND` marker? What 
happens if `NOLINTEND` appears before any `NOLINTBEGIN`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108560

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


[PATCH] D104285: [analyzer] Retrieve a value from list initialization of constant array declaration in a global scope.

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

Some minor drive-by nits, but this looks sensible to me.




Comment at: clang/lib/StaticAnalyzer/Core/RegionStore.cpp:1692-1694
+const bool IsOneDimensionalArray =
+!isa(CAT->getElementType());
+if (IsOneDimensionalArray) {





Comment at: clang/lib/StaticAnalyzer/Core/RegionStore.cpp:1696-1698
+  const uint64_t I = static_cast(Idx.getExtValue());
+  // Use `getZExtValue` because array extent can not be negative.
+  const uint64_t Extent = CAT->getSize().getZExtValue();




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

https://reviews.llvm.org/D104285

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


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

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

SystemZ specific parts LGTM, but it would be good to have someone else review 
the common code / IR changes as well.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109362

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


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

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

I agree with Johannes and Alexey that deferred diags are only needed when 
LangOpts.OMPTargetTriples.empty(). However, I am not sure whether it is only 
needed in device compilation.

For other offloading languages like CUDA/HIP it is needed in both device and 
host compilation.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109175

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


[PATCH] D109178: [PowerPC] Disable vector types when not supported by subtarget features

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

It is not clear what this patch will do with `vector [[un]signed] long`. This 
is currently deprecated but still works - and we don't want it to work with no 
VSX.




Comment at: clang/lib/Headers/altivec.h:8881
 }
 #endif
 

This file is huge and there is a lot of conditional compilation within it. Can 
you please add comments to terminating `endif` as to what it is terminating. 
Presumably this one here terminates `__VSX__`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109178

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


[PATCH] D106809: [clang-offload-bundler] Make Bundle Entry ID backward compatible

2021-09-07 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added inline comments.



Comment at: clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp:148
+// Check if the last option before any colon is a triple field or a GPU 
name
+if (TripleOrGPU.second.startswith("gfx") ||
+TripleOrGPU.second.startswith("sm_")) {

This is rather fragile to determine whether a bundle ID contains GPU arch. Is 
there better way?

At least for HIP offload kind, GPU arch should always be there.



Comment at: clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp:1298
+ // the missing input file.
+  std::vector EmptyArchive;
+  EmptyArchive.clear();

need a test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106809

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


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

2021-09-07 Thread Anirudh Prasad via Phabricator via cfe-commits
anirudhp created this revision.
Herald added subscribers: dexonsmith, jdoerfert, hiraditya.
anirudhp requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

- This patch adds in the GOFF mangling support to the LLVM data layout string. 
A corresponding additional line has been added into the data layout section in 
the language reference documentation.
- Furthermore, this patch also sets the right data layout string for the z/OS 
target in the SystemZ backend.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D109362

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

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

[PATCH] D93110: [analyzer] Implement fine-grained suppressions via attributes

2021-09-07 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/include/clang/Basic/AttrDocs.td:4747-4748
+The ``suppress`` attribute can be applied to variable declarations and 
statements
+to suppess warnings from the Clang Static Analyzer. The analyzer will not 
report
+any issues on the annotated constructs.
+

We may want to clarify that currently, this does not suppress all diagnostics 
and give an example where the FE diagnostic is not suppressed but a CSA one is. 
We may also want to mention that this is expected to be a temporary limitation?



Comment at: clang/include/clang/Basic/AttrDocs.td:4755
+...
+[[clang::analyzer_suppress]] int y = *x; // no warning from the analyzer
+...

This attribute no longer exists.



Comment at: clang/include/clang/Basic/AttrDocs.td:4759-4760
+
+For leaks, suppressions can work both when placed on the statement where the
+issue is reported and on the allocation site.
+

Is this true in general, or just for leaks? e.g., does this also suppress on 
sources of taint rather than on uses of taint?



Comment at: 
clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h:592-593
 
+  /// User-provided in-code suppressions.
+  BugSuppression UserSuppressions;
+

NoQ wrote:
> Even though the attribute is specific to the static analyzer and from that 
> point of view it's appropriate to keep this info in the `BugReporter` object 
> (that will always be specific to the static analyzer), i believe we should 
> ultimately move this into a higher-level entity in `libAnalysis` such as 
> `AnalysisConsumer`. This would allow other tools such as clang-tidy to access 
> that information when integrated into the static analyzer (eg., a-la D95403) 
> and the user treats the entire conglomerate of tools as just "the static 
> analyzer" and expects consistency across checks. That, of course, relies on 
> our ability to look up attributes by source locations.
In addition to considering integration into clang-tidy, we should be 
considering integration into the Clang diagnostics engine as well. I don't 
think the attribute has to work in clang-tidy and clang proper as part of this 
initial patch, but we should have an idea on the path forward so we don't 
duplicate the user suppression list three times.



Comment at: 
clang/include/clang/StaticAnalyzer/Core/BugReporter/BugSuppression.h:9
+//
+//  This file defines BugSuppression, a simple interface class incapsulating
+//  all user provided in-code suppressions.





Comment at: 
clang/include/clang/StaticAnalyzer/Core/BugReporter/BugSuppression.h:14
+
+#ifndef LLVM_CLANG_STATICANALYZER_CORE_BUGREPORTER_SUPPTRESSION_H
+#define LLVM_CLANG_STATICANALYZER_CORE_BUGREPORTER_SUPPTRESSION_H

Typo in the header guard.



Comment at: clang/lib/Sema/SemaDeclAttr.cpp:4708
 static void handleSuppressAttr(Sema , Decl *D, const ParsedAttr ) {
-  if (!AL.checkAtLeastNumArgs(S, 1))
+  if (AL.getAttributeSpellingListIndex() == 0) {
+// Suppression attribute with GSL spelling requires at least 1 argument.

Rather than `== 0`, this should be using something more like ` == 
SuppressAttr::CXX11_gsl_suppress` (or whatever the enumeration spelling comes 
out as from tablegen).



Comment at: clang/lib/Sema/SemaDeclAttr.cpp:4712
+  return;
+  } else if (!isa(D)) {
+// Analyzer suppression applies only to variables and statements.

Should this also apply to `FieldDecl`? `IndirectFieldDecl`?

You mention in the summary that there are open design questions about what this 
should apply to. My thinking is that the second option is the most defensible 
one and is still possible to explain -- the attribute suppresses diagnostics on 
the line on which the attribute appears (with "line" being logical source line, 
not physical source line in a file). Then we can add an argument to the 
attribute in the future if we decide we need finer granularity (e.g., two 
diagnostics issued on the same line and you only want to suppress one 
diagnostic). Using the wider scope means we don't have any way to support the 
fine-grained control that I think is needed in practice. WDYT?



Comment at: clang/lib/Sema/SemaStmtAttr.cpp:55
 SourceRange Range) {
+  if (A.getAttributeSpellingListIndex() == 0 && A.getNumArgs() < 1) {
+// Suppression attribute with GSL spelling requires at least 1 argument.

Same suggestion here as above for the `== 0`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93110

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


[PATCH] D108302: [PowerPC] Fixed the crash due to early if conversion with fixed CR fields.

2021-09-07 Thread Lei Huang via Phabricator via cfe-commits
lei accepted this revision.
lei added a comment.
This revision is now accepted and ready to land.

LGTM
Thx!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108302

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


[PATCH] D109178: [PowerPC] Disable vector types when not supported by subtarget features

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



Comment at: clang/test/CodeGen/builtins-ppc-int128.c:4
+// RUN:   -triple powerpc64-unknown-unknown -target-cpu pwr8 \
+// RUN:  -emit-llvm %s -o - -U__XL_COMPAT_ALTIVEC__ | FileCheck %s
+// RUN: %clang_cc1 -target-feature +altivec -target-feature +vsx \

NeHuang wrote:
> nit: indentation 
thx. Will fix before comit.



Comment at: clang/test/Parser/altivec.c:92
 // These should have errors.
+#ifndef __VSX__
 __vector double vv_d1;   // expected-error {{use of 'double' with 
'__vector' requires VSX support to be enabled (available on POWER7 or later)}}

NeHuang wrote:
> Will this patch also impact `vector double`?   If not, can we move `#ifndef 
> __VSX__` down below `vector double v_d2;`?  
This patch doesn't, but this is needed here since I added RUN line to test 
behavior for when VSX is enabled.  Note the test lines was not changed for 
`vector double`.



Comment at: clang/test/Parser/cxx-altivec.cpp:91
 
-// These should have errors.
+#ifndef __VSX__
+// These should have errors for non pwr7 vsx builds.

NeHuang wrote:
> same as above.
needed due to new RUN line added.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109178

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


[PATCH] D109361: [clang][Driver] Pick the last --driver-mode in case of multiple ones

2021-09-07 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added a comment.

FYI, I've also requested cherry-pick into 13 release in 
https://bugs.llvm.org/show_bug.cgi?id=51779.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109361

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


[PATCH] D109361: [clang][Driver] Pick the last --driver-mode in case of multiple ones

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

Thanks! I tried this locally and it fixes the issue I mentioned on D109361 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109361

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


[PATCH] D109361: [clang][Driver] Pick the last --driver-mode in case of multiple ones

2021-09-07 Thread Kadir Cetinkaya via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG73c00d40bd49: [clang][Driver] Pick the last --driver-mode in 
case of multiple ones (authored by kadircet).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109361

Files:
  clang/lib/Driver/Driver.cpp
  clang/unittests/Driver/ToolChainTest.cpp


Index: clang/unittests/Driver/ToolChainTest.cpp
===
--- clang/unittests/Driver/ToolChainTest.cpp
+++ clang/unittests/Driver/ToolChainTest.cpp
@@ -16,6 +16,7 @@
 #include "clang/Basic/LLVM.h"
 #include "clang/Driver/Compilation.h"
 #include "clang/Driver/Driver.h"
+#include "llvm/ADT/ArrayRef.h"
 #include "llvm/Support/TargetRegistry.h"
 #include "llvm/Support/TargetSelect.h"
 #include "llvm/Support/VirtualFileSystem.h"
@@ -357,4 +358,10 @@
   EXPECT_TRUE(CallbackHasCalled);
 }
 
+TEST(GetDriverMode, PrefersLastDriverMode) {
+  static constexpr const char *Args[] = {"clang-cl", "--driver-mode=foo",
+ "--driver-mode=bar", "foo.cpp"};
+  EXPECT_EQ(getDriverMode(Args[0], llvm::makeArrayRef(Args).slice(1)), "bar");
+}
+
 } // end anonymous namespace.
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -5569,7 +5569,6 @@
 if (!Arg.startswith(OptName))
   continue;
 Opt = Arg;
-break;
   }
   if (Opt.empty())
 Opt = ToolChain::getTargetAndModeFromProgramName(ProgName).DriverMode;


Index: clang/unittests/Driver/ToolChainTest.cpp
===
--- clang/unittests/Driver/ToolChainTest.cpp
+++ clang/unittests/Driver/ToolChainTest.cpp
@@ -16,6 +16,7 @@
 #include "clang/Basic/LLVM.h"
 #include "clang/Driver/Compilation.h"
 #include "clang/Driver/Driver.h"
+#include "llvm/ADT/ArrayRef.h"
 #include "llvm/Support/TargetRegistry.h"
 #include "llvm/Support/TargetSelect.h"
 #include "llvm/Support/VirtualFileSystem.h"
@@ -357,4 +358,10 @@
   EXPECT_TRUE(CallbackHasCalled);
 }
 
+TEST(GetDriverMode, PrefersLastDriverMode) {
+  static constexpr const char *Args[] = {"clang-cl", "--driver-mode=foo",
+ "--driver-mode=bar", "foo.cpp"};
+  EXPECT_EQ(getDriverMode(Args[0], llvm::makeArrayRef(Args).slice(1)), "bar");
+}
+
 } // end anonymous namespace.
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -5569,7 +5569,6 @@
 if (!Arg.startswith(OptName))
   continue;
 Opt = Arg;
-break;
   }
   if (Opt.empty())
 Opt = ToolChain::getTargetAndModeFromProgramName(ProgName).DriverMode;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 73c00d4 - [clang][Driver] Pick the last --driver-mode in case of multiple ones

2021-09-07 Thread Kadir Cetinkaya via cfe-commits

Author: Kadir Cetinkaya
Date: 2021-09-07T15:33:45+02:00
New Revision: 73c00d40bd49ae022f6fbba7200f05facb533e3b

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

LOG: [clang][Driver] Pick the last --driver-mode in case of multiple ones

This was an accidental behaviour change in D106789 and this patch
restores it back to original state.

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

Added: 


Modified: 
clang/lib/Driver/Driver.cpp
clang/unittests/Driver/ToolChainTest.cpp

Removed: 




diff  --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index 4b56a97da717b..a92b6e8c0908b 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -5569,7 +5569,6 @@ llvm::StringRef clang::driver::getDriverMode(StringRef 
ProgName,
 if (!Arg.startswith(OptName))
   continue;
 Opt = Arg;
-break;
   }
   if (Opt.empty())
 Opt = ToolChain::getTargetAndModeFromProgramName(ProgName).DriverMode;

diff  --git a/clang/unittests/Driver/ToolChainTest.cpp 
b/clang/unittests/Driver/ToolChainTest.cpp
index 253c65d0e29fe..f117472957781 100644
--- a/clang/unittests/Driver/ToolChainTest.cpp
+++ b/clang/unittests/Driver/ToolChainTest.cpp
@@ -16,6 +16,7 @@
 #include "clang/Basic/LLVM.h"
 #include "clang/Driver/Compilation.h"
 #include "clang/Driver/Driver.h"
+#include "llvm/ADT/ArrayRef.h"
 #include "llvm/Support/TargetRegistry.h"
 #include "llvm/Support/TargetSelect.h"
 #include "llvm/Support/VirtualFileSystem.h"
@@ -357,4 +358,10 @@ TEST(ToolChainTest, PostCallback) {
   EXPECT_TRUE(CallbackHasCalled);
 }
 
+TEST(GetDriverMode, PrefersLastDriverMode) {
+  static constexpr const char *Args[] = {"clang-cl", "--driver-mode=foo",
+ "--driver-mode=bar", "foo.cpp"};
+  EXPECT_EQ(getDriverMode(Args[0], llvm::makeArrayRef(Args).slice(1)), "bar");
+}
+
 } // end anonymous namespace.



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


[PATCH] D109321: [clang][OpenMP] Fix the bug in codegen for ordered directive

2021-09-07 Thread Peixin Qiao via Phabricator via cfe-commits
peixin added a comment.

  $ clang++ -fopenmp simd.cpp -O1 -Xclang -disable-llvm-passes && ./a.out
  0 1  2  3  4  5  6  7  8  9
  $ clang++ -fopenmp simd.cpp -O2 && ./a.out
  0 1  2  3  4  5  6  7  8  9
  $ clang++ -fopenmp simd.cpp -O3 && ./a.out
  0 1  2  3  4  5  6  7  8  9

This bug is not in clang frontend. I will post it in bugzilla.

Another question is why not add `llvm::Attribute::AlwaysInline` when 
`CGM.getCodeGenOpts().OptimizationLevel` is 0? @jhuber6 I think it is correct 
to add the attribute when `CGM.getCodeGenOpts().OptimizationLevel` is 0.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109321

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


[PATCH] D106789: [clang][Driver] Expose driver mode detection logic

2021-09-07 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added a comment.

Argh, sorry for the mess, sent out D109361 .

FYI, before this patch clang preferred the last `--driver-mode` in case of 
multiple ones and started preferring the first one with this patch. In 
https://github.com/llvm/llvm-project/blob/main/clang/tools/driver/driver.cpp#L474
 it always inserts a `--driver-mode` matching the program name at the beginning 
of the command line, hence it was always preferring CL mode even though you 
explicitly mentioned GCC afterwards.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106789

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


[PATCH] D109361: [clang][Driver] Pick the last --driver-mode in case of multiple ones

2021-09-07 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet created this revision.
kadircet added reviewers: hans, sammccall.
kadircet requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This was an accidental behaviour change in D106789 
 and this patch
restores it back to original state.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D109361

Files:
  clang/lib/Driver/Driver.cpp
  clang/unittests/Driver/ToolChainTest.cpp


Index: clang/unittests/Driver/ToolChainTest.cpp
===
--- clang/unittests/Driver/ToolChainTest.cpp
+++ clang/unittests/Driver/ToolChainTest.cpp
@@ -16,6 +16,7 @@
 #include "clang/Basic/LLVM.h"
 #include "clang/Driver/Compilation.h"
 #include "clang/Driver/Driver.h"
+#include "llvm/ADT/ArrayRef.h"
 #include "llvm/Support/TargetRegistry.h"
 #include "llvm/Support/TargetSelect.h"
 #include "llvm/Support/VirtualFileSystem.h"
@@ -357,4 +358,10 @@
   EXPECT_TRUE(CallbackHasCalled);
 }
 
+TEST(GetDriverMode, PrefersLastDriverMode) {
+  static constexpr const char *Args[] = {"clang-cl", "--driver-mode=foo",
+ "--driver-mode=bar", "foo.cpp"};
+  EXPECT_EQ(getDriverMode(Args[0], llvm::makeArrayRef(Args).slice(1)), "bar");
+}
+
 } // end anonymous namespace.
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -5569,7 +5569,6 @@
 if (!Arg.startswith(OptName))
   continue;
 Opt = Arg;
-break;
   }
   if (Opt.empty())
 Opt = ToolChain::getTargetAndModeFromProgramName(ProgName).DriverMode;


Index: clang/unittests/Driver/ToolChainTest.cpp
===
--- clang/unittests/Driver/ToolChainTest.cpp
+++ clang/unittests/Driver/ToolChainTest.cpp
@@ -16,6 +16,7 @@
 #include "clang/Basic/LLVM.h"
 #include "clang/Driver/Compilation.h"
 #include "clang/Driver/Driver.h"
+#include "llvm/ADT/ArrayRef.h"
 #include "llvm/Support/TargetRegistry.h"
 #include "llvm/Support/TargetSelect.h"
 #include "llvm/Support/VirtualFileSystem.h"
@@ -357,4 +358,10 @@
   EXPECT_TRUE(CallbackHasCalled);
 }
 
+TEST(GetDriverMode, PrefersLastDriverMode) {
+  static constexpr const char *Args[] = {"clang-cl", "--driver-mode=foo",
+ "--driver-mode=bar", "foo.cpp"};
+  EXPECT_EQ(getDriverMode(Args[0], llvm::makeArrayRef(Args).slice(1)), "bar");
+}
+
 } // end anonymous namespace.
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -5569,7 +5569,6 @@
 if (!Arg.startswith(OptName))
   continue;
 Opt = Arg;
-break;
   }
   if (Opt.empty())
 Opt = ToolChain::getTargetAndModeFromProgramName(ProgName).DriverMode;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2021-09-07 Thread Sjoerd Meijer via Phabricator via cfe-commits
SjoerdMeijer added inline comments.



Comment at: clang/lib/Driver/ToolChains/Clang.cpp:1666
+CmdArgs.push_back("-mllvm");
+if (A->getOption().matches(options::OPT_mfix_cmse_cve_2021_35465))
+  CmdArgs.push_back("-arm-fix-cmse-cve-2021-35465=1");

labrinea wrote:
> SjoerdMeijer wrote:
> > I am wondering if this should use `getLastArg` and what happens with test 
> > cases (which I guess need adding) that have both:
> > 
> >   -mno-fix-cmse-cve-2021-35465  -mfix-cmse-cve-2021-35465 
> > 
> > or
> > 
> >   -mfix-cmse-cve-2021-35465  -mno-fix-cmse-cve-2021-35465
> That's the whole point of `getLastArg` as far as I understand: for options 
> that can either enable or disable a feature, so that the last one wins. I'll 
> add more tests.
Ah, got confused, it's indeed right there!


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

https://reviews.llvm.org/D109157

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


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

2021-09-07 Thread Alexandros Lamprineas via Phabricator via cfe-commits
labrinea marked 4 inline comments as done and 6 inline comments as done.
labrinea added inline comments.



Comment at: clang/lib/Driver/ToolChains/Clang.cpp:1666
+CmdArgs.push_back("-mllvm");
+if (A->getOption().matches(options::OPT_mfix_cmse_cve_2021_35465))
+  CmdArgs.push_back("-arm-fix-cmse-cve-2021-35465=1");

SjoerdMeijer wrote:
> I am wondering if this should use `getLastArg` and what happens with test 
> cases (which I guess need adding) that have both:
> 
>   -mno-fix-cmse-cve-2021-35465  -mfix-cmse-cve-2021-35465 
> 
> or
> 
>   -mfix-cmse-cve-2021-35465  -mno-fix-cmse-cve-2021-35465
That's the whole point of `getLastArg` as far as I understand: for options that 
can either enable or disable a feature, so that the last one wins. I'll add 
more tests.


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

https://reviews.llvm.org/D109157

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


[PATCH] D109320: [OpenCL][Docs] Update OpenCL 3.0 implementation status.

2021-09-07 Thread Anton Zabaznov via Phabricator via cfe-commits
azabaznov accepted this revision.
azabaznov added a comment.
This revision is now accepted and ready to land.

LGTM, thanks!


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

https://reviews.llvm.org/D109320

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


  1   2   >