[PATCH] D110669: [RISCV] Update Zba, Zbb, Zbc, and Zbs version from 0.93 to 1.0.

2021-10-12 Thread Craig Topper via Phabricator via cfe-commits
craig.topper updated this revision to Diff 379279.
craig.topper added a comment.

clang-format


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110669

Files:
  clang/lib/Basic/Targets/RISCV.cpp
  clang/lib/Driver/ToolChains/Arch/RISCV.cpp
  clang/test/Driver/riscv-arch.c
  clang/test/Preprocessor/riscv-target-features.c
  llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
  llvm/lib/Target/RISCV/MCTargetDesc/RISCVTargetStreamer.cpp
  llvm/lib/Target/RISCV/RISCVInstrInfoZb.td
  llvm/test/CodeGen/RISCV/attributes.ll
  llvm/test/MC/RISCV/attribute-arch.s

Index: llvm/test/MC/RISCV/attribute-arch.s
===
--- llvm/test/MC/RISCV/attribute-arch.s
+++ llvm/test/MC/RISCV/attribute-arch.s
@@ -40,13 +40,13 @@
 # CHECK: attribute  5, "rv32i2p0_v0p10"
 
 .attribute arch, "rv32izba"
-# CHECK: attribute  5, "rv32i2p0_zba0p93"
+# CHECK: attribute  5, "rv32i2p0_zba1p0"
 
 .attribute arch, "rv32izbb"
-# CHECK: attribute  5, "rv32i2p0_zbb0p93"
+# CHECK: attribute  5, "rv32i2p0_zbb1p0"
 
 .attribute arch, "rv32izbc"
-# CHECK: attribute  5, "rv32i2p0_zbc0p93"
+# CHECK: attribute  5, "rv32i2p0_zbc1p0"
 
 .attribute arch, "rv32izbe"
 # CHECK: attribute  5, "rv32i2p0_zbe0p93"
@@ -64,7 +64,7 @@
 # CHECK: attribute  5, "rv32i2p0_zbr0p93"
 
 .attribute arch, "rv32izbs"
-# CHECK: attribute  5, "rv32i2p0_zbs0p93"
+# CHECK: attribute  5, "rv32i2p0_zbs1p0"
 
 .attribute arch, "rv32izbt"
 # CHECK: attribute  5, "rv32i2p0_zbt0p93"
Index: llvm/test/CodeGen/RISCV/attributes.ll
===
--- llvm/test/CodeGen/RISCV/attributes.ll
+++ llvm/test/CodeGen/RISCV/attributes.ll
@@ -44,17 +44,17 @@
 ; RV32C: .attribute 5, "rv32i2p0_c2p0"
 ; RV32V: .attribute 5, "rv32i2p0_v0p10_zvamo0p10_zvlsseg0p10"
 ; RV32ZFH: .attribute 5, "rv32i2p0_f2p0_zfh0p1"
-; RV32ZBA: .attribute 5, "rv32i2p0_zba0p93"
-; RV32ZBB: .attribute 5, "rv32i2p0_zbb0p93"
-; RV32ZBC: .attribute 5, "rv32i2p0_zbc0p93"
+; RV32ZBA: .attribute 5, "rv32i2p0_zba1p0"
+; RV32ZBB: .attribute 5, "rv32i2p0_zbb1p0"
+; RV32ZBC: .attribute 5, "rv32i2p0_zbc1p0"
 ; RV32ZBE: .attribute 5, "rv32i2p0_zbe0p93"
 ; RV32ZBF: .attribute 5, "rv32i2p0_zbf0p93"
 ; RV32ZBM: .attribute 5, "rv32i2p0_zbm0p93"
 ; RV32ZBP: .attribute 5, "rv32i2p0_zbp0p93"
 ; RV32ZBR: .attribute 5, "rv32i2p0_zbr0p93"
-; RV32ZBS: .attribute 5, "rv32i2p0_zbs0p93"
+; RV32ZBS: .attribute 5, "rv32i2p0_zbs1p0"
 ; RV32ZBT: .attribute 5, "rv32i2p0_zbt0p93"
-; RV32COMBINED: .attribute 5, "rv32i2p0_f2p0_v0p10_zfh0p1_zbb0p93_zvamo0p10_zvlsseg0p10"
+; RV32COMBINED: .attribute 5, "rv32i2p0_f2p0_v0p10_zfh0p1_zbb1p0_zvamo0p10_zvlsseg0p10"
 
 ; RV64M: .attribute 5, "rv64i2p0_m2p0"
 ; RV64A: .attribute 5, "rv64i2p0_a2p0"
@@ -62,18 +62,18 @@
 ; RV64D: .attribute 5, "rv64i2p0_f2p0_d2p0"
 ; RV64C: .attribute 5, "rv64i2p0_c2p0"
 ; RV64ZFH: .attribute 5, "rv64i2p0_f2p0_zfh0p1"
-; RV64ZBA: .attribute 5, "rv64i2p0_zba0p93"
-; RV64ZBB: .attribute 5, "rv64i2p0_zbb0p93"
-; RV64ZBC: .attribute 5, "rv64i2p0_zbc0p93"
+; RV64ZBA: .attribute 5, "rv64i2p0_zba1p0"
+; RV64ZBB: .attribute 5, "rv64i2p0_zbb1p0"
+; RV64ZBC: .attribute 5, "rv64i2p0_zbc1p0"
 ; RV64ZBE: .attribute 5, "rv64i2p0_zbe0p93"
 ; RV64ZBF: .attribute 5, "rv64i2p0_zbf0p93"
 ; RV64ZBM: .attribute 5, "rv64i2p0_zbm0p93"
 ; RV64ZBP: .attribute 5, "rv64i2p0_zbp0p93"
 ; RV64ZBR: .attribute 5, "rv64i2p0_zbr0p93"
-; RV64ZBS: .attribute 5, "rv64i2p0_zbs0p93"
+; RV64ZBS: .attribute 5, "rv64i2p0_zbs1p0"
 ; RV64ZBT: .attribute 5, "rv64i2p0_zbt0p93"
 ; RV64V: .attribute 5, "rv64i2p0_v0p10_zvamo0p10_zvlsseg0p10"
-; RV64COMBINED: .attribute 5, "rv64i2p0_f2p0_v0p10_zfh0p1_zbb0p93_zvamo0p10_zvlsseg0p10"
+; RV64COMBINED: .attribute 5, "rv64i2p0_f2p0_v0p10_zfh0p1_zbb1p0_zvamo0p10_zvlsseg0p10"
 
 
 define i32 @addi(i32 %a) {
Index: llvm/lib/Target/RISCV/RISCVInstrInfoZb.td
===
--- llvm/lib/Target/RISCV/RISCVInstrInfoZb.td
+++ llvm/lib/Target/RISCV/RISCVInstrInfoZb.td
@@ -7,7 +7,17 @@
 //===--===//
 //
 // This file describes the RISC-V instructions from the standard Bitmanip
-// extensions, version 0.93.
+// extensions, versions:
+//   Zba - 1.0
+//   Zbb - 1.0
+//   Zbc - 1.0
+//   Zbs - 1.0
+//   Zbe - 0.93
+//   Zbf - 0.93
+//   Zbm - 0.93
+//   Zbp - 0.93
+//   Zbr - 0.93
+//   Zbt - 0.93
 // This version is still experimental as the Bitmanip extensions haven't been
 // ratified yet.
 //
@@ -485,15 +495,6 @@
 Sched<[WriteRotateReg32, ReadRotateReg32, ReadRotateReg32]>;
 } // Predicates = [HasStdExtZbbOrZbp, IsRV64]
 
-let Predicates = [HasStdExtZbs, IsRV64] in {
-// NOTE: These instructions have been removed from the 0.94 spec. As a result
-// we have no isel patterns for them.
-def BCLRW : ALUW_rr<0b0100100, 0b001, "bclrw">, 

[PATCH] D111078: [AIX] Enable int128 in 64 bit mode

2021-10-12 Thread Kai Luo via Phabricator via cfe-commits
lkail added a comment.

I would like to see more aix triple added to existing tests involving ABI in 
`llvm/test/CodeGen/PowerPC`(such as ppc64-i128-abi.ll), since AIX has 
independent calling convention lowering and is different from linux.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111078

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


[PATCH] D111270: [clang] Pass -clear-ast-before-backend in Clang::ConstructJob()

2021-10-12 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks created this revision.
aeubanks updated this revision to Diff 378327.
aeubanks added a comment.
aeubanks edited the summary of this revision.
aeubanks retitled this revision from "[clang] Always pass 
-clear-ast-before-backend" to "[clang] Pass -clear-ast-before-backend".
aeubanks edited the summary of this revision.
aeubanks added reviewers: rnk, dblaikie.
aeubanks retitled this revision from "[clang] Pass -clear-ast-before-backend" 
to "[clang] Pass -clear-ast-before-backend in Clang::ConstructJob()".
aeubanks published this revision for review.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

update


This clears the memory used for the Clang AST before we run LLVM passes.

https://llvm-compile-time-tracker.com/compare.php?from=b6a8c695542b2987eb9a203d5663a0740cb4725f=05aa5c451dd87b6a8d6c2410eaccb25edf15a16f=max-rss
shows significant memory savings with no slowdown (in fact -O0 slightly speeds 
up).

For more background, see
https://lists.llvm.org/pipermail/cfe-dev/2021-September/068930.html.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D111270

Files:
  clang/lib/Driver/ToolChains/Clang.cpp


Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -4661,6 +4661,7 @@
   // cleanup.
   if (!C.isForDiagnostics())
 CmdArgs.push_back("-disable-free");
+  CmdArgs.push_back("-clear-ast-before-backend");
 
 #ifdef NDEBUG
   const bool IsAssertBuild = false;


Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -4661,6 +4661,7 @@
   // cleanup.
   if (!C.isForDiagnostics())
 CmdArgs.push_back("-disable-free");
+  CmdArgs.push_back("-clear-ast-before-backend");
 
 #ifdef NDEBUG
   const bool IsAssertBuild = false;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D110669: [RISCV] Update Zba, Zbb, Zbc, and Zbs version from 0.93 to 1.0.

2021-10-12 Thread Shao-Ce SUN via Phabricator via cfe-commits
achieveartificialintelligence added inline comments.



Comment at: clang/lib/Driver/ToolChains/Arch/RISCV.cpp:63-65
+  if (Ext == "zbe" ||
   Ext == "zbf" || Ext == "zbm" || Ext == "zbp" || Ext == "zbr" ||
+  Ext == "zbt")

Need format here?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110669

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


[PATCH] D110669: [RISCV] Update Zba, Zbb, Zbc, and Zbs version from 0.93 to 1.0.

2021-10-12 Thread Craig Topper via Phabricator via cfe-commits
craig.topper updated this revision to Diff 379278.
craig.topper added a comment.

Add back dropped changes to RISCV.td


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110669

Files:
  clang/lib/Basic/Targets/RISCV.cpp
  clang/lib/Driver/ToolChains/Arch/RISCV.cpp
  clang/test/Driver/riscv-arch.c
  clang/test/Preprocessor/riscv-target-features.c
  llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
  llvm/lib/Target/RISCV/MCTargetDesc/RISCVTargetStreamer.cpp
  llvm/lib/Target/RISCV/RISCVInstrInfoZb.td
  llvm/test/CodeGen/RISCV/attributes.ll
  llvm/test/MC/RISCV/attribute-arch.s

Index: llvm/test/MC/RISCV/attribute-arch.s
===
--- llvm/test/MC/RISCV/attribute-arch.s
+++ llvm/test/MC/RISCV/attribute-arch.s
@@ -40,13 +40,13 @@
 # CHECK: attribute  5, "rv32i2p0_v0p10"
 
 .attribute arch, "rv32izba"
-# CHECK: attribute  5, "rv32i2p0_zba0p93"
+# CHECK: attribute  5, "rv32i2p0_zba1p0"
 
 .attribute arch, "rv32izbb"
-# CHECK: attribute  5, "rv32i2p0_zbb0p93"
+# CHECK: attribute  5, "rv32i2p0_zbb1p0"
 
 .attribute arch, "rv32izbc"
-# CHECK: attribute  5, "rv32i2p0_zbc0p93"
+# CHECK: attribute  5, "rv32i2p0_zbc1p0"
 
 .attribute arch, "rv32izbe"
 # CHECK: attribute  5, "rv32i2p0_zbe0p93"
@@ -64,7 +64,7 @@
 # CHECK: attribute  5, "rv32i2p0_zbr0p93"
 
 .attribute arch, "rv32izbs"
-# CHECK: attribute  5, "rv32i2p0_zbs0p93"
+# CHECK: attribute  5, "rv32i2p0_zbs1p0"
 
 .attribute arch, "rv32izbt"
 # CHECK: attribute  5, "rv32i2p0_zbt0p93"
Index: llvm/test/CodeGen/RISCV/attributes.ll
===
--- llvm/test/CodeGen/RISCV/attributes.ll
+++ llvm/test/CodeGen/RISCV/attributes.ll
@@ -44,17 +44,17 @@
 ; RV32C: .attribute 5, "rv32i2p0_c2p0"
 ; RV32V: .attribute 5, "rv32i2p0_v0p10_zvamo0p10_zvlsseg0p10"
 ; RV32ZFH: .attribute 5, "rv32i2p0_f2p0_zfh0p1"
-; RV32ZBA: .attribute 5, "rv32i2p0_zba0p93"
-; RV32ZBB: .attribute 5, "rv32i2p0_zbb0p93"
-; RV32ZBC: .attribute 5, "rv32i2p0_zbc0p93"
+; RV32ZBA: .attribute 5, "rv32i2p0_zba1p0"
+; RV32ZBB: .attribute 5, "rv32i2p0_zbb1p0"
+; RV32ZBC: .attribute 5, "rv32i2p0_zbc1p0"
 ; RV32ZBE: .attribute 5, "rv32i2p0_zbe0p93"
 ; RV32ZBF: .attribute 5, "rv32i2p0_zbf0p93"
 ; RV32ZBM: .attribute 5, "rv32i2p0_zbm0p93"
 ; RV32ZBP: .attribute 5, "rv32i2p0_zbp0p93"
 ; RV32ZBR: .attribute 5, "rv32i2p0_zbr0p93"
-; RV32ZBS: .attribute 5, "rv32i2p0_zbs0p93"
+; RV32ZBS: .attribute 5, "rv32i2p0_zbs1p0"
 ; RV32ZBT: .attribute 5, "rv32i2p0_zbt0p93"
-; RV32COMBINED: .attribute 5, "rv32i2p0_f2p0_v0p10_zfh0p1_zbb0p93_zvamo0p10_zvlsseg0p10"
+; RV32COMBINED: .attribute 5, "rv32i2p0_f2p0_v0p10_zfh0p1_zbb1p0_zvamo0p10_zvlsseg0p10"
 
 ; RV64M: .attribute 5, "rv64i2p0_m2p0"
 ; RV64A: .attribute 5, "rv64i2p0_a2p0"
@@ -62,18 +62,18 @@
 ; RV64D: .attribute 5, "rv64i2p0_f2p0_d2p0"
 ; RV64C: .attribute 5, "rv64i2p0_c2p0"
 ; RV64ZFH: .attribute 5, "rv64i2p0_f2p0_zfh0p1"
-; RV64ZBA: .attribute 5, "rv64i2p0_zba0p93"
-; RV64ZBB: .attribute 5, "rv64i2p0_zbb0p93"
-; RV64ZBC: .attribute 5, "rv64i2p0_zbc0p93"
+; RV64ZBA: .attribute 5, "rv64i2p0_zba1p0"
+; RV64ZBB: .attribute 5, "rv64i2p0_zbb1p0"
+; RV64ZBC: .attribute 5, "rv64i2p0_zbc1p0"
 ; RV64ZBE: .attribute 5, "rv64i2p0_zbe0p93"
 ; RV64ZBF: .attribute 5, "rv64i2p0_zbf0p93"
 ; RV64ZBM: .attribute 5, "rv64i2p0_zbm0p93"
 ; RV64ZBP: .attribute 5, "rv64i2p0_zbp0p93"
 ; RV64ZBR: .attribute 5, "rv64i2p0_zbr0p93"
-; RV64ZBS: .attribute 5, "rv64i2p0_zbs0p93"
+; RV64ZBS: .attribute 5, "rv64i2p0_zbs1p0"
 ; RV64ZBT: .attribute 5, "rv64i2p0_zbt0p93"
 ; RV64V: .attribute 5, "rv64i2p0_v0p10_zvamo0p10_zvlsseg0p10"
-; RV64COMBINED: .attribute 5, "rv64i2p0_f2p0_v0p10_zfh0p1_zbb0p93_zvamo0p10_zvlsseg0p10"
+; RV64COMBINED: .attribute 5, "rv64i2p0_f2p0_v0p10_zfh0p1_zbb1p0_zvamo0p10_zvlsseg0p10"
 
 
 define i32 @addi(i32 %a) {
Index: llvm/lib/Target/RISCV/RISCVInstrInfoZb.td
===
--- llvm/lib/Target/RISCV/RISCVInstrInfoZb.td
+++ llvm/lib/Target/RISCV/RISCVInstrInfoZb.td
@@ -7,7 +7,17 @@
 //===--===//
 //
 // This file describes the RISC-V instructions from the standard Bitmanip
-// extensions, version 0.93.
+// extensions, versions:
+//   Zba - 1.0
+//   Zbb - 1.0
+//   Zbc - 1.0
+//   Zbs - 1.0
+//   Zbe - 0.93
+//   Zbf - 0.93
+//   Zbm - 0.93
+//   Zbp - 0.93
+//   Zbr - 0.93
+//   Zbt - 0.93
 // This version is still experimental as the Bitmanip extensions haven't been
 // ratified yet.
 //
@@ -485,15 +495,6 @@
 Sched<[WriteRotateReg32, ReadRotateReg32, ReadRotateReg32]>;
 } // Predicates = [HasStdExtZbbOrZbp, IsRV64]
 
-let Predicates = [HasStdExtZbs, IsRV64] in {
-// NOTE: These instructions have been removed from the 0.94 spec. As a result
-// we have no isel patterns for them.
-def BCLRW : 

[PATCH] D110669: [RISCV] Update Zba, Zbb, Zbc, and Zbs version from 0.93 to 1.0.

2021-10-12 Thread Craig Topper via Phabricator via cfe-commits
craig.topper updated this revision to Diff 379276.
craig.topper added a comment.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110669

Files:
  clang/lib/Basic/Targets/RISCV.cpp
  clang/lib/Driver/ToolChains/Arch/RISCV.cpp
  clang/test/Driver/riscv-arch.c
  clang/test/Preprocessor/riscv-target-features.c
  llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
  llvm/lib/Target/RISCV/MCTargetDesc/RISCVTargetStreamer.cpp
  llvm/test/CodeGen/RISCV/attributes.ll
  llvm/test/MC/RISCV/attribute-arch.s

Index: llvm/test/MC/RISCV/attribute-arch.s
===
--- llvm/test/MC/RISCV/attribute-arch.s
+++ llvm/test/MC/RISCV/attribute-arch.s
@@ -40,13 +40,13 @@
 # CHECK: attribute  5, "rv32i2p0_v0p10"
 
 .attribute arch, "rv32izba"
-# CHECK: attribute  5, "rv32i2p0_zba0p93"
+# CHECK: attribute  5, "rv32i2p0_zba1p0"
 
 .attribute arch, "rv32izbb"
-# CHECK: attribute  5, "rv32i2p0_zbb0p93"
+# CHECK: attribute  5, "rv32i2p0_zbb1p0"
 
 .attribute arch, "rv32izbc"
-# CHECK: attribute  5, "rv32i2p0_zbc0p93"
+# CHECK: attribute  5, "rv32i2p0_zbc1p0"
 
 .attribute arch, "rv32izbe"
 # CHECK: attribute  5, "rv32i2p0_zbe0p93"
@@ -64,7 +64,7 @@
 # CHECK: attribute  5, "rv32i2p0_zbr0p93"
 
 .attribute arch, "rv32izbs"
-# CHECK: attribute  5, "rv32i2p0_zbs0p93"
+# CHECK: attribute  5, "rv32i2p0_zbs1p0"
 
 .attribute arch, "rv32izbt"
 # CHECK: attribute  5, "rv32i2p0_zbt0p93"
Index: llvm/test/CodeGen/RISCV/attributes.ll
===
--- llvm/test/CodeGen/RISCV/attributes.ll
+++ llvm/test/CodeGen/RISCV/attributes.ll
@@ -44,17 +44,17 @@
 ; RV32C: .attribute 5, "rv32i2p0_c2p0"
 ; RV32V: .attribute 5, "rv32i2p0_v0p10_zvamo0p10_zvlsseg0p10"
 ; RV32ZFH: .attribute 5, "rv32i2p0_f2p0_zfh0p1"
-; RV32ZBA: .attribute 5, "rv32i2p0_zba0p93"
-; RV32ZBB: .attribute 5, "rv32i2p0_zbb0p93"
-; RV32ZBC: .attribute 5, "rv32i2p0_zbc0p93"
+; RV32ZBA: .attribute 5, "rv32i2p0_zba1p0"
+; RV32ZBB: .attribute 5, "rv32i2p0_zbb1p0"
+; RV32ZBC: .attribute 5, "rv32i2p0_zbc1p0"
 ; RV32ZBE: .attribute 5, "rv32i2p0_zbe0p93"
 ; RV32ZBF: .attribute 5, "rv32i2p0_zbf0p93"
 ; RV32ZBM: .attribute 5, "rv32i2p0_zbm0p93"
 ; RV32ZBP: .attribute 5, "rv32i2p0_zbp0p93"
 ; RV32ZBR: .attribute 5, "rv32i2p0_zbr0p93"
-; RV32ZBS: .attribute 5, "rv32i2p0_zbs0p93"
+; RV32ZBS: .attribute 5, "rv32i2p0_zbs1p0"
 ; RV32ZBT: .attribute 5, "rv32i2p0_zbt0p93"
-; RV32COMBINED: .attribute 5, "rv32i2p0_f2p0_v0p10_zfh0p1_zbb0p93_zvamo0p10_zvlsseg0p10"
+; RV32COMBINED: .attribute 5, "rv32i2p0_f2p0_v0p10_zfh0p1_zbb1p0_zvamo0p10_zvlsseg0p10"
 
 ; RV64M: .attribute 5, "rv64i2p0_m2p0"
 ; RV64A: .attribute 5, "rv64i2p0_a2p0"
@@ -62,18 +62,18 @@
 ; RV64D: .attribute 5, "rv64i2p0_f2p0_d2p0"
 ; RV64C: .attribute 5, "rv64i2p0_c2p0"
 ; RV64ZFH: .attribute 5, "rv64i2p0_f2p0_zfh0p1"
-; RV64ZBA: .attribute 5, "rv64i2p0_zba0p93"
-; RV64ZBB: .attribute 5, "rv64i2p0_zbb0p93"
-; RV64ZBC: .attribute 5, "rv64i2p0_zbc0p93"
+; RV64ZBA: .attribute 5, "rv64i2p0_zba1p0"
+; RV64ZBB: .attribute 5, "rv64i2p0_zbb1p0"
+; RV64ZBC: .attribute 5, "rv64i2p0_zbc1p0"
 ; RV64ZBE: .attribute 5, "rv64i2p0_zbe0p93"
 ; RV64ZBF: .attribute 5, "rv64i2p0_zbf0p93"
 ; RV64ZBM: .attribute 5, "rv64i2p0_zbm0p93"
 ; RV64ZBP: .attribute 5, "rv64i2p0_zbp0p93"
 ; RV64ZBR: .attribute 5, "rv64i2p0_zbr0p93"
-; RV64ZBS: .attribute 5, "rv64i2p0_zbs0p93"
+; RV64ZBS: .attribute 5, "rv64i2p0_zbs1p0"
 ; RV64ZBT: .attribute 5, "rv64i2p0_zbt0p93"
 ; RV64V: .attribute 5, "rv64i2p0_v0p10_zvamo0p10_zvlsseg0p10"
-; RV64COMBINED: .attribute 5, "rv64i2p0_f2p0_v0p10_zfh0p1_zbb0p93_zvamo0p10_zvlsseg0p10"
+; RV64COMBINED: .attribute 5, "rv64i2p0_f2p0_v0p10_zfh0p1_zbb1p0_zvamo0p10_zvlsseg0p10"
 
 
 define i32 @addi(i32 %a) {
Index: llvm/lib/Target/RISCV/MCTargetDesc/RISCVTargetStreamer.cpp
===
--- llvm/lib/Target/RISCV/MCTargetDesc/RISCVTargetStreamer.cpp
+++ llvm/lib/Target/RISCV/MCTargetDesc/RISCVTargetStreamer.cpp
@@ -65,11 +65,11 @@
   if (STI.hasFeature(RISCV::FeatureStdExtZfh))
 Arch += "_zfh0p1";
   if (STI.hasFeature(RISCV::FeatureStdExtZba))
-Arch += "_zba0p93";
+Arch += "_zba1p0";
   if (STI.hasFeature(RISCV::FeatureStdExtZbb))
-Arch += "_zbb0p93";
+Arch += "_zbb1p0";
   if (STI.hasFeature(RISCV::FeatureStdExtZbc))
-Arch += "_zbc0p93";
+Arch += "_zbc1p0";
   if (STI.hasFeature(RISCV::FeatureStdExtZbe))
 Arch += "_zbe0p93";
   if (STI.hasFeature(RISCV::FeatureStdExtZbf))
@@ -81,7 +81,7 @@
   if (STI.hasFeature(RISCV::FeatureStdExtZbr))
 Arch += "_zbr0p93";
   if (STI.hasFeature(RISCV::FeatureStdExtZbs))
-Arch += "_zbs0p93";
+Arch += "_zbs1p0";
   if (STI.hasFeature(RISCV::FeatureStdExtZbt))
 Arch += "_zbt0p93";
   if 

[PATCH] D111692: [RISCV] Remove Zvamo C intrinsics and builtins.

2021-10-12 Thread Craig Topper via Phabricator via cfe-commits
craig.topper created this revision.
craig.topper added reviewers: kito-cheng, HsiangKai, khchen, rogfer01, 
frasercrmck, arcbbb.
Herald added subscribers: achieveartificialintelligence, StephenFan, vkmr, 
evandro, luismarques, apazos, sameer.abuasal, s.egerton, Jim, benna, psnobl, 
jocewei, PkmX, the_o, brucehoult, MartinMosbeck, edward-jones, zzheng, jrtc27, 
shiva0217, niosHD, sabuasal, simoncook, johnrusso, rbar, asb.
craig.topper requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay.
Herald added a project: clang.

Zvamo is not part of the 1.0 V spec. Remove it for now.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D111692

Files:
  clang/include/clang/Basic/riscv_vector.td
  clang/lib/Basic/Targets/RISCV.cpp
  clang/lib/Basic/Targets/RISCV.h
  clang/lib/Driver/ToolChains/Arch/RISCV.cpp
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vamoadd.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vamoand.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vamomax.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vamomin.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vamoor.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vamoswap.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vamoxor.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vamoadd.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vamoand.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vamomax.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vamomin.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vamoor.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vamoswap.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vamoxor.c
  clang/test/Driver/riscv-arch.c
  clang/test/Preprocessor/riscv-target-features.c
  clang/utils/TableGen/RISCVVEmitter.cpp

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


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

2021-10-12 Thread Shao-Ce SUN via Phabricator via cfe-commits
achieveartificialintelligence updated this revision to Diff 379272.
achieveartificialintelligence marked an inline comment as done.
achieveartificialintelligence added a comment.

Add arch info


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93298

Files:
  llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
  llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp
  llvm/lib/Target/RISCV/MCTargetDesc/RISCVTargetStreamer.cpp
  llvm/lib/Target/RISCV/RISCV.td
  llvm/test/MC/RISCV/attribute-arch.s
  llvm/test/MC/RISCV/rv32i-invalid.s

Index: llvm/test/MC/RISCV/rv32i-invalid.s
===
--- llvm/test/MC/RISCV/rv32i-invalid.s
+++ llvm/test/MC/RISCV/rv32i-invalid.s
@@ -173,9 +173,9 @@
 amomaxu.w s5, s4, (s3) # CHECK: :[[@LINE]]:1: error: instruction requires the following: 'A' (Atomic Instructions)
 fadd.s ft0, ft1, ft2 # CHECK: :[[@LINE]]:1: error: instruction requires the following: 'F' (Single-Precision Floating-Point)
 fadd.h ft0, ft1, ft2 # CHECK: :[[@LINE]]:1: error: instruction requires the following: 'Zfh' (Half-Precision Floating-Point)
-fadd.h a0, a1, a2 # CHECK: :[[@LINE]]:1: error: instruction requires the following: 'Zhinx' (Half Float in Integer)
 fadd.s a0, a1, a2 # CHECK: :[[@LINE]]:1: error: instruction requires the following: 'Zfinx' (Float in Integer)
 fadd.d a0, a2, a4 # CHECK: :[[@LINE]]:1: error: instruction requires the following: 'Zdinx' (Double in Integer)
+fadd.h a0, a1, a2 # CHECK: :[[@LINE]]:1: error: instruction requires the following: 'Zhinx' (Half Float in Integer)
 
 # Using floating point registers when integer registers are expected
 addi a2, ft0, 24 # CHECK: :[[@LINE]]:10: error: invalid operand for instruction
Index: llvm/test/MC/RISCV/attribute-arch.s
===
--- llvm/test/MC/RISCV/attribute-arch.s
+++ llvm/test/MC/RISCV/attribute-arch.s
@@ -72,6 +72,18 @@
 .attribute arch, "rv32ifzfh"
 # CHECK: attribute  5, "rv32i2p0_f2p0_zfh0p1"
 
+.attribute arch, "rv32izfinx"
+# CHECK: attribute  5, "rv32i2p0_zfinx0p1"
+
+.attribute arch, "rv32izdinx"
+# CHECK: attribute  5, "rv32i2p0_zfinx0p1_zdinx0p1"
+
+.attribute arch, "rv32izhinx"
+# CHECK: attribute  5, "rv32i2p0_zfinx0p1_zhinx0p1"
+
+.attribute arch, "rv32izhinxmin"
+# CHECK: attribute  5, "rv32i2p0_zfinx0p1_zhinxmin0p1"
+
 .attribute arch, "rv32ivzvamo_zvlsseg"
 # CHECK: attribute  5, "rv32i2p0_v0p10_zvamo0p10_zvlsseg0p10"
 
Index: llvm/lib/Target/RISCV/RISCV.td
===
--- llvm/lib/Target/RISCV/RISCV.td
+++ llvm/lib/Target/RISCV/RISCV.td
@@ -49,42 +49,42 @@
  AssemblerPredicate<(all_of FeatureStdExtZfh),
  "'Zfh' (Half-Precision Floating-Point)">;
 
-def FeatureExtZfinx
+def FeatureStdExtZfinx
 : SubtargetFeature<"experimental-zfinx", "HasStdExtZfinx", "true",
"'Zfinx' (Float in Integer)">;
 def HasStdExtZfinx : Predicate<"Subtarget->hasStdExtZfinx()">,
-   AssemblerPredicate<(all_of FeatureExtZfinx),
+   AssemblerPredicate<(all_of FeatureStdExtZfinx),
"'Zfinx' (Float in Integer)">;
 
-def FeatureExtZdinx
+def FeatureStdExtZdinx
 : SubtargetFeature<"experimental-zdinx", "HasStdExtZdinx", "true",
"'Zdinx' (Double in Integer)",
-   [FeatureExtZfinx]>;
+   [FeatureStdExtZfinx]>;
 def HasStdExtZdinx : Predicate<"Subtarget->hasStdExtZdinx()">,
-   AssemblerPredicate<(all_of FeatureExtZdinx),
+   AssemblerPredicate<(all_of FeatureStdExtZdinx),
"'Zdinx' (Double in Integer)">;
 
-def FeatureExtZhinx
+def FeatureStdExtZhinx
 : SubtargetFeature<"experimental-zhinx", "HasStdExtZhinx", "true",
"'Zhinx' (Half Float in Integer)",
-   [FeatureExtZfinx]>;
+   [FeatureStdExtZfinx]>;
 def HasStdExtZhinx : Predicate<"Subtarget->hasStdExtZhinx()">,
-   AssemblerPredicate<(all_of FeatureExtZhinx),
+   AssemblerPredicate<(all_of FeatureStdExtZhinx),
"'Zhinx' (Half Float in Integer)">;
 
-def FeatureExtZhinxmin
+def FeatureStdExtZhinxmin
 : SubtargetFeature<"experimental-zhinxmin", "HasStdExtZhinxmin", "true",
"'Zhinxmin' (Half Float in Integer Minimal)",
-   [FeatureExtZfinx]>;
+   [FeatureStdExtZfinx]>;
 def HasStdExtZhinxmin : Predicate<"Subtarget->hasStdExtZhinxmin()">,
-  AssemblerPredicate<(all_of FeatureExtZhinxmin),
+  AssemblerPredicate<(all_of 

[PATCH] D111617: [RISCV] Lazily add RVV C intrinsics.

2021-10-12 Thread Hsiangkai Wang via Phabricator via cfe-commits
HsiangKai added a comment.

As discussed in D110684 , developers complain 
not only compile time, but also binary size & memory usage caused by RVV 
intrinsics. We need to consider binary size, too. Is there other way to handle 
it? Or we should go back to think about the design of RVV intrinsics?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111617

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


[PATCH] D111617: [RISCV] Lazily add RVV C intrinsics.

2021-10-12 Thread Hsiangkai Wang via Phabricator via cfe-commits
HsiangKai added a comment.

Although it reduces the header size, this patch will increase the binary size 
of clang.

Debug build:
Before this patch:

  textdatabss dec hex   
  filename
  263892591   10838284500232  275231107   1067b183  
  clang-14

After this patch:

  textdatabss dec hex   
  filename
  263909721   12085116500232  276495069   107afadd  
  clang-14

Release build:
Before this patch;

  textdatabss dec hex   
  filename
  382952171   8802976410264736481246671   1caf3dcf  
  clang-14

After this patch:

  textdatabss dec hex   
  filename
  387629483   9465258210264736492546801   1d5baaf1  
  clang-14


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111617

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


[PATCH] D110684: [RISCV] Define _m intrinsics as builtins, instead of macros.

2021-10-12 Thread Hsiangkai Wang via Phabricator via cfe-commits
HsiangKai added a comment.

We are working on a patch, D111617 , to 
reduce the large header size caused by abundant RISC-V vector intrinsics.
From the measurement depicted in D103228 , it 
should be helpful for compile time.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110684

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


[PATCH] D95168: [clang-format] Add InsertBraces option

2021-10-12 Thread Tiago Macarios via Phabricator via cfe-commits
tiagoma added a comment.

go for it


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95168

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


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

2021-10-12 Thread David Blaikie via cfe-commits
On Mon, Oct 11, 2021 at 2:46 PM Richard Smith  wrote:

> On Wed, 15 Sept 2021 at 13:52, David Blaikie  wrote:
>
>> On Tue, Sep 14, 2021 at 10:04 AM Richard Smith 
>> wrote:
>>
>>> On Mon, 13 Sept 2021 at 19:24, David Blaikie via cfe-commits <
>>> cfe-commits@lists.llvm.org> wrote:
>>>

 Author: David Blaikie
 Date: 2021-09-13T19:17:05-07:00
 New Revision: 2bd84938470bf2e337801faafb8a67710f46429d

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

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

 Since these map to the same effective type - render them the same/in the
 more legible way (const x[n]).

>>>
>>> Nice!
>>>
>>>
 Added:


 Modified:
 clang/lib/AST/TypePrinter.cpp
 clang/test/ARCMT/cxx-checking.mm
 clang/test/AST/ast-dump-APValue-arithmetic.cpp
 clang/test/AST/ast-dump-APValue-array.cpp
 clang/test/CXX/basic/basic.types/p10.cpp
 clang/test/Sema/assign.c
 clang/test/Sema/typedef-retain.c
 clang/test/SemaCXX/reinterpret-cast.cpp
 clang/test/SemaCXX/static-assert-cxx17.cpp

 Removed:




 
 diff  --git a/clang/lib/AST/TypePrinter.cpp
 b/clang/lib/AST/TypePrinter.cpp
 index aef1e4f3f4953..251db97c7db08 100644
 --- a/clang/lib/AST/TypePrinter.cpp
 +++ b/clang/lib/AST/TypePrinter.cpp
 @@ -200,11 +200,12 @@ bool TypePrinter::canPrefixQualifiers(const Type
 *T,
// type expands to a simple string.
bool CanPrefixQualifiers = false;
NeedARCStrongQualifier = false;
 -  Type::TypeClass TC = T->getTypeClass();
 +  const Type *UnderlyingType = T;
if (const auto *AT = dyn_cast(T))
 -TC = AT->desugar()->getTypeClass();
 +UnderlyingType = AT->desugar().getTypePtr();
if (const auto *Subst = dyn_cast(T))
 -TC = Subst->getReplacementType()->getTypeClass();
 +UnderlyingType = Subst->getReplacementType().getTypePtr();
 +  Type::TypeClass TC = UnderlyingType->getTypeClass();

switch (TC) {
  case Type::Auto:
 @@ -243,6 +244,9 @@ bool TypePrinter::canPrefixQualifiers(const Type *T,

  case Type::ConstantArray:
  case Type::IncompleteArray:
 +  return canPrefixQualifiers(
 +
 cast(UnderlyingType)->getElementType().getTypePtr(),
 +  NeedARCStrongQualifier);
  case Type::VariableArray:
  case Type::DependentSizedArray:

>>>
>>> Can we give these two cases the same treatment?
>>>
>>
>> Handled the DependentSizedArray in
>> https://github.com/llvm/llvm-project/commit/40acc0adad59ac39e9a7a02fcd93161298500c00
>>
>> But per the comment in that commit I wasn't able to reproduce the problem
>> with a variable array - though we could include it in the handling on
>> principle/for consistency, even without a test/etc. Perhaps there's a way
>> to test/provoke the behavior you might know that I couldn't figure out?
>>
>> Details from the commit:
>>
>> The VariableArray case I couldn't figure out how to test/provoke -
>> you
>>
>> can't write/form a variable array in any context other than a local
>>
>> variable that I know of, and in that case `const int x[n]` is the
>>
>> normalized form already (array-of-const) and you can't use typedefs
>>
>> (since you can't typedef int[n] with variable 'n') to force the
>>
>> const-array AST that would produce the undesirable type printing "int
>>
>> const [n]".
>>
>
> C has a fairly surprising rule here -- you actually can define a VLA type
> in a local typedef. For example,
>
> void f(int n) {
> typedef int arr[n];
> const arr x;
> }
>
> ... is valid in C. In C++ mode, this produces:
>
> :3:15: error: default initialization of an object of const type
> 'const arr' (aka 'int const[n]')
>
> (note, 'int const[n]' not 'const int[n]').
>

Oh, right, good to understand! Yep, fixed and tested with this:
39093279f2ede4af9048b89d048d7fe9182a50f8

Huh, funny diagnostic experience aside here: https://godbolt.org/z/W46b3qc49
void f(int i) {
typedef int x[i];
const x y = {};
}
:2:19: error: variable-sized object may not be initialized
typedef int x[i];
  ^

With no pointer/note/etc to the 'y' variable - the typedef and variable
could be quite far apart. The diagnostic would be hard to read/understand.


> Oh, also - another quirk of array type printing that I'd be up for
>> addressing if you've got an opinion on it:
>>
>> "int [n]" is printed with a space between the "int" and array.
>> "int *const[n]" is printed without a space before the array (though both
>> have a space after "int")
>>
>> ClangFormat formats 

[clang] 3909327 - Improve printing of const variable sized arrays

2021-10-12 Thread David Blaikie via cfe-commits

Author: David Blaikie
Date: 2021-10-12T19:04:53-07:00
New Revision: 39093279f2ede4af9048b89d048d7fe9182a50f8

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

LOG: Improve printing of const variable sized arrays

Follow-on from 40acc0adad59ac39e9a7a02fcd93161298500c00 with help from
Richard Smith on how to provoke this particular case.

Added: 
clang/test/Sema/vla.cpp

Modified: 
clang/lib/AST/TypePrinter.cpp

Removed: 




diff  --git a/clang/lib/AST/TypePrinter.cpp b/clang/lib/AST/TypePrinter.cpp
index 3c7a6b8b9e95..e573037db10e 100644
--- a/clang/lib/AST/TypePrinter.cpp
+++ b/clang/lib/AST/TypePrinter.cpp
@@ -242,6 +242,7 @@ bool TypePrinter::canPrefixQualifiers(const Type *T,
 T->isObjCQualifiedIdType() || T->isObjCQualifiedClassType();
   break;
 
+case Type::VariableArray:
 case Type::DependentSizedArray:
   NeedARCStrongQualifier = true;
   LLVM_FALLTHROUGH;
@@ -251,9 +252,6 @@ bool TypePrinter::canPrefixQualifiers(const Type *T,
   return canPrefixQualifiers(
   cast(UnderlyingType)->getElementType().getTypePtr(),
   NeedARCStrongQualifier);
-case Type::VariableArray:
-  NeedARCStrongQualifier = true;
-  LLVM_FALLTHROUGH;
 
 case Type::Adjusted:
 case Type::Decayed:

diff  --git a/clang/test/Sema/vla.cpp b/clang/test/Sema/vla.cpp
new file mode 100644
index ..b4416a07cf0e
--- /dev/null
+++ b/clang/test/Sema/vla.cpp
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only
+
+void f1(int n) {
+  typedef int x[n];
+  const x y; // expected-error {{default initialization of an object of const 
type 'const x' (aka 'const int [n]')}}
+}



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


[PATCH] D111617: [RISCV] Lazily add RVV C intrinsics.

2021-10-12 Thread Hsiangkai Wang via Phabricator via cfe-commits
HsiangKai added inline comments.



Comment at: clang/lib/Sema/SemaLookup.cpp:923
+
+  const RVVIntrinsicInfo *Intrinsic = std::find_if(
+  std::begin(RVVIntrinsicInfos), std::end(RVVIntrinsicInfos),

kito-cheng wrote:
> rogfer01 wrote:
> > Not for this patch: I think this table may be a bit large so all lookups 
> > (including those that will fail) will be slower after a `#pragma riscv 
> > intrinsic vector` is found.
> > 
> > Filtering them as fast as possible (looking at the spec shows that 
> > currently all RVV intrinsics start with `v`) or using some hash table (if 
> > too difficult to build at compile time we could build it the first time we 
> > get here?) might be something we want to do.
> OpenCL using a tablegen-based generator to generate a big swtich table to 
> speed up the lookup rather than linear scan, here is generated file:
> 
> https://gist.github.com/kito-cheng/46616c82c0f25e5df31ff5eaa14914ba#file-openclbuiltins-inc-L8055
> 
> I think we could using same approach to prevent the slow down.
Indeed, OpenCL generates a checking function, `isOpenCLBuiltin`, as the filter. 
I will use the similar approach to filter the queries.



Comment at: clang/lib/Sema/SemaLookup.cpp:1011
 
+  if (PP.getPredefines() == "#define __riscv_pragma_vector_intrinsics") {
+const TargetInfo  = Context.getTargetInfo();

rogfer01 wrote:
> This seems a bit fragile if there are more predefines than just this one. I 
> understand the intent is to avoid looking up the RVV builtin every time, only 
> do that if we have found the pragma, right?
> 
> Several pragma handlers receive a reference to `Sema` (in an object called 
> `Action` or `Actions`) and then they notify `Sema` (via a member function 
> that would have to be added to it) about having parsed the pragma. That could 
> be used to set some flag to true in `Sema` itself and also emit diagnostics 
> if we want (e.g. what if the pragma is used twice? can it be used anywhere?).
> 
> Do you think this would be workable?
I should add a flag somewhere as the checking condition. I will try to find a 
better way to do it. Thanks for your suggestion. I think it is workable.

The purpose of the pragma is to enable the lazily insertion. If users do not 
include `riscv_vector.h` and they use `vadd` as the function call, we will not 
treat it as a vector generic intrinsic.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111617

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


[PATCH] D107944: [hmaptool] Port to python3

2021-10-12 Thread Bruno Cardoso Lopes via Phabricator via cfe-commits
bruno added a comment.

Overall looks great but there are some test failures, looks like you also need 
to update line 223?

  --
  Traceback (most recent call last):
File "/var/lib/buildkite-agent/builds/llvm-project/build/bin/hmaptool", 
line 296, in 
  main()
File "/var/lib/buildkite-agent/builds/llvm-project/build/bin/hmaptool", 
line 293, in main
  commands[cmd](cmd, sys.argv[2:])
File "/var/lib/buildkite-agent/builds/llvm-project/build/bin/hmaptool", 
line 223, in action_write
  f.write(magic.encode())
  AttributeError: 'bytes' object has no attribute 'encode'
  --


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107944

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


[PATCH] D110684: [RISCV] Define _m intrinsics as builtins, instead of macros.

2021-10-12 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

This has been the first time RISC-V added something and caused 
performance/memory/test execution regression for other users.

The problem should be considered seriously (I don't even mind reverting the 
patch.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110684

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


[PATCH] D106755: Extended format string checking to wprintf/wscanf

2021-10-12 Thread Aaron Gyes via Phabricator via cfe-commits
floam added a comment.

still working on this?


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

https://reviews.llvm.org/D106755

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


[PATCH] D111665: [CUDA] Provide address space conversion builtins.

2021-10-12 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment.

In D111665#3059989 , @jdoerfert wrote:

> Except when it doesn't get instcombined away: https://godbolt.org/z/YE4EfEPde

Well, it does get translated into sensible PTX, so, while not ideal, it's not 
too big of a deal.
Using an integer is a sensible approach to prevent accidental load/store using 
a wrong address space.

An alternative would be to make conversion functions return a pointer with 
specific AS attribute, but that's clang-specific and it would not work for 
something that needs to plug in into CUDA headers that were written for NVCC.

So, yeah. It could be better, but it's tolerable. At least we didn't have to 
resort to using inline asm. :-)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111665

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


[PATCH] D111517: [X86] Remove little support we had for MPX

2021-10-12 Thread Fangrui Song via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc2d4fe51bb4f: [X86] Remove little support we had for MPX 
(authored by MaskRay).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111517

Files:
  clang/test/CodeGen/ms-inline-asm.c
  llvm/lib/Target/X86/Disassembler/X86Disassembler.cpp
  llvm/lib/Target/X86/Disassembler/X86DisassemblerDecoder.h
  llvm/lib/Target/X86/X86InstrInfo.cpp
  llvm/lib/Target/X86/X86InstrInfo.td
  llvm/lib/Target/X86/X86InstrMPX.td
  llvm/lib/Target/X86/X86RegisterInfo.td
  llvm/test/CodeGen/X86/ipra-reg-usage.ll
  llvm/test/MC/X86/mpx-encodings.s
  llvm/unittests/tools/llvm-exegesis/X86/SnippetGeneratorTest.cpp

Index: llvm/unittests/tools/llvm-exegesis/X86/SnippetGeneratorTest.cpp
===
--- llvm/unittests/tools/llvm-exegesis/X86/SnippetGeneratorTest.cpp
+++ llvm/unittests/tools/llvm-exegesis/X86/SnippetGeneratorTest.cpp
@@ -213,26 +213,6 @@
   ASSERT_TRUE(BC.Key.Instructions[0].getOperand(3).isImm());
 }
 
-TEST_F(X86ParallelSnippetGeneratorTest, ParallelInstruction) {
-  // - BNDCL32rr
-  // - Op0 Explicit Use RegClass(BNDR)
-  // - Op1 Explicit Use RegClass(GR32)
-  // - Var0 [Op0]
-  // - Var1 [Op1]
-  const unsigned Opcode = X86::BNDCL32rr;
-  const auto CodeTemplates = checkAndGetCodeTemplates(Opcode);
-  ASSERT_THAT(CodeTemplates, SizeIs(1));
-  const auto  = CodeTemplates[0];
-  EXPECT_THAT(CT.Info, HasSubstr("parallel"));
-  EXPECT_THAT(CT.Execution, ExecutionMode::UNKNOWN);
-  ASSERT_THAT(CT.Instructions, SizeIs(1));
-  const InstructionTemplate  = CT.Instructions[0];
-  EXPECT_THAT(IT.getOpcode(), Opcode);
-  ASSERT_THAT(IT.getVariableValues(), SizeIs(2));
-  EXPECT_THAT(IT.getVariableValues()[0], IsInvalid());
-  EXPECT_THAT(IT.getVariableValues()[1], IsInvalid());
-}
-
 TEST_F(X86ParallelSnippetGeneratorTest, SerialInstruction) {
   // - CDQ
   // - Op0 Implicit Def Reg(EAX)
Index: llvm/test/MC/X86/mpx-encodings.s
===
--- llvm/test/MC/X86/mpx-encodings.s
+++ /dev/null
@@ -1,41 +0,0 @@
-// RUN: llvm-mc -triple x86_64-- --show-encoding %s |\
-// RUN:   FileCheck %s --check-prefixes=CHECK,ENCODING
-
-// RUN: llvm-mc -triple x86_64-- -filetype=obj %s |\
-// RUN:   llvm-objdump -d - | FileCheck %s
-
-// CHECK: bndmk (%rax), %bnd0
-// ENCODING:  encoding: [0xf3,0x0f,0x1b,0x00]
-bndmk (%rax), %bnd0
-
-// CHECK: bndmk 1024(%rax), %bnd1
-// ENCODING:  encoding: [0xf3,0x0f,0x1b,0x88,0x00,0x04,0x00,0x00]
-bndmk 1024(%rax), %bnd1
-
-// CHECK: bndmov  %bnd2, %bnd1
-// ENCODING:  encoding: [0x66,0x0f,0x1a,0xca]
-bndmov %bnd2, %bnd1
-
-// CHECK: bndmov %bnd1, 1024(%r9)
-// ENCODING:  encoding: [0x66,0x41,0x0f,0x1b,0x89,0x00,0x04,0x00,0x00]
-bndmov %bnd1, 1024(%r9)
-
-// CHECK: bndstx %bnd1, 1024(%rax)
-// ENCODING:  encoding: [0x0f,0x1b,0x88,0x00,0x04,0x00,0x00]
-bndstx %bnd1, 1024(%rax)
-
-// CHECK: bndldx 1024(%r8), %bnd1
-// ENCODING:  encoding: [0x41,0x0f,0x1a,0x88,0x00,0x04,0x00,0x00]
-bndldx 1024(%r8), %bnd1
-
-// CHECK: bndcl 121(%r10), %bnd1
-// ENCODING:  encoding: [0xf3,0x41,0x0f,0x1a,0x4a,0x79]
-bndcl 121(%r10), %bnd1
-
-// CHECK: bndcn 121(%rcx), %bnd3
-// ENCODING:  encoding: [0xf2,0x0f,0x1b,0x59,0x79]
-bndcn 121(%rcx), %bnd3
-
-// CHECK: bndcu %rdx, %bnd3
-// ENCODING:  encoding: [0xf2,0x0f,0x1a,0xda]
-bndcu %rdx, %bnd3
Index: llvm/test/CodeGen/X86/ipra-reg-usage.ll
===
--- llvm/test/CodeGen/X86/ipra-reg-usage.ll
+++ llvm/test/CodeGen/X86/ipra-reg-usage.ll
@@ -3,7 +3,7 @@
 target triple = "x86_64-unknown-unknown"
 declare void @bar1()
 define preserve_allcc void @foo()#0 {
-; CHECK: foo Clobbered Registers: $cs $df $ds $eflags $eip $eiz $es $esp $fpcw $fpsw $fs $gs $hip $hsp $ip $mxcsr $rip $riz $rsp $sp $sph $spl $ss $ssp $tmmcfg $bnd0 $bnd1 $bnd2 $bnd3 $cr0 $cr1 $cr2 $cr3 $cr4 $cr5 $cr6 $cr7 $cr8 $cr9 $cr10 $cr11 $cr12 $cr13 $cr14 $cr15 $dr0 $dr1 $dr2 $dr3 $dr4 $dr5 $dr6 $dr7 $dr8 $dr9 $dr10 $dr11 $dr12 $dr13 $dr14 $dr15 $fp0 $fp1 $fp2 $fp3 $fp4 $fp5 $fp6 $fp7 $k0 $k1 $k2 $k3 $k4 $k5 $k6 $k7 $mm0 $mm1 $mm2 $mm3 $mm4 $mm5 $mm6 $mm7 $r11 $st0 $st1 $st2 $st3 $st4 $st5 $st6 $st7 $tmm0 $tmm1 $tmm2 $tmm3 $tmm4 $tmm5 $tmm6 $tmm7 $xmm16 $xmm17 $xmm18 $xmm19 $xmm20 $xmm21 $xmm22 $xmm23 $xmm24 $xmm25 $xmm26 $xmm27 $xmm28 $xmm29 $xmm30 $xmm31 $ymm0 $ymm1 $ymm2 $ymm3 $ymm4 $ymm5 $ymm6 $ymm7 $ymm8 $ymm9 $ymm10 $ymm11 $ymm12 $ymm13 $ymm14 $ymm15 $ymm16 $ymm17 $ymm18 $ymm19 $ymm20 $ymm21 $ymm22 $ymm23 $ymm24 $ymm25 $ymm26 $ymm27 $ymm28 $ymm29 $ymm30 $ymm31 $zmm0 $zmm1 $zmm2 $zmm3 $zmm4 $zmm5 $zmm6 $zmm7 $zmm8 $zmm9 $zmm10 $zmm11 $zmm12 $zmm13 $zmm14 $zmm15 $zmm16 $zmm17 $zmm18 $zmm19 $zmm20 $zmm21 $zmm22 $zmm23 $zmm24 $zmm25 $zmm26 $zmm27 $zmm28 $zmm29 $zmm30 $zmm31 $r11b $r11bh $r11d $r11w $r11wh $k0_k1 $k2_k3 

[clang] c2d4fe5 - [X86] Remove little support we had for MPX

2021-10-12 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2021-10-12T16:18:51-07:00
New Revision: c2d4fe51bb4f98870a2358a32809f849b0751d7c

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

LOG: [X86] Remove little support we had for MPX

GCC 9.1 removed Intel MPX support. Linux kernel removed MPX in 2019.
glibc 2.35 will remove MPX.

Our support is limited: we support assembling of bndmov but not bnd.
Just remove it.

Reviewed By: pengfei, skan

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

Added: 


Modified: 
clang/test/CodeGen/ms-inline-asm.c
llvm/lib/Target/X86/Disassembler/X86Disassembler.cpp
llvm/lib/Target/X86/Disassembler/X86DisassemblerDecoder.h
llvm/lib/Target/X86/X86InstrInfo.cpp
llvm/lib/Target/X86/X86InstrInfo.td
llvm/lib/Target/X86/X86RegisterInfo.td
llvm/test/CodeGen/X86/ipra-reg-usage.ll
llvm/unittests/tools/llvm-exegesis/X86/SnippetGeneratorTest.cpp

Removed: 
llvm/lib/Target/X86/X86InstrMPX.td
llvm/test/MC/X86/mpx-encodings.s



diff  --git a/clang/test/CodeGen/ms-inline-asm.c 
b/clang/test/CodeGen/ms-inline-asm.c
index d1e3552d31ac3..ef0345b2a867c 100644
--- a/clang/test/CodeGen/ms-inline-asm.c
+++ b/clang/test/CodeGen/ms-inline-asm.c
@@ -675,17 +675,6 @@ void t46() {
   // CHECK: call void asm sideeffect inteldialect "add eax, [eax + $$-128]", 
"~{eax},~{flags},~{dirflag},~{fpsr},~{flags}"()
 }
 
-void t47() {
-  // CHECK-LABEL: define{{.*}} void @t47
-  __asm {
-bndmk bnd0, dword ptr [eax]
-bndmk bnd1, dword ptr [ebx]
-bndmk bnd2, dword ptr [ecx]
-bndmk bnd3, dword ptr [edx]
-  }
-  // CHECK: call void asm sideeffect inteldialect "bndmk bnd0, dword ptr 
[eax]\0A\09bndmk bnd1, dword ptr [ebx]\0A\09bndmk bnd2, dword ptr 
[ecx]\0A\09bndmk bnd3, dword ptr [edx]", 
"~{bnd0},~{bnd1},~{bnd2},~{bnd3},~{dirflag},~{fpsr},~{flags}"()
-}
-
 void dot_operator(){
   // CHECK-LABEL: define{{.*}} void @dot_operator
__asm { mov eax, 3[ebx]A.b}

diff  --git a/llvm/lib/Target/X86/Disassembler/X86Disassembler.cpp 
b/llvm/lib/Target/X86/Disassembler/X86Disassembler.cpp
index 45d32de208309..908eb6d1fab13 100644
--- a/llvm/lib/Target/X86/Disassembler/X86Disassembler.cpp
+++ b/llvm/lib/Target/X86/Disassembler/X86Disassembler.cpp
@@ -806,10 +806,6 @@ static int readModRM(struct InternalInstruction *insn) {
   return prefix##_DR0 + index; 
\
 case TYPE_CONTROLREG:  
\
   return prefix##_CR0 + index; 
\
-case TYPE_BNDR:
\
-  if (index > 3)   
\
-*valid = 0;
\
-  return prefix##_BND0 + index;
\
 case TYPE_MVSIBX:  
\
   return prefix##_XMM0 + index;
\
 case TYPE_MVSIBY:  
\

diff  --git a/llvm/lib/Target/X86/Disassembler/X86DisassemblerDecoder.h 
b/llvm/lib/Target/X86/Disassembler/X86DisassemblerDecoder.h
index 4346f4c0055e3..95d3c8ede366f 100644
--- a/llvm/lib/Target/X86/Disassembler/X86DisassemblerDecoder.h
+++ b/llvm/lib/Target/X86/Disassembler/X86DisassemblerDecoder.h
@@ -374,12 +374,6 @@ namespace X86Disassembler {
   ENTRY(CR14) \
   ENTRY(CR15)
 
-#define REGS_BOUND\
-  ENTRY(BND0) \
-  ENTRY(BND1) \
-  ENTRY(BND2) \
-  ENTRY(BND3)
-
 #undef  REGS_TMM
 #define REGS_TMM  \
   ENTRY(TMM0) \
@@ -414,7 +408,6 @@ namespace X86Disassembler {
   REGS_SEGMENT\
   REGS_DEBUG  \
   REGS_CONTROL\
-  REGS_BOUND  \
   REGS_TMM\
   ENTRY(RIP)
 

diff  --git a/llvm/lib/Target/X86/X86InstrInfo.cpp 
b/llvm/lib/Target/X86/X86InstrInfo.cpp
index e06202d378a6a..3526955f28142 100644
--- a/llvm/lib/Target/X86/X86InstrInfo.cpp
+++ b/llvm/lib/Target/X86/X86InstrInfo.cpp
@@ -3718,12 +3718,6 @@ static unsigned getLoadStoreRegOpcode(Register Reg,
HasAVX? X86::VMOVUPSmr :
X86::MOVUPSmr);
 }
-if (X86::BNDRRegClass.hasSubClassEq(RC)) {
-  if (STI.is64Bit())
-return load ? X86::BNDMOV64rm : X86::BNDMOV64mr;
-  else
-return load ? X86::BNDMOV32rm : X86::BNDMOV32mr;
-}
 llvm_unreachable("Unknown 16-byte regclass");
   }
   case 32:

diff  --git a/llvm/lib/Target/X86/X86InstrInfo.td 
b/llvm/lib/Target/X86/X86InstrInfo.td
index 64bc3e9490524..6a619aff0a45c 100644
--- a/llvm/lib/Target/X86/X86InstrInfo.td
+++ b/llvm/lib/Target/X86/X86InstrInfo.td
@@ -3159,9 +3159,6 

[PATCH] D111665: [CUDA] Provide address space conversion builtins.

2021-10-12 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

In D111665#3059690 , @tra wrote:

> In D111665#3059427 , @jdoerfert 
> wrote:
>
>> Not loving the magic constants here but I don't think we have a enum or 
>> similar right now.
>
> Yup.
>
>> I also have to question the people that choose `size_t` here... we will end 
>> up with int2ptr(ptr2int(...)) IR everywhere if this is actually used 
>> (outside the asm uses in cuda).
>
> I guess size_t was 'good enough' to accommodate all pointer sizes (though it 
> should've been `uintptr_t`).
>
> I think this chain of conversions gets quickly instcombined away even at 
> `-O1`:
> E.g: https://godbolt.org/z/4vd94cEsj

Except when it doesn't get instcombined away: https://godbolt.org/z/YE4EfEPde


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111665

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


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

2021-10-12 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov marked 3 inline comments as done.
mizvekov added inline comments.



Comment at: clang/test/SemaCXX/sugared-auto.cpp:146
+return a;
+  return N(); // expected-error {{but deduced as 'SARS (*)() throw(Man, 
Vibrio)' (aka 'void (*)() throw(Man, Vibrio)')}}
+}

mizvekov wrote:
> rsmith wrote:
> > rsmith wrote:
> > > Why don't we get `Virus` as the deduced return type from line 143 here?
> > Oh, never mind, we've not updated the conditional expression handling to 
> > use `getCommonSugar` yet. We probably should -- it currently has a very 
> > minimal form of the same thing; see `Sema::FindCompositePointerType`. That 
> > can presumably be changed to use `getCommonSugar` once it strips down to a 
> > common type. On around `SemaExprCXX.cpp:6870`:
> > ```
> > -  QualType Composite = Composite1;
> > +  QualType Composite = Context.getCommonSugar(Composite1, Composite2);
> > ```
> Yeah, if you look into the next patch in the stack, which is still WIP, there 
> is a change that fixes this aspect of this test case, but it's a different 
> change than what you are proposing here. I will take a look again, but are 
> you proposing that I add this sort of changes to this same patch, or keep 
> things separate as I am trying to do?
> Either answer is fine, less patches means less rebuild time for me :-)
This is done in https://reviews.llvm.org/D111509


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111283

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


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

2021-10-12 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov created this revision.
mizvekov retitled this revision from "[clang] WIP: Use getCommonSugar in an 
assortment of places" to "[clang] WIP: use getCommonSugar in an assortment of 
places".
mizvekov updated this revision to Diff 378694.
mizvekov added a comment.
mizvekov updated this revision to Diff 378776.
Herald added subscribers: kbarton, nemanjai.
mizvekov updated this revision to Diff 378810.
mizvekov updated this revision to Diff 378820.
mizvekov updated this revision to Diff 378830.
mizvekov updated this revision to Diff 378831.
mizvekov updated this revision to Diff 378843.
mizvekov updated this revision to Diff 379197.
mizvekov retitled this revision from "[clang] WIP: use getCommonSugar in an 
assortment of places" to "[clang] use getCommonSugar in an assortment of 
places".
mizvekov published this revision for review.
Herald added projects: clang, Sanitizers, clang-tools-extra.
Herald added subscribers: cfe-commits, Sanitizers.

.


mizvekov added a comment.

.


mizvekov added a comment.

.


mizvekov added a comment.

.


mizvekov added a comment.

.


mizvekov added a comment.

.


mizvekov added a comment.

.


mizvekov added a comment.

.


For this patch, a simple search was performed for patterns where there are
two types (usually an LHS and an RHS) which are structurally the same, and there
is some result type which is resolved as either one of them (typically LHS for
consistency).

We change those cases to resolve as the common sugared type between those two,
utilizing the new infrastructure created for this purpose.

It is likely that we miss other cases where this change could be performed as
well.

Depends on D111283 

Signed-off-by: Matheus Izvekov 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D111509

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

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

[PATCH] D111680: [NFC] Rename EmitAssemblyHelper new/legacy PM methods

2021-10-12 Thread Arthur Eubanks 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 rGb6a8c695542b: [NFC] Rename EmitAssemblyHelper new/legacy PM 
methods (authored by aeubanks).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111680

Files:
  clang/lib/CodeGen/BackendUtil.cpp


Index: clang/lib/CodeGen/BackendUtil.cpp
===
--- clang/lib/CodeGen/BackendUtil.cpp
+++ clang/lib/CodeGen/BackendUtil.cpp
@@ -172,11 +172,16 @@
 
   std::unique_ptr TM;
 
+  // Emit output using the legacy pass manager for the optimization pipeline.
+  // This will be removed soon when using the legacy pass manager for the
+  // optimization pipeline is no longer supported.
+  void EmitAssemblyWithLegacyPassManager(BackendAction Action,
+ std::unique_ptr 
OS);
+
+  // Emit output using the new pass manager for the optimization pipeline. This
+  // is the default.
   void EmitAssembly(BackendAction Action,
 std::unique_ptr OS);
-
-  void EmitAssemblyWithNewPassManager(BackendAction Action,
-  std::unique_ptr OS);
 };
 
 // We need this wrapper to access LangOpts and CGOpts from extension functions
@@ -966,8 +971,8 @@
   return true;
 }
 
-void EmitAssemblyHelper::EmitAssembly(BackendAction Action,
-  std::unique_ptr OS) {
+void EmitAssemblyHelper::EmitAssemblyWithLegacyPassManager(
+BackendAction Action, std::unique_ptr OS) {
   TimeRegion Region(CodeGenOpts.TimePasses ?  : nullptr);
 
   setCommandLineOpts(CodeGenOpts);
@@ -1509,8 +1514,8 @@
 ///
 /// This API is planned to have its functionality finished and then to replace
 /// `EmitAssembly` at some point in the future when the default switches.
-void EmitAssemblyHelper::EmitAssemblyWithNewPassManager(
-BackendAction Action, std::unique_ptr OS) {
+void EmitAssemblyHelper::EmitAssembly(BackendAction Action,
+  std::unique_ptr OS) {
   TimeRegion Region(CodeGenOpts.TimePasses ?  : nullptr);
   setCommandLineOpts(CodeGenOpts);
 
@@ -1686,8 +1691,8 @@
 
   EmitAssemblyHelper AsmHelper(Diags, HeaderOpts, CGOpts, TOpts, LOpts, M);
 
-  if (!CGOpts.LegacyPassManager)
-AsmHelper.EmitAssemblyWithNewPassManager(Action, std::move(OS));
+  if (CGOpts.LegacyPassManager)
+AsmHelper.EmitAssemblyWithLegacyPassManager(Action, std::move(OS));
   else
 AsmHelper.EmitAssembly(Action, std::move(OS));
 


Index: clang/lib/CodeGen/BackendUtil.cpp
===
--- clang/lib/CodeGen/BackendUtil.cpp
+++ clang/lib/CodeGen/BackendUtil.cpp
@@ -172,11 +172,16 @@
 
   std::unique_ptr TM;
 
+  // Emit output using the legacy pass manager for the optimization pipeline.
+  // This will be removed soon when using the legacy pass manager for the
+  // optimization pipeline is no longer supported.
+  void EmitAssemblyWithLegacyPassManager(BackendAction Action,
+ std::unique_ptr OS);
+
+  // Emit output using the new pass manager for the optimization pipeline. This
+  // is the default.
   void EmitAssembly(BackendAction Action,
 std::unique_ptr OS);
-
-  void EmitAssemblyWithNewPassManager(BackendAction Action,
-  std::unique_ptr OS);
 };
 
 // We need this wrapper to access LangOpts and CGOpts from extension functions
@@ -966,8 +971,8 @@
   return true;
 }
 
-void EmitAssemblyHelper::EmitAssembly(BackendAction Action,
-  std::unique_ptr OS) {
+void EmitAssemblyHelper::EmitAssemblyWithLegacyPassManager(
+BackendAction Action, std::unique_ptr OS) {
   TimeRegion Region(CodeGenOpts.TimePasses ?  : nullptr);
 
   setCommandLineOpts(CodeGenOpts);
@@ -1509,8 +1514,8 @@
 ///
 /// This API is planned to have its functionality finished and then to replace
 /// `EmitAssembly` at some point in the future when the default switches.
-void EmitAssemblyHelper::EmitAssemblyWithNewPassManager(
-BackendAction Action, std::unique_ptr OS) {
+void EmitAssemblyHelper::EmitAssembly(BackendAction Action,
+  std::unique_ptr OS) {
   TimeRegion Region(CodeGenOpts.TimePasses ?  : nullptr);
   setCommandLineOpts(CodeGenOpts);
 
@@ -1686,8 +1691,8 @@
 
   EmitAssemblyHelper AsmHelper(Diags, HeaderOpts, CGOpts, TOpts, LOpts, M);
 
-  if (!CGOpts.LegacyPassManager)
-AsmHelper.EmitAssemblyWithNewPassManager(Action, std::move(OS));
+  if (CGOpts.LegacyPassManager)
+AsmHelper.EmitAssemblyWithLegacyPassManager(Action, std::move(OS));
   else
 AsmHelper.EmitAssembly(Action, std::move(OS));
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org

[clang] b6a8c69 - [NFC] Rename EmitAssemblyHelper new/legacy PM methods

2021-10-12 Thread Arthur Eubanks via cfe-commits

Author: Arthur Eubanks
Date: 2021-10-12T15:41:44-07:00
New Revision: b6a8c695542b2987eb9a203d5663a0740cb4725f

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

LOG: [NFC] Rename EmitAssemblyHelper new/legacy PM methods

To reflect the fact that the new PM is the default now.

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

Added: 


Modified: 
clang/lib/CodeGen/BackendUtil.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/BackendUtil.cpp 
b/clang/lib/CodeGen/BackendUtil.cpp
index 5e0ee8e0ab9b..986c9e8104e9 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -172,11 +172,16 @@ class EmitAssemblyHelper {
 
   std::unique_ptr TM;
 
+  // Emit output using the legacy pass manager for the optimization pipeline.
+  // This will be removed soon when using the legacy pass manager for the
+  // optimization pipeline is no longer supported.
+  void EmitAssemblyWithLegacyPassManager(BackendAction Action,
+ std::unique_ptr 
OS);
+
+  // Emit output using the new pass manager for the optimization pipeline. This
+  // is the default.
   void EmitAssembly(BackendAction Action,
 std::unique_ptr OS);
-
-  void EmitAssemblyWithNewPassManager(BackendAction Action,
-  std::unique_ptr OS);
 };
 
 // We need this wrapper to access LangOpts and CGOpts from extension functions
@@ -966,8 +971,8 @@ bool EmitAssemblyHelper::AddEmitPasses(legacy::PassManager 
,
   return true;
 }
 
-void EmitAssemblyHelper::EmitAssembly(BackendAction Action,
-  std::unique_ptr OS) {
+void EmitAssemblyHelper::EmitAssemblyWithLegacyPassManager(
+BackendAction Action, std::unique_ptr OS) {
   TimeRegion Region(CodeGenOpts.TimePasses ?  : nullptr);
 
   setCommandLineOpts(CodeGenOpts);
@@ -1509,8 +1514,8 @@ void EmitAssemblyHelper::RunCodegenPipeline(
 ///
 /// This API is planned to have its functionality finished and then to replace
 /// `EmitAssembly` at some point in the future when the default switches.
-void EmitAssemblyHelper::EmitAssemblyWithNewPassManager(
-BackendAction Action, std::unique_ptr OS) {
+void EmitAssemblyHelper::EmitAssembly(BackendAction Action,
+  std::unique_ptr OS) {
   TimeRegion Region(CodeGenOpts.TimePasses ?  : nullptr);
   setCommandLineOpts(CodeGenOpts);
 
@@ -1686,8 +1691,8 @@ void clang::EmitBackendOutput(DiagnosticsEngine ,
 
   EmitAssemblyHelper AsmHelper(Diags, HeaderOpts, CGOpts, TOpts, LOpts, M);
 
-  if (!CGOpts.LegacyPassManager)
-AsmHelper.EmitAssemblyWithNewPassManager(Action, std::move(OS));
+  if (CGOpts.LegacyPassManager)
+AsmHelper.EmitAssemblyWithLegacyPassManager(Action, std::move(OS));
   else
 AsmHelper.EmitAssembly(Action, std::move(OS));
 



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


[PATCH] D111680: [NFC] Rename EmitAssemblyHelper new/legacy PM methods

2021-10-12 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks updated this revision to Diff 379208.
aeubanks added a comment.

add comment
I'd rather switch everything to lowerCamel at once rather than just a few 
methods


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111680

Files:
  clang/lib/CodeGen/BackendUtil.cpp


Index: clang/lib/CodeGen/BackendUtil.cpp
===
--- clang/lib/CodeGen/BackendUtil.cpp
+++ clang/lib/CodeGen/BackendUtil.cpp
@@ -172,11 +172,16 @@
 
   std::unique_ptr TM;
 
+  // Emit output using the legacy pass manager for the optimization pipeline.
+  // This will be removed soon when using the legacy pass manager for the
+  // optimization pipeline is no longer supported.
+  void EmitAssemblyWithLegacyPassManager(BackendAction Action,
+ std::unique_ptr 
OS);
+
+  // Emit output using the new pass manager for the optimization pipeline. This
+  // is the default.
   void EmitAssembly(BackendAction Action,
 std::unique_ptr OS);
-
-  void EmitAssemblyWithNewPassManager(BackendAction Action,
-  std::unique_ptr OS);
 };
 
 // We need this wrapper to access LangOpts and CGOpts from extension functions
@@ -966,8 +971,8 @@
   return true;
 }
 
-void EmitAssemblyHelper::EmitAssembly(BackendAction Action,
-  std::unique_ptr OS) {
+void EmitAssemblyHelper::EmitAssemblyWithLegacyPassManager(
+BackendAction Action, std::unique_ptr OS) {
   TimeRegion Region(CodeGenOpts.TimePasses ?  : nullptr);
 
   setCommandLineOpts(CodeGenOpts);
@@ -1509,8 +1514,8 @@
 ///
 /// This API is planned to have its functionality finished and then to replace
 /// `EmitAssembly` at some point in the future when the default switches.
-void EmitAssemblyHelper::EmitAssemblyWithNewPassManager(
-BackendAction Action, std::unique_ptr OS) {
+void EmitAssemblyHelper::EmitAssembly(BackendAction Action,
+  std::unique_ptr OS) {
   TimeRegion Region(CodeGenOpts.TimePasses ?  : nullptr);
   setCommandLineOpts(CodeGenOpts);
 
@@ -1686,8 +1691,8 @@
 
   EmitAssemblyHelper AsmHelper(Diags, HeaderOpts, CGOpts, TOpts, LOpts, M);
 
-  if (!CGOpts.LegacyPassManager)
-AsmHelper.EmitAssemblyWithNewPassManager(Action, std::move(OS));
+  if (CGOpts.LegacyPassManager)
+AsmHelper.EmitAssemblyWithLegacyPassManager(Action, std::move(OS));
   else
 AsmHelper.EmitAssembly(Action, std::move(OS));
 


Index: clang/lib/CodeGen/BackendUtil.cpp
===
--- clang/lib/CodeGen/BackendUtil.cpp
+++ clang/lib/CodeGen/BackendUtil.cpp
@@ -172,11 +172,16 @@
 
   std::unique_ptr TM;
 
+  // Emit output using the legacy pass manager for the optimization pipeline.
+  // This will be removed soon when using the legacy pass manager for the
+  // optimization pipeline is no longer supported.
+  void EmitAssemblyWithLegacyPassManager(BackendAction Action,
+ std::unique_ptr OS);
+
+  // Emit output using the new pass manager for the optimization pipeline. This
+  // is the default.
   void EmitAssembly(BackendAction Action,
 std::unique_ptr OS);
-
-  void EmitAssemblyWithNewPassManager(BackendAction Action,
-  std::unique_ptr OS);
 };
 
 // We need this wrapper to access LangOpts and CGOpts from extension functions
@@ -966,8 +971,8 @@
   return true;
 }
 
-void EmitAssemblyHelper::EmitAssembly(BackendAction Action,
-  std::unique_ptr OS) {
+void EmitAssemblyHelper::EmitAssemblyWithLegacyPassManager(
+BackendAction Action, std::unique_ptr OS) {
   TimeRegion Region(CodeGenOpts.TimePasses ?  : nullptr);
 
   setCommandLineOpts(CodeGenOpts);
@@ -1509,8 +1514,8 @@
 ///
 /// This API is planned to have its functionality finished and then to replace
 /// `EmitAssembly` at some point in the future when the default switches.
-void EmitAssemblyHelper::EmitAssemblyWithNewPassManager(
-BackendAction Action, std::unique_ptr OS) {
+void EmitAssemblyHelper::EmitAssembly(BackendAction Action,
+  std::unique_ptr OS) {
   TimeRegion Region(CodeGenOpts.TimePasses ?  : nullptr);
   setCommandLineOpts(CodeGenOpts);
 
@@ -1686,8 +1691,8 @@
 
   EmitAssemblyHelper AsmHelper(Diags, HeaderOpts, CGOpts, TOpts, LOpts, M);
 
-  if (!CGOpts.LegacyPassManager)
-AsmHelper.EmitAssemblyWithNewPassManager(Action, std::move(OS));
+  if (CGOpts.LegacyPassManager)
+AsmHelper.EmitAssemblyWithLegacyPassManager(Action, std::move(OS));
   else
 AsmHelper.EmitAssembly(Action, std::move(OS));
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D111229: [PowerPC][Builtin] Allowing __rlwnm to accept a variable as a shift parameter

2021-10-12 Thread Amy Kwan via Phabricator via cfe-commits
amyk accepted this revision as: amyk.
amyk added a comment.

Aside from the comment made by Victor, also LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111229

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


[PATCH] D111665: [CUDA] Provide address space conversion builtins.

2021-10-12 Thread Artem Belevich via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf526ee5b8517: [CUDA] Provide address space conversion 
builtins. (authored by tra).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111665

Files:
  clang/lib/Headers/__clang_cuda_intrinsics.h


Index: clang/lib/Headers/__clang_cuda_intrinsics.h
===
--- clang/lib/Headers/__clang_cuda_intrinsics.h
+++ clang/lib/Headers/__clang_cuda_intrinsics.h
@@ -483,4 +483,36 @@
 
 #endif // !defined(__CUDA_ARCH__) || __CUDA_ARCH__ >= 320
 
+#if CUDA_VERSION >= 11000
+extern "C" {
+__device__ inline size_t __nv_cvta_generic_to_global_impl(const void *__ptr) {
+  return (size_t)(void __attribute__((address_space(1))) *)__ptr;
+}
+__device__ inline size_t __nv_cvta_generic_to_shared_impl(const void *__ptr) {
+  return (size_t)(void __attribute__((address_space(3))) *)__ptr;
+}
+__device__ inline size_t __nv_cvta_generic_to_constant_impl(const void *__ptr) 
{
+  return (size_t)(void __attribute__((address_space(4))) *)__ptr;
+}
+__device__ inline size_t __nv_cvta_generic_to_local_impl(const void *__ptr) {
+  return (size_t)(void __attribute__((address_space(5))) *)__ptr;
+}
+__device__ inline void *__nv_cvta_global_to_generic_impl(size_t __ptr) {
+  return (void *)(void __attribute__((address_space(1))) *)__ptr;
+}
+__device__ inline void *__nv_cvta_shared_to_generic_impl(size_t __ptr) {
+  return (void *)(void __attribute__((address_space(3))) *)__ptr;
+}
+__device__ inline void *__nv_cvta_constant_to_generic_impl(size_t __ptr) {
+  return (void *)(void __attribute__((address_space(4))) *)__ptr;
+}
+__device__ inline void *__nv_cvta_local_to_generic_impl(size_t __ptr) {
+  return (void *)(void __attribute__((address_space(5))) *)__ptr;
+}
+__device__ inline uint32_t __nvvm_get_smem_pointer(void *__ptr) {
+  return __nv_cvta_generic_to_shared_impl(__ptr);
+}
+} // extern "C"
+#endif // CUDA_VERSION >= 11000
+
 #endif // defined(__CLANG_CUDA_INTRINSICS_H__)


Index: clang/lib/Headers/__clang_cuda_intrinsics.h
===
--- clang/lib/Headers/__clang_cuda_intrinsics.h
+++ clang/lib/Headers/__clang_cuda_intrinsics.h
@@ -483,4 +483,36 @@
 
 #endif // !defined(__CUDA_ARCH__) || __CUDA_ARCH__ >= 320
 
+#if CUDA_VERSION >= 11000
+extern "C" {
+__device__ inline size_t __nv_cvta_generic_to_global_impl(const void *__ptr) {
+  return (size_t)(void __attribute__((address_space(1))) *)__ptr;
+}
+__device__ inline size_t __nv_cvta_generic_to_shared_impl(const void *__ptr) {
+  return (size_t)(void __attribute__((address_space(3))) *)__ptr;
+}
+__device__ inline size_t __nv_cvta_generic_to_constant_impl(const void *__ptr) {
+  return (size_t)(void __attribute__((address_space(4))) *)__ptr;
+}
+__device__ inline size_t __nv_cvta_generic_to_local_impl(const void *__ptr) {
+  return (size_t)(void __attribute__((address_space(5))) *)__ptr;
+}
+__device__ inline void *__nv_cvta_global_to_generic_impl(size_t __ptr) {
+  return (void *)(void __attribute__((address_space(1))) *)__ptr;
+}
+__device__ inline void *__nv_cvta_shared_to_generic_impl(size_t __ptr) {
+  return (void *)(void __attribute__((address_space(3))) *)__ptr;
+}
+__device__ inline void *__nv_cvta_constant_to_generic_impl(size_t __ptr) {
+  return (void *)(void __attribute__((address_space(4))) *)__ptr;
+}
+__device__ inline void *__nv_cvta_local_to_generic_impl(size_t __ptr) {
+  return (void *)(void __attribute__((address_space(5))) *)__ptr;
+}
+__device__ inline uint32_t __nvvm_get_smem_pointer(void *__ptr) {
+  return __nv_cvta_generic_to_shared_impl(__ptr);
+}
+} // extern "C"
+#endif // CUDA_VERSION >= 11000
+
 #endif // defined(__CLANG_CUDA_INTRINSICS_H__)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] f526ee5 - [CUDA] Provide address space conversion builtins.

2021-10-12 Thread Artem Belevich via cfe-commits

Author: Artem Belevich
Date: 2021-10-12T14:56:39-07:00
New Revision: f526ee5b8517b60620cd03bb3e5945ed69d6bfaa

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

LOG: [CUDA] Provide address space conversion builtins.

CUDA-11 headers rely on these NVCC builtins.
Despite having `__nv` previx, those are *not* provided by libdevice.

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

Added: 


Modified: 
clang/lib/Headers/__clang_cuda_intrinsics.h

Removed: 




diff  --git a/clang/lib/Headers/__clang_cuda_intrinsics.h 
b/clang/lib/Headers/__clang_cuda_intrinsics.h
index c7bff6a9d8fe..e0875bbcbf4a 100644
--- a/clang/lib/Headers/__clang_cuda_intrinsics.h
+++ b/clang/lib/Headers/__clang_cuda_intrinsics.h
@@ -483,4 +483,36 @@ inline __device__ unsigned __funnelshift_rc(unsigned 
low32, unsigned high32,
 
 #endif // !defined(__CUDA_ARCH__) || __CUDA_ARCH__ >= 320
 
+#if CUDA_VERSION >= 11000
+extern "C" {
+__device__ inline size_t __nv_cvta_generic_to_global_impl(const void *__ptr) {
+  return (size_t)(void __attribute__((address_space(1))) *)__ptr;
+}
+__device__ inline size_t __nv_cvta_generic_to_shared_impl(const void *__ptr) {
+  return (size_t)(void __attribute__((address_space(3))) *)__ptr;
+}
+__device__ inline size_t __nv_cvta_generic_to_constant_impl(const void *__ptr) 
{
+  return (size_t)(void __attribute__((address_space(4))) *)__ptr;
+}
+__device__ inline size_t __nv_cvta_generic_to_local_impl(const void *__ptr) {
+  return (size_t)(void __attribute__((address_space(5))) *)__ptr;
+}
+__device__ inline void *__nv_cvta_global_to_generic_impl(size_t __ptr) {
+  return (void *)(void __attribute__((address_space(1))) *)__ptr;
+}
+__device__ inline void *__nv_cvta_shared_to_generic_impl(size_t __ptr) {
+  return (void *)(void __attribute__((address_space(3))) *)__ptr;
+}
+__device__ inline void *__nv_cvta_constant_to_generic_impl(size_t __ptr) {
+  return (void *)(void __attribute__((address_space(4))) *)__ptr;
+}
+__device__ inline void *__nv_cvta_local_to_generic_impl(size_t __ptr) {
+  return (void *)(void __attribute__((address_space(5))) *)__ptr;
+}
+__device__ inline uint32_t __nvvm_get_smem_pointer(void *__ptr) {
+  return __nv_cvta_generic_to_shared_impl(__ptr);
+}
+} // extern "C"
+#endif // CUDA_VERSION >= 11000
+
 #endif // defined(__CLANG_CUDA_INTRINSICS_H__)



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


[PATCH] D111062: [RISCV] Rename some assembler mnemonic and intrinsic functions for RVV 1.0.

2021-10-12 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment.

I think this looks good other than the whitespace in 
fixed-vectors-mask-logic.ll that Jessica commented on.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111062

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


[PATCH] D110684: [RISCV] Define _m intrinsics as builtins, instead of macros.

2021-10-12 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment.

In D110684#3059698 , @aeubanks wrote:

> In D110684#3057498 , @nikic wrote:
>
>> I noticed this a few time in the past already, but this is the worst one yet:
>>
>> Compile-time: 
>> https://llvm-compile-time-tracker.com/compare.php?from=6641d29b70993bce6dbd7e0e0f1040753d38842f=97f0c63783f52389bd8842df205379ceade7a89d=instructions
>> Max-rss: 
>> https://llvm-compile-time-tracker.com/compare.php?from=6641d29b70993bce6dbd7e0e0f1040753d38842f=97f0c63783f52389bd8842df205379ceade7a89d=max-rss
>> Plus a >1% increase in clang total binary size.
>>
>> This happens every time a new slew of RISCV intrinsic permutations gets 
>> added, which seem to suffer from an extreme degree of redundancy. Is it 
>> possible to do something about this?
>
> +1, it seems bad to regress overall Clang memory usage by 1% by adding some 
> intrinsics, especially when we're not targeting RISCV.

Is the max-rss increase due to the binary size increase?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110684

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


[PATCH] D111680: [NFC] Rename EmitAssemblyHelper new/legacy PM methods

2021-10-12 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: clang/lib/CodeGen/BackendUtil.cpp:175
 
+  void EmitAssemblyWithLegacyPassManager(BackendAction Action,
+ std::unique_ptr 
OS);

Perhaps add a comment to bring awareness to possible downstream users 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111680

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


[PATCH] D111680: [NFC] Rename EmitAssemblyHelper new/legacy PM methods

2021-10-12 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.

Consider switching to `functionName` while updating the function names.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111680

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


[PATCH] D110357: [Analyzer] Extend ConstraintAssignor to handle remainder op

2021-10-12 Thread Gabor Marton via Phabricator via cfe-commits
martong updated this revision to Diff 379189.
martong marked 3 inline comments as done.
martong added a comment.

- Fix logic error
- Add more test cases
- Use SymbolRef


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110357

Files:
  
clang/include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h
  clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
  clang/test/Analysis/constraint-assignor.c

Index: clang/test/Analysis/constraint-assignor.c
===
--- /dev/null
+++ clang/test/Analysis/constraint-assignor.c
@@ -0,0 +1,93 @@
+// RUN: %clang_analyze_cc1 %s \
+// RUN:   -analyzer-checker=core \
+// RUN:   -analyzer-checker=debug.ExprInspection \
+// RUN:   -verify
+
+// expected-no-diagnostics
+
+void clang_analyzer_warnIfReached();
+
+void rem_constant_rhs_eq_zero(int x, int y) {
+  if (x % 3 != 0) // x % 3 == 0 -> x == 0
+return;
+  if (x * y == 0) // x * y != 0 -> contradiction
+return;
+  clang_analyzer_warnIfReached(); // no-warning
+  (void)x; // keep the constraints alive.
+}
+
+void rem_symbolic_rhs_eq_zero(int x, int y, int z) {
+  if (x % z != 0) // x % z == 0 -> x == 0
+return;
+  if (x * y == 0) // x * y != 0 -> contradiction
+return;
+  clang_analyzer_warnIfReached(); // no-warning
+  (void)x; // keep the constraints alive.
+}
+
+void rem_constant_rhs_ne_zero(int x, int y) {
+  if (x % 3 == 0) // x % 3 != 0 -> x != 0
+return;
+  if (x * y != 0) // x * y == 0
+return;
+  if (y != 1) // y == 1 -> x == 0
+return;
+  clang_analyzer_warnIfReached(); // no-warning
+  (void)x; // keep the constraints alive.
+}
+
+void rem_symbolic_rhs_ne_zero(int x, int y, int z) {
+  if (x % z == 0) // x % z != 0 -> x != 0
+return;
+  if (x * y != 0) // x * y == 0
+return;
+  if (y != 1) // y == 1 -> x == 0
+return;
+  clang_analyzer_warnIfReached(); // no-warning
+  (void)x; // keep the constraints alive.
+}
+
+void rem_symbolic_rhs_eq_zero_nested(int w, int x, int y, int z) {
+  if (w % x % z != 0) // w % x % z == 0 -> w % x == 0
+return;
+  if (w % x * y == 0) // w % x * y != 0 -> contradiction
+return;
+  clang_analyzer_warnIfReached(); // no-warning
+  (void)(w * x); // keep the constraints alive.
+}
+
+void rem_constant_rhs_eq_zero_early_contradiction(int x, int y) {
+  if (x == 0) // x != 0
+return;
+  if (x % 3 != 0) // x % 3 == 0 -> x == 0 -> contradiction
+return;
+  clang_analyzer_warnIfReached(); // no-warning
+  (void)x; // keep the constraints alive.
+}
+
+void rem_symbolic_rhs_eq_zero_early_contradiction(int x, int y, int z) {
+  if (x == 0) // x != 0
+return;
+  if (x % z != 0) // x % z == 0 -> x == 0 -> contradiction
+return;
+  clang_analyzer_warnIfReached(); // no-warning
+  (void)x; // keep the constraints alive.
+}
+
+void rem_constant_rhs_ne_zero_early_contradiction(int x, int y) {
+  if ((x + y) != 0) // (x + y) == 0
+return;
+  if ((x + y) % 3 == 0) // (x + y) % 3 != 0 -> (x + y) != 0 -> contradiction
+return;
+  clang_analyzer_warnIfReached(); // no-warning
+  (void)x; // keep the constraints alive.
+}
+
+void rem_symbolic_rhs_ne_zero_early_contradiction(int x, int y, int z) {
+  if ((x + y) != 0) // (x + y) == 0
+return;
+  if ((x + y) % z == 0) // (x + y) % z != 0 -> (x + y) != 0 -> contradiction
+return;
+  clang_analyzer_warnIfReached(); // no-warning
+  (void)x; // keep the constraints alive.
+}
Index: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
===
--- clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
+++ clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
@@ -1610,7 +1610,35 @@
 return Assignor.assign(CoS, NewConstraint);
   }
 
+  /// Handle expressions like: a % b == 0.
+  template 
+  bool handleRemainderOp(const SymT *Sym, RangeSet Constraint) {
+if (Sym->getOpcode() != BO_Rem)
+  return true;
+const SymbolRef LHS = Sym->getLHS();
+const llvm::APSInt  =
+Builder.getBasicValueFactory().getValue(0, LHS->getType());
+const llvm::APSInt *ConcreteValue = Constraint.getConcreteValue();
+// a % b == 0 implies that a == 0.
+if (ConcreteValue && *ConcreteValue == Zero) {
+  State = RCM.assumeSymEQ(State, LHS, Zero, Zero);
+  if (!State)
+return false;
+}
+// a % b != 0 implies that a != 0.
+if (!Constraint.containsZero()) {
+  State = RCM.assumeSymNE(State, LHS, Zero, Zero);
+  if (!State)
+return false;
+}
+return true;
+  }
+
   inline bool assignSymExprToConst(const SymExpr *Sym, Const Constraint);
+  inline bool assignSymIntExprToRangeSet(const SymIntExpr *Sym,
+ RangeSet Constraint) {
+return handleRemainderOp(Sym, Constraint);
+  }
   inline bool assignSymSymExprToRangeSet(const 

[PATCH] D110357: [Analyzer] Extend ConstraintAssignor to handle remainder op

2021-10-12 Thread Gabor Marton via Phabricator via cfe-commits
martong marked 5 inline comments as done.
martong added inline comments.



Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:1619
+  return true;
+const SymExpr *LHS = Sym->getLHS();
+const llvm::APSInt  =

ASDenysPetrov wrote:
> steakhal wrote:
> > 
> Since `SymbolRef` actually is already `const`. (`using SymbolRef = const 
> SymExpr *;`)
Fair enough.



Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:1623
+if (Constraint.containsZero())
+  State = RCM.assumeSymEQ(State, LHS, Zero, Zero);
+else

steakhal wrote:
> In case the `Constraint` //might be// zero, why do you constrain `LHS` so 
> that it **must be** zero?
> I could not come up with a concrete example, but I hope you got my concern.
> We either have a logic flaw or we lack an assertion here stating this hidden 
> assumption about `Constraints`.
Ahh, very good catch, sharp eyes! This mistake slipped in when I extended the 
original logic with `a % b == 0 implies that a == 0`. Fixed it.



Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:1603-1604
 
+  template 
+  bool handleRem(const SymT *Sym, RangeSet Constraint) {
+// a % b != 0 implies that a != 0.

steakhal wrote:
> martong wrote:
> > ASDenysPetrov wrote:
> > > steakhal wrote:
> > > > Why is this not a `const` member function?
> > > IMO it's better to rename the function `handleRemainderOp`.
> > > 
> > > Add a function description in comments above. 
> > > E.g. Handle expressions like: `a % b == 0`. ... Returns `true` when 
> > > //bla-bla//, otherwise returns `false`.
> > > Why is this not a const member function?
> > Because `RCM.assumeSymNE` is not `const`.
> > 
> > > IMO it's better to rename the function handleRemainderOp.
> > I agree, changed it.
> >> Why is this not a const member function?
> > Because RCM.assumeSymNE is not const.
> I don't think it's an excuse: https://godbolt.org/z/nEcsozheq
> 
> ---
> 
> Aside from that, I would clarify that it will try to apply the following 
> *two* assumptions:
> `a % b == 0 implies that a == 0.`
> `a % b != 0 implies that a != 0.`
> Now the comment only highlights the latter.
> >> Why is this not a const member function?
> > Because RCM.assumeSymNE is not const.
> I don't think it's an excuse: https://godbolt.org/z/nEcsozheq
Yeah you're right. It has nothing to do with the non-constness of 
`RCM.assumeSymNE`, my bad. The problem is that we try to assign a new state to 
the member non-const `State` and assignment is non-const:
```
No viable overloaded '='
/home/egbomrt/WORK/llvm4/git/llvm-project/llvm/include/llvm/ADT/IntrusiveRefCntPtr.h:188:23:
note: candidate function not viable: 'this' argument has type 'const 
clang::ento::ProgramStateRef' (aka 'const IntrusiveRefCntPtr'), but method is not marked const
```

> ---
> 
> Aside from that, I would clarify that it will try to apply the following 
> *two* assumptions:
> `a % b == 0 implies that a == 0.`
> `a % b != 0 implies that a != 0.`
> Now the comment only highlights the latter.
Ok, I've added those comments.





Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:1609-1612
+  const SymExpr *LHS = Sym->getLHS();
+  const llvm::APSInt  =
+  Builder.getBasicValueFactory().getValue(0, LHS->getType());
+  State = RCM->assumeSymNE(State, LHS, Zero, Zero);

ASDenysPetrov wrote:
> martong wrote:
> > steakhal wrote:
> > > ASDenysPetrov wrote:
> > > > Maybe make some more complex assumptions to cover complex **LHS's**?
> > > Oh nice.
> > `State->assume` goes through many higher level abstractions and finally 
> > calls `assumeSymNE`, so I think calling that would be a pessimization in 
> > this case.
> I agree, but then you lose an internal simplification of LHS symbol.
Well, I cannot come up any disadvantages of  using`State->assume` other than 
some performance constraints. On the other hand, that could simplify the 
implementation by eliminating the need for `RCM`. I'll give it a try and 
perhaps will update the patch accordingly.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110357

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


[PATCH] D111680: [NFC] Rename EmitAssemblyHelper new/legacy PM methods

2021-10-12 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks created this revision.
aeubanks added a reviewer: MaskRay.
Herald added a subscriber: ormris.
Herald added a reviewer: ctetreau.
Herald added a reviewer: ctetreau.
Herald added a reviewer: ctetreau.
aeubanks requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

To reflect the fact that the new PM is the default now.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D111680

Files:
  clang/lib/CodeGen/BackendUtil.cpp


Index: clang/lib/CodeGen/BackendUtil.cpp
===
--- clang/lib/CodeGen/BackendUtil.cpp
+++ clang/lib/CodeGen/BackendUtil.cpp
@@ -172,11 +172,11 @@
 
   std::unique_ptr TM;
 
+  void EmitAssemblyWithLegacyPassManager(BackendAction Action,
+ std::unique_ptr 
OS);
+
   void EmitAssembly(BackendAction Action,
 std::unique_ptr OS);
-
-  void EmitAssemblyWithNewPassManager(BackendAction Action,
-  std::unique_ptr OS);
 };
 
 // We need this wrapper to access LangOpts and CGOpts from extension functions
@@ -966,8 +966,8 @@
   return true;
 }
 
-void EmitAssemblyHelper::EmitAssembly(BackendAction Action,
-  std::unique_ptr OS) {
+void EmitAssemblyHelper::EmitAssemblyWithLegacyPassManager(
+BackendAction Action, std::unique_ptr OS) {
   TimeRegion Region(CodeGenOpts.TimePasses ?  : nullptr);
 
   setCommandLineOpts(CodeGenOpts);
@@ -1509,8 +1509,8 @@
 ///
 /// This API is planned to have its functionality finished and then to replace
 /// `EmitAssembly` at some point in the future when the default switches.
-void EmitAssemblyHelper::EmitAssemblyWithNewPassManager(
-BackendAction Action, std::unique_ptr OS) {
+void EmitAssemblyHelper::EmitAssembly(BackendAction Action,
+  std::unique_ptr OS) {
   TimeRegion Region(CodeGenOpts.TimePasses ?  : nullptr);
   setCommandLineOpts(CodeGenOpts);
 
@@ -1686,8 +1686,8 @@
 
   EmitAssemblyHelper AsmHelper(Diags, HeaderOpts, CGOpts, TOpts, LOpts, M);
 
-  if (!CGOpts.LegacyPassManager)
-AsmHelper.EmitAssemblyWithNewPassManager(Action, std::move(OS));
+  if (CGOpts.LegacyPassManager)
+AsmHelper.EmitAssemblyWithLegacyPassManager(Action, std::move(OS));
   else
 AsmHelper.EmitAssembly(Action, std::move(OS));
 


Index: clang/lib/CodeGen/BackendUtil.cpp
===
--- clang/lib/CodeGen/BackendUtil.cpp
+++ clang/lib/CodeGen/BackendUtil.cpp
@@ -172,11 +172,11 @@
 
   std::unique_ptr TM;
 
+  void EmitAssemblyWithLegacyPassManager(BackendAction Action,
+ std::unique_ptr OS);
+
   void EmitAssembly(BackendAction Action,
 std::unique_ptr OS);
-
-  void EmitAssemblyWithNewPassManager(BackendAction Action,
-  std::unique_ptr OS);
 };
 
 // We need this wrapper to access LangOpts and CGOpts from extension functions
@@ -966,8 +966,8 @@
   return true;
 }
 
-void EmitAssemblyHelper::EmitAssembly(BackendAction Action,
-  std::unique_ptr OS) {
+void EmitAssemblyHelper::EmitAssemblyWithLegacyPassManager(
+BackendAction Action, std::unique_ptr OS) {
   TimeRegion Region(CodeGenOpts.TimePasses ?  : nullptr);
 
   setCommandLineOpts(CodeGenOpts);
@@ -1509,8 +1509,8 @@
 ///
 /// This API is planned to have its functionality finished and then to replace
 /// `EmitAssembly` at some point in the future when the default switches.
-void EmitAssemblyHelper::EmitAssemblyWithNewPassManager(
-BackendAction Action, std::unique_ptr OS) {
+void EmitAssemblyHelper::EmitAssembly(BackendAction Action,
+  std::unique_ptr OS) {
   TimeRegion Region(CodeGenOpts.TimePasses ?  : nullptr);
   setCommandLineOpts(CodeGenOpts);
 
@@ -1686,8 +1686,8 @@
 
   EmitAssemblyHelper AsmHelper(Diags, HeaderOpts, CGOpts, TOpts, LOpts, M);
 
-  if (!CGOpts.LegacyPassManager)
-AsmHelper.EmitAssemblyWithNewPassManager(Action, std::move(OS));
+  if (CGOpts.LegacyPassManager)
+AsmHelper.EmitAssemblyWithLegacyPassManager(Action, std::move(OS));
   else
 AsmHelper.EmitAssembly(Action, std::move(OS));
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D111582: [clang] Teardown new PM data structures before running codegen pipeline

2021-10-12 Thread Arthur Eubanks 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 rG2cadef6537b3: [clang] Teardown new PM data structures before 
running codegen pipeline (authored by aeubanks).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111582

Files:
  clang/lib/CodeGen/BackendUtil.cpp

Index: clang/lib/CodeGen/BackendUtil.cpp
===
--- clang/lib/CodeGen/BackendUtil.cpp
+++ clang/lib/CodeGen/BackendUtil.cpp
@@ -147,6 +147,14 @@
 return F;
   }
 
+  void
+  RunOptimizationPipeline(BackendAction Action,
+  std::unique_ptr ,
+  std::unique_ptr );
+  void RunCodegenPipeline(BackendAction Action,
+  std::unique_ptr ,
+  std::unique_ptr );
+
 public:
   EmitAssemblyHelper(DiagnosticsEngine &_Diags,
  const HeaderSearchOptions ,
@@ -1199,29 +1207,9 @@
   });
 }
 
-/// A clean version of `EmitAssembly` that uses the new pass manager.
-///
-/// Not all features are currently supported in this system, but where
-/// necessary it falls back to the legacy pass manager to at least provide
-/// basic functionality.
-///
-/// This API is planned to have its functionality finished and then to replace
-/// `EmitAssembly` at some point in the future when the default switches.
-void EmitAssemblyHelper::EmitAssemblyWithNewPassManager(
-BackendAction Action, std::unique_ptr OS) {
-  TimeRegion Region(CodeGenOpts.TimePasses ?  : nullptr);
-  setCommandLineOpts(CodeGenOpts);
-
-  bool RequiresCodeGen = (Action != Backend_EmitNothing &&
-  Action != Backend_EmitBC &&
-  Action != Backend_EmitLL);
-  CreateTargetMachine(RequiresCodeGen);
-
-  if (RequiresCodeGen && !TM)
-return;
-  if (TM)
-TheModule->setDataLayout(TM->createDataLayout());
-
+void EmitAssemblyHelper::RunOptimizationPipeline(
+BackendAction Action, std::unique_ptr ,
+std::unique_ptr ) {
   Optional PGOOpt;
 
   if (CodeGenOpts.hasProfileIRInstr())
@@ -1437,18 +1425,7 @@
   MPM.addPass(ModuleMemProfilerPass());
 }
   }
-
-  // FIXME: We still use the legacy pass manager to do code generation. We
-  // create that pass manager here and use it as needed below.
-  legacy::PassManager CodeGenPasses;
-  bool NeedCodeGen = false;
-  std::unique_ptr ThinLinkOS, DwoOS;
-
-  // Append any output we need to the pass manager.
   switch (Action) {
-  case Backend_EmitNothing:
-break;
-
   case Backend_EmitBC:
 if (CodeGenOpts.PrepareForThinLTO && !CodeGenOpts.DisableLLVMPasses) {
   if (!CodeGenOpts.ThinLinkBitcodeFile.empty()) {
@@ -1464,8 +1441,7 @@
   // Emit a module summary by default for Regular LTO except for ld64
   // targets
   bool EmitLTOSummary =
-  (CodeGenOpts.PrepareForLTO &&
-   !CodeGenOpts.DisableLLVMPasses &&
+  (CodeGenOpts.PrepareForLTO && !CodeGenOpts.DisableLLVMPasses &&
llvm::Triple(TheModule->getTargetTriple()).getVendor() !=
llvm::Triple::Apple);
   if (EmitLTOSummary) {
@@ -1483,10 +1459,28 @@
 MPM.addPass(PrintModulePass(*OS, "", CodeGenOpts.EmitLLVMUseLists));
 break;
 
+  default:
+break;
+  }
+
+  // Now that we have all of the passes ready, run them.
+  PrettyStackTraceString CrashInfo("Optimizer");
+  MPM.run(*TheModule, MAM);
+}
+
+void EmitAssemblyHelper::RunCodegenPipeline(
+BackendAction Action, std::unique_ptr ,
+std::unique_ptr ) {
+  // We still use the legacy PM to run the codegen pipeline since the new PM
+  // does not work with the codegen pipeline.
+  // FIXME: make the new PM work with the codegen pipeline.
+  legacy::PassManager CodeGenPasses;
+
+  // Append any output we need to the pass manager.
+  switch (Action) {
   case Backend_EmitAssembly:
   case Backend_EmitMCNull:
   case Backend_EmitObj:
-NeedCodeGen = true;
 CodeGenPasses.add(
 createTargetTransformInfoWrapperPass(getTargetIRAnalysis()));
 if (!CodeGenOpts.SplitDwarfOutput.empty()) {
@@ -1499,22 +1493,42 @@
   // FIXME: Should we handle this error differently?
   return;
 break;
+  default:
+return;
   }
 
+  PrettyStackTraceString CrashInfo("Code generation");
+  CodeGenPasses.run(*TheModule);
+}
+
+/// A clean version of `EmitAssembly` that uses the new pass manager.
+///
+/// Not all features are currently supported in this system, but where
+/// necessary it falls back to the legacy pass manager to at least provide
+/// basic functionality.
+///
+/// This API is planned to have its functionality finished and then to replace
+/// `EmitAssembly` at some point in the future when the default switches.
+void EmitAssemblyHelper::EmitAssemblyWithNewPassManager(
+BackendAction Action, std::unique_ptr OS) {
+  TimeRegion 

[clang] 2cadef6 - [clang] Teardown new PM data structures before running codegen pipeline

2021-10-12 Thread Arthur Eubanks via cfe-commits

Author: Arthur Eubanks
Date: 2021-10-12T14:17:11-07:00
New Revision: 2cadef6537b351cc696e2de1f5c8e9fbe6055980

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

LOG: [clang] Teardown new PM data structures before running codegen pipeline

Do this by refactoring the optimization and codegen pipelines into separate 
functions.

This saves a tiny bit of memory in non-LTO builds [1].

[1] 
https://llvm-compile-time-tracker.com/compare.php?from=fbddf22ef72d3c2e9b14e1501841b03380eef12b=cd276df52eb6f2b84a8e1efe5318460c6debf82d=max-rss

Reviewed By: dblaikie

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

Added: 


Modified: 
clang/lib/CodeGen/BackendUtil.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/BackendUtil.cpp 
b/clang/lib/CodeGen/BackendUtil.cpp
index c0e1303fe639..5e0ee8e0ab9b 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -147,6 +147,14 @@ class EmitAssemblyHelper {
 return F;
   }
 
+  void
+  RunOptimizationPipeline(BackendAction Action,
+  std::unique_ptr ,
+  std::unique_ptr );
+  void RunCodegenPipeline(BackendAction Action,
+  std::unique_ptr ,
+  std::unique_ptr );
+
 public:
   EmitAssemblyHelper(DiagnosticsEngine &_Diags,
  const HeaderSearchOptions ,
@@ -1199,29 +1207,9 @@ static void addSanitizers(const Triple ,
   });
 }
 
-/// A clean version of `EmitAssembly` that uses the new pass manager.
-///
-/// Not all features are currently supported in this system, but where
-/// necessary it falls back to the legacy pass manager to at least provide
-/// basic functionality.
-///
-/// This API is planned to have its functionality finished and then to replace
-/// `EmitAssembly` at some point in the future when the default switches.
-void EmitAssemblyHelper::EmitAssemblyWithNewPassManager(
-BackendAction Action, std::unique_ptr OS) {
-  TimeRegion Region(CodeGenOpts.TimePasses ?  : nullptr);
-  setCommandLineOpts(CodeGenOpts);
-
-  bool RequiresCodeGen = (Action != Backend_EmitNothing &&
-  Action != Backend_EmitBC &&
-  Action != Backend_EmitLL);
-  CreateTargetMachine(RequiresCodeGen);
-
-  if (RequiresCodeGen && !TM)
-return;
-  if (TM)
-TheModule->setDataLayout(TM->createDataLayout());
-
+void EmitAssemblyHelper::RunOptimizationPipeline(
+BackendAction Action, std::unique_ptr ,
+std::unique_ptr ) {
   Optional PGOOpt;
 
   if (CodeGenOpts.hasProfileIRInstr())
@@ -1437,18 +1425,7 @@ void EmitAssemblyHelper::EmitAssemblyWithNewPassManager(
   MPM.addPass(ModuleMemProfilerPass());
 }
   }
-
-  // FIXME: We still use the legacy pass manager to do code generation. We
-  // create that pass manager here and use it as needed below.
-  legacy::PassManager CodeGenPasses;
-  bool NeedCodeGen = false;
-  std::unique_ptr ThinLinkOS, DwoOS;
-
-  // Append any output we need to the pass manager.
   switch (Action) {
-  case Backend_EmitNothing:
-break;
-
   case Backend_EmitBC:
 if (CodeGenOpts.PrepareForThinLTO && !CodeGenOpts.DisableLLVMPasses) {
   if (!CodeGenOpts.ThinLinkBitcodeFile.empty()) {
@@ -1464,8 +1441,7 @@ void EmitAssemblyHelper::EmitAssemblyWithNewPassManager(
   // Emit a module summary by default for Regular LTO except for ld64
   // targets
   bool EmitLTOSummary =
-  (CodeGenOpts.PrepareForLTO &&
-   !CodeGenOpts.DisableLLVMPasses &&
+  (CodeGenOpts.PrepareForLTO && !CodeGenOpts.DisableLLVMPasses &&
llvm::Triple(TheModule->getTargetTriple()).getVendor() !=
llvm::Triple::Apple);
   if (EmitLTOSummary) {
@@ -1483,10 +1459,28 @@ void EmitAssemblyHelper::EmitAssemblyWithNewPassManager(
 MPM.addPass(PrintModulePass(*OS, "", CodeGenOpts.EmitLLVMUseLists));
 break;
 
+  default:
+break;
+  }
+
+  // Now that we have all of the passes ready, run them.
+  PrettyStackTraceString CrashInfo("Optimizer");
+  MPM.run(*TheModule, MAM);
+}
+
+void EmitAssemblyHelper::RunCodegenPipeline(
+BackendAction Action, std::unique_ptr ,
+std::unique_ptr ) {
+  // We still use the legacy PM to run the codegen pipeline since the new PM
+  // does not work with the codegen pipeline.
+  // FIXME: make the new PM work with the codegen pipeline.
+  legacy::PassManager CodeGenPasses;
+
+  // Append any output we need to the pass manager.
+  switch (Action) {
   case Backend_EmitAssembly:
   case Backend_EmitMCNull:
   case Backend_EmitObj:
-NeedCodeGen = true;
 CodeGenPasses.add(
 createTargetTransformInfoWrapperPass(getTargetIRAnalysis()));
 if (!CodeGenOpts.SplitDwarfOutput.empty()) {
@@ -1499,22 +1493,42 @@ void 

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

2021-10-12 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov updated this revision to Diff 379179.
mizvekov added a comment.

- Introduce TDK_ALreadyDiagnosed.

Addresses rsmith's review comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111283

Files:
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/AST/Type.h
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaStmt.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/test/SemaCXX/sugared-auto.cpp

Index: clang/test/SemaCXX/sugared-auto.cpp
===
--- clang/test/SemaCXX/sugared-auto.cpp
+++ clang/test/SemaCXX/sugared-auto.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++20
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++20 -fblocks -fenable-matrix -Wno-dynamic-exception-spec
 
 enum class N {};
 
@@ -9,6 +9,26 @@
 using Man = Animal;
 using Dog = Animal;
 
+using ManPtr = Man *;
+using DogPtr = Dog *;
+
+using SocratesPtr = ManPtr;
+
+using ConstMan = const Man;
+using ConstDog = const Dog;
+
+using Virus = void;
+using SARS = Virus;
+using Ebola = Virus;
+
+using Bacteria = float;
+using Bacilli = Bacteria;
+using Vibrio = Bacteria;
+
+struct Plant;
+using Gymnosperm = Plant;
+using Angiosperm = Plant;
+
 namespace variable {
 
 auto x1 = Animal();
@@ -41,3 +61,115 @@
 N t3 = x3; // expected-error {{lvalue of type 'Animal' (aka 'int')}}
 
 } // namespace function_basic
+
+namespace function_multiple_basic {
+
+N t1 = [] { // expected-error {{rvalue of type 'Animal' (aka 'int')}}
+  if (true)
+return Man();
+  return Dog();
+}();
+
+N t2 = []() -> decltype(auto) { // expected-error {{rvalue of type 'Animal' (aka 'int')}}
+  if (true)
+return Man();
+  return Dog();
+}();
+
+N t3 = [] { // expected-error {{rvalue of type 'Animal' (aka 'int')}}
+  if (true)
+return Dog();
+  auto x = Man();
+  return x;
+}();
+
+N t4 = [] { // expected-error {{rvalue of type 'int'}}
+  if (true)
+return Dog();
+  return 1;
+}();
+
+N t5 = [] { // expected-error {{rvalue of type 'Virus' (aka 'void')}}
+  if (true)
+return Ebola();
+  return SARS();
+}();
+
+N t6 = [] { // expected-error {{rvalue of type 'void'}}
+  if (true)
+return SARS();
+  return;
+}();
+
+} // namespace function_multiple_basic
+
+#define TEST_AUTO(X, A, B) \
+  auto X(A a, B b) {   \
+if (0) \
+  return a;\
+if (0) \
+  return b;\
+return N();\
+  }
+#define TEST_DAUTO(X, A, B) \
+  decltype(auto) X(A a, B b) {  \
+if (0)  \
+  return static_cast(a); \
+if (0)  \
+  return static_cast(b); \
+return N(); \
+  }
+
+namespace misc {
+
+TEST_AUTO(t1, ManPtr, DogPtr)  // expected-error {{but deduced as 'Animal *' (aka 'int *')}}
+TEST_AUTO(t2, ManPtr, int *)   // expected-error {{but deduced as 'int *'}}
+TEST_AUTO(t3, SocratesPtr, ManPtr) // expected-error {{but deduced as 'ManPtr' (aka 'int *')}}
+
+TEST_AUTO(t4, _Atomic(Man), _Atomic(Dog)) // expected-error {{but deduced as '_Atomic(Animal)'}}
+
+using block_man = void (^)(Man);
+using block_dog = void (^)(Dog);
+TEST_AUTO(t5, block_man, block_dog) // expected-error {{but deduced as 'void (^)(Animal)'}}
+
+using fp1 = SARS (*)(Man, DogPtr) throw(Vibrio);
+using fp2 = Ebola (*)(Dog, ManPtr) throw(Bacilli);
+TEST_AUTO(t6, fp1, fp2); // expected-error {{but deduced as 'Virus (*)(Animal, Animal *) throw(Bacteria)' (aka 'void (*)(int, int *) throw(Bacteria)')}}
+
+using fp3 = SARS (*)() throw(Man);
+using fp4 = Ebola (*)() throw(Vibrio);
+auto t7(fp3 a, fp4 b) {
+  if (false)
+return true ? a : b;
+  if (false)
+return a;
+  return N(); // expected-error {{but deduced as 'SARS (*)() throw(Man, Vibrio)' (aka 'void (*)() throw(Man, Vibrio)')}}
+}
+
+using fp5 = void (*)(const Man);
+using fp6 = void (*)(Dog);
+TEST_AUTO(t8, fp5, fp6); // expected-error {{but deduced as 'void (*)(const Animal)' (aka 'void (*)(const int)')}}
+
+using fp6 = void (*)(ConstMan);
+using fp7 = void (*)(ConstDog);
+TEST_AUTO(t10, fp6, fp7); // expected-error {{but deduced as 'void (*)(const Animal)' (aka 'void (*)(const int)')}}
+
+TEST_AUTO(t11, Man Angiosperm::*, Dog Gymnosperm::*) // expected-error {{but deduced as 'Animal Plant::*'}}
+
+TEST_DAUTO(t12, const Man &, const Dog &) // expected-error {{but deduced as 'const Animal &' (aka 'const int &')}}
+
+TEST_DAUTO(t13, Man &&, Dog &&) // expected-error {{but deduced as 'Animal &&' (aka 'int &&')}}
+
+using matrix_man = Man __attribute__((matrix_type(4, 4)));
+using matrix_dog = Dog __attribute__((matrix_type(4, 4)));
+TEST_AUTO(t14, matrix_man, matrix_dog) // expected-error {{but deduced as 'Animal 

[PATCH] D110684: [RISCV] Define _m intrinsics as builtins, instead of macros.

2021-10-12 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks added a comment.

In D110684#3057498 , @nikic wrote:

> I noticed this a few time in the past already, but this is the worst one yet:
>
> Compile-time: 
> https://llvm-compile-time-tracker.com/compare.php?from=6641d29b70993bce6dbd7e0e0f1040753d38842f=97f0c63783f52389bd8842df205379ceade7a89d=instructions
> Max-rss: 
> https://llvm-compile-time-tracker.com/compare.php?from=6641d29b70993bce6dbd7e0e0f1040753d38842f=97f0c63783f52389bd8842df205379ceade7a89d=max-rss
> Plus a >1% increase in clang total binary size.
>
> This happens every time a new slew of RISCV intrinsic permutations gets 
> added, which seem to suffer from an extreme degree of redundancy. Is it 
> possible to do something about this?

+1, it seems bad to regress overall Clang memory usage by 1% by adding some 
intrinsics, especially when we're not targeting RISCV.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110684

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


[PATCH] D111665: [CUDA] Provide address space conversion builtins.

2021-10-12 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment.

In D111665#3059427 , @jdoerfert wrote:

> Not loving the magic constants here but I don't think we have a enum or 
> similar right now.

Yup.

> I also have to question the people that choose `size_t` here... we will end 
> up with int2ptr(ptr2int(...)) IR everywhere if this is actually used (outside 
> the asm uses in cuda).

I guess size_t was 'good enough' to accommodate all pointer sizes (though it 
should've been `uintptr_t`).

I think this chain of conversions gets quickly instcombined away even at `-O1`:
E.g: https://godbolt.org/z/4vd94cEsj


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111665

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


[PATCH] D111582: [clang] Teardown new PM data structures before running codegen pipeline

2021-10-12 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks updated this revision to Diff 379175.
aeubanks added a comment.

add back a (similar) comment


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111582

Files:
  clang/lib/CodeGen/BackendUtil.cpp

Index: clang/lib/CodeGen/BackendUtil.cpp
===
--- clang/lib/CodeGen/BackendUtil.cpp
+++ clang/lib/CodeGen/BackendUtil.cpp
@@ -147,6 +147,14 @@
 return F;
   }
 
+  void
+  RunOptimizationPipeline(BackendAction Action,
+  std::unique_ptr ,
+  std::unique_ptr );
+  void RunCodegenPipeline(BackendAction Action,
+  std::unique_ptr ,
+  std::unique_ptr );
+
 public:
   EmitAssemblyHelper(DiagnosticsEngine &_Diags,
  const HeaderSearchOptions ,
@@ -1199,29 +1207,9 @@
   });
 }
 
-/// A clean version of `EmitAssembly` that uses the new pass manager.
-///
-/// Not all features are currently supported in this system, but where
-/// necessary it falls back to the legacy pass manager to at least provide
-/// basic functionality.
-///
-/// This API is planned to have its functionality finished and then to replace
-/// `EmitAssembly` at some point in the future when the default switches.
-void EmitAssemblyHelper::EmitAssemblyWithNewPassManager(
-BackendAction Action, std::unique_ptr OS) {
-  TimeRegion Region(CodeGenOpts.TimePasses ?  : nullptr);
-  setCommandLineOpts(CodeGenOpts);
-
-  bool RequiresCodeGen = (Action != Backend_EmitNothing &&
-  Action != Backend_EmitBC &&
-  Action != Backend_EmitLL);
-  CreateTargetMachine(RequiresCodeGen);
-
-  if (RequiresCodeGen && !TM)
-return;
-  if (TM)
-TheModule->setDataLayout(TM->createDataLayout());
-
+void EmitAssemblyHelper::RunOptimizationPipeline(
+BackendAction Action, std::unique_ptr ,
+std::unique_ptr ) {
   Optional PGOOpt;
 
   if (CodeGenOpts.hasProfileIRInstr())
@@ -1437,18 +1425,7 @@
   MPM.addPass(ModuleMemProfilerPass());
 }
   }
-
-  // FIXME: We still use the legacy pass manager to do code generation. We
-  // create that pass manager here and use it as needed below.
-  legacy::PassManager CodeGenPasses;
-  bool NeedCodeGen = false;
-  std::unique_ptr ThinLinkOS, DwoOS;
-
-  // Append any output we need to the pass manager.
   switch (Action) {
-  case Backend_EmitNothing:
-break;
-
   case Backend_EmitBC:
 if (CodeGenOpts.PrepareForThinLTO && !CodeGenOpts.DisableLLVMPasses) {
   if (!CodeGenOpts.ThinLinkBitcodeFile.empty()) {
@@ -1464,8 +1441,7 @@
   // Emit a module summary by default for Regular LTO except for ld64
   // targets
   bool EmitLTOSummary =
-  (CodeGenOpts.PrepareForLTO &&
-   !CodeGenOpts.DisableLLVMPasses &&
+  (CodeGenOpts.PrepareForLTO && !CodeGenOpts.DisableLLVMPasses &&
llvm::Triple(TheModule->getTargetTriple()).getVendor() !=
llvm::Triple::Apple);
   if (EmitLTOSummary) {
@@ -1483,10 +1459,28 @@
 MPM.addPass(PrintModulePass(*OS, "", CodeGenOpts.EmitLLVMUseLists));
 break;
 
+  default:
+break;
+  }
+
+  // Now that we have all of the passes ready, run them.
+  PrettyStackTraceString CrashInfo("Optimizer");
+  MPM.run(*TheModule, MAM);
+}
+
+void EmitAssemblyHelper::RunCodegenPipeline(
+BackendAction Action, std::unique_ptr ,
+std::unique_ptr ) {
+  // We still use the legacy PM to run the codegen pipeline since the new PM
+  // does not work with the codegen pipeline.
+  // FIXME: make the new PM work with the codegen pipeline.
+  legacy::PassManager CodeGenPasses;
+
+  // Append any output we need to the pass manager.
+  switch (Action) {
   case Backend_EmitAssembly:
   case Backend_EmitMCNull:
   case Backend_EmitObj:
-NeedCodeGen = true;
 CodeGenPasses.add(
 createTargetTransformInfoWrapperPass(getTargetIRAnalysis()));
 if (!CodeGenOpts.SplitDwarfOutput.empty()) {
@@ -1499,22 +1493,42 @@
   // FIXME: Should we handle this error differently?
   return;
 break;
+  default:
+return;
   }
 
+  PrettyStackTraceString CrashInfo("Code generation");
+  CodeGenPasses.run(*TheModule);
+}
+
+/// A clean version of `EmitAssembly` that uses the new pass manager.
+///
+/// Not all features are currently supported in this system, but where
+/// necessary it falls back to the legacy pass manager to at least provide
+/// basic functionality.
+///
+/// This API is planned to have its functionality finished and then to replace
+/// `EmitAssembly` at some point in the future when the default switches.
+void EmitAssemblyHelper::EmitAssemblyWithNewPassManager(
+BackendAction Action, std::unique_ptr OS) {
+  TimeRegion Region(CodeGenOpts.TimePasses ?  : nullptr);
+  setCommandLineOpts(CodeGenOpts);
+
+  bool RequiresCodeGen = (Action != Backend_EmitNothing &&
+   

[PATCH] D111258: [PowerPC] Emit dcbt and dcbtst in place of their extended mnemonics on AIX

2021-10-12 Thread Albion Fung via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb4b9f9b4b3cf: [PowerPC] Emit dcbt and dcbtst in place of 
their extended mnemonics on AIX (authored by Conanap).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111258

Files:
  llvm/lib/Target/PowerPC/MCTargetDesc/PPCInstPrinter.cpp
  llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-prefetch.ll


Index: llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-prefetch.ll
===
--- llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-prefetch.ll
+++ llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-prefetch.ll
@@ -26,14 +26,14 @@
 ; CHECK-AIX:   # %bb.0: # %entry
 ; CHECK-AIX-NEXT:lwz 3, L..C0(2) # @vpa
 ; CHECK-AIX-NEXT:lwz 3, 0(3)
-; CHECK-AIX-NEXT:dcbtstt 0, 3
+; CHECK-AIX-NEXT:dcbtst 0, 3, 16
 ; CHECK-AIX-NEXT:blr
 ;
 ; CHECK-AIX64-LABEL: test_dcbtstt:
 ; CHECK-AIX64:   # %bb.0: # %entry
 ; CHECK-AIX64-NEXT:ld 3, L..C0(2) # @vpa
 ; CHECK-AIX64-NEXT:ld 3, 0(3)
-; CHECK-AIX64-NEXT:dcbtstt 0, 3
+; CHECK-AIX64-NEXT:dcbtst 0, 3, 16
 ; CHECK-AIX64-NEXT:blr
 entry:
   %0 = load i8*, i8** @vpa, align 8
@@ -55,14 +55,14 @@
 ; CHECK-AIX:   # %bb.0: # %entry
 ; CHECK-AIX-NEXT:lwz 3, L..C0(2) # @vpa
 ; CHECK-AIX-NEXT:lwz 3, 0(3)
-; CHECK-AIX-NEXT:dcbtt 0, 3
+; CHECK-AIX-NEXT:dcbt 0, 3, 16
 ; CHECK-AIX-NEXT:blr
 ;
 ; CHECK-AIX64-LABEL: test_dcbtt:
 ; CHECK-AIX64:   # %bb.0: # %entry
 ; CHECK-AIX64-NEXT:ld 3, L..C0(2) # @vpa
 ; CHECK-AIX64-NEXT:ld 3, 0(3)
-; CHECK-AIX64-NEXT:dcbtt 0, 3
+; CHECK-AIX64-NEXT:dcbt 0, 3, 16
 ; CHECK-AIX64-NEXT:blr
 entry:
   %0 = load i8*, i8** @vpa, align 8
Index: llvm/lib/Target/PowerPC/MCTargetDesc/PPCInstPrinter.cpp
===
--- llvm/lib/Target/PowerPC/MCTargetDesc/PPCInstPrinter.cpp
+++ llvm/lib/Target/PowerPC/MCTargetDesc/PPCInstPrinter.cpp
@@ -158,7 +158,10 @@
   //dcbt ra, rb, th [server]
   //dcbt th, ra, rb [embedded]
   //  where th can be omitted when it is 0. dcbtst is the same.
-  if (MI->getOpcode() == PPC::DCBT || MI->getOpcode() == PPC::DCBTST) {
+  // On AIX, only emit the extended mnemonics for dcbt and dcbtst if
+  // the "modern assembler" is available.
+  if ((MI->getOpcode() == PPC::DCBT || MI->getOpcode() == PPC::DCBTST) &&
+  (!TT.isOSAIX() || STI.getFeatureBits()[PPC::FeatureModernAIXAs])) {
 unsigned char TH = MI->getOperand(0).getImm();
 O << "\tdcbt";
 if (MI->getOpcode() == PPC::DCBTST)


Index: llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-prefetch.ll
===
--- llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-prefetch.ll
+++ llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-prefetch.ll
@@ -26,14 +26,14 @@
 ; CHECK-AIX:   # %bb.0: # %entry
 ; CHECK-AIX-NEXT:lwz 3, L..C0(2) # @vpa
 ; CHECK-AIX-NEXT:lwz 3, 0(3)
-; CHECK-AIX-NEXT:dcbtstt 0, 3
+; CHECK-AIX-NEXT:dcbtst 0, 3, 16
 ; CHECK-AIX-NEXT:blr
 ;
 ; CHECK-AIX64-LABEL: test_dcbtstt:
 ; CHECK-AIX64:   # %bb.0: # %entry
 ; CHECK-AIX64-NEXT:ld 3, L..C0(2) # @vpa
 ; CHECK-AIX64-NEXT:ld 3, 0(3)
-; CHECK-AIX64-NEXT:dcbtstt 0, 3
+; CHECK-AIX64-NEXT:dcbtst 0, 3, 16
 ; CHECK-AIX64-NEXT:blr
 entry:
   %0 = load i8*, i8** @vpa, align 8
@@ -55,14 +55,14 @@
 ; CHECK-AIX:   # %bb.0: # %entry
 ; CHECK-AIX-NEXT:lwz 3, L..C0(2) # @vpa
 ; CHECK-AIX-NEXT:lwz 3, 0(3)
-; CHECK-AIX-NEXT:dcbtt 0, 3
+; CHECK-AIX-NEXT:dcbt 0, 3, 16
 ; CHECK-AIX-NEXT:blr
 ;
 ; CHECK-AIX64-LABEL: test_dcbtt:
 ; CHECK-AIX64:   # %bb.0: # %entry
 ; CHECK-AIX64-NEXT:ld 3, L..C0(2) # @vpa
 ; CHECK-AIX64-NEXT:ld 3, 0(3)
-; CHECK-AIX64-NEXT:dcbtt 0, 3
+; CHECK-AIX64-NEXT:dcbt 0, 3, 16
 ; CHECK-AIX64-NEXT:blr
 entry:
   %0 = load i8*, i8** @vpa, align 8
Index: llvm/lib/Target/PowerPC/MCTargetDesc/PPCInstPrinter.cpp
===
--- llvm/lib/Target/PowerPC/MCTargetDesc/PPCInstPrinter.cpp
+++ llvm/lib/Target/PowerPC/MCTargetDesc/PPCInstPrinter.cpp
@@ -158,7 +158,10 @@
   //dcbt ra, rb, th [server]
   //dcbt th, ra, rb [embedded]
   //  where th can be omitted when it is 0. dcbtst is the same.
-  if (MI->getOpcode() == PPC::DCBT || MI->getOpcode() == PPC::DCBTST) {
+  // On AIX, only emit the extended mnemonics for dcbt and dcbtst if
+  // the "modern assembler" is available.
+  if ((MI->getOpcode() == PPC::DCBT || MI->getOpcode() == PPC::DCBTST) &&
+  (!TT.isOSAIX() || STI.getFeatureBits()[PPC::FeatureModernAIXAs])) {
 unsigned char TH = MI->getOperand(0).getImm();
 O << "\tdcbt";
 if (MI->getOpcode() == PPC::DCBTST)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org

[PATCH] D102923: [clang][lex] Remark on search path usage

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

In D102923#3059592 , @teemperor wrote:

> This seems to have broken compiling some versions of Foundation/Dispatch with 
> -fmodules enabled (which breaks the LLDB test suite when it tries to compile 
> any Objective-C tests). Can you take a look and/or revert? I mailed you the 
> version/compiler errors.

FYI, Jan is in Europe; if this is blocking LLDB I suggest reverting and he can 
evaluate tomorrow. (I'm a bit surprised this commit triggers a failure anywhere 
since it should be NFC aside from remarks, but I guess there must be a logic 
issue.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102923

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


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

2021-10-12 Thread Anshil Gandhi via Phabricator via cfe-commits
gandhi21299 added inline comments.



Comment at: llvm/test/CodeGen/AMDGPU/inline-calls.ll:3
 ; RUN: llc -march=amdgcn -mcpu=tonga -verify-machineinstrs < %s | FileCheck  %s
-; RUN: llc -march=r600 -mcpu=redwood -verify-machineinstrs < %s | FileCheck %s
 

@tstellar  Is there a way to restrict the AlwaysInliner to only run on amdgcn 
architecture?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109707

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


[PATCH] D102923: [clang][lex] Remark on search path usage

2021-10-12 Thread Raphael Isemann via Phabricator via cfe-commits
teemperor reopened this revision.
teemperor added a comment.
This revision is now accepted and ready to land.

This seems to have broken compiling some versions of Foundation/Dispatch with 
-fmodules enabled (which breaks the LLDB test suite when it tries to compile 
any Objective-C tests). Can you take a look and/or revert? I mailed you the 
version/compiler errors.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102923

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


[PATCH] D111229: [PowerPC][Builtin] Allowing __rlwnm to accept a variable as a shift parameter

2021-10-12 Thread Victor Huang via Phabricator via cfe-commits
NeHuang accepted this revision as: NeHuang.
NeHuang added a comment.
This revision is now accepted and ready to land.

Thanks. LGTM. One minor can be addressed when commit it.




Comment at: clang/test/CodeGen/builtins-ppc-xlcompat-rotate.c:71
+
+  /*shift = 31, mask = 0x1FF = 511*/
+  unsigned int res = __builtin_ppc_rlwnm(ui, shift, 0x1FF);

please remove `shift = 31,` in the comment 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111229

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


[PATCH] D110357: [Analyzer] Extend ConstraintAssignor to handle remainder op

2021-10-12 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added inline comments.



Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:1619
+  return true;
+const SymExpr *LHS = Sym->getLHS();
+const llvm::APSInt  =

steakhal wrote:
> 
Since `SymbolRef` actually is already `const`. (`using SymbolRef = const 
SymExpr *;`)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110357

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


[PATCH] D111229: [PowerPC][Builtin] Allowing __rlwnm to accept a variable as a shift parameter

2021-10-12 Thread Kamau Bridgeman via Phabricator via cfe-commits
kamaub updated this revision to Diff 379149.
kamaub added a comment.

Adding shift variable test case to `builtins-ppc-xlcompat-rotate.c` as per
review comment request.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111229

Files:
  clang/include/clang/Basic/BuiltinsPPC.def
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/builtins-ppc-xlcompat-error.c
  clang/test/CodeGen/builtins-ppc-xlcompat-rotate.c


Index: clang/test/CodeGen/builtins-ppc-xlcompat-rotate.c
===
--- clang/test/CodeGen/builtins-ppc-xlcompat-rotate.c
+++ clang/test/CodeGen/builtins-ppc-xlcompat-rotate.c
@@ -56,6 +56,22 @@
   unsigned int res = __builtin_ppc_rlwnm(ui, 31, 0x1FF);
 }
 
+void test_builtin_ppc_rlwnm2(unsigned int shift) {
+  // CHECK-LABEL: test_builtin_ppc_rlwnm2
+  // CHECK:   %shift.addr = alloca i32, align 4
+  // CHECK-NEXT:  %res = alloca i32, align 4
+  // CHECK-NEXT:  store i32 %shift, i32* %shift.addr, align 4
+  // CHECK-NEXT:  [[RA:%[0-9]+]] = load i32, i32* @ui, align 4
+  // CHECK-NEXT:  [[RB:%[0-9]+]] = load i32, i32* %shift.addr, align 4
+  // CHECK-NEXT:  [[RC:%[0-9]+]] = call i32 @llvm.fshl.i32(i32 [[RA]], i32 
[[RA]], i32 [[RB]])
+  // CHECK-NEXT:  [[RD:%[0-9]+]] = and i32 [[RC]], 511
+  // CHECK-NEXT:  store i32 [[RD]], i32* %res, align 4
+  // CHECK-NEXT:  ret void
+
+  /*shift = 31, mask = 0x1FF = 511*/
+  unsigned int res = __builtin_ppc_rlwnm(ui, shift, 0x1FF);
+}
+
 // CHECK-LABEL: @testrotatel4(
 // CHECK: [[TMP:%.*]] = call i32 @llvm.fshl.i32(i32 {{%.*}}, i32 
{{%.*}}, i32 {{%.*}})
 // CHECK-NEXT:ret i32 [[TMP]]
Index: clang/test/CodeGen/builtins-ppc-xlcompat-error.c
===
--- clang/test/CodeGen/builtins-ppc-xlcompat-error.c
+++ clang/test/CodeGen/builtins-ppc-xlcompat-error.c
@@ -41,10 +41,8 @@
 }
 
 void test_builtin_ppc_rlwnm() {
-  unsigned int shift;
   unsigned int mask;
-  unsigned int res = __builtin_ppc_rlwnm(ui, shift, 7); // expected-error 
{{argument to '__builtin_ppc_rlwnm' must be a constant integer}}
-  res = __builtin_ppc_rlwnm(ui, 31, mask);  // expected-error 
{{argument to '__builtin_ppc_rlwnm' must be a constant integer}}
+  unsigned int res = __builtin_ppc_rlwnm(ui, 31, mask);  // 
expected-error {{argument to '__builtin_ppc_rlwnm' must be a constant integer}}
   res = __builtin_ppc_rlwnm(ui, 31, 0xFF0F0F00);// expected-error 
{{argument 2 value should represent a contiguous bit field}}
 }
 
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -3432,8 +3432,7 @@
   // For __rlwnm, __rlwimi and __rldimi, the last parameter mask must
   // be a constant that represents a contiguous bit field.
   case PPC::BI__builtin_ppc_rlwnm:
-return SemaBuiltinConstantArg(TheCall, 1, Result) ||
-   SemaValueIsRunOfOnes(TheCall, 2);
+return SemaValueIsRunOfOnes(TheCall, 2);
   case PPC::BI__builtin_ppc_rlwimi:
   case PPC::BI__builtin_ppc_rldimi:
 return SemaBuiltinConstantArg(TheCall, 2, Result) ||
Index: clang/include/clang/Basic/BuiltinsPPC.def
===
--- clang/include/clang/Basic/BuiltinsPPC.def
+++ clang/include/clang/Basic/BuiltinsPPC.def
@@ -117,7 +117,7 @@
 BUILTIN(__builtin_ppc_maddhdu, "ULLiULLiULLiULLi", "")
 BUILTIN(__builtin_ppc_maddld, "LLiLLiLLiLLi", "")
 // Rotate
-BUILTIN(__builtin_ppc_rlwnm, "UiUiIUiIUi", "")
+BUILTIN(__builtin_ppc_rlwnm, "UiUiUiIUi", "")
 BUILTIN(__builtin_ppc_rlwimi, "UiUiUiIUiIUi", "")
 BUILTIN(__builtin_ppc_rldimi, "ULLiULLiULLiIUiIULLi", "")
 // load


Index: clang/test/CodeGen/builtins-ppc-xlcompat-rotate.c
===
--- clang/test/CodeGen/builtins-ppc-xlcompat-rotate.c
+++ clang/test/CodeGen/builtins-ppc-xlcompat-rotate.c
@@ -56,6 +56,22 @@
   unsigned int res = __builtin_ppc_rlwnm(ui, 31, 0x1FF);
 }
 
+void test_builtin_ppc_rlwnm2(unsigned int shift) {
+  // CHECK-LABEL: test_builtin_ppc_rlwnm2
+  // CHECK:   %shift.addr = alloca i32, align 4
+  // CHECK-NEXT:  %res = alloca i32, align 4
+  // CHECK-NEXT:  store i32 %shift, i32* %shift.addr, align 4
+  // CHECK-NEXT:  [[RA:%[0-9]+]] = load i32, i32* @ui, align 4
+  // CHECK-NEXT:  [[RB:%[0-9]+]] = load i32, i32* %shift.addr, align 4
+  // CHECK-NEXT:  [[RC:%[0-9]+]] = call i32 @llvm.fshl.i32(i32 [[RA]], i32 [[RA]], i32 [[RB]])
+  // CHECK-NEXT:  [[RD:%[0-9]+]] = and i32 [[RC]], 511
+  // CHECK-NEXT:  store i32 [[RD]], i32* %res, align 4
+  // CHECK-NEXT:  ret void
+
+  /*shift = 31, mask = 0x1FF = 511*/
+  unsigned int res = __builtin_ppc_rlwnm(ui, shift, 0x1FF);
+}
+
 // CHECK-LABEL: @testrotatel4(
 // CHECK: [[TMP:%.*]] = call i32 @llvm.fshl.i32(i32 {{%.*}}, i32 

[PATCH] D111642: [Analyzer][solver] Simplification: reorganize equalities with adjustment

2021-10-12 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added a comment.

The coverage report of the test shows that L2124 is uncovered. Please add a 
test demonstrating that path as well.
I'm gonna come back to this tomorrow.




Comment at: clang/test/Analysis/solver-sym-simplification-adjustment.c:36
+  clang_analyzer_warnIfReached();  // expected-warning{{REACHABLE}}
+  if (b != 1)  // b == 1  --> c + 1: [-1,0] --> c: [-2,-1]
+return;

Please express that `C: [-2,-1]` is then intersected with the already 
associated range which is `[-1,1]`, thus we get `c: [-1,-1]`.



Comment at: clang/test/Analysis/solver-sym-simplification-adjustment.c:55
+  if (b != 1) // b == 1  --> c + 1 == 0 --> c == -1 contradiction
+return;
+  clang_analyzer_warnIfReached(); // no warning

Can we infer within this true branch that `b` must be `0` to make this path 
feasible?
If we already can infer this, can we put there the appropriate assertion?
If not, an assertion would be justified with a FIXME.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111642

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


[PATCH] D111665: [CUDA] Provide address space conversion builtins.

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

Not loving the magic constants here but I don't think we have a enum or similar 
right now.
I also have to question the people that choose `size_t` here... we will end up 
with int2ptr(ptr2int(...)) IR everywhere if this is actually used (outside the 
asm uses in cuda).
Anyway, LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111665

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


[PATCH] D111041: [clang-tidy] Remove 'IgnoreDestructors = true' from cppcoreguidelines-explicit-virtual-functions

2021-10-12 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D111041#3059245 , @carlosgalvezp 
wrote:

>> Eh, I personally don't care all that much one way or the other (so sure, I 
>> can do that!), but I recall there being a push to keep the "title" line 
>> under something very small (50 chars?) because of the way tools sometimes 
>> display this information to users, so I've always stripped the bit within [] 
>> to ensure we keep a sufficiently short title.
>
> Yeah I understand, it makes sense. I just find that in general that's not 
> respected so I wonder if people choose consistency in using [] over short 
> commit messages. I can also find this in the Docs:
>
>> When the changes are restricted to a specific part of the code (e.g. a 
>> back-end or optimization pass), it is customary to add a tag to the 
>> beginning of the line in square brackets. For example, “[SCEV] …” or 
>> “[OpenMP] …”. This helps email filters and searches for post-commit reviews.
>
> Anyhow, minor detail :)

Yeah, we're pretty inconsistent about this because it depends on the committer 
and what process they use to land commits. I commit manually (I don't use arc), 
so I can leave the tags in easily enough.

>> That said, I'm wondering if you're planning to stick around in the 
>> clang-tidy community? If so, given that you've got a few good patches 
>> accepted already, it might be time to consider getting you commit privileges 
>> of your own. 
>> https://llvm.org/docs/DeveloperPolicy.html#obtaining-commit-access has more 
>> details on what that entails.
>
> That'd be great, thanks for the support! Since I'm mostly working on this on 
> my spare time I can't promise much involvement, but rather occasional bug 
> fixes and minor improvements. Still would be good to lift the commit burden 
> from you haha. I really enjoy the repro structure, build system and 
> processes, it's a very nice codebase to work with. If time allows I could 
> potentially look into larger pieces of work, like adding new clang-tidy 
> modules (e.g. Misra/Autosar checks). I find some local forks here and there 
> that have done it but never pushed upstream, which I find a bit sad.

It's totally up to you if you'd like to request commit access or not (I'll 
happily support your request), but it's not a burden for me to commit things. I 
just have to be around to babysit the bots in case a fix or revert is needed, 
basically. My recommendation is: if you think you'll do patches here and there 
as time allows, you might as well request commit access; if you think your 
contributions are likely to not continue in the future, then no reason to do 
that dance.


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

https://reviews.llvm.org/D111041

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


[PATCH] D110357: [Analyzer] Extend ConstraintAssignor to handle remainder op

2021-10-12 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added a comment.

BWT the following lines are uncovered by tests: L1627, L1651, L1758
Please adjust your tests accordingly.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110357

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


[PATCH] D111582: [clang] Teardown new PM data structures before running codegen pipeline

2021-10-12 Thread David Blaikie via Phabricator via cfe-commits
dblaikie accepted this revision.
dblaikie added a comment.
This revision is now accepted and ready to land.

Looks great!




Comment at: clang/lib/CodeGen/BackendUtil.cpp:1441-1442
-
-  // FIXME: We still use the legacy pass manager to do code generation. We
-  // create that pass manager here and use it as needed below.
-  legacy::PassManager CodeGenPasses;

Looks like this comment got lost - might be worth preserving in 
`RunCodegenPipeline`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111582

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


[PATCH] D111669: No longer crash when a consteval function returns a structure

2021-10-12 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman created this revision.
aaron.ballman added reviewers: erichkeane, rsmith, rjmccall.
aaron.ballman requested review of this revision.
Herald added a project: clang.

I don't think the aggregate emitter needs to emit anything when handling a 
constant expression which has an unused result. The unused result means we have 
nowhere to store the value anyway during codegen, so this early returns in that 
case.

This addresses PR51484.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D111669

Files:
  clang/lib/CodeGen/CGExprAgg.cpp
  clang/test/CodeGenCXX/cxx20-consteval-crash.cpp


Index: clang/test/CodeGenCXX/cxx20-consteval-crash.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/cxx20-consteval-crash.cpp
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -std=c++20 %s -emit-llvm 
-o - | FileCheck %s
+
+// Test case comes from PR51484, where this code previously caused a crash.
+struct X { int val; };
+consteval X g() { return {0}; }
+void f() { g(); }
+
+// CHECK: define dso_local void @_Z1fv() #0 {
+// CHECK: entry:
+// CHECK-NOT: call i32 @_Z1gv()
+// CHECK:  ret void
+// CHECK: }
Index: clang/lib/CodeGen/CGExprAgg.cpp
===
--- clang/lib/CodeGen/CGExprAgg.cpp
+++ clang/lib/CodeGen/CGExprAgg.cpp
@@ -127,6 +127,10 @@
   }
 
   void VisitConstantExpr(ConstantExpr *E) {
+// If the result is unused, no need to emit anything for it.
+if (IsResultUnused)
+  return;
+
 if (llvm::Value *Result = ConstantEmitter(CGF).tryEmitConstantExpr(E)) {
   CGF.EmitAggregateStore(Result, Dest.getAddress(),
  E->getType().isVolatileQualified());


Index: clang/test/CodeGenCXX/cxx20-consteval-crash.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/cxx20-consteval-crash.cpp
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -std=c++20 %s -emit-llvm -o - | FileCheck %s
+
+// Test case comes from PR51484, where this code previously caused a crash.
+struct X { int val; };
+consteval X g() { return {0}; }
+void f() { g(); }
+
+// CHECK: define dso_local void @_Z1fv() #0 {
+// CHECK: entry:
+// CHECK-NOT: call i32 @_Z1gv()
+// CHECK:  ret void
+// CHECK: }
Index: clang/lib/CodeGen/CGExprAgg.cpp
===
--- clang/lib/CodeGen/CGExprAgg.cpp
+++ clang/lib/CodeGen/CGExprAgg.cpp
@@ -127,6 +127,10 @@
   }
 
   void VisitConstantExpr(ConstantExpr *E) {
+// If the result is unused, no need to emit anything for it.
+if (IsResultUnused)
+  return;
+
 if (llvm::Value *Result = ConstantEmitter(CGF).tryEmitConstantExpr(E)) {
   CGF.EmitAggregateStore(Result, Dest.getAddress(),
  E->getType().isVolatileQualified());
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D111229: [PowerPC][Builtin] Allowing __rlwnm to accept a variable as a shift parameter

2021-10-12 Thread Victor Huang via Phabricator via cfe-commits
NeHuang added a comment.

Please check and add a test  in 
`clang/test/CodeGen/builtins-ppc-xlcompat-rotate.c` with `shift` as a variable.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111229

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


[PATCH] D111371: [Support][ThinLTO] Move ThinLTO caching to LLVM Support library.

2021-10-12 Thread Noah Shutty via Phabricator via cfe-commits
noajshu added a comment.

@tejohnson Thanks for your comments! From my perspective this patch is done. 
Please let me know if you have any further changes to suggest before accepting. 
Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111371

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


[PATCH] D111665: [CUDA] Provide address space conversion builtins.

2021-10-12 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment.

Tested by verifying that generated code (both PTX and SASS) matches that of 
NVCC: https://godbolt.org/z/rWYYx63bT


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111665

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


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

2021-10-12 Thread Emma Blink via Phabricator via cfe-commits
0x1eaf marked an inline comment as done.
0x1eaf added a comment.

I don't have commit access, so would appreciate if you commit it, thanks!

Forgot to mention on Friday:

I've instrumented preamble building, but haven't instrumented background 
indexing which is outside of `TUScheduler.cpp` and would require exposing 
`crashDump*` helpers and preferably moving them out of `TUScheduler.cpp`. And I 
think it might be easier to review it separately. Speaking of the helpers, 
where would you prefer those to be: a new file+header under clangd/support, or 
in some existing place?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109506

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


[PATCH] D111655: [analyzer] non-obvious analyzer warning: Use of zero-allocated memory

2021-10-12 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

Yuck I forgot to forge commit author. Sorry!!




Comment at: clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp:2474-2475
 auto R = std::make_unique(
-*BT_UseZerroAllocated[*CheckKind], "Use of zero-allocated memory", N);
+*BT_UseZerroAllocated[*CheckKind],
+"Use of memory allocated with size zero", N);
 

Quuxplusone wrote:
> Peanut gallery says:
> (1) Might want to fix the typo in "Zerro" at the same time, or in a followup 
> commit.
> (2) I would naively have expected all the test cases below to give something 
> simple like "Read/write beyond end of allocated space," because they allocate 
> N bytes and then try to read/write into byte number N. This is //never// 
> allowed in C or C++, regardless of the value of N; there's nothing special 
> about N=0. So I don't see why it needs //any// special diagnostic (confusing 
> or otherwise).
The only thing special about N=0 is that the static analyzer is currently 
better at catching it. It's much easier to catch correctly and avoid false 
positives when *any* use is disallowed than when some uses are allowed but some 
aren't.

Speaking of typos, it probably also makes sense to fix the bug type message 
("Use of zero allocated") to include a subject.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111655

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


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

2021-10-12 Thread Emma Blink via Phabricator via cfe-commits
0x1eaf updated this revision to Diff 379124.
0x1eaf added a comment.

Updated the AST worker crash handler to avoid `std::string` copy: used a char 
pointer instead.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109506

Files:
  clang-tools-extra/clangd/JSONTransport.cpp
  clang-tools-extra/clangd/TUScheduler.cpp
  clang-tools-extra/clangd/support/CMakeLists.txt
  clang-tools-extra/clangd/support/ThreadCrashReporter.cpp
  clang-tools-extra/clangd/support/ThreadCrashReporter.h
  clang-tools-extra/clangd/test/crash.test
  clang-tools-extra/clangd/tool/ClangdMain.cpp
  clang-tools-extra/clangd/unittests/CMakeLists.txt
  clang-tools-extra/clangd/unittests/ThreadCrashReporterTests.cpp

Index: clang-tools-extra/clangd/unittests/ThreadCrashReporterTests.cpp
===
--- /dev/null
+++ clang-tools-extra/clangd/unittests/ThreadCrashReporterTests.cpp
@@ -0,0 +1,78 @@
+///===- ThreadCrashReporterTests.cpp - Thread local signal handling tests -===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "support/ThreadCrashReporter.h"
+#include "support/Threading.h"
+#include "llvm/Support/Signals.h"
+#include "gtest/gtest.h"
+#include 
+#include 
+
+namespace clang {
+namespace clangd {
+
+namespace {
+
+static void infoSignalHandler() { ThreadCrashReporter::runCrashHandlers(); }
+
+TEST(ThreadCrashReporterTest, All) {
+#if defined(_WIN32)
+  // Simulate signals on Windows for unit testing purposes.
+  // The `crash.test` lit test checks the end-to-end integration.
+  auto SignalCurrentThread = []() { infoSignalHandler(); };
+#else
+  llvm::sys::SetInfoSignalFunction();
+  auto SignalCurrentThread = []() { raise(SIGUSR1); };
+#endif
+
+  AsyncTaskRunner Runner;
+  auto SignalAnotherThread = [&]() {
+Runner.runAsync("signal another thread", SignalCurrentThread);
+Runner.wait();
+  };
+
+  bool Called;
+  {
+ThreadCrashReporter ScopedReporter([]() { Called = true; });
+// Check handler gets called when a signal gets delivered to the current
+// thread.
+Called = false;
+SignalCurrentThread();
+EXPECT_TRUE(Called);
+
+// Check handler does not get called when another thread gets signalled.
+Called = false;
+SignalAnotherThread();
+EXPECT_FALSE(Called);
+  }
+  // Check handler does not get called when the reporter object goes out of
+  // scope.
+  Called = false;
+  SignalCurrentThread();
+  EXPECT_FALSE(Called);
+
+  std::string Order = "";
+  {
+ThreadCrashReporter ScopedReporter([] { Order.push_back('a'); });
+{
+  ThreadCrashReporter ScopedReporter([] { Order.push_back('b'); });
+  SignalCurrentThread();
+}
+// Check that handlers are called in LIFO order.
+EXPECT_EQ(Order, "ba");
+
+// Check that current handler is the only one after the nested scope is
+// over.
+SignalCurrentThread();
+EXPECT_EQ(Order, "baa");
+  }
+}
+
+} // namespace
+} // namespace clangd
+} // namespace clang
Index: clang-tools-extra/clangd/unittests/CMakeLists.txt
===
--- clang-tools-extra/clangd/unittests/CMakeLists.txt
+++ clang-tools-extra/clangd/unittests/CMakeLists.txt
@@ -88,6 +88,7 @@
   TestIndex.cpp
   TestTU.cpp
   TestWorkspace.cpp
+  ThreadCrashReporterTests.cpp
   TidyProviderTests.cpp
   TypeHierarchyTests.cpp
   URITests.cpp
Index: clang-tools-extra/clangd/tool/ClangdMain.cpp
===
--- clang-tools-extra/clangd/tool/ClangdMain.cpp
+++ clang-tools-extra/clangd/tool/ClangdMain.cpp
@@ -24,6 +24,7 @@
 #include "refactor/Rename.h"
 #include "support/Path.h"
 #include "support/Shutdown.h"
+#include "support/ThreadCrashReporter.h"
 #include "support/ThreadsafeFS.h"
 #include "support/Trace.h"
 #include "clang/Format/Format.h"
@@ -679,6 +680,8 @@
 
   llvm::InitializeAllTargetInfos();
   llvm::sys::PrintStackTraceOnErrorSignal(argv[0]);
+  llvm::sys::AddSignalHandler(
+  [](void *) { ThreadCrashReporter::runCrashHandlers(); }, nullptr);
   llvm::sys::SetInterruptFunction();
   llvm::cl::SetVersionPrinter([](llvm::raw_ostream ) {
 OS << versionString() << "\n"
Index: clang-tools-extra/clangd/test/crash.test
===
--- /dev/null
+++ clang-tools-extra/clangd/test/crash.test
@@ -0,0 +1,5 @@
+# Overflow the recursive json parser, prevent `yes` error due to broken pipe and `clangd` SIGSEGV from being treated as a failure.
+# RUN: (yes '[' || :) | head -n 5 | (clangd --input-style=delimited 2>&1 || :) | FileCheck %s
+#  CHECK: Signalled while processing message:

[PATCH] D111665: [CUDA] Provide address space conversion builtins.

2021-10-12 Thread Artem Belevich via Phabricator via cfe-commits
tra created this revision.
tra added a reviewer: jdoerfert.
Herald added subscribers: bixia, yaxunl.
tra requested review of this revision.
Herald added a project: clang.

CUDA-11 headers rely on these NVCC builtins.
Despite having `__nv` previx, those are *not* provided by libdevice.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D111665

Files:
  clang/lib/Headers/__clang_cuda_intrinsics.h


Index: clang/lib/Headers/__clang_cuda_intrinsics.h
===
--- clang/lib/Headers/__clang_cuda_intrinsics.h
+++ clang/lib/Headers/__clang_cuda_intrinsics.h
@@ -483,4 +483,36 @@
 
 #endif // !defined(__CUDA_ARCH__) || __CUDA_ARCH__ >= 320
 
+#if CUDA_VERSION >= 11000
+extern "C" {
+__device__ inline size_t __nv_cvta_generic_to_global_impl(const void *__ptr) {
+  return (size_t)(void __attribute__((address_space(1))) *)__ptr;
+}
+__device__ inline size_t __nv_cvta_generic_to_shared_impl(const void *__ptr) {
+  return (size_t)(void __attribute__((address_space(3))) *)__ptr;
+}
+__device__ inline size_t __nv_cvta_generic_to_constant_impl(const void *__ptr) 
{
+  return (size_t)(void __attribute__((address_space(4))) *)__ptr;
+}
+__device__ inline size_t __nv_cvta_generic_to_local_impl(const void *__ptr) {
+  return (size_t)(void __attribute__((address_space(5))) *)__ptr;
+}
+__device__ inline void *__nv_cvta_global_to_generic_impl(size_t __ptr) {
+  return (void *)(void __attribute__((address_space(1))) *)__ptr;
+}
+__device__ inline void *__nv_cvta_shared_to_generic_impl(size_t __ptr) {
+  return (void *)(void __attribute__((address_space(3))) *)__ptr;
+}
+__device__ inline void *__nv_cvta_constant_to_generic_impl(size_t __ptr) {
+  return (void *)(void __attribute__((address_space(4))) *)__ptr;
+}
+__device__ inline void *__nv_cvta_local_to_generic_impl(size_t __ptr) {
+  return (void *)(void __attribute__((address_space(5))) *)__ptr;
+}
+__device__ inline uint32_t __nvvm_get_smem_pointer(void *__ptr) {
+  return __nv_cvta_generic_to_shared_impl(__ptr);
+}
+} // extern "C"
+#endif // CUDA_VERSION >= 11000
+
 #endif // defined(__CLANG_CUDA_INTRINSICS_H__)


Index: clang/lib/Headers/__clang_cuda_intrinsics.h
===
--- clang/lib/Headers/__clang_cuda_intrinsics.h
+++ clang/lib/Headers/__clang_cuda_intrinsics.h
@@ -483,4 +483,36 @@
 
 #endif // !defined(__CUDA_ARCH__) || __CUDA_ARCH__ >= 320
 
+#if CUDA_VERSION >= 11000
+extern "C" {
+__device__ inline size_t __nv_cvta_generic_to_global_impl(const void *__ptr) {
+  return (size_t)(void __attribute__((address_space(1))) *)__ptr;
+}
+__device__ inline size_t __nv_cvta_generic_to_shared_impl(const void *__ptr) {
+  return (size_t)(void __attribute__((address_space(3))) *)__ptr;
+}
+__device__ inline size_t __nv_cvta_generic_to_constant_impl(const void *__ptr) {
+  return (size_t)(void __attribute__((address_space(4))) *)__ptr;
+}
+__device__ inline size_t __nv_cvta_generic_to_local_impl(const void *__ptr) {
+  return (size_t)(void __attribute__((address_space(5))) *)__ptr;
+}
+__device__ inline void *__nv_cvta_global_to_generic_impl(size_t __ptr) {
+  return (void *)(void __attribute__((address_space(1))) *)__ptr;
+}
+__device__ inline void *__nv_cvta_shared_to_generic_impl(size_t __ptr) {
+  return (void *)(void __attribute__((address_space(3))) *)__ptr;
+}
+__device__ inline void *__nv_cvta_constant_to_generic_impl(size_t __ptr) {
+  return (void *)(void __attribute__((address_space(4))) *)__ptr;
+}
+__device__ inline void *__nv_cvta_local_to_generic_impl(size_t __ptr) {
+  return (void *)(void __attribute__((address_space(5))) *)__ptr;
+}
+__device__ inline uint32_t __nvvm_get_smem_pointer(void *__ptr) {
+  return __nv_cvta_generic_to_shared_impl(__ptr);
+}
+} // extern "C"
+#endif // CUDA_VERSION >= 11000
+
 #endif // defined(__CLANG_CUDA_INTRINSICS_H__)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D111041: [clang-tidy] Remove 'IgnoreDestructors = true' from cppcoreguidelines-explicit-virtual-functions

2021-10-12 Thread Carlos Galvez via Phabricator via cfe-commits
carlosgalvezp added a comment.

> Eh, I personally don't care all that much one way or the other (so sure, I 
> can do that!), but I recall there being a push to keep the "title" line under 
> something very small (50 chars?) because of the way tools sometimes display 
> this information to users, so I've always stripped the bit within [] to 
> ensure we keep a sufficiently short title.

Yeah I understand, it makes sense. I just find that in general that's not 
respected so I wonder if people choose consistency in using [] over short 
commit messages. I can also find this in the Docs:

> When the changes are restricted to a specific part of the code (e.g. a 
> back-end or optimization pass), it is customary to add a tag to the beginning 
> of the line in square brackets. For example, “[SCEV] …” or “[OpenMP] …”. This 
> helps email filters and searches for post-commit reviews.

Anyhow, minor detail :)

> That said, I'm wondering if you're planning to stick around in the clang-tidy 
> community? If so, given that you've got a few good patches accepted already, 
> it might be time to consider getting you commit privileges of your own. 
> https://llvm.org/docs/DeveloperPolicy.html#obtaining-commit-access has more 
> details on what that entails.

That'd be great, thanks for the support! Since I'm mostly working on this on my 
spare time I can't promise much involvement, but rather occasional bug fixes 
and minor improvements. Still would be good to lift the commit burden from you 
haha. I really enjoy the repro structure, build system and processes, it's a 
very nice codebase to work with. If time allows I could potentially look into 
larger pieces of work, like adding new clang-tidy modules (e.g. Misra/Autosar 
checks). I find some local forks here and there that have done it but never 
pushed upstream, which I find a bit sad.


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

https://reviews.llvm.org/D111041

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


[PATCH] D109981: [Diagnostics] Don't drop a statically set NoWarningAsError flag during option processing

2021-10-12 Thread Wolfgang Pieb via Phabricator via cfe-commits
wolfgangp added a comment.

ping ...


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

https://reviews.llvm.org/D109981

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


[PATCH] D99797: [analyzer] Implemented RangeSet::Factory::unite function to handle intersections and adjacency

2021-10-12 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added a comment.

I still need to chew through the code but on a high level, I think it looks 
correct.
PS: the test coverage is outstanding! F19575968: unite-patch-line-coverage.zip 





Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:149
+
+RangeSet RangeSet::Factory::unite(RangeSet Original, llvm::APSInt Point) {
+  return unite(Original, Range(ValueFactory.getValue(Point)));

Why do you take `APSInt`s by value? Generally, we take them by reference.



Comment at: clang/unittests/StaticAnalyzer/RangeSetTest.cpp:81
   const llvm::APSInt (BaseType X) {
-llvm::APSInt Dummy = Base;
-Dummy = X;
-return BVF.getValue(Dummy);
+static llvm::APSInt Base{sizeof(BaseType) * 8,
+ std::is_unsigned::value};

Shouldn't you use `sizeof(BaseType) * CHAR_BIT` instead?


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

https://reviews.llvm.org/D99797

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


[PATCH] D111582: [clang] Clear IR analyses before codegen pipeline

2021-10-12 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks updated this revision to Diff 379111.
aeubanks added a comment.

refactor


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111582

Files:
  clang/lib/CodeGen/BackendUtil.cpp

Index: clang/lib/CodeGen/BackendUtil.cpp
===
--- clang/lib/CodeGen/BackendUtil.cpp
+++ clang/lib/CodeGen/BackendUtil.cpp
@@ -147,6 +147,14 @@
 return F;
   }
 
+  void
+  RunOptimizationPipeline(BackendAction Action,
+  std::unique_ptr ,
+  std::unique_ptr );
+  void RunCodegenPipeline(BackendAction Action,
+  std::unique_ptr ,
+  std::unique_ptr );
+
 public:
   EmitAssemblyHelper(DiagnosticsEngine &_Diags,
  const HeaderSearchOptions ,
@@ -1199,29 +1207,9 @@
   });
 }
 
-/// A clean version of `EmitAssembly` that uses the new pass manager.
-///
-/// Not all features are currently supported in this system, but where
-/// necessary it falls back to the legacy pass manager to at least provide
-/// basic functionality.
-///
-/// This API is planned to have its functionality finished and then to replace
-/// `EmitAssembly` at some point in the future when the default switches.
-void EmitAssemblyHelper::EmitAssemblyWithNewPassManager(
-BackendAction Action, std::unique_ptr OS) {
-  TimeRegion Region(CodeGenOpts.TimePasses ?  : nullptr);
-  setCommandLineOpts(CodeGenOpts);
-
-  bool RequiresCodeGen = (Action != Backend_EmitNothing &&
-  Action != Backend_EmitBC &&
-  Action != Backend_EmitLL);
-  CreateTargetMachine(RequiresCodeGen);
-
-  if (RequiresCodeGen && !TM)
-return;
-  if (TM)
-TheModule->setDataLayout(TM->createDataLayout());
-
+void EmitAssemblyHelper::RunOptimizationPipeline(
+BackendAction Action, std::unique_ptr ,
+std::unique_ptr ) {
   Optional PGOOpt;
 
   if (CodeGenOpts.hasProfileIRInstr())
@@ -1437,18 +1425,7 @@
   MPM.addPass(ModuleMemProfilerPass());
 }
   }
-
-  // FIXME: We still use the legacy pass manager to do code generation. We
-  // create that pass manager here and use it as needed below.
-  legacy::PassManager CodeGenPasses;
-  bool NeedCodeGen = false;
-  std::unique_ptr ThinLinkOS, DwoOS;
-
-  // Append any output we need to the pass manager.
   switch (Action) {
-  case Backend_EmitNothing:
-break;
-
   case Backend_EmitBC:
 if (CodeGenOpts.PrepareForThinLTO && !CodeGenOpts.DisableLLVMPasses) {
   if (!CodeGenOpts.ThinLinkBitcodeFile.empty()) {
@@ -1464,8 +1441,7 @@
   // Emit a module summary by default for Regular LTO except for ld64
   // targets
   bool EmitLTOSummary =
-  (CodeGenOpts.PrepareForLTO &&
-   !CodeGenOpts.DisableLLVMPasses &&
+  (CodeGenOpts.PrepareForLTO && !CodeGenOpts.DisableLLVMPasses &&
llvm::Triple(TheModule->getTargetTriple()).getVendor() !=
llvm::Triple::Apple);
   if (EmitLTOSummary) {
@@ -1483,10 +1459,25 @@
 MPM.addPass(PrintModulePass(*OS, "", CodeGenOpts.EmitLLVMUseLists));
 break;
 
+  default:
+break;
+  }
+
+  // Now that we have all of the passes ready, run them.
+  PrettyStackTraceString CrashInfo("Optimizer");
+  MPM.run(*TheModule, MAM);
+}
+
+void EmitAssemblyHelper::RunCodegenPipeline(
+BackendAction Action, std::unique_ptr ,
+std::unique_ptr ) {
+  legacy::PassManager CodeGenPasses;
+
+  // Append any output we need to the pass manager.
+  switch (Action) {
   case Backend_EmitAssembly:
   case Backend_EmitMCNull:
   case Backend_EmitObj:
-NeedCodeGen = true;
 CodeGenPasses.add(
 createTargetTransformInfoWrapperPass(getTargetIRAnalysis()));
 if (!CodeGenOpts.SplitDwarfOutput.empty()) {
@@ -1499,22 +1490,42 @@
   // FIXME: Should we handle this error differently?
   return;
 break;
+  default:
+return;
   }
 
+  PrettyStackTraceString CrashInfo("Code generation");
+  CodeGenPasses.run(*TheModule);
+}
+
+/// A clean version of `EmitAssembly` that uses the new pass manager.
+///
+/// Not all features are currently supported in this system, but where
+/// necessary it falls back to the legacy pass manager to at least provide
+/// basic functionality.
+///
+/// This API is planned to have its functionality finished and then to replace
+/// `EmitAssembly` at some point in the future when the default switches.
+void EmitAssemblyHelper::EmitAssemblyWithNewPassManager(
+BackendAction Action, std::unique_ptr OS) {
+  TimeRegion Region(CodeGenOpts.TimePasses ?  : nullptr);
+  setCommandLineOpts(CodeGenOpts);
+
+  bool RequiresCodeGen = (Action != Backend_EmitNothing &&
+  Action != Backend_EmitBC && Action != Backend_EmitLL);
+  CreateTargetMachine(RequiresCodeGen);
+
+  if (RequiresCodeGen && !TM)
+return;
+  if (TM)
+

[PATCH] D111488: [Clang][clang-nvlink-wrapper] Pass nvlink path to the wrapper

2021-10-12 Thread Michael Kruse via Phabricator via cfe-commits
Meinersbur added a comment.

Thanks, this fixed the errors introduced in D105191 
: 
http://meinersbur.de:8011/#/builders/1/builds/1594


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111488

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


[PATCH] D111041: [clang-tidy] Remove 'IgnoreDestructors = true' from cppcoreguidelines-explicit-virtual-functions

2021-10-12 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D111041#3059054 , @carlosgalvezp 
wrote:

> Thanks a lot for the review and the help!
>
> By the way, should we keep the [clang-tidy] header for the next commits? 
> Glancing at the commit history, I think it's much easier to see what the 
> commit is updating, and probably can setup email filters to only receive 
> notifications e.g. when [clang-tidy] is in the commit message. It's also 
> consistent with the rest of commits. For example this one:
>
> https://github.com/llvm/llvm-project/commit/a76cfc2e840ff373b80e3a5f84fc48c5f1f90d8a

Eh, I personally don't care all that much one way or the other (so sure, I can 
do that!), but I recall there being a push to keep the "title" line under 
something very small (50 chars?) because of the way tools sometimes display 
this information to users, so I've always stripped the bit within [] to ensure 
we keep a sufficiently short title.

That said, I'm wondering if you're planning to stick around in the clang-tidy 
community? If so, given that you've got a few good patches accepted already, it 
might be time to consider getting you commit privileges of your own. 
https://llvm.org/docs/DeveloperPolicy.html#obtaining-commit-access has more 
details on what that entails.


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

https://reviews.llvm.org/D111041

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


[PATCH] D111655: [analyzer] non-obvious analyzer warning: Use of zero-allocated memory

2021-10-12 Thread Artem Dergachev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf3ec9d8501c9: [analyzer] Fix non-obvious analyzer warning: 
Use of zero-allocated memory. (authored by dergachev.a).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111655

Files:
  clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
  clang/test/Analysis/NewDelete-checker-test.cpp
  clang/test/Analysis/malloc.c

Index: clang/test/Analysis/malloc.c
===
--- clang/test/Analysis/malloc.c
+++ clang/test/Analysis/malloc.c
@@ -261,23 +261,23 @@
 
 void CheckUseZeroAllocated1() {
   int *p = malloc(0);
-  *p = 1; // expected-warning {{Use of zero-allocated memory}}
+  *p = 1; // expected-warning {{Use of memory allocated with size zero}}
   free(p);
 }
 
 char CheckUseZeroAllocated2() {
   char *p = alloca(0);
-  return *p; // expected-warning {{Use of zero-allocated memory}}
+  return *p; // expected-warning {{Use of memory allocated with size zero}}
 }
 
 char CheckUseZeroWinAllocated2() {
   char *p = _alloca(0);
-  return *p; // expected-warning {{Use of zero-allocated memory}}
+  return *p; // expected-warning {{Use of memory allocated with size zero}}
 }
 
 void UseZeroAllocated(int *p) {
   if (p)
-*p = 7; // expected-warning {{Use of zero-allocated memory}}
+*p = 7; // expected-warning {{Use of memory allocated with size zero}}
 }
 void CheckUseZeroAllocated3() {
   int *p = malloc(0);
@@ -287,39 +287,39 @@
 void f(char);
 void CheckUseZeroAllocated4() {
   char *p = valloc(0);
-  f(*p); // expected-warning {{Use of zero-allocated memory}}
+  f(*p); // expected-warning {{Use of memory allocated with size zero}}
   free(p);
 }
 
 void CheckUseZeroAllocated5() {
   int *p = calloc(0, 2);
-  *p = 1; // expected-warning {{Use of zero-allocated memory}}
+  *p = 1; // expected-warning {{Use of memory allocated with size zero}}
   free(p);
 }
 
 void CheckUseZeroAllocated6() {
   int *p = calloc(2, 0);
-  *p = 1; // expected-warning {{Use of zero-allocated memory}}
+  *p = 1; // expected-warning {{Use of memory allocated with size zero}}
   free(p);
 }
 
 void CheckUseZeroAllocated7() {
   int *p = realloc(0, 0);
-  *p = 1; // expected-warning {{Use of zero-allocated memory}}
+  *p = 1; // expected-warning {{Use of memory allocated with size zero}}
   free(p);
 }
 
 void CheckUseZeroAllocated8() {
   int *p = malloc(8);
   int *q = realloc(p, 0);
-  *q = 1; // expected-warning {{Use of zero-allocated memory}}
+  *q = 1; // expected-warning {{Use of memory allocated with size zero}}
   free(q);
 }
 
 void CheckUseZeroAllocated9() {
   int *p = realloc(0, 0);
   int *q = realloc(p, 0);
-  *q = 1; // expected-warning {{Use of zero-allocated memory}}
+  *q = 1; // expected-warning {{Use of memory allocated with size zero}}
   free(q);
 }
 
@@ -344,7 +344,7 @@
   char *p = malloc(s);
 
   if (b)
-*p = 1; // expected-warning {{Use of zero-allocated memory}}
+*p = 1; // expected-warning {{Use of memory allocated with size zero}}
 
   free(p);
 }
@@ -372,7 +372,7 @@
   char *q = realloc(p, s);
 
   if (b)
-*q = 1; // expected-warning {{Use of zero-allocated memory}}
+*q = 1; // expected-warning {{Use of memory allocated with size zero}}
 
   free(q);
 }
Index: clang/test/Analysis/NewDelete-checker-test.cpp
===
--- clang/test/Analysis/NewDelete-checker-test.cpp
+++ clang/test/Analysis/NewDelete-checker-test.cpp
@@ -105,13 +105,13 @@
 
 void testUseZeroAlloc1() {
   int *p = (int *)operator new(0);
-  *p = 1; // newdelete-warning {{Use of zero-allocated memory}}
+  *p = 1; // newdelete-warning {{Use of memory allocated with size zero}}
   delete p;
 }
 
 int testUseZeroAlloc2() {
   int *p = (int *)operator new[](0);
-  return p[0]; // newdelete-warning {{Use of zero-allocated memory}}
+  return p[0]; // newdelete-warning {{Use of memory allocated with size zero}}
   delete[] p;
 }
 
@@ -119,7 +119,7 @@
 
 void testUseZeroAlloc3() {
   int *p = new int[0];
-  f(*p); // newdelete-warning {{Use of zero-allocated memory}}
+  f(*p); // newdelete-warning {{Use of memory allocated with size zero}}
   delete[] p;
 }
 
Index: clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
@@ -2471,7 +2471,8 @@
   categories::MemoryError));
 
 auto R = std::make_unique(
-*BT_UseZerroAllocated[*CheckKind], "Use of zero-allocated memory", N);
+*BT_UseZerroAllocated[*CheckKind],
+"Use of memory allocated with size zero", N);
 
 R->addRange(Range);
 if (Sym) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org

[clang] f3ec9d8 - [analyzer] Fix non-obvious analyzer warning: Use of zero-allocated memory.

2021-10-12 Thread Artem Dergachev via cfe-commits

Author: Artem Dergachev
Date: 2021-10-12T10:41:00-07:00
New Revision: f3ec9d8501c91c22c1578470e638c74120f60667

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

LOG: [analyzer] Fix non-obvious analyzer warning: Use of zero-allocated memory.

Clarify the message provided when the analyzer catches the use of memory
that is allocated with size zero.

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

Added: 


Modified: 
clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
clang/test/Analysis/NewDelete-checker-test.cpp
clang/test/Analysis/malloc.c

Removed: 




diff  --git a/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
index 9899298b348a0..5f505f8a03719 100644
--- a/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
@@ -2471,7 +2471,8 @@ void MallocChecker::HandleUseZeroAlloc(CheckerContext , 
SourceRange Range,
   categories::MemoryError));
 
 auto R = std::make_unique(
-*BT_UseZerroAllocated[*CheckKind], "Use of zero-allocated memory", N);
+*BT_UseZerroAllocated[*CheckKind],
+"Use of memory allocated with size zero", N);
 
 R->addRange(Range);
 if (Sym) {

diff  --git a/clang/test/Analysis/NewDelete-checker-test.cpp 
b/clang/test/Analysis/NewDelete-checker-test.cpp
index 86df9d01dfb01..5a06c8327f717 100644
--- a/clang/test/Analysis/NewDelete-checker-test.cpp
+++ b/clang/test/Analysis/NewDelete-checker-test.cpp
@@ -105,13 +105,13 @@ void testNewInvalidationPlacement(PtrWrapper *w) {
 
 void testUseZeroAlloc1() {
   int *p = (int *)operator new(0);
-  *p = 1; // newdelete-warning {{Use of zero-allocated memory}}
+  *p = 1; // newdelete-warning {{Use of memory allocated with size zero}}
   delete p;
 }
 
 int testUseZeroAlloc2() {
   int *p = (int *)operator new[](0);
-  return p[0]; // newdelete-warning {{Use of zero-allocated memory}}
+  return p[0]; // newdelete-warning {{Use of memory allocated with size zero}}
   delete[] p;
 }
 
@@ -119,7 +119,7 @@ void f(int);
 
 void testUseZeroAlloc3() {
   int *p = new int[0];
-  f(*p); // newdelete-warning {{Use of zero-allocated memory}}
+  f(*p); // newdelete-warning {{Use of memory allocated with size zero}}
   delete[] p;
 }
 

diff  --git a/clang/test/Analysis/malloc.c b/clang/test/Analysis/malloc.c
index add5dc7fe8c21..ef275ae5028b6 100644
--- a/clang/test/Analysis/malloc.c
+++ b/clang/test/Analysis/malloc.c
@@ -261,23 +261,23 @@ void CheckUseZeroAllocatedNoWarn4() {
 
 void CheckUseZeroAllocated1() {
   int *p = malloc(0);
-  *p = 1; // expected-warning {{Use of zero-allocated memory}}
+  *p = 1; // expected-warning {{Use of memory allocated with size zero}}
   free(p);
 }
 
 char CheckUseZeroAllocated2() {
   char *p = alloca(0);
-  return *p; // expected-warning {{Use of zero-allocated memory}}
+  return *p; // expected-warning {{Use of memory allocated with size zero}}
 }
 
 char CheckUseZeroWinAllocated2() {
   char *p = _alloca(0);
-  return *p; // expected-warning {{Use of zero-allocated memory}}
+  return *p; // expected-warning {{Use of memory allocated with size zero}}
 }
 
 void UseZeroAllocated(int *p) {
   if (p)
-*p = 7; // expected-warning {{Use of zero-allocated memory}}
+*p = 7; // expected-warning {{Use of memory allocated with size zero}}
 }
 void CheckUseZeroAllocated3() {
   int *p = malloc(0);
@@ -287,39 +287,39 @@ void CheckUseZeroAllocated3() {
 void f(char);
 void CheckUseZeroAllocated4() {
   char *p = valloc(0);
-  f(*p); // expected-warning {{Use of zero-allocated memory}}
+  f(*p); // expected-warning {{Use of memory allocated with size zero}}
   free(p);
 }
 
 void CheckUseZeroAllocated5() {
   int *p = calloc(0, 2);
-  *p = 1; // expected-warning {{Use of zero-allocated memory}}
+  *p = 1; // expected-warning {{Use of memory allocated with size zero}}
   free(p);
 }
 
 void CheckUseZeroAllocated6() {
   int *p = calloc(2, 0);
-  *p = 1; // expected-warning {{Use of zero-allocated memory}}
+  *p = 1; // expected-warning {{Use of memory allocated with size zero}}
   free(p);
 }
 
 void CheckUseZeroAllocated7() {
   int *p = realloc(0, 0);
-  *p = 1; // expected-warning {{Use of zero-allocated memory}}
+  *p = 1; // expected-warning {{Use of memory allocated with size zero}}
   free(p);
 }
 
 void CheckUseZeroAllocated8() {
   int *p = malloc(8);
   int *q = realloc(p, 0);
-  *q = 1; // expected-warning {{Use of zero-allocated memory}}
+  *q = 1; // expected-warning {{Use of memory allocated with size zero}}
   free(q);
 }
 
 void CheckUseZeroAllocated9() {
   int *p = realloc(0, 0);
   int *q = realloc(p, 0);
-  *q = 1; // expected-warning {{Use of zero-allocated memory}}
+  *q = 1; // expected-warning 

[PATCH] D111560: [clang][modules] Cache loads of modules imported by PCH

2021-10-12 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith accepted this revision.
dexonsmith added a comment.
This revision is now accepted and ready to land.

LGTM. It'd be nice to split out the move of `ReadModuleNames` into an NFC prep 
patch for a cleaner commit history before pushing, but up to you.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111560

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


[PATCH] D111371: [Support][ThinLTO] Move ThinLTO caching to LLVM Support library.

2021-10-12 Thread Noah Shutty via Phabricator via cfe-commits
noajshu updated this revision to Diff 379104.
noajshu added a comment.

Make cache dir parameter a Twine and avoid unnecessary copy in conversion to 
SmallString.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111371

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  lld/COFF/LTO.cpp
  lld/ELF/LTO.cpp
  lld/MachO/LTO.cpp
  lld/wasm/LTO.cpp
  llvm/include/llvm/LTO/Caching.h
  llvm/include/llvm/LTO/LTO.h
  llvm/include/llvm/LTO/legacy/LTOCodeGenerator.h
  llvm/include/llvm/Support/Caching.h
  llvm/lib/LTO/CMakeLists.txt
  llvm/lib/LTO/Caching.cpp
  llvm/lib/LTO/LTOCodeGenerator.cpp
  llvm/lib/Support/CMakeLists.txt
  llvm/lib/Support/Caching.cpp
  llvm/tools/gold/gold-plugin.cpp
  llvm/tools/llvm-lto/llvm-lto.cpp
  llvm/tools/llvm-lto2/llvm-lto2.cpp

Index: llvm/tools/llvm-lto2/llvm-lto2.cpp
===
--- llvm/tools/llvm-lto2/llvm-lto2.cpp
+++ llvm/tools/llvm-lto2/llvm-lto2.cpp
@@ -19,10 +19,10 @@
 #include "llvm/CodeGen/CommandFlags.h"
 #include "llvm/Config/llvm-config.h"
 #include "llvm/IR/DiagnosticPrinter.h"
-#include "llvm/LTO/Caching.h"
 #include "llvm/LTO/LTO.h"
 #include "llvm/Passes/PassPlugin.h"
 #include "llvm/Remarks/HotnessThresholdParser.h"
+#include "llvm/Support/Caching.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/InitLLVM.h"
@@ -362,14 +362,13 @@
   if (HasErrors)
 return 1;
 
-  auto AddStream =
-  [&](size_t Task) -> std::unique_ptr {
+  auto AddStream = [&](size_t Task) -> std::unique_ptr {
 std::string Path = OutputFilename + "." + utostr(Task);
 
 std::error_code EC;
 auto S = std::make_unique(Path, EC, sys::fs::OF_None);
 check(EC, Path);
-return std::make_unique(std::move(S));
+return std::make_unique(std::move(S));
   };
 
   auto AddBuffer = [&](size_t Task, std::unique_ptr MB) {
@@ -378,7 +377,8 @@
 
   NativeObjectCache Cache;
   if (!CacheDir.empty())
-Cache = check(localCache(CacheDir, AddBuffer), "failed to create cache");
+Cache = check(localCache("ThinLTO", "Thin", CacheDir, AddBuffer),
+  "failed to create cache");
 
   check(Lto.run(AddStream, Cache), "LTO::run failed");
   return 0;
Index: llvm/tools/llvm-lto/llvm-lto.cpp
===
--- llvm/tools/llvm-lto/llvm-lto.cpp
+++ llvm/tools/llvm-lto/llvm-lto.cpp
@@ -1097,8 +1097,7 @@
 error("writing merged module failed.");
 }
 
-auto AddStream =
-[&](size_t Task) -> std::unique_ptr {
+auto AddStream = [&](size_t Task) -> std::unique_ptr {
   std::string PartFilename = OutputFilename;
   if (Parallelism != 1)
 PartFilename += "." + utostr(Task);
@@ -1108,7 +1107,7 @@
   std::make_unique(PartFilename, EC, sys::fs::OF_None);
   if (EC)
 error("error opening the file '" + PartFilename + "': " + EC.message());
-  return std::make_unique(std::move(S));
+  return std::make_unique(std::move(S));
 };
 
 if (!CodeGen.compileOptimized(AddStream, Parallelism))
Index: llvm/tools/gold/gold-plugin.cpp
===
--- llvm/tools/gold/gold-plugin.cpp
+++ llvm/tools/gold/gold-plugin.cpp
@@ -1081,12 +1081,11 @@
   size_t MaxTasks = Lto->getMaxTasks();
   std::vector, bool>> Files(MaxTasks);
 
-  auto AddStream =
-  [&](size_t Task) -> std::unique_ptr {
+  auto AddStream = [&](size_t Task) -> std::unique_ptr {
 Files[Task].second = !SaveTemps;
 int FD = getOutputFileName(Filename, /* TempOutFile */ !SaveTemps,
Files[Task].first, Task);
-return std::make_unique(
+return std::make_unique(
 std::make_unique(FD, true));
   };
 
@@ -1096,7 +1095,7 @@
 
   NativeObjectCache Cache;
   if (!options::cache_dir.empty())
-Cache = check(localCache(options::cache_dir, AddBuffer));
+Cache = check(localCache("ThinLTO", "Thin", options::cache_dir, AddBuffer));
 
   check(Lto->run(AddStream, Cache));
 
Index: llvm/lib/Support/Caching.cpp
===
--- llvm/lib/Support/Caching.cpp
+++ llvm/lib/Support/Caching.cpp
@@ -1,4 +1,4 @@
-//===-Caching.cpp - LLVM Link Time Optimizer Cache Handling ---===//
+//===-Caching.cpp - LLVM File Cache Handling --===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -6,11 +6,11 @@
 //
 //===--===//
 //
-// This file implements the Caching for ThinLTO.
+// This file implements the Caching used by ThinLTO.
 //
 //===--===//
 
-#include "llvm/LTO/Caching.h"
+#include "llvm/Support/Caching.h"
 

[PATCH] D111229: [PowerPC][Builtin] Allowing __rlwnm to accept a variable as a shift parameter

2021-10-12 Thread Kamau Bridgeman via Phabricator via cfe-commits
kamaub updated this revision to Diff 379103.
kamaub added a comment.

Addressing review request to remove unnecessary testing line.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111229

Files:
  clang/include/clang/Basic/BuiltinsPPC.def
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/builtins-ppc-xlcompat-error.c


Index: clang/test/CodeGen/builtins-ppc-xlcompat-error.c
===
--- clang/test/CodeGen/builtins-ppc-xlcompat-error.c
+++ clang/test/CodeGen/builtins-ppc-xlcompat-error.c
@@ -41,10 +41,8 @@
 }
 
 void test_builtin_ppc_rlwnm() {
-  unsigned int shift;
   unsigned int mask;
-  unsigned int res = __builtin_ppc_rlwnm(ui, shift, 7); // expected-error 
{{argument to '__builtin_ppc_rlwnm' must be a constant integer}}
-  res = __builtin_ppc_rlwnm(ui, 31, mask);  // expected-error 
{{argument to '__builtin_ppc_rlwnm' must be a constant integer}}
+  unsigned int res = __builtin_ppc_rlwnm(ui, 31, mask);  // 
expected-error {{argument to '__builtin_ppc_rlwnm' must be a constant integer}}
   res = __builtin_ppc_rlwnm(ui, 31, 0xFF0F0F00);// expected-error 
{{argument 2 value should represent a contiguous bit field}}
 }
 
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -3432,8 +3432,7 @@
   // For __rlwnm, __rlwimi and __rldimi, the last parameter mask must
   // be a constant that represents a contiguous bit field.
   case PPC::BI__builtin_ppc_rlwnm:
-return SemaBuiltinConstantArg(TheCall, 1, Result) ||
-   SemaValueIsRunOfOnes(TheCall, 2);
+return SemaValueIsRunOfOnes(TheCall, 2);
   case PPC::BI__builtin_ppc_rlwimi:
   case PPC::BI__builtin_ppc_rldimi:
 return SemaBuiltinConstantArg(TheCall, 2, Result) ||
Index: clang/include/clang/Basic/BuiltinsPPC.def
===
--- clang/include/clang/Basic/BuiltinsPPC.def
+++ clang/include/clang/Basic/BuiltinsPPC.def
@@ -117,7 +117,7 @@
 BUILTIN(__builtin_ppc_maddhdu, "ULLiULLiULLiULLi", "")
 BUILTIN(__builtin_ppc_maddld, "LLiLLiLLiLLi", "")
 // Rotate
-BUILTIN(__builtin_ppc_rlwnm, "UiUiIUiIUi", "")
+BUILTIN(__builtin_ppc_rlwnm, "UiUiUiIUi", "")
 BUILTIN(__builtin_ppc_rlwimi, "UiUiUiIUiIUi", "")
 BUILTIN(__builtin_ppc_rldimi, "ULLiULLiULLiIUiIULLi", "")
 // load


Index: clang/test/CodeGen/builtins-ppc-xlcompat-error.c
===
--- clang/test/CodeGen/builtins-ppc-xlcompat-error.c
+++ clang/test/CodeGen/builtins-ppc-xlcompat-error.c
@@ -41,10 +41,8 @@
 }
 
 void test_builtin_ppc_rlwnm() {
-  unsigned int shift;
   unsigned int mask;
-  unsigned int res = __builtin_ppc_rlwnm(ui, shift, 7); // expected-error {{argument to '__builtin_ppc_rlwnm' must be a constant integer}}
-  res = __builtin_ppc_rlwnm(ui, 31, mask);  // expected-error {{argument to '__builtin_ppc_rlwnm' must be a constant integer}}
+  unsigned int res = __builtin_ppc_rlwnm(ui, 31, mask);  // expected-error {{argument to '__builtin_ppc_rlwnm' must be a constant integer}}
   res = __builtin_ppc_rlwnm(ui, 31, 0xFF0F0F00);// expected-error {{argument 2 value should represent a contiguous bit field}}
 }
 
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -3432,8 +3432,7 @@
   // For __rlwnm, __rlwimi and __rldimi, the last parameter mask must
   // be a constant that represents a contiguous bit field.
   case PPC::BI__builtin_ppc_rlwnm:
-return SemaBuiltinConstantArg(TheCall, 1, Result) ||
-   SemaValueIsRunOfOnes(TheCall, 2);
+return SemaValueIsRunOfOnes(TheCall, 2);
   case PPC::BI__builtin_ppc_rlwimi:
   case PPC::BI__builtin_ppc_rldimi:
 return SemaBuiltinConstantArg(TheCall, 2, Result) ||
Index: clang/include/clang/Basic/BuiltinsPPC.def
===
--- clang/include/clang/Basic/BuiltinsPPC.def
+++ clang/include/clang/Basic/BuiltinsPPC.def
@@ -117,7 +117,7 @@
 BUILTIN(__builtin_ppc_maddhdu, "ULLiULLiULLiULLi", "")
 BUILTIN(__builtin_ppc_maddld, "LLiLLiLLiLLi", "")
 // Rotate
-BUILTIN(__builtin_ppc_rlwnm, "UiUiIUiIUi", "")
+BUILTIN(__builtin_ppc_rlwnm, "UiUiUiIUi", "")
 BUILTIN(__builtin_ppc_rlwimi, "UiUiUiIUiIUi", "")
 BUILTIN(__builtin_ppc_rldimi, "ULLiULLiULLiIUiIULLi", "")
 // load
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D111570: [clang/CFG] Don't explicitly add AttributedStmtClass to AlwaysAddList

2021-10-12 Thread Nico Weber 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 rG2cc42758a9d8: [clang/CFG] Dont explicitly add 
AttributedStmtClass to AlwaysAddList (authored by thakis).
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111570

Files:
  clang/lib/Sema/AnalysisBasedWarnings.cpp


Index: clang/lib/Sema/AnalysisBasedWarnings.cpp
===
--- clang/lib/Sema/AnalysisBasedWarnings.cpp
+++ clang/lib/Sema/AnalysisBasedWarnings.cpp
@@ -2272,8 +2272,7 @@
   .setAlwaysAdd(Stmt::CStyleCastExprClass)
   .setAlwaysAdd(Stmt::DeclRefExprClass)
   .setAlwaysAdd(Stmt::ImplicitCastExprClass)
-  .setAlwaysAdd(Stmt::UnaryOperatorClass)
-  .setAlwaysAdd(Stmt::AttributedStmtClass);
+  .setAlwaysAdd(Stmt::UnaryOperatorClass);
   }
 
   // Install the logical handler.


Index: clang/lib/Sema/AnalysisBasedWarnings.cpp
===
--- clang/lib/Sema/AnalysisBasedWarnings.cpp
+++ clang/lib/Sema/AnalysisBasedWarnings.cpp
@@ -2272,8 +2272,7 @@
   .setAlwaysAdd(Stmt::CStyleCastExprClass)
   .setAlwaysAdd(Stmt::DeclRefExprClass)
   .setAlwaysAdd(Stmt::ImplicitCastExprClass)
-  .setAlwaysAdd(Stmt::UnaryOperatorClass)
-  .setAlwaysAdd(Stmt::AttributedStmtClass);
+  .setAlwaysAdd(Stmt::UnaryOperatorClass);
   }
 
   // Install the logical handler.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 2cc4275 - [clang/CFG] Don't explicitly add AttributedStmtClass to AlwaysAddList

2021-10-12 Thread Nico Weber via cfe-commits

Author: Nico Weber
Date: 2021-10-12T13:29:19-04:00
New Revision: 2cc42758a9d89da7c726b78232dfba02314957a9

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

LOG: [clang/CFG] Don't explicitly add AttributedStmtClass to AlwaysAddList

CFGBuilder::addStmt() implicitly passes AddStmtChoice::AlwaysAdd
to Visit() already, so this should have no behavior change.

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

Added: 


Modified: 
clang/lib/Sema/AnalysisBasedWarnings.cpp

Removed: 




diff  --git a/clang/lib/Sema/AnalysisBasedWarnings.cpp 
b/clang/lib/Sema/AnalysisBasedWarnings.cpp
index 2b089ff084ca..e28203e4e00b 100644
--- a/clang/lib/Sema/AnalysisBasedWarnings.cpp
+++ b/clang/lib/Sema/AnalysisBasedWarnings.cpp
@@ -2272,8 +2272,7 @@ void clang::sema::AnalysisBasedWarnings::IssueWarnings(
   .setAlwaysAdd(Stmt::CStyleCastExprClass)
   .setAlwaysAdd(Stmt::DeclRefExprClass)
   .setAlwaysAdd(Stmt::ImplicitCastExprClass)
-  .setAlwaysAdd(Stmt::UnaryOperatorClass)
-  .setAlwaysAdd(Stmt::AttributedStmtClass);
+  .setAlwaysAdd(Stmt::UnaryOperatorClass);
   }
 
   // Install the logical handler.



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


[PATCH] D111543: [clang][modules] Stop creating `IdentifierInfo` for names of explicit modules

2021-10-12 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith accepted this revision.
dexonsmith added a comment.
This revision is now accepted and ready to land.

I wonder if it would be more clear going forward to name this additional cache 
by its purpose, so it doesn't sound more general than it really is. As 
currently named, it might look like all top-level modules should be stored in 
that map instead of the IdentifierInfo map.

Once you update the naming and/or comments to avoid that potential pitfall, 
this LGTM.




Comment at: clang/include/clang/Lex/ModuleMap.h:104-106
+  /// Top-module loading cache, indexed by module names.
+  /// nullptr is stored for modules that are known to fail to load.
+  llvm::StringMap CachedTopLevelModuleLoads;

Would be good to say why this is separate from CachedModuleLoads. Maybe, "for 
when an `IdentifierInfo` isn't available".

Or, should this be called `CachedExplicitModuleLoads` and be more clear about 
the purpose?
- Use this for explicit modules from external sources.
- Use `CachedModuleLoads` as a cache for source references where there's an 
`IdentifierInfo`.



Comment at: clang/include/clang/Lex/ModuleMap.h:714-717
+  /// Cache a top-level module load.  M might be nullptr.
+  void cacheTopLevelModuleLoad(StringRef ModuleName, Module *M) {
+CachedTopLevelModuleLoads[ModuleName] = M;
+  }

If you change the name of the member, please change the API to match.



Comment at: clang/include/clang/Lex/ModuleMap.h:101-102
 
   /// The top-level modules that are known.
   llvm::StringMap Modules;
 

dexonsmith wrote:
> I wonder, could `-fmodule-file=...` be using this map instead (already a 
> StringMap), and the map below reserved for "real" identifiers?
> 
Can you explain in the commit message why this map can't be expanded to serve 
this purpose?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111543

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


[PATCH] D111542: [analyzer] Retrieve incomplete array extent from its redeclaration.

2021-10-12 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added inline comments.



Comment at: clang/test/Analysis/initialization.c:101-102
+
+const int glob_arr3[];  // Incomplete array declaration
+const int glob_arr3[4] = {1, 2, 3}; // Incomplete Array redeclaration
+void foo() {

ASDenysPetrov wrote:
> martong wrote:
> > I'd like to see some more elaborate test cases. Notably
> > ```
> > const int glob_arr3[];  // Incomplete array declaration
> > const int glob_arr3[4] = {1, 2, 3}; // Incomplete Array redeclaration
> > const int glob_arr3[];  // Incomplete array redeclaration
> > ```
> > here neither the canonical nor the most recent decl have the initexpr.
> > And I think this is what @balazske tried to point out.
> Exactly. I'll add this particular case, but I should mention that **AST** 
> surprisingly shows the third redeclaration as `ConstantArrayType` with the 
> extent. Thus, it works for the current fix.
> ```
> |-VarDecl 0xc0725b0  col:11 glob_arr3 'const int []'
> |-VarDecl 0xc072700 prev 0xc0725b0  col:11 glob_arr3 'const 
> int [4]' cinit
> | `-InitListExpr 0xc072830  'const int [4]'
> |   |-array_filler: ImplicitValueInitExpr 0xc0728a8 <> 'const 
> int'
> |   |-IntegerLiteral 0xc072768  'int' 1
> |   |-IntegerLiteral 0xc072788  'int' 2
> |   `-IntegerLiteral 0xc0727a8  'int' 3
> `-VarDecl 0xc0728e0 prev 0xc072700  col:11 glob_arr3 'const 
> int [4]'
> ```
So, the redeclaration actually changed the type to `ConstantArrayType`. If so, 
you should probably mention this in the comment.


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

https://reviews.llvm.org/D111542

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


[PATCH] D110357: [Analyzer] Extend ConstraintAssignor to handle remainder op

2021-10-12 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added inline comments.



Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:1619
+  return true;
+const SymExpr *LHS = Sym->getLHS();
+const llvm::APSInt  =





Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:1623
+if (Constraint.containsZero())
+  State = RCM.assumeSymEQ(State, LHS, Zero, Zero);
+else

In case the `Constraint` //might be// zero, why do you constrain `LHS` so that 
it **must be** zero?
I could not come up with a concrete example, but I hope you got my concern.
We either have a logic flaw or we lack an assertion here stating this hidden 
assumption about `Constraints`.



Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:1626-1628
+if (!State)
+  return false;
+return true;





Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:1603-1604
 
+  template 
+  bool handleRem(const SymT *Sym, RangeSet Constraint) {
+// a % b != 0 implies that a != 0.

martong wrote:
> ASDenysPetrov wrote:
> > steakhal wrote:
> > > Why is this not a `const` member function?
> > IMO it's better to rename the function `handleRemainderOp`.
> > 
> > Add a function description in comments above. 
> > E.g. Handle expressions like: `a % b == 0`. ... Returns `true` when 
> > //bla-bla//, otherwise returns `false`.
> > Why is this not a const member function?
> Because `RCM.assumeSymNE` is not `const`.
> 
> > IMO it's better to rename the function handleRemainderOp.
> I agree, changed it.
>> Why is this not a const member function?
> Because RCM.assumeSymNE is not const.
I don't think it's an excuse: https://godbolt.org/z/nEcsozheq

---

Aside from that, I would clarify that it will try to apply the following *two* 
assumptions:
`a % b == 0 implies that a == 0.`
`a % b != 0 implies that a != 0.`
Now the comment only highlights the latter.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110357

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


[PATCH] D111655: [analyzer] non-obvious analyzer warning: Use of zero-allocated memory

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



Comment at: clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp:2474-2475
 auto R = std::make_unique(
-*BT_UseZerroAllocated[*CheckKind], "Use of zero-allocated memory", N);
+*BT_UseZerroAllocated[*CheckKind],
+"Use of memory allocated with size zero", N);
 

Peanut gallery says:
(1) Might want to fix the typo in "Zerro" at the same time, or in a followup 
commit.
(2) I would naively have expected all the test cases below to give something 
simple like "Read/write beyond end of allocated space," because they allocate N 
bytes and then try to read/write into byte number N. This is //never// allowed 
in C or C++, regardless of the value of N; there's nothing special about N=0. 
So I don't see why it needs //any// special diagnostic (confusing or otherwise).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111655

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


[PATCH] D111208: [clang-tidy] Support globbing in NOLINT* expressions

2021-10-12 Thread Carlos Galvez via Phabricator via cfe-commits
carlosgalvezp added inline comments.



Comment at: clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp:349
+  // Allow specifying a few checks with a glob expression.
+  GlobList Globs(ChecksStr);
+  if (!Globs.contains(CheckName))

salman-javed-nz wrote:
> carlosgalvezp wrote:
> > aaron.ballman wrote:
> > > carlosgalvezp wrote:
> > > > salman-javed-nz wrote:
> > > > > What happens when `CheckStr` is empty?
> > > > > How has Clang-Tidy treated `// NOLINT()` in the past? Does this patch 
> > > > > change the behaviour? What //should // be the "right" behaviour?
> > > > Very good question! Currently on master `// NOLINT()` will *not* 
> > > > suppress warnings. However `// NOLINT(` will. My patch shouldn't change 
> > > > existing behavior - an empty list of globs will return false when 
> > > > calling `contains`.
> > > > 
> > > > I'll add a unit test to cover this case!
> > > (All of this is a bit orthogonal to this patch, so no changes requested 
> > > here.)
> > > 
> > > Naively, I would expect `NOLINT()` to be an error because it expects an 
> > > argument and none was given. (I'd expect `NOLINT(` to also be an error 
> > > because the syntax is malformed.)
> > Fully agree! If I find some time I can give it a try on a separate patch
> The NOLINT syntax was borrowed from Google's cpplint.py. cpplint uses a regex 
> search to find NOLINT expressions, but it's pretty naive, leading to quirks 
> like `NOLINT(` being accepted as a valid expression. Clang-Tidy has inherited 
> the same quirks by being interoperable with cpplint's syntax.
> 
> How important it is to maintain compatibility with the more funky aspects of 
> cpplint's `NOLINT` behaviour, I'm not sure. The two programs' syntaxes aren't 
> fully compatible nowadays anyway. To give an example, cpplint doesn't support 
> multiple checks separated by commas on the same line. This glob feature will 
> be another divergence. 
> 
> Just something to think about for next time.
I'd gladly decouple clang-tidy and cpplint. Personally I don't find the benefit 
of running both, clang-tidy is way superior.



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

https://reviews.llvm.org/D111208

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


[PATCH] D111208: [clang-tidy] Support globbing in NOLINT* expressions

2021-10-12 Thread Carlos Galvez via Phabricator via cfe-commits
carlosgalvezp updated this revision to Diff 379097.
carlosgalvezp marked an inline comment as done.
carlosgalvezp added a comment.

Addressed @salman-javed-nz comment.


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

https://reviews.llvm.org/D111208

Files:
  clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
  clang-tools-extra/clang-tidy/GlobList.cpp
  clang-tools-extra/clang-tidy/GlobList.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/index.rst
  clang-tools-extra/test/clang-tidy/infrastructure/nolint.cpp
  
clang-tools-extra/test/clang-tidy/infrastructure/nolintbeginend-begin-global-end-specific.cpp
  
clang-tools-extra/test/clang-tidy/infrastructure/nolintbeginend-begin-specific-end-global.cpp
  
clang-tools-extra/test/clang-tidy/infrastructure/nolintbeginend-mismatched-check-names.cpp
  clang-tools-extra/test/clang-tidy/infrastructure/nolintbeginend.cpp
  clang-tools-extra/test/clang-tidy/infrastructure/nolintnextline.cpp

Index: clang-tools-extra/test/clang-tidy/infrastructure/nolintnextline.cpp
===
--- clang-tools-extra/test/clang-tidy/infrastructure/nolintnextline.cpp
+++ clang-tools-extra/test/clang-tidy/infrastructure/nolintnextline.cpp
@@ -11,21 +11,25 @@
 class D { D(int i); };
 // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: single-argument constructors must be marked explicit
 
-// NOLINTNEXTLINE(*)
+// NOLINTNEXTLINE()
 class D1 { D1(int i); };
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: single-argument constructors must be marked explicit
 
-// NOLINTNEXTLINE(not-closed-bracket-is-treated-as-skip-all
+// NOLINTNEXTLINE(*)
 class D2 { D2(int i); };
 
-// NOLINTNEXTLINE(google-explicit-constructor)
+// NOLINTNEXTLINE(not-closed-bracket-is-treated-as-skip-all
 class D3 { D3(int i); };
 
-// NOLINTNEXTLINE(some-check, google-explicit-constructor)
+// NOLINTNEXTLINE(google-explicit-constructor)
 class D4 { D4(int i); };
 
-// NOLINTNEXTLINE without-brackets-skip-all, another-check
+// NOLINTNEXTLINE(some-check, google-explicit-constructor)
 class D5 { D5(int i); };
 
+// NOLINTNEXTLINE without-brackets-skip-all, another-check
+class D6 { D6(int i); };
+
 // NOLINTNEXTLINE
 
 class E { E(int i); };
@@ -46,6 +50,38 @@
 // NOLINTNEXTLINE
 MACRO_NOARG
 
-// CHECK-MESSAGES: Suppressed 9 warnings (9 NOLINT)
+// NOLINTNEXTLINE(google*)
+class I1 { I1(int i); };
+
+// NOLINTNEXTLINE(*explicit-constructor)
+class I2 { I2(int i); };
+
+// NOLINTNEXTLINE(*explicit*)
+class I3 { I3(int i); };
+
+// NOLINTNEXTLINE(-explicit-constructor)
+class I4 { I4(int x); };
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: single-argument constructors must be marked explicit
+
+// NOLINTNEXTLINE(google*,-google*)
+class I5 { I5(int x); };
+
+// NOLINTNEXTLINE(*,-google*)
+class I6 { I6(int x); };
+
+int array1[10];
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: do not declare C-style arrays, use std::array<> instead [cppcoreguidelines-avoid-c-arrays,modernize-avoid-c-arrays]
+
+// NOLINTNEXTLINE(cppcoreguidelines-avoid-c-arrays)
+int array2[10];
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: do not declare C-style arrays, use std::array<> instead [modernize-avoid-c-arrays]
+
+// NOLINTNEXTLINE(cppcoreguidelines-avoid-c-arrays,modernize-avoid-c-arrays)
+int array3[10];
+
+// NOLINTNEXTLINE(*-avoid-c-arrays)
+int array4[10];
+
+// CHECK-MESSAGES: Suppressed 19 warnings (19 NOLINT)
 
-// RUN: %check_clang_tidy %s google-explicit-constructor %t --
+// RUN: %check_clang_tidy %s google-explicit-constructor,clang-diagnostic-unused-variable,cppcoreguidelines-avoid-c-arrays,modernize-avoid-c-arrays %t -- -extra-arg=-Wunused-variable
Index: clang-tools-extra/test/clang-tidy/infrastructure/nolintbeginend.cpp
===
--- clang-tools-extra/test/clang-tidy/infrastructure/nolintbeginend.cpp
+++ clang-tools-extra/test/clang-tidy/infrastructure/nolintbeginend.cpp
@@ -1,4 +1,4 @@
-// RUN: %check_clang_tidy %s google-explicit-constructor %t
+// RUN: %check_clang_tidy %s google-explicit-constructor,clang-diagnostic-unused-variable,cppcoreguidelines-avoid-c-arrays,modernize-avoid-c-arrays %t -- -extra-arg=-Wunused-variable
 
 class A { A(int i); };
 // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: single-argument constructors must be marked explicit
@@ -34,60 +34,54 @@
 class C1 { C1(int i); };
 // NOLINTEND(google-explicit-constructor)
 
-// NOLINTBEGIN(*)
+// NOLINTBEGIN()
 class C2 { C2(int i); };
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: single-argument constructors must be marked explicit
+// NOLINTEND()
+
+// NOLINTBEGIN(*)
+class C3 { C3(int i); };
 // NOLINTEND(*)
 
 // NOLINTBEGIN(some-other-check)
-class C3 { C3(int i); };
+class C4 { C4(int i); };
 // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: single-argument constructors must be marked explicit
 // NOLINTEND(some-other-check)
 
 // NOLINTBEGIN(some-other-check, google-explicit-constructor)
-class C4 { 

[PATCH] D111371: [Support][ThinLTO] Move ThinLTO caching to LLVM Support library.

2021-10-12 Thread Noah Shutty via Phabricator via cfe-commits
noajshu updated this revision to Diff 379095.
noajshu added a comment.

rebase against main


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111371

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  lld/COFF/LTO.cpp
  lld/ELF/LTO.cpp
  lld/MachO/LTO.cpp
  lld/wasm/LTO.cpp
  llvm/include/llvm/LTO/Caching.h
  llvm/include/llvm/LTO/LTO.h
  llvm/include/llvm/LTO/legacy/LTOCodeGenerator.h
  llvm/include/llvm/Support/Caching.h
  llvm/lib/LTO/CMakeLists.txt
  llvm/lib/LTO/Caching.cpp
  llvm/lib/LTO/LTOCodeGenerator.cpp
  llvm/lib/Support/CMakeLists.txt
  llvm/lib/Support/Caching.cpp
  llvm/tools/gold/gold-plugin.cpp
  llvm/tools/llvm-lto/llvm-lto.cpp
  llvm/tools/llvm-lto2/llvm-lto2.cpp

Index: llvm/tools/llvm-lto2/llvm-lto2.cpp
===
--- llvm/tools/llvm-lto2/llvm-lto2.cpp
+++ llvm/tools/llvm-lto2/llvm-lto2.cpp
@@ -19,10 +19,10 @@
 #include "llvm/CodeGen/CommandFlags.h"
 #include "llvm/Config/llvm-config.h"
 #include "llvm/IR/DiagnosticPrinter.h"
-#include "llvm/LTO/Caching.h"
 #include "llvm/LTO/LTO.h"
 #include "llvm/Passes/PassPlugin.h"
 #include "llvm/Remarks/HotnessThresholdParser.h"
+#include "llvm/Support/Caching.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/InitLLVM.h"
@@ -362,14 +362,13 @@
   if (HasErrors)
 return 1;
 
-  auto AddStream =
-  [&](size_t Task) -> std::unique_ptr {
+  auto AddStream = [&](size_t Task) -> std::unique_ptr {
 std::string Path = OutputFilename + "." + utostr(Task);
 
 std::error_code EC;
 auto S = std::make_unique(Path, EC, sys::fs::OF_None);
 check(EC, Path);
-return std::make_unique(std::move(S));
+return std::make_unique(std::move(S));
   };
 
   auto AddBuffer = [&](size_t Task, std::unique_ptr MB) {
@@ -378,7 +377,8 @@
 
   NativeObjectCache Cache;
   if (!CacheDir.empty())
-Cache = check(localCache(CacheDir, AddBuffer), "failed to create cache");
+Cache = check(localCache("ThinLTO", "Thin", CacheDir, AddBuffer),
+  "failed to create cache");
 
   check(Lto.run(AddStream, Cache), "LTO::run failed");
   return 0;
Index: llvm/tools/llvm-lto/llvm-lto.cpp
===
--- llvm/tools/llvm-lto/llvm-lto.cpp
+++ llvm/tools/llvm-lto/llvm-lto.cpp
@@ -1097,8 +1097,7 @@
 error("writing merged module failed.");
 }
 
-auto AddStream =
-[&](size_t Task) -> std::unique_ptr {
+auto AddStream = [&](size_t Task) -> std::unique_ptr {
   std::string PartFilename = OutputFilename;
   if (Parallelism != 1)
 PartFilename += "." + utostr(Task);
@@ -1108,7 +1107,7 @@
   std::make_unique(PartFilename, EC, sys::fs::OF_None);
   if (EC)
 error("error opening the file '" + PartFilename + "': " + EC.message());
-  return std::make_unique(std::move(S));
+  return std::make_unique(std::move(S));
 };
 
 if (!CodeGen.compileOptimized(AddStream, Parallelism))
Index: llvm/tools/gold/gold-plugin.cpp
===
--- llvm/tools/gold/gold-plugin.cpp
+++ llvm/tools/gold/gold-plugin.cpp
@@ -1081,12 +1081,11 @@
   size_t MaxTasks = Lto->getMaxTasks();
   std::vector, bool>> Files(MaxTasks);
 
-  auto AddStream =
-  [&](size_t Task) -> std::unique_ptr {
+  auto AddStream = [&](size_t Task) -> std::unique_ptr {
 Files[Task].second = !SaveTemps;
 int FD = getOutputFileName(Filename, /* TempOutFile */ !SaveTemps,
Files[Task].first, Task);
-return std::make_unique(
+return std::make_unique(
 std::make_unique(FD, true));
   };
 
@@ -1096,7 +1095,7 @@
 
   NativeObjectCache Cache;
   if (!options::cache_dir.empty())
-Cache = check(localCache(options::cache_dir, AddBuffer));
+Cache = check(localCache("ThinLTO", "Thin", options::cache_dir, AddBuffer));
 
   check(Lto->run(AddStream, Cache));
 
Index: llvm/lib/Support/Caching.cpp
===
--- llvm/lib/Support/Caching.cpp
+++ llvm/lib/Support/Caching.cpp
@@ -1,4 +1,4 @@
-//===-Caching.cpp - LLVM Link Time Optimizer Cache Handling ---===//
+//===-Caching.cpp - LLVM File Cache Handling --===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -6,11 +6,11 @@
 //
 //===--===//
 //
-// This file implements the Caching for ThinLTO.
+// This file implements the Caching used by ThinLTO.
 //
 //===--===//
 
-#include "llvm/LTO/Caching.h"
+#include "llvm/Support/Caching.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/Support/Errc.h"
 #include 

[PATCH] D111655: [analyzer] non-obvious analyzer warning: Use of zero-allocated memory

2021-10-12 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ accepted this revision.
NoQ added a comment.
This revision is now accepted and ready to land.

LGTM! Can confirm, people were confused.

I'll commit.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111655

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


[PATCH] D111041: [clang-tidy] Remove 'IgnoreDestructors = true' from cppcoreguidelines-explicit-virtual-functions

2021-10-12 Thread Carlos Galvez via Phabricator via cfe-commits
carlosgalvezp added a comment.

Thanks a lot for the review and the help!

By the way, should we keep the [clang-tidy] header for the next commits? 
Glancing at the commit history, I think it's much easier to see what the commit 
is updating, and probably can setup email filters to only receive notifications 
e.g. when [clang-tidy] is in the commit message. It's also consistent with the 
rest of commits. For example this one:

https://github.com/llvm/llvm-project/commit/a76cfc2e840ff373b80e3a5f84fc48c5f1f90d8a


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

https://reviews.llvm.org/D111041

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


[PATCH] D111542: [analyzer] Retrieve incomplete array extent from its redeclaration.

2021-10-12 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added inline comments.



Comment at: clang/lib/StaticAnalyzer/Core/RegionStore.cpp:1661-1663
 // Check if the containing array has an initialized value that we can 
trust.
 // We can trust a const value or a value of a global initializer in main().
+const VarDecl *VD = VR->getDecl()->getMostRecentDecl();

martong wrote:
> 
Thnx, I'll try this approach.



Comment at: clang/test/Analysis/initialization.c:101-102
+
+const int glob_arr3[];  // Incomplete array declaration
+const int glob_arr3[4] = {1, 2, 3}; // Incomplete Array redeclaration
+void foo() {

martong wrote:
> I'd like to see some more elaborate test cases. Notably
> ```
> const int glob_arr3[];  // Incomplete array declaration
> const int glob_arr3[4] = {1, 2, 3}; // Incomplete Array redeclaration
> const int glob_arr3[];  // Incomplete array redeclaration
> ```
> here neither the canonical nor the most recent decl have the initexpr.
> And I think this is what @balazske tried to point out.
Exactly. I'll add this particular case, but I should mention that **AST** 
surprisingly shows the third redeclaration as `ConstantArrayType` with the 
extent. Thus, it works for the current fix.
```
|-VarDecl 0xc0725b0  col:11 glob_arr3 'const int []'
|-VarDecl 0xc072700 prev 0xc0725b0  col:11 glob_arr3 'const 
int [4]' cinit
| `-InitListExpr 0xc072830  'const int [4]'
|   |-array_filler: ImplicitValueInitExpr 0xc0728a8 <> 'const int'
|   |-IntegerLiteral 0xc072768  'int' 1
|   |-IntegerLiteral 0xc072788  'int' 2
|   `-IntegerLiteral 0xc0727a8  'int' 3
`-VarDecl 0xc0728e0 prev 0xc072700  col:11 glob_arr3 'const 
int [4]'
```


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

https://reviews.llvm.org/D111542

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


[PATCH] D111582: [clang] Clear IR analyses before codegen pipeline

2021-10-12 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

Any chance of refactoring this code so naturally these objects are lexically 
scoped to their necessary lifetime, and just cease to exist before the code gen 
passes are run? (looks like this function is pretty long and might benefit from 
being broken up into pieces anyway - and one of those pieces could have these 
managers as locals, and return once that work is done, before the code gen work 
is started?)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111582

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


[clang] 57b40b5 - [AST, CodeGen, Driver] Use llvm::is_contained (NFC)

2021-10-12 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2021-10-12T09:19:49-07:00
New Revision: 57b40b5f34383634949d1639e64a5c2acd0dc5f6

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

LOG: [AST, CodeGen, Driver] Use llvm::is_contained (NFC)

Added: 


Modified: 
clang/lib/AST/CXXInheritance.cpp
clang/lib/AST/DeclCXX.cpp
clang/lib/AST/ParentMapContext.cpp
clang/lib/AST/RecordLayoutBuilder.cpp
clang/lib/AST/Type.cpp
clang/lib/AST/VTableBuilder.cpp
clang/lib/CodeGen/CGDebugInfo.cpp
clang/lib/CodeGen/CGOpenMPRuntime.cpp
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Driver/ToolChains/Hexagon.cpp

Removed: 




diff  --git a/clang/lib/AST/CXXInheritance.cpp 
b/clang/lib/AST/CXXInheritance.cpp
index 9027fa7a7515..cc787eddad2f 100644
--- a/clang/lib/AST/CXXInheritance.cpp
+++ b/clang/lib/AST/CXXInheritance.cpp
@@ -465,7 +465,7 @@ void OverridingMethods::add(unsigned OverriddenSubobject,
 UniqueVirtualMethod Overriding) {
   SmallVectorImpl 
 = Overrides[OverriddenSubobject];
-  if (llvm::find(SubobjectOverrides, Overriding) == SubobjectOverrides.end())
+  if (!llvm::is_contained(SubobjectOverrides, Overriding))
 SubobjectOverrides.push_back(Overriding);
 }
 

diff  --git a/clang/lib/AST/DeclCXX.cpp b/clang/lib/AST/DeclCXX.cpp
index 119450480c1f..016d28879227 100644
--- a/clang/lib/AST/DeclCXX.cpp
+++ b/clang/lib/AST/DeclCXX.cpp
@@ -1776,7 +1776,7 @@ void CXXRecordDecl::removeConversion(const NamedDecl 
*ConvDecl) {
   for (unsigned I = 0, E = Convs.size(); I != E; ++I) {
 if (Convs[I].getDecl() == ConvDecl) {
   Convs.erase(I);
-  assert(llvm::find(Convs, ConvDecl) == Convs.end() &&
+  assert(!llvm::is_contained(Convs, ConvDecl) &&
  "conversion was found multiple times in unresolved set");
   return;
 }
@@ -3014,8 +3014,7 @@ CXXRecordDecl 
*ConstructorUsingShadowDecl::getNominatedBaseClass() const {
 void BaseUsingDecl::anchor() {}
 
 void BaseUsingDecl::addShadowDecl(UsingShadowDecl *S) {
-  assert(std::find(shadow_begin(), shadow_end(), S) == shadow_end() &&
- "declaration already in set");
+  assert(!llvm::is_contained(shadows(), S) && "declaration already in set");
   assert(S->getIntroducer() == this);
 
   if (FirstUsingShadow.getPointer())
@@ -3024,8 +3023,7 @@ void BaseUsingDecl::addShadowDecl(UsingShadowDecl *S) {
 }
 
 void BaseUsingDecl::removeShadowDecl(UsingShadowDecl *S) {
-  assert(std::find(shadow_begin(), shadow_end(), S) != shadow_end() &&
- "declaration not in set");
+  assert(llvm::is_contained(shadows(), S) && "declaration not in set");
   assert(S->getIntroducer() == this);
 
   // Remove S from the shadow decl chain. This is O(n) but hopefully rare.

diff  --git a/clang/lib/AST/ParentMapContext.cpp 
b/clang/lib/AST/ParentMapContext.cpp
index 847e14c0c1e5..d216be5b59e8 100644
--- a/clang/lib/AST/ParentMapContext.cpp
+++ b/clang/lib/AST/ParentMapContext.cpp
@@ -389,11 +389,10 @@ class ParentMapContext::ParentMap::ASTVisitor
   auto *Vector = NodeOrVector.template get();
   // Skip duplicates for types that have memoization data.
   // We must check that the type has memoization data before calling
-  // std::find() because DynTypedNode::operator== can't compare all
+  // llvm::is_contained() because DynTypedNode::operator== can't compare 
all
   // types.
   bool Found = ParentStack.back().getMemoizationData() &&
-   std::find(Vector->begin(), Vector->end(),
- ParentStack.back()) != Vector->end();
+   llvm::is_contained(*Vector, ParentStack.back());
   if (!Found)
 Vector->push_back(ParentStack.back());
 }

diff  --git a/clang/lib/AST/RecordLayoutBuilder.cpp 
b/clang/lib/AST/RecordLayoutBuilder.cpp
index d17d1e26742c..35c0e92038a7 100644
--- a/clang/lib/AST/RecordLayoutBuilder.cpp
+++ b/clang/lib/AST/RecordLayoutBuilder.cpp
@@ -240,7 +240,7 @@ EmptySubobjectMap::CanPlaceSubobjectAtOffset(const 
CXXRecordDecl *RD,
 return true;
 
   const ClassVectorTy  = I->second;
-  if (llvm::find(Classes, RD) == Classes.end())
+  if (!llvm::is_contained(Classes, RD))
 return true;
 
   // There is already an empty class of the same type at this offset.

diff  --git a/clang/lib/AST/Type.cpp b/clang/lib/AST/Type.cpp
index de57b40b221a..58cae0378a98 100644
--- a/clang/lib/AST/Type.cpp
+++ b/clang/lib/AST/Type.cpp
@@ -3507,7 +3507,7 @@ bool RecordType::hasConstFields() const {
 return true;
   FieldTy = FieldTy.getCanonicalType();
   if (const auto *FieldRecTy = FieldTy->getAs()) {
-if (llvm::find(RecordTypeList, FieldRecTy) == RecordTypeList.end())
+if (!llvm::is_contained(RecordTypeList, FieldRecTy))
   

[PATCH] D111488: [Clang][clang-nvlink-wrapper] Pass nvlink path to the wrapper

2021-10-12 Thread Saiyedul Islam via Phabricator via cfe-commits
saiislam added inline comments.



Comment at: clang/lib/Driver/ToolChains/Cuda.cpp:617
+  // Find nvlink and pass it as "--nvlink-command=" argument of 
clang-nvlink-wrapper.
+  auto NvlinkBin = getToolChain().GetProgramPath("nvlink");
+  const char *NvlinkPath =

Meinersbur wrote:
> [style] [[ 
> https://llvm.org/docs/CodingStandards.html#use-auto-type-deduction-to-make-code-more-readable
>  | LLVM's coding standard does not use almost-always-auto ]].
> 
> It's not immediately obvious here, does `GetProgramPath` look into the 
> BinPath detected by CudaInstallationDetector? I applied the patch locally to 
> http://meinersbur.de:8011/#/builders/1 and it actually does work.
Yes, you are right. `CudaToolChain` constructor initializes binary paths 
obtained from `CudaInstallationDetector` which is used by this call.



Comment at: clang/tools/clang-nvlink-wrapper/ClangNvlinkWrapper.cpp:50
+
+static cl::opt NvlinkUserPath("nvlink-command",
+   cl::desc("path of nvlink binary"),

tra wrote:
> Nit. Clang already has `--ptxas-path=` option. It may be worth using `-path` 
> suffix here for consistency, too.
changed it to --nvlink-path


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111488

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


[PATCH] D111488: [Clang][clang-nvlink-wrapper] Pass nvlink path to the wrapper

2021-10-12 Thread Saiyedul Islam via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf56548829c4c: [Clang][clang-nvlink-wrapper] Pass nvlink path 
to the wrapper (authored by saiislam).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111488

Files:
  clang/lib/Driver/ToolChains/Cuda.cpp
  clang/tools/clang-nvlink-wrapper/ClangNvlinkWrapper.cpp

Index: clang/tools/clang-nvlink-wrapper/ClangNvlinkWrapper.cpp
===
--- clang/tools/clang-nvlink-wrapper/ClangNvlinkWrapper.cpp
+++ clang/tools/clang-nvlink-wrapper/ClangNvlinkWrapper.cpp
@@ -25,6 +25,7 @@
 /// 2. nvlink -o a.out-openmp-nvptx64 /tmp/a.cubin /tmp/b.cubin
 //===-===//
 
+#include "clang/Basic/Version.h"
 #include "llvm/Object/Archive.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/Errc.h"
@@ -41,6 +42,19 @@
 
 static cl::opt Help("h", cl::desc("Alias for -help"), cl::Hidden);
 
+// Mark all our options with this category, everything else (except for -help)
+// will be hidden.
+static cl::OptionCategory
+ClangNvlinkWrapperCategory("clang-nvlink-wrapper options");
+
+static cl::opt NvlinkUserPath("nvlink-path",
+   cl::desc("Path of nvlink binary"),
+   cl::cat(ClangNvlinkWrapperCategory));
+
+// Do not parse nvlink options
+static cl::list
+NVArgs(cl::Sink, cl::desc("..."));
+
 static Error runNVLink(std::string NVLinkPath,
SmallVectorImpl ) {
   std::vector NVLArgs;
@@ -119,8 +133,20 @@
   return Error::success();
 }
 
+static void PrintVersion(raw_ostream ) {
+  OS << clang::getClangToolFullVersion("clang-nvlink-wrapper") << '\n';
+}
+
 int main(int argc, const char **argv) {
   sys::PrintStackTraceOnErrorSignal(argv[0]);
+  cl::SetVersionPrinter(PrintVersion);
+  cl::HideUnrelatedOptions(ClangNvlinkWrapperCategory);
+  cl::ParseCommandLineOptions(
+  argc, argv,
+  "A wrapper tool over nvlink program. It transparently passes every \n"
+  "input option and objects to nvlink except archive files and path of \n"
+  "nvlink binary. It reads each input archive file to extract archived \n"
+  "cubin files as temporary files.\n");
 
   if (Help) {
 cl::PrintHelpMessage();
@@ -132,12 +158,7 @@
 exit(1);
   };
 
-  ErrorOr NvlinkPath = sys::findProgramByName("nvlink");
-  if (!NvlinkPath) {
-reportError(createStringError(NvlinkPath.getError(),
-  "unable to find 'nvlink' in path"));
-  }
-
+  std::string NvlinkPath;
   SmallVector Argv(argv, argv + argc);
   SmallVector ArgvSubst;
   SmallVector TmpFiles;
@@ -145,8 +166,7 @@
   StringSaver Saver(Alloc);
   cl::ExpandResponseFiles(Saver, cl::TokenizeGNUCommandLine, Argv);
 
-  for (size_t i = 1; i < Argv.size(); ++i) {
-std::string Arg = Argv[i];
+  for (const std::string  : NVArgs) {
 if (sys::path::extension(Arg) == ".a") {
   if (Error Err = extractArchiveFiles(Arg, ArgvSubst, TmpFiles))
 reportError(std::move(Err));
@@ -155,7 +175,19 @@
 }
   }
 
-  if (Error Err = runNVLink(NvlinkPath.get(), ArgvSubst))
+  NvlinkPath = NvlinkUserPath;
+
+  // If user hasn't specified nvlink binary then search it in PATH
+  if (NvlinkPath.empty()) {
+ErrorOr NvlinkPathErr = sys::findProgramByName("nvlink");
+if (!NvlinkPathErr) {
+  reportError(createStringError(NvlinkPathErr.getError(),
+"unable to find 'nvlink' in path"));
+}
+NvlinkPath = NvlinkPathErr.get();
+  }
+
+  if (Error Err = runNVLink(NvlinkPath, ArgvSubst))
 reportError(std::move(Err));
   if (Error Err = cleanupTmpFiles(TmpFiles))
 reportError(std::move(Err));
Index: clang/lib/Driver/ToolChains/Cuda.cpp
===
--- clang/lib/Driver/ToolChains/Cuda.cpp
+++ clang/lib/Driver/ToolChains/Cuda.cpp
@@ -613,6 +613,11 @@
   AddStaticDeviceLibsLinking(C, *this, JA, Inputs, Args, CmdArgs, "nvptx", GPUArch,
   false, false);
 
+  // Find nvlink and pass it as "--nvlink-path=" argument of
+  // clang-nvlink-wrapper.
+  CmdArgs.push_back(Args.MakeArgString(
+  Twine("--nvlink-path=" + getToolChain().GetProgramPath("nvlink";
+
   const char *Exec =
   Args.MakeArgString(getToolChain().GetProgramPath("clang-nvlink-wrapper"));
   C.addCommand(std::make_unique(
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] f565488 - [Clang][clang-nvlink-wrapper] Pass nvlink path to the wrapper

2021-10-12 Thread Saiyedul Islam via cfe-commits

Author: Saiyedul Islam
Date: 2021-10-12T16:15:52Z
New Revision: f56548829c4c696d798c252bf097b71538bd45d7

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

LOG: [Clang][clang-nvlink-wrapper] Pass nvlink path to the wrapper

Added support of a "--nvlink-path" option in clang-nvlink-wrapper which
takes the path of nvlink binary.

Static Device Library support for OpenMP (D105191) now searches for
nvlink binary and passes its location via this option. In absence
of this option, nvlink binary is searched in locations in PATH.

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/Cuda.cpp
clang/tools/clang-nvlink-wrapper/ClangNvlinkWrapper.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Cuda.cpp 
b/clang/lib/Driver/ToolChains/Cuda.cpp
index 18351dae39f7e..0ad1ffb079b31 100644
--- a/clang/lib/Driver/ToolChains/Cuda.cpp
+++ b/clang/lib/Driver/ToolChains/Cuda.cpp
@@ -613,6 +613,11 @@ void NVPTX::OpenMPLinker::ConstructJob(Compilation , 
const JobAction ,
   AddStaticDeviceLibsLinking(C, *this, JA, Inputs, Args, CmdArgs, "nvptx", 
GPUArch,
   false, false);
 
+  // Find nvlink and pass it as "--nvlink-path=" argument of
+  // clang-nvlink-wrapper.
+  CmdArgs.push_back(Args.MakeArgString(
+  Twine("--nvlink-path=" + getToolChain().GetProgramPath("nvlink";
+
   const char *Exec =
   
Args.MakeArgString(getToolChain().GetProgramPath("clang-nvlink-wrapper"));
   C.addCommand(std::make_unique(

diff  --git a/clang/tools/clang-nvlink-wrapper/ClangNvlinkWrapper.cpp 
b/clang/tools/clang-nvlink-wrapper/ClangNvlinkWrapper.cpp
index 5c8b7b9db6884..bc5b9a9f1fde7 100644
--- a/clang/tools/clang-nvlink-wrapper/ClangNvlinkWrapper.cpp
+++ b/clang/tools/clang-nvlink-wrapper/ClangNvlinkWrapper.cpp
@@ -25,6 +25,7 @@
 /// 2. nvlink -o a.out-openmp-nvptx64 /tmp/a.cubin /tmp/b.cubin
 //===-===//
 
+#include "clang/Basic/Version.h"
 #include "llvm/Object/Archive.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/Errc.h"
@@ -41,6 +42,19 @@ using namespace llvm;
 
 static cl::opt Help("h", cl::desc("Alias for -help"), cl::Hidden);
 
+// Mark all our options with this category, everything else (except for -help)
+// will be hidden.
+static cl::OptionCategory
+ClangNvlinkWrapperCategory("clang-nvlink-wrapper options");
+
+static cl::opt NvlinkUserPath("nvlink-path",
+   cl::desc("Path of nvlink binary"),
+   
cl::cat(ClangNvlinkWrapperCategory));
+
+// Do not parse nvlink options
+static cl::list
+NVArgs(cl::Sink, cl::desc("..."));
+
 static Error runNVLink(std::string NVLinkPath,
SmallVectorImpl ) {
   std::vector NVLArgs;
@@ -119,8 +133,20 @@ static Error cleanupTmpFiles(SmallVectorImpl 
) {
   return Error::success();
 }
 
+static void PrintVersion(raw_ostream ) {
+  OS << clang::getClangToolFullVersion("clang-nvlink-wrapper") << '\n';
+}
+
 int main(int argc, const char **argv) {
   sys::PrintStackTraceOnErrorSignal(argv[0]);
+  cl::SetVersionPrinter(PrintVersion);
+  cl::HideUnrelatedOptions(ClangNvlinkWrapperCategory);
+  cl::ParseCommandLineOptions(
+  argc, argv,
+  "A wrapper tool over nvlink program. It transparently passes every \n"
+  "input option and objects to nvlink except archive files and path of \n"
+  "nvlink binary. It reads each input archive file to extract archived \n"
+  "cubin files as temporary files.\n");
 
   if (Help) {
 cl::PrintHelpMessage();
@@ -132,12 +158,7 @@ int main(int argc, const char **argv) {
 exit(1);
   };
 
-  ErrorOr NvlinkPath = sys::findProgramByName("nvlink");
-  if (!NvlinkPath) {
-reportError(createStringError(NvlinkPath.getError(),
-  "unable to find 'nvlink' in path"));
-  }
-
+  std::string NvlinkPath;
   SmallVector Argv(argv, argv + argc);
   SmallVector ArgvSubst;
   SmallVector TmpFiles;
@@ -145,8 +166,7 @@ int main(int argc, const char **argv) {
   StringSaver Saver(Alloc);
   cl::ExpandResponseFiles(Saver, cl::TokenizeGNUCommandLine, Argv);
 
-  for (size_t i = 1; i < Argv.size(); ++i) {
-std::string Arg = Argv[i];
+  for (const std::string  : NVArgs) {
 if (sys::path::extension(Arg) == ".a") {
   if (Error Err = extractArchiveFiles(Arg, ArgvSubst, TmpFiles))
 reportError(std::move(Err));
@@ -155,7 +175,19 @@ int main(int argc, const char **argv) {
 }
   }
 
-  if (Error Err = runNVLink(NvlinkPath.get(), ArgvSubst))
+  NvlinkPath = NvlinkUserPath;
+
+  // If user hasn't specified nvlink binary then search it in PATH
+  if (NvlinkPath.empty()) {
+ErrorOr NvlinkPathErr = 

[PATCH] D111655: [analyzer] non-obvious analyzer warning: Use of zero-allocated memory

2021-10-12 Thread Chris D'Angelo via Phabricator via cfe-commits
chrisdangelo created this revision.
chrisdangelo added a reviewer: NoQ.
Herald added subscribers: manas, steakhal, ASDenysPetrov, martong, dkrupp, 
donat.nagy, Szelethus, mikhail.ramalho, a.sidorin, szepet, baloghadamsoftware, 
xazax.hun.
chrisdangelo requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This change clarifies the message provided when the analyzer catches the use of 
memory that is allocated with size zero.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D111655

Files:
  clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
  clang/test/Analysis/NewDelete-checker-test.cpp
  clang/test/Analysis/malloc.c

Index: clang/test/Analysis/malloc.c
===
--- clang/test/Analysis/malloc.c
+++ clang/test/Analysis/malloc.c
@@ -261,23 +261,23 @@
 
 void CheckUseZeroAllocated1() {
   int *p = malloc(0);
-  *p = 1; // expected-warning {{Use of zero-allocated memory}}
+  *p = 1; // expected-warning {{Use of memory allocated with size zero}}
   free(p);
 }
 
 char CheckUseZeroAllocated2() {
   char *p = alloca(0);
-  return *p; // expected-warning {{Use of zero-allocated memory}}
+  return *p; // expected-warning {{Use of memory allocated with size zero}}
 }
 
 char CheckUseZeroWinAllocated2() {
   char *p = _alloca(0);
-  return *p; // expected-warning {{Use of zero-allocated memory}}
+  return *p; // expected-warning {{Use of memory allocated with size zero}}
 }
 
 void UseZeroAllocated(int *p) {
   if (p)
-*p = 7; // expected-warning {{Use of zero-allocated memory}}
+*p = 7; // expected-warning {{Use of memory allocated with size zero}}
 }
 void CheckUseZeroAllocated3() {
   int *p = malloc(0);
@@ -287,39 +287,39 @@
 void f(char);
 void CheckUseZeroAllocated4() {
   char *p = valloc(0);
-  f(*p); // expected-warning {{Use of zero-allocated memory}}
+  f(*p); // expected-warning {{Use of memory allocated with size zero}}
   free(p);
 }
 
 void CheckUseZeroAllocated5() {
   int *p = calloc(0, 2);
-  *p = 1; // expected-warning {{Use of zero-allocated memory}}
+  *p = 1; // expected-warning {{Use of memory allocated with size zero}}
   free(p);
 }
 
 void CheckUseZeroAllocated6() {
   int *p = calloc(2, 0);
-  *p = 1; // expected-warning {{Use of zero-allocated memory}}
+  *p = 1; // expected-warning {{Use of memory allocated with size zero}}
   free(p);
 }
 
 void CheckUseZeroAllocated7() {
   int *p = realloc(0, 0);
-  *p = 1; // expected-warning {{Use of zero-allocated memory}}
+  *p = 1; // expected-warning {{Use of memory allocated with size zero}}
   free(p);
 }
 
 void CheckUseZeroAllocated8() {
   int *p = malloc(8);
   int *q = realloc(p, 0);
-  *q = 1; // expected-warning {{Use of zero-allocated memory}}
+  *q = 1; // expected-warning {{Use of memory allocated with size zero}}
   free(q);
 }
 
 void CheckUseZeroAllocated9() {
   int *p = realloc(0, 0);
   int *q = realloc(p, 0);
-  *q = 1; // expected-warning {{Use of zero-allocated memory}}
+  *q = 1; // expected-warning {{Use of memory allocated with size zero}}
   free(q);
 }
 
@@ -344,7 +344,7 @@
   char *p = malloc(s);
 
   if (b)
-*p = 1; // expected-warning {{Use of zero-allocated memory}}
+*p = 1; // expected-warning {{Use of memory allocated with size zero}}
 
   free(p);
 }
@@ -372,7 +372,7 @@
   char *q = realloc(p, s);
 
   if (b)
-*q = 1; // expected-warning {{Use of zero-allocated memory}}
+*q = 1; // expected-warning {{Use of memory allocated with size zero}}
 
   free(q);
 }
Index: clang/test/Analysis/NewDelete-checker-test.cpp
===
--- clang/test/Analysis/NewDelete-checker-test.cpp
+++ clang/test/Analysis/NewDelete-checker-test.cpp
@@ -105,13 +105,13 @@
 
 void testUseZeroAlloc1() {
   int *p = (int *)operator new(0);
-  *p = 1; // newdelete-warning {{Use of zero-allocated memory}}
+  *p = 1; // newdelete-warning {{Use of memory allocated with size zero}}
   delete p;
 }
 
 int testUseZeroAlloc2() {
   int *p = (int *)operator new[](0);
-  return p[0]; // newdelete-warning {{Use of zero-allocated memory}}
+  return p[0]; // newdelete-warning {{Use of memory allocated with size zero}}
   delete[] p;
 }
 
@@ -119,7 +119,7 @@
 
 void testUseZeroAlloc3() {
   int *p = new int[0];
-  f(*p); // newdelete-warning {{Use of zero-allocated memory}}
+  f(*p); // newdelete-warning {{Use of memory allocated with size zero}}
   delete[] p;
 }
 
Index: clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
@@ -2471,7 +2471,8 @@
   categories::MemoryError));
 
 auto R = std::make_unique(
-*BT_UseZerroAllocated[*CheckKind], "Use of zero-allocated memory", N);
+*BT_UseZerroAllocated[*CheckKind],
+"Use of memory 

[PATCH] D111654: [analyzer] Retrieve a value from list initialization of multi-dimensional array declaration.

2021-10-12 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov created this revision.
ASDenysPetrov added reviewers: NoQ, aaron.ballman, steakhal, martong, 
vsavchenko.
Herald added subscribers: manas, dkrupp, donat.nagy, Szelethus, 
mikhail.ramalho, a.sidorin, rnkovacs, szepet, baloghadamsoftware, xazax.hun.
ASDenysPetrov requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Add support of multi-dimensional arrays in 
`RegionStoreManager::getBindingForElement`. Handle nested ElementRegion's 
getting offsets and checking for being in bounds. Get values from the nested 
initialization lists using obtained offsets.

Example:

  const int arr[3][2] = {{1, 2}, {3, 4}};
  arr[0][0];  // 1
  arr[0][1];  // 2
  arr[0][2];  // UB
  arr[1][0];  // 3
  arr[1][1];  // 4
  arr[1][-1]; // UB
  arr[2][0];  // 0
  arr[2][1];  // 0
  arr[-2][0]; // UB

P.S. this patch also includes D111542  fix 
(without test cases, which I'll add separately).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D111654

Files:
  clang/include/clang/AST/Type.h
  clang/lib/AST/Type.cpp
  clang/lib/StaticAnalyzer/Core/RegionStore.cpp
  clang/test/Analysis/initialization.c
  clang/test/Analysis/initialization.cpp

Index: clang/test/Analysis/initialization.cpp
===
--- clang/test/Analysis/initialization.cpp
+++ clang/test/Analysis/initialization.cpp
@@ -15,8 +15,7 @@
 int const arr[2][2] = {};
 void arr2init() {
   int i = 1;
-  // FIXME: Should recognize that it is 0.
-  clang_analyzer_eval(arr[i][0]); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(arr[i][0]); // expected-warning{{FALSE}}
 }
 
 int const glob_arr1[3] = {};
@@ -54,77 +53,55 @@
   return glob_arr3[0]; // no-warning (garbage or undefined)
 }
 
-// TODO: Support multidimensional array.
 int const glob_arr4[4][2] = {};
 void glob_array_index2() {
-  // FIXME: Should be TRUE.
-  clang_analyzer_eval(glob_arr4[1][0] == 0); // expected-warning{{UNKNOWN}}
-  // FIXME: Should be TRUE.
-  clang_analyzer_eval(glob_arr4[1][1] == 0); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(glob_arr4[0][0] == 0); // expected-warning{{TRUE}}
+  clang_analyzer_eval(glob_arr4[1][0] == 0); // expected-warning{{TRUE}}
+  clang_analyzer_eval(glob_arr4[1][1] == 0); // expected-warning{{TRUE}}
 }
 
-// TODO: Support multidimensional array.
 void glob_invalid_index3() {
   int idx = -42;
-  // FIXME: Should warn {{garbage or undefined}}.
-  auto x = glob_arr4[1][idx]; // no-warning
+  auto x = glob_arr4[1][idx]; // expected-warning{{garbage or undefined}}
 }
 
-// TODO: Support multidimensional array.
 void glob_invalid_index4() {
   const int *ptr = glob_arr4[1];
   int idx = -42;
-  // FIXME: Should warn {{garbage or undefined}}.
-  auto x = ptr[idx]; // no-warning
+  auto x = ptr[idx]; // expected-warning{{garbage or undefined}}
 }
 
-// TODO: Support multidimensional array.
 int const glob_arr5[4][2] = {{1}, 3, 4, 5};
 void glob_array_index3() {
-  // FIXME: Should be TRUE.
-  clang_analyzer_eval(glob_arr5[0][0] == 1); // expected-warning{{UNKNOWN}}
-  // FIXME: Should be TRUE.
-  clang_analyzer_eval(glob_arr5[0][1] == 0); // expected-warning{{UNKNOWN}}
-  // FIXME: Should be TRUE.
-  clang_analyzer_eval(glob_arr5[1][0] == 3); // expected-warning{{UNKNOWN}}
-  // FIXME: Should be TRUE.
-  clang_analyzer_eval(glob_arr5[1][1] == 4); // expected-warning{{UNKNOWN}}
-  // FIXME: Should be TRUE.
-  clang_analyzer_eval(glob_arr5[2][0] == 5); // expected-warning{{UNKNOWN}}
-  // FIXME: Should be TRUE.
-  clang_analyzer_eval(glob_arr5[2][1] == 0); // expected-warning{{UNKNOWN}}
-  // FIXME: Should be TRUE.
-  clang_analyzer_eval(glob_arr5[3][0] == 0); // expected-warning{{UNKNOWN}}
-  // FIXME: Should be TRUE.
-  clang_analyzer_eval(glob_arr5[3][1] == 0); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(glob_arr5[0][0] == 1); // expected-warning{{TRUE}}
+  clang_analyzer_eval(glob_arr5[0][1] == 0); // expected-warning{{TRUE}}
+  clang_analyzer_eval(glob_arr5[1][0] == 3); // expected-warning{{TRUE}}
+  clang_analyzer_eval(glob_arr5[1][1] == 4); // expected-warning{{TRUE}}
+  clang_analyzer_eval(glob_arr5[2][0] == 5); // expected-warning{{TRUE}}
+  clang_analyzer_eval(glob_arr5[2][1] == 0); // expected-warning{{TRUE}}
+  clang_analyzer_eval(glob_arr5[3][0] == 0); // expected-warning{{TRUE}}
+  clang_analyzer_eval(glob_arr5[3][1] == 0); // expected-warning{{TRUE}}
 }
 
-// TODO: Support multidimensional array.
 void glob_ptr_index2() {
+  // FIXME: Fix cast.
   int const *ptr = glob_arr5[1];
   // FIXME: Should be TRUE.
-  clang_analyzer_eval(ptr[0] == 3); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(ptr[0] == 3); // expected-warning{{UNDEFINED}}
   // FIXME: Should be TRUE.
-  clang_analyzer_eval(ptr[1] == 4); // expected-warning{{UNKNOWN}}
-  // FIXME: Should be UNDEFINED.
-  clang_analyzer_eval(ptr[2] == 5); // expected-warning{{UNKNOWN}}
-  // FIXME: Should be UNDEFINED.
- 

[PATCH] D110823: [clangd] Add code completion of param name on /* inside function calls.

2021-10-12 Thread Adam Czachorowski via Phabricator via cfe-commits
adamcz added inline comments.



Comment at: clang-tools-extra/clangd/CodeComplete.cpp:1145
+  CodeCompletionTUInfo CCTUInfo;
+  std::vector 
+  // For de-duplication only. StringRefs based on strings in ParamNames.

kadircet wrote:
> nit: Why not directly have an `llvm::DenseSet` here? I am not sure if the 
> order we're preserving currently is a good one anyway (depends a lot on the 
> order of includes, i think?). If we really want to preserve some ordering, it 
> would probably make sense to have the lexicographical one instead.
I decided to preserve the order to match what SignatureHelp is doing, but I now 
realize it re-orders them anyway, so good point, fixed.

Note that I used std::set, since that works with std::string and I don't think 
we can safely return llvm::StringRef here.



Comment at: clang-tools-extra/clangd/CodeComplete.cpp:1966
+bool shouldCodeCompleteComment(llvm::StringRef Content, unsigned ,
+   llvm::StringRef ) {
+  if (Content.empty())

kadircet wrote:
> this might read easier as:
> 
> ```
> while (!Contents.empty() && isAciiIdentifierContinue(Contents.back())
>   Contents = Contents.drop_back();
> Contents.rtrim(); // by default this drops the chars you have in `Whitespace` 
> already.
> Offset = Contents.size();
> return Contents.endswith("/*");
> ```
> 
> this has the different behaviour for `/* qwer ^` but I don't think we want to 
> complete after a word anyway (that's not what we do in the rest of the 
> completion, space terminates the previous identifier).
> 
> As for propagating prefix, I think it's enough to check that the file content 
> endswith whatever name we're going to suggest in the signature help collector.
> 
> nit: As for `Offset`, I might actually prefer returning an 
> `Optional` while renaming the function to 
> `getFunctionArgumentCommentStart`, but i am fine with this too, up to you.
First, returning Optional instead of bool + unsigned is better. Done.

Second, you're right that there's no need to return Prefix, it can be just as 
easily computed later. However, we still need it. I'm not sure what you're 
suggesting with checking if content ends with name. If it's literally 
Content.endswith(Name) that means you must have already typed the entire 
argument name.
I moved the CommentPrefix computation out of this function to make the 
signature nicer. It's just one line anyway. We can't easily move this to the 
collector, since it gets the original content, meaning we'd have to pass two 
offsets (original completion point and the new one) so we can extract something 
like "fun(/*foo^);" - we need to remove everything before /* and everything 
after ^. Does that explanation make sense?

Third, your version is better now. Note there is no difference in behavior on 
"/* qwer ^". There's even a test for that. I think I ended up with that 
complicated version because of the Prefix extraction, and, ironically, the "/* 
qwer ^" case - I just confused myself too much ;-)

Thanks


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110823

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


[PATCH] D110823: [clangd] Add code completion of param name on /* inside function calls.

2021-10-12 Thread Adam Czachorowski via Phabricator via cfe-commits
adamcz updated this revision to Diff 379070.
adamcz marked 3 inline comments as done.
adamcz added a comment.

next round of review comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110823

Files:
  clang-tools-extra/clangd/ClangdLSPServer.cpp
  clang-tools-extra/clangd/CodeComplete.cpp
  clang-tools-extra/clangd/test/initialize-params.test
  clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp

Index: clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
===
--- clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
+++ clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
@@ -3279,6 +3279,35 @@
   EXPECT_THAT(Result.Completions, Not(testing::IsEmpty()));
 }
 
+TEST(CompletionTest, CommentParamName) {
+  clangd::CodeCompleteOptions Opts;
+  const std::string Code = R"cpp(
+void fun(int foo, int bar);
+void overloaded(int param_int);
+void overloaded(int param_int, int param_other);
+void overloaded(char param_char);
+int main() {
+  )cpp";
+
+  EXPECT_THAT(completions(Code + "fun(/*^", {}, Opts).Completions,
+  UnorderedElementsAre(Labeled("foo=")));
+  EXPECT_THAT(completions(Code + "fun(1, /*^", {}, Opts).Completions,
+  UnorderedElementsAre(Labeled("bar=")));
+  EXPECT_THAT(completions(Code + "/*^", {}, Opts).Completions, IsEmpty());
+  // Test de-duplication.
+  EXPECT_THAT(
+  completions(Code + "overloaded(/*^", {}, Opts).Completions,
+  UnorderedElementsAre(Labeled("param_int="), Labeled("param_char=")));
+  // Comment already has some text in it.
+  EXPECT_THAT(completions(Code + "fun(/*  ^", {}, Opts).Completions,
+  UnorderedElementsAre(Labeled("foo=")));
+  EXPECT_THAT(completions(Code + "fun(/* f^", {}, Opts).Completions,
+  UnorderedElementsAre(Labeled("foo=")));
+  EXPECT_THAT(completions(Code + "fun(/* x^", {}, Opts).Completions, IsEmpty());
+  EXPECT_THAT(completions(Code + "fun(/* f ^", {}, Opts).Completions,
+  IsEmpty());
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/test/initialize-params.test
===
--- clang-tools-extra/clangd/test/initialize-params.test
+++ clang-tools-extra/clangd/test/initialize-params.test
@@ -48,7 +48,8 @@
 # CHECK-NEXT:  ">",
 # CHECK-NEXT:  ":",
 # CHECK-NEXT:  "\"",
-# CHECK-NEXT:  "/"
+# CHECK-NEXT:  "/",
+# CHECK-NEXT:  "*"
 # CHECK-NEXT:]
 # CHECK-NEXT:  },
 # CHECK-NEXT:  "declarationProvider": true,
Index: clang-tools-extra/clangd/CodeComplete.cpp
===
--- clang-tools-extra/clangd/CodeComplete.cpp
+++ clang-tools-extra/clangd/CodeComplete.cpp
@@ -1098,6 +1098,50 @@
   const SymbolIndex *Index;
 }; // SignatureHelpCollector
 
+// Used only for completion of C-style comments in function call (i.e.
+// /*foo=*/7). Similar to SignatureHelpCollector, but needs to do less work.
+class ParamNameCollector final : public CodeCompleteConsumer {
+public:
+  ParamNameCollector(const clang::CodeCompleteOptions ,
+ std::set )
+  : CodeCompleteConsumer(CodeCompleteOpts),
+Allocator(std::make_shared()),
+CCTUInfo(Allocator), ParamNames(ParamNames) {}
+
+  void ProcessOverloadCandidates(Sema , unsigned CurrentArg,
+ OverloadCandidate *Candidates,
+ unsigned NumCandidates,
+ SourceLocation OpenParLoc) override {
+assert(CurrentArg <= (unsigned)std::numeric_limits::max() &&
+   "too many arguments");
+
+for (unsigned I = 0; I < NumCandidates; ++I) {
+  OverloadCandidate Candidate = Candidates[I];
+  auto *Func = Candidate.getFunction();
+  if (!Func || Func->getNumParams() <= CurrentArg)
+continue;
+  auto *PVD = Func->getParamDecl(CurrentArg);
+  if (!PVD)
+continue;
+  auto *Ident = PVD->getIdentifier();
+  if (!Ident)
+continue;
+  auto Name = Ident->getName();
+  if (!Name.empty())
+ParamNames.insert(Name.str());
+}
+  }
+
+private:
+  GlobalCodeCompletionAllocator () override { return *Allocator; }
+
+  CodeCompletionTUInfo () override { return CCTUInfo; }
+
+  std::shared_ptr Allocator;
+  CodeCompletionTUInfo CCTUInfo;
+  std::set 
+};
+
 struct SemaCompleteInput {
   PathRef FileName;
   size_t Offset;
@@ -1857,6 +1901,59 @@
   return Result;
 }
 
+// Code complete the argument name on "/*" inside function call.
+// Offset should be pointing to the start of the comment, i.e.:
+// foo(^/*, rather than foo(/*^) where the cursor probably is.
+CodeCompleteResult codeCompleteComment(PathRef FileName, unsigned Offset,
+   

[PATCH] D111542: [analyzer] Retrieve incomplete array extent from its redeclaration.

2021-10-12 Thread Gabor Marton via Phabricator via cfe-commits
martong added inline comments.



Comment at: clang/lib/StaticAnalyzer/Core/RegionStore.cpp:1663
 // We can trust a const value or a value of a global initializer in main().
-const VarDecl *VD = VR->getDecl();
+const VarDecl *VD = VR->getDecl()->getMostRecentDecl();
 if (VD->getType().isConstQualified() ||

ASDenysPetrov wrote:
> NoQ wrote:
> > ASDenysPetrov wrote:
> > > steakhal wrote:
> > > > I think you supposed to use the `getCanonicalDecl()` instead.
> > > Using `getCanonicalDecl` does not fix the issue. I've checked.
> > Aha ok, can you try iterating over `redecls()`?
> > 
> > Separately, I suspect that this should be performed before the `VarRegion` 
> > is constructed in the first place. Maybe in its constructor we should 
> > `assert(VD->isThisDeclarationADefinition())` or something like that.
> > Aha ok, can you try iterating over redecls()?
> Do you assume that in a list `{redecl1, redecl2, redecl3}` **redecl2** may be 
> our guy but **1** and **3** may not?
> > Separately, I suspect that this should be performed before the VarRegion is 
> > constructed in the first place. 
> I'm not sure I got what you mean, but as I undestood that it is not be a part 
> of this fix, right?
I think this should be part of this fix, but you don't have to do that 
iteration, there is a better thing for the job: `getAnyInitializer`.

What we need is to find that Decl that has the InitExpr attached. This may not 
be the canonical nor the most recent redecl.
Please see my code change suggestion below.



Comment at: clang/lib/StaticAnalyzer/Core/RegionStore.cpp:1661-1663
 // Check if the containing array has an initialized value that we can 
trust.
 // We can trust a const value or a value of a global initializer in main().
+const VarDecl *VD = VR->getDecl()->getMostRecentDecl();





Comment at: clang/test/Analysis/initialization.c:101-102
+
+const int glob_arr3[];  // Incomplete array declaration
+const int glob_arr3[4] = {1, 2, 3}; // Incomplete Array redeclaration
+void foo() {

I'd like to see some more elaborate test cases. Notably
```
const int glob_arr3[];  // Incomplete array declaration
const int glob_arr3[4] = {1, 2, 3}; // Incomplete Array redeclaration
const int glob_arr3[];  // Incomplete array redeclaration
```
here neither the canonical nor the most recent decl have the initexpr.
And I think this is what @balazske tried to point out.


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

https://reviews.llvm.org/D111542

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


[PATCH] D111062: [RISCV] Rename some assembler mnemonic and intrinsic functions for RVV 1.0.

2021-10-12 Thread Jessica Clarke via Phabricator via cfe-commits
jrtc27 added inline comments.



Comment at: llvm/lib/Target/RISCV/RISCVInstrInfoV.td:1378
+def : InstAlias<"vmornot.mm $vd, $vs2, $vs1",
+(VMORN_MM VR:$vd, VR:$vs2, VR:$vs1), 0>;
+

Ugh, spec mandating aliases for the pre-ratified names... this is just going to 
encourage people who don't know any better to use the old names and you'll 
never be able to kill it off :(



Comment at: llvm/test/CodeGen/RISCV/rvv/fixed-vectors-mask-logic.ll:1
-; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
-; RUN: llc -mtriple=riscv32 -mattr=+experimental-v 
-riscv-v-vector-bits-min=128 -verify-machineinstrs < %s | FileCheck %s
-; RUN: llc -mtriple=riscv64 -mattr=+experimental-v 
-riscv-v-vector-bits-min=128 -verify-machineinstrs < %s | FileCheck %s
-; RUN: llc -mtriple=riscv32 -mattr=+experimental-v 
-riscv-v-vector-bits-min=128 -verify-machineinstrs < %s | FileCheck %s
+  ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+  ; RUN: llc -mtriple=riscv32 -mattr=+experimental-v 
-riscv-v-vector-bits-min=128 -verify-machineinstrs < %s | FileCheck %s

Revert

(how do you even manage that, the NOTE line is autogenerated...)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111062

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


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

2021-10-12 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov added a comment.

In D111283#3056748 , @rsmith wrote:

> Do you have examples showing what this does in practice for errors in 
> real-world code? I'm concerned that stripping back to the common type sugar 
> may produce an unintuitive result in some cases, although it certainly does 
> seem at least theoretically nice to use a commutative and associative 
> function to combine deductions like this. The kind of thing I'd be worried 
> about would be (eg) a container where the `iterator` and `const_iterator` are 
> the same, but where the common sugar of `T::iterator` and `T::const_iterator` 
> are some internal type that the user has never heard of. In general it seems 
> like this sugar stripping could result in types that are distant from the 
> user's code. As an extreme example, in the case where one of the types is 
> canonical and the other is not, it seems like stripping all the way back to 
> the canonical type would be worse than ignoring the canonical version of the 
> type and keeping the sugared version.

I don't have handy access to very large code bases where this could be deployed 
experimentally, but this is something I can try to look into.

> Perhaps we could treat canonical types as a special case (effectively 
> assuming they came from taking a type and canonicalizing it at some point, 
> rather than from a type the user wrote) and when combining two types, use the 
> non-canonical type if one of them is canonical, and otherwise use the common 
> sugar. That should still be commutative and associative and generally 
> well-behaved, but won't degrade badly when given a canonical type as input. I 
> think that still leaves the possibility of a surprising outcome when 
> combining types that both desugar to some internal type, though I'm not sure 
> what we can do about that other than make an arbitrary choice of which type 
> sugar we like more.

The thing I would be concerned with this special case is that it would also 
give surprising results, ie it could deduce that Socrates is a Dog.
I guess there are two use cases scenarios here, one where we have this 
transparent hierarchy, and this algorithm gives results that make intuitive 
sense,
and the other where we have some typedef which we want to be opaque in order to 
not expose internal details.

So exploring your example, suppose we try to deduce from an iterator and a 
const_iterator.
We have some options here:

- We deduce as either iterator or const_iterator. If there is an IS-A 
relationship between them, and we pick the right choice, then we pack up and go 
home, job well done. If there is no such relationship, neither answer seems 
right.
- We deduce the canonical type, which might be something like `struct 
vendor::detail::Foo *`. This exposes internal details, but at least it has some 
vocabulary information, so you know this is a pointer to an object of some 
internal class. It's not good from a user friendliness PoV, but it's good from 
a 'I want to debug this thing' perspective.
- We deduce to some type sugar which is meant to be internal, like 
`vendor::detail::iterator_t`. This is not very good, maybe it's worse from a 
user friendliness PoV than the bullet point above as we expose even more 
internal details. But maybe in some cases it's better as the vendor can also 
pick a name for the typedef which is more explanatory than the the canonical 
type, which will still be available in the 'aka', so from the debuggability 
perspective this also seems better.
- We create some new type sugar which wraps the information that some type was 
deduced from two other types. This might be too much information overload, and 
we still need to have an answer to the 'single step desugar' of it, so I am not 
exploring this much further for now ;)

The problem of hiding internal details in error messages is a general problem, 
that maybe this solution would make a bit worse in some cases,
but that also means that solutions to the general problem can also remedy the 
problems we cause here.
One such idea (not proposing formally, just giving an example) would be an 
attribute on typedefs which hides the underlying sugar,
making it AS-IF the typedef was written on the canonical type. But it would 
still not hide the canonical type which is also
implementation detail, so not a huge win.

Going back to the 'treat canonical types as not written' workaround, I think 
there are too many cases where we are doing the wrong thing here in clang.
Basically any type written bare without any name / keyword qualifiers will not 
be treated by some ElaboratedType like mechanism. I suppose that as we fix
those problems, the need for this workaround will sort of disappear. I am not 
too opposed to it, but I think it might be better to give less, but more 
correct information, than
to some times make wild guesses ;-P

> I've not yet done any detailed review of the common type sugar computation 
> mechanism.

[PATCH] D110913: [analyzer][solver] Handle simplification to ConcreteInt

2021-10-12 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added a comment.

Looks good to me. I very much like this.
Check my nits inline. Given those are fixed I'm gonna accept this.




Comment at: 
clang/include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h:392-397
+/// Try to simplify a given symbolic expression based on the constraints in
+/// State. This is needed because the Environment bindings are not getting
+/// updated when a new constraint is added to the State. If the symbol is
+/// simplified to a non-symbol (e.g. to a constant) then the original symbol
+/// is returned.
 SymbolRef simplify(ProgramStateRef State, SymbolRef Sym);

Okay, I like it!
However, it's still not entirely clear to me *when* to use which.
Could you clarify that aspect too?
Sorry for being picky but I'm not an expert on this part of the code and if 
it's not clear to me, it probably won't be clear to newcomers either.



Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:2110
+
+SymbolRef SimplifiedMemberSym = nullptr;
+SVal SimplifiedMemberVal = simplifyToSVal(State, MemberSym);

By initializing it here, it will be much cleaner:
1) It's not mutated, thus it can be `const`
2) We can spare the `else` branch.

Also consider marking the rest of the variables `const`, so that the lack of 
constness would actually suggest mutability.



Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:2112
+SVal SimplifiedMemberVal = simplifyToSVal(State, MemberSym);
+if (const auto CI = SimplifiedMemberVal.getAs()) {
+  const llvm::APSInt  = CI->getValue();

I think a comment would be appreciated describing that we only look for 
infeasibility here, nothing else.
Thus, the //fallthrough// in the feasible case is intentional.



Comment at: clang/test/Analysis/solver-sym-simplification-concreteint.c:17
+return;
+  clang_analyzer_warnIfReached(); // expected-no-diagnostics
+

Consider following the convention and using the `// no-warning` comment instead.
I'm also requesting an additional test case, exercising the fallthrough 
behavior I stated in an earlier comment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110913

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


[PATCH] D110065: [AArch64] Add support for the 'R' architecture profile.

2021-10-12 Thread John Brawn via Phabricator via cfe-commits
john.brawn added inline comments.



Comment at: llvm/lib/Target/AArch64/MCTargetDesc/AArch64InstPrinter.cpp:1548
+
+static const AArch64SysReg::SysReg *lookupSysReg(unsigned Val, bool Read,
+ const MCSubtargetInfo ) {

It would be better if we had a generic way to handle registers with overlapping 
encodings, instead of handling the two registers explicitly here. I'm not sure 
of the best way to do that, but looking at AArch64SystemOperands.td it looks 
like maybe a way to do it would to add an extra "AltName" field to give an 
alternate name for the same encoding, so e.g. TTBR0_EL2 would have AltName 
VSCTLR_EL2 and vice-versa. So you'd first lookup by encoding, then if that 
didn't work you'd lookup by name with AltName and check if that one is valid.



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

https://reviews.llvm.org/D110065

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


  1   2   >