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

2022-08-29 Thread Stephan Bergmann via Phabricator via cfe-commits
sberg added a comment.

In D126864#3698798 , @sberg wrote:

> I'm surprised that

[...]

> causes a warning?  I would have expected it to be suppressed in this case, as 
> with the lax `-fstrict-flex-arrays=0` default, and only to hit with the 
> stricter `-fstrict-flex-arrays=2`.

appears to be addressed with https://reviews.llvm.org/D132853 "[clang] Fix 
-Warray-bound interaction with -fstrict-flex-arrays=1", thanks


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126864

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


[PATCH] D132640: [clang-tidy] Fix modernize-use-emplace to support alias cases

2022-08-29 Thread Dong-hee Na via Phabricator via cfe-commits
corona10 added a comment.

In D132640#3757395 , @njames93 wrote:

> In D132640#3757277 , @corona10 
> wrote:
>
>> @njames93 Can we land this patch before it occurs conflicting with other 
>> changes?
>
> Yes, sorry do you have commit access. If you don't what is your GitHub name 
> and email that I should use when committing.

Thanks, I don't have a commit bit :)

Github name: corona10
email: donghee.n...@gmail.com

Thank you!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132640

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


[PATCH] D132819: [RISCV] Add MC support of RISCV zcmp Extension

2022-08-29 Thread Xinlong Wu via Phabricator via cfe-commits
VincentWu updated this revision to Diff 456545.
VincentWu marked an inline comment as done.
VincentWu added a comment.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

clear patch


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132819

Files:
  clang/test/Preprocessor/riscv-target-features.c
  llvm/lib/Support/RISCVISAInfo.cpp
  llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
  llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp
  llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.cpp
  llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.h
  llvm/lib/Target/RISCV/MCTargetDesc/RISCVInstPrinter.cpp
  llvm/lib/Target/RISCV/MCTargetDesc/RISCVInstPrinter.h
  llvm/lib/Target/RISCV/MCTargetDesc/RISCVMCCodeEmitter.cpp
  llvm/lib/Target/RISCV/RISCV.td
  llvm/lib/Target/RISCV/RISCVInstrInfo.cpp
  llvm/lib/Target/RISCV/RISCVInstrInfo.h
  llvm/lib/Target/RISCV/RISCVInstrInfoZc.td
  llvm/lib/Target/RISCV/RISCVRegisterInfo.td
  llvm/lib/Target/RISCV/RISCVSubtarget.h
  llvm/test/MC/RISCV/attribute-arch.s
  llvm/test/MC/RISCV/rv32zcmp-Invalid.s
  llvm/test/MC/RISCV/rv32zcmp-valid.s
  llvm/test/MC/RISCV/rv64zcmp-Invalid.s
  llvm/test/MC/RISCV/rv64zcmp-valid.s

Index: llvm/test/MC/RISCV/rv64zcmp-valid.s
===
--- /dev/null
+++ llvm/test/MC/RISCV/rv64zcmp-valid.s
@@ -0,0 +1,149 @@
+# RUN: llvm-mc %s -triple=riscv64 -mattr=experimental-zcmp -riscv-no-aliases -show-encoding \
+# RUN: | FileCheck -check-prefixes=CHECK-ASM,CHECK-ASM-AND-OBJ %s
+# RUN: llvm-mc -filetype=obj -triple=riscv64 -mattr=experimental-zcmp < %s \
+# RUN: | llvm-objdump --mattr=-c,experimental-zcmp -M no-aliases -d -r - \
+# RUN: | FileCheck --check-prefixes=CHECK-ASM-AND-OBJ %s
+
+# CHECK-ASM-AND-OBJ: cm.mvsa01 s1, s0
+# CHECK-ASM: encoding: [0xa2,0xac]
+cm.mvsa01 s1, s0
+
+# CHECK-ASM-AND-OBJ: cm.mva01s s1, s0
+# CHECK-ASM: encoding: [0xe2,0xac]
+cm.mva01s s1, s0
+
+# CHECK-ASM-AND-OBJ: cm.popret   {ra}, 16
+# CHECK-ASM: encoding: [0x42,0xbe]
+cm.popret {ra}, 16
+
+# CHECK-ASM-AND-OBJ: cm.popret   {ra}, 32
+# CHECK-ASM: encoding: [0x46,0xbe]
+cm.popret {ra}, 32
+
+# CHECK-ASM-AND-OBJ: cm.popret   {ra, s0}, 64
+# CHECK-ASM: encoding: [0x5e,0xbe]
+cm.popret {ra, s0}, 64
+
+# CHECK-ASM-AND-OBJ: cm.popret   {ra, s0-s1}, 32
+# CHECK-ASM: encoding: [0x62,0xbe]
+cm.popret {ra,s0-s1}, 32
+
+# CHECK-ASM-AND-OBJ: cm.popret   {ra, s0-s2}, 32
+# CHECK-ASM: encoding: [0x72,0xbe]
+cm.popret {ra, s0-s2}, 32
+
+# CHECK-ASM-AND-OBJ: cm.popret   {ra, s0-s3}, 64
+# CHECK-ASM: encoding: [0x86,0xbe]
+cm.popret {ra, s0-s3}, 64
+
+# CHECK-ASM-AND-OBJ: cm.popret   {ra, s0-s5}, 64
+# CHECK-ASM: encoding: [0xa2,0xbe]
+cm.popret {ra, s0-s5}, 64
+
+# CHECK-ASM-AND-OBJ: cm.popret   {ra, s0-s7}, 80
+# CHECK-ASM: encoding: [0xc2,0xbe]
+cm.popret {ra, s0-s7}, 80
+
+# CHECK-ASM-AND-OBJ: cm.popret   {ra, s0-s11}, 112
+# CHECK-ASM: encoding: [0xf2,0xbe]
+cm.popret {ra, s0-s11}, 112
+
+# CHECK-ASM-AND-OBJ: cm.popretz   {ra}, 16
+# CHECK-ASM: encoding: [0x42,0xbc]
+cm.popretz {ra}, 16
+
+# CHECK-ASM-AND-OBJ: cm.popretz   {ra}, 32
+# CHECK-ASM: encoding: [0x46,0xbc]
+cm.popretz {ra}, 32
+
+# CHECK-ASM-AND-OBJ: cm.popretz   {ra, s0}, 64
+# CHECK-ASM: encoding: [0x5e,0xbc]
+cm.popretz {ra, s0}, 64
+
+# CHECK-ASM-AND-OBJ: cm.popretz   {ra, s0-s1}, 32
+# CHECK-ASM: encoding: [0x62,0xbc]
+cm.popretz {ra, s0-s1}, 32
+
+# CHECK-ASM-AND-OBJ: cm.popretz   {ra, s0-s2}, 32
+# CHECK-ASM: encoding: [0x72,0xbc]
+cm.popretz {ra, s0-s2}, 32
+
+# CHECK-ASM-AND-OBJ: cm.popretz   {ra, s0-s3}, 64
+# CHECK-ASM: encoding: [0x86,0xbc]
+cm.popretz {ra, s0-s3}, 64
+
+# CHECK-ASM-AND-OBJ: cm.popretz   {ra, s0-s5}, 64
+# CHECK-ASM: encoding: [0xa2,0xbc]
+cm.popretz {ra, s0-s5}, 64
+
+# CHECK-ASM-AND-OBJ: cm.popretz   {ra, s0-s7}, 80
+# CHECK-ASM: encoding: [0xc2,0xbc]
+cm.popretz {ra, s0-s7}, 80
+
+# CHECK-ASM-AND-OBJ: cm.popretz   {ra, s0-s11}, 112
+# CHECK-ASM: encoding: [0xf2,0xbc]
+cm.popretz {ra, s0-s11}, 112
+
+# CHECK-ASM-AND-OBJ: cm.pop  {ra}, 16
+# CHECK-ASM: encoding: [0x42,0xba]
+cm.pop {ra}, 16
+
+# CHECK-ASM-AND-OBJ: cm.pop  {ra}, 32
+# CHECK-ASM: encoding: [0x46,0xba]
+cm.pop {ra}, 32
+
+# CHECK-ASM-AND-OBJ: cm.pop  {ra, s0}, 16
+# CHECK-ASM: encoding: [0x52,0xba]
+cm.pop {ra, s0}, 16
+
+# CHECK-ASM-AND-OBJ: cm.pop  {ra, s0-s1}, 32
+# CHECK-ASM: encoding: [0x62,0xba]
+cm.pop {ra, s0-s1}, 32
+
+# CHECK-ASM-AND-OBJ: cm.pop  {ra, s0-s2}, 32
+# CHECK-ASM: encoding: [0x72,0xba]
+cm.pop {ra, s0-s2}, 32
+
+# CHECK-ASM-AND-OBJ: cm.pop  {ra, s0-s5}, 64
+# CHECK-ASM: encoding: [0xa2,0xba]
+cm.pop {ra, s0-s5}, 64
+
+# CHECK-ASM-AND-OBJ: cm.pop  {ra, s0-s7}, 80
+# CHECK-ASM: encoding: [0xc2,0xba]
+cm.pop {ra, s0-s7}, 80
+
+# CHECK-ASM-AND-OBJ: cm.pop  {ra, s0-s11}, 112
+# CHECK-ASM: encoding: [0xf2,0xba]
+cm.pop {ra, s0-s11}, 112
+
+# CHECK-ASM-AND-OBJ: cm.push {ra}, -16
+# CHECK-ASM: encoding: [0x42,0xb8]
+cm.push {ra}, -16
+
+# 

[PATCH] D132550: Changes to code ownership in clang and clang-tidy

2022-08-29 Thread Tanya Lattner via Phabricator via cfe-commits
tonic added a comment.

Moving to GitHub PRs is the path forward. Let's save ourselves some work and 
add them now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132550

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


[PATCH] D132640: [clang-tidy] Fix modernize-use-emplace to support alias cases

2022-08-29 Thread Nathan James via Phabricator via cfe-commits
njames93 added a comment.

In D132640#3757277 , @corona10 wrote:

> @njames93 Can we land this patch before it occurs conflicting with other 
> changes?

Yes, sorry do you have commit access. If you don't what is your GitHub name and 
email that I should use when committing.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132640

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


[PATCH] D132831: [clang][Interp] Handle SubstNonTypeTemplateParmExprs

2022-08-29 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder added inline comments.



Comment at: clang/lib/AST/Interp/ByteCodeExprGen.cpp:273
+const SubstNonTypeTemplateParmExpr *E) {
+  return this->visit(E->getReplacement());
+}

tahonermann wrote:
> erichkeane wrote:
> > tbaeder wrote:
> > > erichkeane wrote:
> > > > Is there nothing special that has to happen when these are reference 
> > > > parameters?  Can you at least add a test for that?
> > > Umm, I don't really do references yet (I haven't tested them at all and I 
> > > don't think they are implemented).
> > Hmm... that is unfortunate.  We really should be doing references ASAP, as 
> > they are going to be a pretty critical/oft-needed during testing kinda 
> > thing.  I'd at least want a commented-out test that you can re-enable ASAP.
> Are not-yet-implemented features consistently implemented such that constant 
> evaluation will fail with a (possibly unhelpful) diagnostic? As in 
> https://godbolt.org/z/8vvdca9Ma? If so, can tests be added ahead of time with 
> annotations for expected errors (essentially false positives to be addressed 
> later)?
Some are always (like unhandled AST node), some are not.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132831

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


[clang] 740a75c - Fix assumption that Clang version number is numeric.

2022-08-29 Thread Richard Smith via cfe-commits

Author: Richard Smith
Date: 2022-08-29T21:42:11-07:00
New Revision: 740a75c9d6adf8a26ebd13fc1d3460c728550624

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

LOG: Fix assumption that Clang version number is numeric.

This can be set at configure time and might include other characters.

Added: 


Modified: 
clang/test/Driver/driverkit-path.c

Removed: 




diff  --git a/clang/test/Driver/driverkit-path.c 
b/clang/test/Driver/driverkit-path.c
index 0b752b1fc9c4..690145b240dc 100644
--- a/clang/test/Driver/driverkit-path.c
+++ b/clang/test/Driver/driverkit-path.c
@@ -29,6 +29,6 @@ int main() { return 0; }
 // INC:   -isysroot [[PATH:[^ ]*/Inputs/DriverKit19.0.sdk]]
 // INC-LABEL: #include <...> search starts here:
 // INC:   [[PATH]]/System/DriverKit/usr/local/include
-// INC:   /lib/clang/{{[0-9\.]+}}/include
+// INC:   /lib/clang/{{[^/ ]+}}/include
 // INC:   [[PATH]]/System/DriverKit/usr/include
 // INC:   [[PATH]]/System/DriverKit/System/Library/Frameworks (framework 
directory)



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


[PATCH] D131141: [RISCV] Add MC support of RISCV Zcb Extension

2022-08-29 Thread Xinlong Wu via Phabricator via cfe-commits
VincentWu updated this revision to Diff 456542.
VincentWu marked 6 inline comments as done.
VincentWu added a comment.

address comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131141

Files:
  clang/test/Preprocessor/riscv-target-features.c
  llvm/lib/Support/RISCVISAInfo.cpp
  llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
  llvm/lib/Target/RISCV/RISCV.td
  llvm/lib/Target/RISCV/RISCVInstrInfo.td
  llvm/lib/Target/RISCV/RISCVInstrInfoZc.td
  llvm/lib/Target/RISCV/RISCVSubtarget.h
  llvm/test/CodeGen/RISCV/attributes.ll
  llvm/test/MC/RISCV/attribute-arch.s
  llvm/test/MC/RISCV/rv32zcb-invalid.s
  llvm/test/MC/RISCV/rv32zcb-valid.s
  llvm/test/MC/RISCV/rv64zcb-valid.s

Index: llvm/test/MC/RISCV/rv64zcb-valid.s
===
--- /dev/null
+++ llvm/test/MC/RISCV/rv64zcb-valid.s
@@ -0,0 +1,22 @@
+# RUN: llvm-mc %s -triple=riscv64 -mattr=+m,+zbb,+zba,+experimental-zcb -riscv-no-aliases -show-encoding \
+# RUN: | FileCheck -check-prefixes=CHECK-ASM,CHECK-ASM-AND-OBJ %s
+# RUN: llvm-mc -filetype=obj -triple=riscv64 -mattr=+m,+zbb,+zba,+experimental-zcb < %s \
+# RUN: | llvm-objdump --mattr=+m,+zbb,+zba,experimental-zcb -M no-aliases -d -r - \
+# RUN: | FileCheck --check-prefixes=CHECK-ASM-AND-OBJ %s
+#
+# RUN: not llvm-mc -triple riscv64 \
+# RUN: -riscv-no-aliases -show-encoding < %s 2>&1 \
+# RUN: | FileCheck -check-prefixes=CHECK-NO-EXT %s
+# RUN: not llvm-mc -triple riscv32 -mattr=+m,+zbb,+zba,+experimental-zcb \
+# RUN: -riscv-no-aliases -show-encoding < %s 2>&1 \
+# RUN: | FileCheck -check-prefixes=CHECK-NO-RV64 %s
+
+# CHECK-ASM-AND-OBJ: c.zext.w s0
+# CHECK-ASM: encoding: [0x71,0x9c]
+# CHECK-NO-EXT: error: instruction requires the following: 'Zba' (Address Generation Instructions), 'Zcb' (Shortened format for basic bit manipulation instructions) 
+# CHECK-NO-RV64: error: instruction requires the following: RV64I Base Instruction Set
+c.zext.w s0
+
+# CHECK-ASM-AND-OBJ: c.zext.w s0
+# CHECK-ASM: encoding: [0x71,0x9c]
+add.uw s0, s0, zero
Index: llvm/test/MC/RISCV/rv32zcb-valid.s
===
--- /dev/null
+++ llvm/test/MC/RISCV/rv32zcb-valid.s
@@ -0,0 +1,148 @@
+# RUN: llvm-mc %s -triple=riscv32 -mattr=+m,+zbb,+zba,+experimental-zcb -riscv-no-aliases -show-encoding \
+# RUN: | FileCheck -check-prefixes=CHECK-ASM,CHECK-ASM-AND-OBJ %s
+# RUN: llvm-mc -filetype=obj -triple=riscv32 -mattr=+m,+zbb,+zba,+experimental-zcb < %s \
+# RUN: | llvm-objdump --mattr=+m,+zbb,+zba,+experimental-zcb -M no-aliases -d -r - \
+# RUN: | FileCheck --check-prefixes=CHECK-ASM-AND-OBJ %s
+# RUN: llvm-mc %s -triple=riscv64 -mattr=+m,+zbb,+zba,+experimental-zcb -riscv-no-aliases -show-encoding \
+# RUN: | FileCheck -check-prefixes=CHECK-ASM,CHECK-ASM-AND-OBJ %s
+# RUN: llvm-mc -filetype=obj -triple=riscv64 -mattr=+m,+zbb,+zba,+experimental-zcb < %s \
+# RUN: | llvm-objdump --mattr=+m,+zbb,+zba,experimental-zcb -M no-aliases -d -r - \
+# RUN: | FileCheck --check-prefixes=CHECK-ASM-AND-OBJ %s
+#
+# RUN: not llvm-mc -triple riscv64 \
+# RUN: -riscv-no-aliases -show-encoding < %s 2>&1 \
+# RUN: | FileCheck -check-prefixes=CHECK-NO-EXT %s
+# RUN: not llvm-mc -triple riscv64 \
+# RUN: -riscv-no-aliases -show-encoding < %s 2>&1 \
+# RUN: | FileCheck -check-prefixes=CHECK-NO-EXT %s
+
+# CHECK-ASM-AND-OBJ: c.zext.b s0
+# CHECK-ASM: encoding: [0x61,0x9c]
+# CHECK-NO-EXT: error: instruction requires the following: 'Zcb' (Shortened format for basic bit manipulation instructions)
+c.zext.b s0
+
+# CHECK-ASM-AND-OBJ: c.sext.b s0
+# CHECK-ASM: encoding: [0x65,0x9c]
+# CHECK-NO-EXT: error: instruction requires the following: 'Zbb' (Basic Bit-Manipulation), 'Zcb' (Shortened format for basic bit manipulation instructions){{$}}
+c.sext.b s0
+
+# CHECK-ASM-AND-OBJ: c.zext.h s0
+# CHECK-ASM: encoding: [0x69,0x9c]
+# CHECK-NO-EXT: error: instruction requires the following: 'Zbb' (Basic Bit-Manipulation), 'Zcb' (Shortened format for basic bit manipulation instructions){{$}}
+c.zext.h s0
+
+# CHECK-ASM-AND-OBJ: c.sext.h s0
+# CHECK-ASM: encoding: [0x6d,0x9c]
+# CHECK-NO-EXT: error: instruction requires the following: 'Zbb' (Basic Bit-Manipulation), 'Zcb' (Shortened format for basic bit manipulation instructions){{$}}
+c.sext.h s0
+
+# CHECK-ASM-AND-OBJ: c.not s0
+# CHECK-ASM: encoding: [0x75,0x9c]
+# CHECK-NO-EXT: error: instruction requires the following: 'Zcb' (Shortened format for basic bit manipulation instructions){{$}}
+c.not s0
+
+# CHECK-ASM-AND-OBJ: c.mul s0, s1
+# CHECK-ASM: encoding: [0x45,0x9c]
+# CHECK-NO-EXT: error: instruction requires the following: 'M' (Integer Multiplication and Division) or 'Zmmul' (Integer Multiplication), 'Zcb' (Shortened format for basic bit manipulation instructions){{$}}
+c.mul s0, s1
+
+# CHECK-ASM-AND-OBJ: c.lbu a5, 2(a4)
+# CHECK-ASM: 

[PATCH] D132909: [msan] Use Debug Info to point to affected fields

2022-08-29 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka updated this revision to Diff 456541.
vitalybuka added a comment.

rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132909

Files:
  clang/lib/CodeGen/CGClass.cpp
  clang/test/CodeGenCXX/sanitize-dtor-bit-field.cpp
  clang/test/CodeGenCXX/sanitize-dtor-callback.cpp
  clang/test/CodeGenCXX/sanitize-dtor-derived-class.cpp
  clang/test/CodeGenCXX/sanitize-dtor-nontrivial-virtual-base.cpp
  clang/test/CodeGenCXX/sanitize-dtor-trivial-base.cpp
  clang/test/CodeGenCXX/sanitize-dtor-trivial.cpp
  clang/test/CodeGenCXX/sanitize-dtor-vtable.cpp
  compiler-rt/test/msan/dtor-base-access.cpp
  compiler-rt/test/msan/use-after-dtor.cpp

Index: compiler-rt/test/msan/use-after-dtor.cpp
===
--- compiler-rt/test/msan/use-after-dtor.cpp
+++ compiler-rt/test/msan/use-after-dtor.cpp
@@ -34,7 +34,8 @@
 
   // CHECK-ORIGINS: Member fields were destroyed
   // CHECK-ORIGINS: {{#0 0x.* in __sanitizer_dtor_callback}}
-  // CHECK-ORIGINS: {{#1 0x.* in .*~Simple.*cpp:}}[[@LINE-18]]:
+  // CHECK-ORIGINS: {{#1 0x.* in .*~Simple.*cpp:}}[[@LINE-24]]:
+  // CHECK-ORIGINS: {{#2 0x.* in .*~Simple.*cpp:}}[[@LINE-19]]:
 
   // CHECK-UAD: SUMMARY: MemorySanitizer: use-of-uninitialized-value {{.*main}}
   // CHECK-UAD-OFF-NOT: SUMMARY: MemorySanitizer: use-of-uninitialized-value
Index: compiler-rt/test/msan/dtor-base-access.cpp
===
--- compiler-rt/test/msan/dtor-base-access.cpp
+++ compiler-rt/test/msan/dtor-base-access.cpp
@@ -68,17 +68,20 @@
   __msan_print_shadow(>tb0, sizeof(g->tb0));
   // CHECK: Member fields were destroyed
   // CHECK: {{#0 0x.* in __sanitizer_dtor_callback}}
-  // CHECK: {{#1 0x.* in .*~Derived.*cpp:}}[[@LINE-20]]:
+  // CHECK: {{#1 0x.* in .*~Derived.*cpp:}}[[@LINE-56]]:
+  // CHECK: {{#2 0x.* in .*~Derived.*cpp:}}[[@LINE-21]]:
 
   __msan_print_shadow(>b, sizeof(g->b));
   // CHECK: Member fields were destroyed
   // CHECK: {{#0 0x.* in __sanitizer_dtor_callback}}
-  // CHECK: {{#1 0x.* in .*~Base.*cpp:}}[[@LINE-33]]:
+  // CHECK: {{#1 0x.* in .*~Base.*cpp:}}[[@LINE-67]]:
+  // CHECK: {{#2 0x.* in .*~Base.*cpp:}}[[@LINE-35]]:
 
   __msan_print_shadow(>tb1, sizeof(g->tb1));
   // CHECK: Member fields were destroyed
   // CHECK: {{#0 0x.* in __sanitizer_dtor_callback}}
-  // CHECK: {{#1 0x.* in .*~Derived.*cpp:}}[[@LINE-30]]:
+  // CHECK: {{#1 0x.* in .*~Derived.*cpp:}}[[@LINE-62]]:
+  // CHECK: {{#2 0x.* in .*~Derived.*cpp:}}[[@LINE-33]]:
 
   return 0;
 }
Index: clang/test/CodeGenCXX/sanitize-dtor-vtable.cpp
===
--- clang/test/CodeGenCXX/sanitize-dtor-vtable.cpp
+++ clang/test/CodeGenCXX/sanitize-dtor-vtable.cpp
@@ -25,22 +25,23 @@
 // CHECK-LABEL: define {{.*}}BD1Ev
 // CHECK: call void {{.*}}BD2Ev
 // CHECK: call void {{.*}}AD2Ev
-// CHECK: call void @__sanitizer_dtor_callback_vptr({{.*}}, !dbg ![[DI1:[0-9]+]]
+// CHECK: call void @__sanitizer_dtor_callback_vptr{{.*}}, !dbg ![[DI1:[0-9]+]]
 // CHECK: ret void
 
 // Since no virtual bases, poison vtable ptr here.
 // CHECK-LABEL: define {{.*}}AD2Ev
-// CHECK: call void @__sanitizer_dtor_callback_fields({{.*}}, !dbg ![[DI2:[0-9]+]]
-// CHECK: call void @__sanitizer_dtor_callback_vptr({{.*}}, !dbg ![[DI2]]
+// CHECK: call void @__sanitizer_dtor_callback_fields{{.*}}, !dbg ![[DI2:[0-9]+]]
+// CHECK: call void @__sanitizer_dtor_callback_vptr{{.*}}, !dbg ![[DI3:[0-9]+]]
 // CHECK: ret void
 
 // Poison members
 // CHECK-LABEL: define {{.*}}BD2Ev
-// CHECK: call void @__sanitizer_dtor_callback_fields({{.*}}, !dbg ![[DI4:[0-9]+]]
+// CHECK: call void @__sanitizer_dtor_callback_fields{{.*}}, !dbg ![[DI4:[0-9]+]]
 // CHECK: ret void
 
-// CHECK-LABEL: !DIFile{{.*}}cpp
+// CHECK-LABEL: !DIFile{{.*}}sanitize-dtor-vtable.cpp
 
 // CHECK-DAG: ![[DI1]] = {{.*}}line: [[@LINE-28]]
-// CHECK-DAG: ![[DI2]] = {{.*}}line: [[@LINE-37]]
-// CHECK-DAG: ![[DI4]] = {{.*}}line: [[@LINE-30]]
+// CHECK-DAG: ![[DI2]] = {{.*}}line: [[@LINE-39]]
+// CHECK-DAG: ![[DI3]] = {{.*}}line: [[@LINE-38]]
+// CHECK-DAG: ![[DI4]] = {{.*}}line: [[@LINE-33]]
Index: clang/test/CodeGenCXX/sanitize-dtor-trivial.cpp
===
--- clang/test/CodeGenCXX/sanitize-dtor-trivial.cpp
+++ clang/test/CodeGenCXX/sanitize-dtor-trivial.cpp
@@ -16,4 +16,4 @@
 
 // CHECK-LABEL: !DIFile{{.*}}.cpp
 
-// CHECK-DAG: ![[DI]] = {{.*}}line: [[@LINE-371]]
+// CHECK: ![[DI]] = {{.*}}line: [[@LINE-9]]
Index: clang/test/CodeGenCXX/sanitize-dtor-trivial-base.cpp
===
--- clang/test/CodeGenCXX/sanitize-dtor-trivial-base.cpp
+++ clang/test/CodeGenCXX/sanitize-dtor-trivial-base.cpp
@@ -20,10 +20,11 @@
 // Poison members, then poison the trivial base class.
 // CHECK-LABEL: define {{.*}}DerivedD2Ev
 // CHECK: %[[GEP:[0-9a-z]+]] = 

[PATCH] D132907: [msan] Add more specific messages for use-after-destroy

2022-08-29 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka updated this revision to Diff 456540.
vitalybuka added a comment.

rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132907

Files:
  clang/lib/CodeGen/CGClass.cpp
  clang/test/CodeGenCXX/sanitize-dtor-bit-field.cpp
  clang/test/CodeGenCXX/sanitize-dtor-callback.cpp
  clang/test/CodeGenCXX/sanitize-dtor-derived-class.cpp
  clang/test/CodeGenCXX/sanitize-dtor-nontrivial-virtual-base.cpp
  clang/test/CodeGenCXX/sanitize-dtor-tail-call.cpp
  clang/test/CodeGenCXX/sanitize-dtor-trivial-base.cpp
  clang/test/CodeGenCXX/sanitize-dtor-trivial.cpp
  clang/test/CodeGenCXX/sanitize-dtor-vtable.cpp
  clang/test/CodeGenCXX/sanitize-dtor-zero-size-field.cpp
  compiler-rt/include/sanitizer/msan_interface.h
  compiler-rt/lib/msan/msan.h
  compiler-rt/lib/msan/msan_interceptors.cpp
  compiler-rt/lib/msan/msan_interface_internal.h
  compiler-rt/lib/msan/msan_report.cpp
  compiler-rt/test/msan/dtor-base-access.cpp
  compiler-rt/test/msan/dtor-vtable-multiple-inheritance.cpp
  compiler-rt/test/msan/use-after-dtor.cpp

Index: compiler-rt/test/msan/use-after-dtor.cpp
===
--- compiler-rt/test/msan/use-after-dtor.cpp
+++ compiler-rt/test/msan/use-after-dtor.cpp
@@ -32,7 +32,7 @@
   // CHECK-UAD: WARNING: MemorySanitizer: use-of-uninitialized-value
   // CHECK-UAD: {{#0 0x.* in main.*use-after-dtor.cpp:}}[[@LINE-3]]
 
-  // CHECK-ORIGINS: Memory was marked as uninitialized
+  // CHECK-ORIGINS: Member fields were destroyed
   // CHECK-ORIGINS: {{#0 0x.* in __sanitizer_dtor_callback}}
   // CHECK-ORIGINS: {{#1 0x.* in .*~Simple.*cpp:}}[[@LINE-18]]:
 
Index: compiler-rt/test/msan/dtor-vtable-multiple-inheritance.cpp
===
--- compiler-rt/test/msan/dtor-vtable-multiple-inheritance.cpp
+++ compiler-rt/test/msan/dtor-vtable-multiple-inheritance.cpp
@@ -51,8 +51,8 @@
   // This fails
 #ifdef CVPTR
   c->A_Foo();
-// CVPTR: Memory was marked as uninitialized
-// CVPTR: {{#0 0x.* in __sanitizer_dtor_callback}}
+// CVPTR: Virtual table ptr was destroyed
+// CVPTR: {{#0 0x.* in __sanitizer_dtor_callback_vptr}}
 // CVPTR: {{#1 0x.* in ~C .*cpp:}}[[@LINE-28]]:
 // CVPTR: {{#2 0x.* in main .*cpp:}}[[@LINE-7]]:
 #endif
@@ -63,16 +63,16 @@
   // Both of these fail
 #ifdef EAVPTR
   e->A_Foo();
-// EAVPTR: Memory was marked as uninitialized
-// EAVPTR: {{#0 0x.* in __sanitizer_dtor_callback}}
+// EAVPTR: Virtual table ptr was destroyed
+// EAVPTR: {{#0 0x.* in __sanitizer_dtor_callback_vptr}}
 // EAVPTR: {{#1 0x.* in ~E .*cpp:}}[[@LINE-25]]:
 // EAVPTR: {{#2 0x.* in main .*cpp:}}[[@LINE-7]]:
 #endif
 
 #ifdef EDVPTR
   e->D_Foo();
-// EDVPTR: Memory was marked as uninitialized
-// EDVPTR: {{#0 0x.* in __sanitizer_dtor_callback}}
+// EDVPTR: Virtual table ptr was destroyed
+// EDVPTR: {{#0 0x.* in __sanitizer_dtor_callback_vptr}}
 // EDVPTR: {{#1 0x.* in ~E .*cpp:}}[[@LINE-33]]:
 // EDVPTR: {{#2 0x.* in main .*cpp:}}[[@LINE-15]]:
 #endif
Index: compiler-rt/test/msan/dtor-base-access.cpp
===
--- compiler-rt/test/msan/dtor-base-access.cpp
+++ compiler-rt/test/msan/dtor-base-access.cpp
@@ -66,17 +66,17 @@
   assert(__msan_test_shadow(>d, sizeof(g->d)) == 0);
 
   __msan_print_shadow(>tb0, sizeof(g->tb0));
-  // CHECK: Memory was marked as uninitialized
+  // CHECK: Member fields were destroyed
   // CHECK: {{#0 0x.* in __sanitizer_dtor_callback}}
   // CHECK: {{#1 0x.* in .*~Derived.*cpp:}}[[@LINE-20]]:
 
   __msan_print_shadow(>b, sizeof(g->b));
-  // CHECK: Memory was marked as uninitialized
+  // CHECK: Member fields were destroyed
   // CHECK: {{#0 0x.* in __sanitizer_dtor_callback}}
   // CHECK: {{#1 0x.* in .*~Base.*cpp:}}[[@LINE-33]]:
 
   __msan_print_shadow(>tb1, sizeof(g->tb1));
-  // CHECK: Memory was marked as uninitialized
+  // CHECK: Member fields were destroyed
   // CHECK: {{#0 0x.* in __sanitizer_dtor_callback}}
   // CHECK: {{#1 0x.* in .*~Derived.*cpp:}}[[@LINE-30]]:
 
Index: compiler-rt/lib/msan/msan_report.cpp
===
--- compiler-rt/lib/msan/msan_report.cpp
+++ compiler-rt/lib/msan/msan_report.cpp
@@ -81,6 +81,13 @@
 Printf("  %sMemory was marked as uninitialized%s\n", d.Origin(),
d.Default());
 break;
+  case STACK_TRACE_TAG_FIELDS:
+Printf("  %sMember fields were destroyed%s\n", d.Origin(), d.Default());
+break;
+  case STACK_TRACE_TAG_VPTR:
+Printf("  %sVirtual table ptr was destroyed%s\n", d.Origin(),
+   d.Default());
+break;
   default:
 Printf("  %sUninitialized value was created%s\n", d.Origin(),
d.Default());
Index: compiler-rt/lib/msan/msan_interface_internal.h
===
--- 

[PATCH] D131469: [Clang] change default storing path of `-ftime-trace`

2022-08-29 Thread dongjunduo via Phabricator via cfe-commits
dongjunduo updated this revision to Diff 456535.
dongjunduo added a comment.

Rewrite comments and commit log


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131469

Files:
  clang/lib/Driver/Driver.cpp
  clang/test/Driver/check-time-trace.cpp
  clang/tools/driver/cc1_main.cpp

Index: clang/tools/driver/cc1_main.cpp
===
--- clang/tools/driver/cc1_main.cpp
+++ clang/tools/driver/cc1_main.cpp
@@ -256,17 +256,10 @@
   llvm::TimerGroup::clearAll();
 
   if (llvm::timeTraceProfilerEnabled()) {
-SmallString<128> Path(Clang->getFrontendOpts().OutputFile);
-llvm::sys::path::replace_extension(Path, "json");
-if (!Clang->getFrontendOpts().TimeTracePath.empty()) {
-  // replace the suffix to '.json' directly
-  SmallString<128> TracePath(Clang->getFrontendOpts().TimeTracePath);
-  if (llvm::sys::fs::is_directory(TracePath))
-llvm::sys::path::append(TracePath, llvm::sys::path::filename(Path));
-  Path.assign(TracePath);
-}
+SmallString<128> TracePath(Clang->getFrontendOpts().TimeTracePath);
+assert(!TracePath.empty() && "`-ftime-trace=` is empty");
 if (auto profilerOutput = Clang->createOutputFile(
-Path.str(), /*Binary=*/false, /*RemoveFileOnSignal=*/false,
+TracePath.str(), /*Binary=*/false, /*RemoveFileOnSignal=*/false,
 /*useTemporary=*/false)) {
   llvm::timeTraceProfilerWrite(*profilerOutput);
   profilerOutput.reset();
Index: clang/test/Driver/check-time-trace.cpp
===
--- clang/test/Driver/check-time-trace.cpp
+++ clang/test/Driver/check-time-trace.cpp
@@ -1,3 +1,8 @@
+// RUN: rm -rf %T/exe && mkdir %T/exe
+// RUN: %clangxx -ftime-trace -ftime-trace-granularity=0 -o %T/exe/check-time-trace %s
+// RUN: cat %T/exe/check-time-trace*.json \
+// RUN:   | %python -c 'import json, sys; json.dump(json.loads(sys.stdin.read()), sys.stdout, sort_keys=True, indent=2)' \
+// RUN:   | FileCheck %s
 // RUN: %clangxx -S -ftime-trace -ftime-trace-granularity=0 -o %T/check-time-trace %s
 // RUN: cat %T/check-time-trace.json \
 // RUN:   | %python -c 'import json, sys; json.dump(json.loads(sys.stdin.read()), sys.stdout, sort_keys=True, indent=2)' \
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -4658,6 +4658,102 @@
   llvm_unreachable("invalid phase in ConstructPhaseAction");
 }
 
+// Infer data storing path of the options `-ftime-trace`, `-ftime-trace=`
+void InferTimeTracePath(Compilation ) {
+  bool HasTimeTrace =
+  C.getArgs().getLastArg(options::OPT_ftime_trace) != nullptr;
+  bool HasTimeTraceFile =
+  C.getArgs().getLastArg(options::OPT_ftime_trace_EQ) != nullptr;
+  // Whether `-ftime-trace` or `-ftime-trace=` are specified
+  if (!HasTimeTrace && !HasTimeTraceFile)
+return;
+
+  // If `-ftime-trace=` is specified, TracePath is the .
+  // Else if there is a linking job, TracePath is the parent path of .exe,
+  // then the OutputFile's name may be appended to it.
+  // Else, TracePath is "",
+  // then the full OutputFile's path may be appended to it.
+  SmallString<128> TracePath("");
+
+  if (HasTimeTraceFile) {
+TracePath = SmallString<128>(
+C.getArgs().getLastArg(options::OPT_ftime_trace_EQ)->getValue());
+  } else {
+// Get linking executable file's parent path as TracePath's parent path,
+// default is ".". Filename may be determined and added into TracePath then.
+//
+// e.g. executable file's path: /usr/local/a.out
+//  its parent's path:  /usr/local
+for (auto  : C.getJobs()) {
+  if (J.getSource().getKind() == Action::LinkJobClass) {
+assert(!J.getOutputFilenames().empty() &&
+   "linking output filename is empty");
+auto OutputFilePath =
+SmallString<128>(J.getOutputFilenames()[0].c_str());
+if (llvm::sys::path::has_parent_path(OutputFilePath)) {
+  TracePath = llvm::sys::path::parent_path(OutputFilePath);
+} else {
+  TracePath = SmallString<128>(".");
+}
+break;
+  }
+}
+  }
+
+  // Add or replace the modified -ftime-trace=` to all clang jobs
+  for (auto  : C.getJobs()) {
+if (J.getSource().getKind() == Action::AssembleJobClass ||
+J.getSource().getKind() == Action::BackendJobClass ||
+J.getSource().getKind() == Action::CompileJobClass) {
+  SmallString<128> TracePathReal = TracePath;
+  SmallString<128> OutputPath(J.getOutputFilenames()[0].c_str());
+  std::string arg = std::string("-ftime-trace=");
+  if (!HasTimeTraceFile) {
+if (TracePathReal.empty()) {
+  // /xxx/yyy.o => /xxx/yyy.json
+  llvm::sys::path::replace_extension(OutputPath, "json");
+   

[PATCH] D131469: [Clang] change default storing path of `-ftime-trace`

2022-08-29 Thread dongjunduo via Phabricator via cfe-commits
dongjunduo updated this revision to Diff 456533.
dongjunduo added a comment.

Replace -ftime-trace with -ftime-trace= also


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131469

Files:
  clang/lib/Driver/Driver.cpp
  clang/test/Driver/check-time-trace.cpp
  clang/tools/driver/cc1_main.cpp

Index: clang/tools/driver/cc1_main.cpp
===
--- clang/tools/driver/cc1_main.cpp
+++ clang/tools/driver/cc1_main.cpp
@@ -256,17 +256,10 @@
   llvm::TimerGroup::clearAll();
 
   if (llvm::timeTraceProfilerEnabled()) {
-SmallString<128> Path(Clang->getFrontendOpts().OutputFile);
-llvm::sys::path::replace_extension(Path, "json");
-if (!Clang->getFrontendOpts().TimeTracePath.empty()) {
-  // replace the suffix to '.json' directly
-  SmallString<128> TracePath(Clang->getFrontendOpts().TimeTracePath);
-  if (llvm::sys::fs::is_directory(TracePath))
-llvm::sys::path::append(TracePath, llvm::sys::path::filename(Path));
-  Path.assign(TracePath);
-}
+SmallString<128> TracePath(Clang->getFrontendOpts().TimeTracePath);
+assert(!TracePath.empty() && "`-ftime-trace=` is empty");
 if (auto profilerOutput = Clang->createOutputFile(
-Path.str(), /*Binary=*/false, /*RemoveFileOnSignal=*/false,
+TracePath.str(), /*Binary=*/false, /*RemoveFileOnSignal=*/false,
 /*useTemporary=*/false)) {
   llvm::timeTraceProfilerWrite(*profilerOutput);
   profilerOutput.reset();
Index: clang/test/Driver/check-time-trace.cpp
===
--- clang/test/Driver/check-time-trace.cpp
+++ clang/test/Driver/check-time-trace.cpp
@@ -1,3 +1,8 @@
+// RUN: rm -rf %T/exe && mkdir %T/exe
+// RUN: %clangxx -ftime-trace -ftime-trace-granularity=0 -o %T/exe/check-time-trace %s
+// RUN: cat %T/exe/check-time-trace*.json \
+// RUN:   | %python -c 'import json, sys; json.dump(json.loads(sys.stdin.read()), sys.stdout, sort_keys=True, indent=2)' \
+// RUN:   | FileCheck %s
 // RUN: %clangxx -S -ftime-trace -ftime-trace-granularity=0 -o %T/check-time-trace %s
 // RUN: cat %T/check-time-trace.json \
 // RUN:   | %python -c 'import json, sys; json.dump(json.loads(sys.stdin.read()), sys.stdout, sort_keys=True, indent=2)' \
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -4658,6 +4658,102 @@
   llvm_unreachable("invalid phase in ConstructPhaseAction");
 }
 
+// Infer data storing path of the options `-ftime-trace`, `-ftime-trace=`
+void InferTimeTracePath(Compilation ) {
+  bool HasTimeTrace =
+  C.getArgs().getLastArg(options::OPT_ftime_trace) != nullptr;
+  bool HasTimeTraceFile =
+  C.getArgs().getLastArg(options::OPT_ftime_trace_EQ) != nullptr;
+  // Whether `-ftime-trace` or `-ftime-trace=` are specified
+  if (!HasTimeTrace && !HasTimeTraceFile)
+return;
+
+  // If `-ftime-trace=` is specified, TracePath is the .
+  // Else if there is a linking job, TracePath is the parent path of .exe,
+  // then the OutputFile's name may be appended to it.
+  // Else, TracePath is "",
+  // then the full OutputFile's path may be appended to it.
+  SmallString<128> TracePath("");
+
+  if (HasTimeTraceFile) {
+TracePath = SmallString<128>(
+C.getArgs().getLastArg(options::OPT_ftime_trace_EQ)->getValue());
+  } else {
+// Get linking executable file's parent path as TracePath's parent path,
+// default is ".". Filename may be determined and added into TracePath then.
+//
+// e.g. executable file's path: /usr/local/a.out
+//  its parent's path:  /usr/local
+for (auto  : C.getJobs()) {
+  if (J.getSource().getKind() == Action::LinkJobClass) {
+assert(!J.getOutputFilenames().empty() &&
+   "linking output filename is empty");
+auto OutputFilePath =
+SmallString<128>(J.getOutputFilenames()[0].c_str());
+if (llvm::sys::path::has_parent_path(OutputFilePath)) {
+  TracePath = llvm::sys::path::parent_path(OutputFilePath);
+} else {
+  TracePath = SmallString<128>(".");
+}
+break;
+  }
+}
+  }
+
+  // Add or replace the modified -ftime-trace=` to all clang jobs
+  for (auto  : C.getJobs()) {
+if (J.getSource().getKind() == Action::AssembleJobClass ||
+J.getSource().getKind() == Action::BackendJobClass ||
+J.getSource().getKind() == Action::CompileJobClass) {
+  SmallString<128> TracePathReal = TracePath;
+  SmallString<128> OutputPath(J.getOutputFilenames()[0].c_str());
+  std::string arg = std::string("-ftime-trace=");
+  if (!HasTimeTraceFile) {
+if (TracePathReal.empty()) {
+  // /xxx/yyy.o => /xxx/yyy.json
+  llvm::sys::path::replace_extension(OutputPath, 

[clang] d9d7e12 - [test][msan] Use -DAG to match Debug Info

2022-08-29 Thread Vitaly Buka via cfe-commits

Author: Vitaly Buka
Date: 2022-08-29T20:32:41-07:00
New Revision: d9d7e1211b5b0bfaacd220650b8eec8d0efe69c1

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

LOG: [test][msan] Use -DAG to match Debug Info

Added: 


Modified: 
clang/test/CodeGenCXX/sanitize-dtor-bit-field.cpp
clang/test/CodeGenCXX/sanitize-dtor-callback.cpp
clang/test/CodeGenCXX/sanitize-dtor-derived-class.cpp
clang/test/CodeGenCXX/sanitize-dtor-nontrivial-virtual-base.cpp
clang/test/CodeGenCXX/sanitize-dtor-trivial-base.cpp
clang/test/CodeGenCXX/sanitize-dtor-trivial.cpp
clang/test/CodeGenCXX/sanitize-dtor-vtable.cpp

Removed: 




diff  --git a/clang/test/CodeGenCXX/sanitize-dtor-bit-field.cpp 
b/clang/test/CodeGenCXX/sanitize-dtor-bit-field.cpp
index 71be40984644..6629cd8b274e 100644
--- a/clang/test/CodeGenCXX/sanitize-dtor-bit-field.cpp
+++ b/clang/test/CodeGenCXX/sanitize-dtor-bit-field.cpp
@@ -83,7 +83,7 @@ Adjacent ad;
 
 // CHECK-LABEL: !DIFile{{.*}}cpp
 
-// CHECK: ![[DI1]] = {{.*}}line: [[@LINE-68]]
-// CHECK: ![[DI2]] = {{.*}}line: [[@LINE-53]]
-// CHECK: ![[DI3]] = {{.*}}line: [[@LINE-41]]
-// CHECK: ![[DI4]] = {{.*}}line: [[@LINE-28]]
+// CHECK-DAG: ![[DI1]] = {{.*}}line: [[@LINE-68]]
+// CHECK-DAG: ![[DI2]] = {{.*}}line: [[@LINE-53]]
+// CHECK-DAG: ![[DI3]] = {{.*}}line: [[@LINE-41]]
+// CHECK-DAG: ![[DI4]] = {{.*}}line: [[@LINE-28]]

diff  --git a/clang/test/CodeGenCXX/sanitize-dtor-callback.cpp 
b/clang/test/CodeGenCXX/sanitize-dtor-callback.cpp
index 7396e0d2d2df..d42008a7ad79 100644
--- a/clang/test/CodeGenCXX/sanitize-dtor-callback.cpp
+++ b/clang/test/CodeGenCXX/sanitize-dtor-callback.cpp
@@ -70,6 +70,6 @@ Defaulted_Non_Trivial def_non_trivial;
 
 // CHECK-LABEL: !DIFile{{.*}}cpp
 
-// CHECK: ![[DI1]] = {{.*}}line: [[@LINE-64]]
-// CHECK: ![[DI2]] = {{.*}}line: [[@LINE-55]]
-// CHECK: ![[DI3]] = {{.*}}line: [[@LINE-33]]
+// CHECK-DAG: ![[DI1]] = {{.*}}line: [[@LINE-64]]
+// CHECK-DAG: ![[DI2]] = {{.*}}line: [[@LINE-55]]
+// CHECK-DAG: ![[DI3]] = {{.*}}line: [[@LINE-33]]

diff  --git a/clang/test/CodeGenCXX/sanitize-dtor-derived-class.cpp 
b/clang/test/CodeGenCXX/sanitize-dtor-derived-class.cpp
index 5c2bec68a5e1..1a6aa9ed1cdb 100644
--- a/clang/test/CodeGenCXX/sanitize-dtor-derived-class.cpp
+++ b/clang/test/CodeGenCXX/sanitize-dtor-derived-class.cpp
@@ -62,5 +62,5 @@ Derived d;
 
 // CHECK-LABEL: !DIFile{{.*}}cpp
 
-// CHECK: ![[DI1]] = {{.*}}line: [[@LINE-49]]
-// CHECK: ![[DI3]] = {{.*}}line: [[@LINE-39]]
+// CHECK-DAG: ![[DI1]] = {{.*}}line: [[@LINE-49]]
+// CHECK-DAG: ![[DI3]] = {{.*}}line: [[@LINE-39]]

diff  --git a/clang/test/CodeGenCXX/sanitize-dtor-nontrivial-virtual-base.cpp 
b/clang/test/CodeGenCXX/sanitize-dtor-nontrivial-virtual-base.cpp
index 75cee72a51df..d30bd3ade749 100644
--- a/clang/test/CodeGenCXX/sanitize-dtor-nontrivial-virtual-base.cpp
+++ b/clang/test/CodeGenCXX/sanitize-dtor-nontrivial-virtual-base.cpp
@@ -86,8 +86,8 @@ Derived d;
 
 // CHECK-LABEL: !DIFile{{.*}}.cpp
 
-// CHECK: ![[DI0]] = {{.*}}line: [[@LINE-49]]
-// CHECK: ![[DI1]] = {{.*}}line: [[@LINE-60]]
-// CHECK: ![[DI2]] = {{.*}}line: [[@LINE-71]]
-// CHECK: ![[DI3]] = {{.*}}line: [[@LINE-52]]
-// CHECK: ![[DI5]] = {{.*}}line: [[@LINE-83]]
+// CHECK-DAG: ![[DI0]] = {{.*}}line: [[@LINE-49]]
+// CHECK-DAG: ![[DI1]] = {{.*}}line: [[@LINE-60]]
+// CHECK-DAG: ![[DI2]] = {{.*}}line: [[@LINE-71]]
+// CHECK-DAG: ![[DI3]] = {{.*}}line: [[@LINE-52]]
+// CHECK-DAG: ![[DI5]] = {{.*}}line: [[@LINE-83]]

diff  --git a/clang/test/CodeGenCXX/sanitize-dtor-trivial-base.cpp 
b/clang/test/CodeGenCXX/sanitize-dtor-trivial-base.cpp
index cf5d0a258be1..5da9405b7406 100644
--- a/clang/test/CodeGenCXX/sanitize-dtor-trivial-base.cpp
+++ b/clang/test/CodeGenCXX/sanitize-dtor-trivial-base.cpp
@@ -26,4 +26,4 @@ Derived d;
 
 // CHECK-LABEL: !DIFile{{.*}}cpp
 
-// CHECK: ![[DI]] = {{.*}}line: [[@LINE-14]]
+// CHECK-DAG: ![[DI]] = {{.*}}line: [[@LINE-14]]

diff  --git a/clang/test/CodeGenCXX/sanitize-dtor-trivial.cpp 
b/clang/test/CodeGenCXX/sanitize-dtor-trivial.cpp
index 586df912aca9..eb60f7fa46eb 100644
--- a/clang/test/CodeGenCXX/sanitize-dtor-trivial.cpp
+++ b/clang/test/CodeGenCXX/sanitize-dtor-trivial.cpp
@@ -14,12 +14,7 @@ Trivial t;
 
 // CHECK: call void @__sanitizer_dtor_callback({{.*}}, !dbg ![[DI:[0-9]+]]
 
-// CHECK-LABEL: !DIFile{{.*}}.cpp
-
-// CHECK: ![[DI]] = {{.*}}line: [[@LINE-371]]
 
 // CHECK-LABEL: !DIFile{{.*}}cpp
 
-// CHECK: ![[DI1]] = {{.*}}line: [[@LINE-28]]
-// CHECK: ![[DI2]] = {{.*}}line: [[@LINE-37]]
-// CHECK: ![[DI4]] = {{.*}}line: [[@LINE-30]]
+// CHECK-DAG: ![[DI]] = {{.*}}line: [[@LINE-28]]

diff  --git a/clang/test/CodeGenCXX/sanitize-dtor-vtable.cpp 
b/clang/test/CodeGenCXX/sanitize-dtor-vtable.cpp
index 3cf91d9d01cf..063ff7ffdb08 100644
--- 

[PATCH] D132909: [msan] Use Debug Info to point to affected fields

2022-08-29 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka created this revision.
Herald added a subscriber: Enna1.
Herald added a project: All.
vitalybuka requested review of this revision.
Herald added projects: clang, Sanitizers.
Herald added subscribers: Sanitizers, cfe-commits.

Depends on: D132907 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D132909

Files:
  clang/lib/CodeGen/CGClass.cpp
  clang/test/CodeGenCXX/sanitize-dtor-bit-field.cpp
  clang/test/CodeGenCXX/sanitize-dtor-callback.cpp
  clang/test/CodeGenCXX/sanitize-dtor-derived-class.cpp
  clang/test/CodeGenCXX/sanitize-dtor-nontrivial-virtual-base.cpp
  clang/test/CodeGenCXX/sanitize-dtor-trivial-base.cpp
  clang/test/CodeGenCXX/sanitize-dtor-trivial.cpp
  clang/test/CodeGenCXX/sanitize-dtor-vtable.cpp
  compiler-rt/test/msan/dtor-base-access.cpp
  compiler-rt/test/msan/use-after-dtor.cpp

Index: compiler-rt/test/msan/use-after-dtor.cpp
===
--- compiler-rt/test/msan/use-after-dtor.cpp
+++ compiler-rt/test/msan/use-after-dtor.cpp
@@ -34,7 +34,8 @@
 
   // CHECK-ORIGINS: Member fields were destroyed
   // CHECK-ORIGINS: {{#0 0x.* in __sanitizer_dtor_callback}}
-  // CHECK-ORIGINS: {{#1 0x.* in .*~Simple.*cpp:}}[[@LINE-18]]:
+  // CHECK-ORIGINS: {{#1 0x.* in .*~Simple.*cpp:}}[[@LINE-24]]:
+  // CHECK-ORIGINS: {{#2 0x.* in .*~Simple.*cpp:}}[[@LINE-19]]:
 
   // CHECK-UAD: SUMMARY: MemorySanitizer: use-of-uninitialized-value {{.*main}}
   // CHECK-UAD-OFF-NOT: SUMMARY: MemorySanitizer: use-of-uninitialized-value
Index: compiler-rt/test/msan/dtor-base-access.cpp
===
--- compiler-rt/test/msan/dtor-base-access.cpp
+++ compiler-rt/test/msan/dtor-base-access.cpp
@@ -68,17 +68,20 @@
   __msan_print_shadow(>tb0, sizeof(g->tb0));
   // CHECK: Member fields were destroyed
   // CHECK: {{#0 0x.* in __sanitizer_dtor_callback}}
-  // CHECK: {{#1 0x.* in .*~Derived.*cpp:}}[[@LINE-20]]:
+  // CHECK: {{#1 0x.* in .*~Derived.*cpp:}}[[@LINE-56]]:
+  // CHECK: {{#2 0x.* in .*~Derived.*cpp:}}[[@LINE-21]]:
 
   __msan_print_shadow(>b, sizeof(g->b));
   // CHECK: Member fields were destroyed
   // CHECK: {{#0 0x.* in __sanitizer_dtor_callback}}
-  // CHECK: {{#1 0x.* in .*~Base.*cpp:}}[[@LINE-33]]:
+  // CHECK: {{#1 0x.* in .*~Base.*cpp:}}[[@LINE-67]]:
+  // CHECK: {{#2 0x.* in .*~Base.*cpp:}}[[@LINE-35]]:
 
   __msan_print_shadow(>tb1, sizeof(g->tb1));
   // CHECK: Member fields were destroyed
   // CHECK: {{#0 0x.* in __sanitizer_dtor_callback}}
-  // CHECK: {{#1 0x.* in .*~Derived.*cpp:}}[[@LINE-30]]:
+  // CHECK: {{#1 0x.* in .*~Derived.*cpp:}}[[@LINE-62]]:
+  // CHECK: {{#2 0x.* in .*~Derived.*cpp:}}[[@LINE-33]]:
 
   return 0;
 }
Index: clang/test/CodeGenCXX/sanitize-dtor-vtable.cpp
===
--- clang/test/CodeGenCXX/sanitize-dtor-vtable.cpp
+++ clang/test/CodeGenCXX/sanitize-dtor-vtable.cpp
@@ -25,22 +25,23 @@
 // CHECK-LABEL: define {{.*}}BD1Ev
 // CHECK: call void {{.*}}BD2Ev
 // CHECK: call void {{.*}}AD2Ev
-// CHECK: call void @__sanitizer_dtor_callback_vptr({{.*}}, !dbg ![[DI1:[0-9]+]]
+// CHECK: call void @__sanitizer_dtor_callback_vptr{{.*}}, !dbg ![[DI1:[0-9]+]]
 // CHECK: ret void
 
 // Since no virtual bases, poison vtable ptr here.
 // CHECK-LABEL: define {{.*}}AD2Ev
-// CHECK: call void @__sanitizer_dtor_callback_fields({{.*}}, !dbg ![[DI2:[0-9]+]]
-// CHECK: call void @__sanitizer_dtor_callback_vptr({{.*}}, !dbg ![[DI2]]
+// CHECK: call void @__sanitizer_dtor_callback_fields{{.*}}, !dbg ![[DI2:[0-9]+]]
+// CHECK: call void @__sanitizer_dtor_callback_vptr{{.*}}, !dbg ![[DI3:[0-9]+]]
 // CHECK: ret void
 
 // Poison members
 // CHECK-LABEL: define {{.*}}BD2Ev
-// CHECK: call void @__sanitizer_dtor_callback_fields({{.*}}, !dbg ![[DI4:[0-9]+]]
+// CHECK: call void @__sanitizer_dtor_callback_fields{{.*}}, !dbg ![[DI4:[0-9]+]]
 // CHECK: ret void
 
-// CHECK-LABEL: !DIFile{{.*}}cpp
+// CHECK-LABEL: !DIFile{{.*}}sanitize-dtor-vtable.cpp
 
-// CHECK: ![[DI1]] = {{.*}}line: [[@LINE-28]]
-// CHECK: ![[DI2]] = {{.*}}line: [[@LINE-37]]
-// CHECK: ![[DI4]] = {{.*}}line: [[@LINE-30]]
+// CHECK-DAG: ![[DI1]] = {{.*}}line: [[@LINE-28]]
+// CHECK-DAG: ![[DI2]] = {{.*}}line: [[@LINE-39]]
+// CHECK-DAG: ![[DI3]] = {{.*}}line: [[@LINE-38]]
+// CHECK-DAG: ![[DI4]] = {{.*}}line: [[@LINE-33]]
Index: clang/test/CodeGenCXX/sanitize-dtor-trivial.cpp
===
--- clang/test/CodeGenCXX/sanitize-dtor-trivial.cpp
+++ clang/test/CodeGenCXX/sanitize-dtor-trivial.cpp
@@ -16,10 +16,4 @@
 
 // CHECK-LABEL: !DIFile{{.*}}.cpp
 
-// CHECK: ![[DI]] = {{.*}}line: [[@LINE-371]]
-
-// CHECK-LABEL: !DIFile{{.*}}cpp
-
-// CHECK: ![[DI1]] = {{.*}}line: [[@LINE-28]]
-// CHECK: ![[DI2]] = {{.*}}line: [[@LINE-37]]
-// CHECK: ![[DI4]] = {{.*}}line: [[@LINE-30]]
+// CHECK: ![[DI]] = {{.*}}line: [[@LINE-9]]
Index: 

[PATCH] D128750: [C++20] Implement P2113R0: Changes to the Partial Ordering of Constrained Functions

2022-08-29 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen requested review of this revision.
ychen added a comment.

@royjacobson: really appreciate it if you could take another look.
@mizvekov: I saw you mentioned in the Discourse that you want to review 
template-related stuff and you have been actively working in that area, do you 
mind having a look at the patch? Thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128750

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


[PATCH] D131464: [test] Make tests pass regardless of gnu++14/gnu++17 default

2022-08-29 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay marked 5 inline comments as done.
MaskRay added inline comments.



Comment at: llvm/utils/lit/lit/llvm/config.py:570
+clang_std_values = ('98', '11', '14', '17', '20', '2b')
+def add_stdcxx(s):
+t = s[8:]

aaron.ballman wrote:
> If we like this approach, we should probably add `add_stdc` as well (not as 
> part of this patch, we can do all of C++ first, then come back and hit up C 
> after we've finished).
Agree. This can be left as another patch.



Comment at: llvm/utils/lit/lit/llvm/config.py:579
+l = h - clang_std_group % (h-l+1)
+self.config.substitutions.append((s, '-std=c++' + 
clang_std_values[l]))
+

aaron.ballman wrote:
> MaskRay wrote:
> > aaron.ballman wrote:
> > > One thing we should consider is whether we want to run in *all* the 
> > > specified language modes instead of just the newest mode. This will make 
> > > running tests slower because we'll run significantly more of them, and it 
> > > might get awkward if a lot of tests change behavior in the different 
> > > language modes, so I don't suggest it as part of this patch.
> > This is difficult in lit. Will answer in my main comment.
> It's unfortunate that it's difficult in lit. I'm fine punting on that work 
> for now, but I think we should try to invest in it (or are you saying 
> "difficult" as in "not worth the effort"?)
I have asked for help on 
https://discourse.llvm.org/t/lit-run-a-run-line-multiple-times-with-different-replacements/64932


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131464

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


[PATCH] D128750: [C++20] Implement P2113R0: Changes to the Partial Ordering of Constrained Functions

2022-08-29 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen updated this revision to Diff 456528.
ychen added a comment.
This revision is now accepted and ready to land.

- handle constrained placeholder [pack] types


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128750

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/AST/DeclTemplate.h
  clang/include/clang/Sema/Sema.h
  clang/include/clang/Sema/SemaConcept.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/DeclTemplate.cpp
  clang/lib/Sema/SemaConcept.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/lib/Sema/SemaTemplateInstantiate.cpp
  clang/test/CXX/over/over.match/over.match.best/p1-2a.cpp
  clang/test/CXX/temp/temp.decls/temp.fct/temp.func.order/p6.cpp
  clang/www/cxx_status.html

Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -967,7 +967,7 @@
   
   
 https://wg21.link/p2113r0;>P2113R0
-No
+Clang 16
   
 
 
Index: clang/test/CXX/temp/temp.decls/temp.fct/temp.func.order/p6.cpp
===
--- clang/test/CXX/temp/temp.decls/temp.fct/temp.func.order/p6.cpp
+++ clang/test/CXX/temp/temp.decls/temp.fct/temp.func.order/p6.cpp
@@ -1,10 +1,17 @@
 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++20 %s
 
-struct A;
-struct B;
-
 template  constexpr bool True = true;
 template  concept C = True;
+template  concept D = C && sizeof(T) > 2;
+template  concept E = D && alignof(T) > 1;
+
+struct A {};
+template  struct S {};
+template  struct X {};
+
+namespace p6 {
+
+struct B;
 
 void f(C auto &, auto &) = delete;
 template  void f(Q &, C auto &);
@@ -13,14 +20,85 @@
   f(*ap, *bp);
 }
 
-template  struct X {};
-
+#if 0
+// FIXME: [temp.func.order]p6.2.1 is not implemented, matching GCC.
 template  bool operator==(X, V) = delete;
 templatebool operator==(T, X);
 
 bool h() {
   return X{} == 0;
 }
+#endif
+
+template class U, typename... Z>
+void foo(T, U) = delete;
+template class U, typename... Z>
+void foo(T, U) = delete;
+template class U, typename... Z>
+void foo(T, U);
+
+void bar(S s) {
+  foo(0, s);
+}
+
+} // namespace p6
+
+namespace TestConversionFunction {
+struct Y {
+  template operator X(); // expected-note {{candidate function [with T = int, U = int]}}
+  template operator X(); // expected-note {{candidate function [with T = int, U = int]}}
+};
+
+X f() {
+  return Y{}; // expected-error {{conversion from 'Y' to 'X' is ambiguous}}
+}
+}
+
+namespace ClassPartialSpecPartialOrdering {
+template struct Y { Y()=delete; }; // expected-note {{template is declared here}}
+template struct Y {}; // expected-error {{class template partial specialization is not more specialized than the primary template}}
+
+template struct B{ B()=delete; };
+template struct B { B()=delete; };
+template struct B {};
+
+template class U, typename... Z>
+struct Some { Some()=delete; };
+template class U, typename... Z>
+struct Some { Some()=delete; };
+template class U, typename... Z>
+struct Some {};
+
+void f() {
+  B b;
+  Some c;
+}
+
+template struct Z; // expected-note {{template is declared here}}
+template struct Z; // expected-error {{class template partial specialization is not more specialized than the primary template}}
+
+template struct W1;
+template struct W1 {};
+
+template struct W2;
+template struct W2 {};
+
+template
+concept C1 = C && C;
+template
+concept D1 = D && C;
+
+template auto T> struct W3;
+template auto T> struct W3 {};
+
+template auto... T> struct W4;
+template auto... T> struct W4 {};
+
+struct W1<0> w1;
+struct W2<0> w2;
+struct W3<0> w3;
+struct W4<0> w4;
+}
 
 namespace PR53640 {
 
Index: clang/test/CXX/over/over.match/over.match.best/p1-2a.cpp
===
--- clang/test/CXX/over/over.match/over.match.best/p1-2a.cpp
+++ clang/test/CXX/over/over.match/over.match.best/p1-2a.cpp
@@ -98,26 +98,31 @@
   static_assert(is_same_v()), void>); // expected-error {{call to 'bar' is ambiguous}}
 
   template
-  constexpr int goo(int a) requires AtLeast2 && true {
+  constexpr int goo(int a) requires AtLeast2 && true { // expected-note {{candidate function}}
 return 1;
   }
 
   template
-  constexpr int goo(const int b) requires AtLeast2 {
+  constexpr int goo(const int b) requires AtLeast2 { // expected-note {{candidate function}}
 return 2;
   }
 
-  // Only trailing requires clauses of redeclarations are compared for overload resolution.
+  // [temp.func.order] p5
+  //   Since, in a call context, such type deduction considers only parameters
+  //   for which there are explicit call arguments, some parameters are ignored
+  //   (namely, function parameter packs, parameters with default arguments, and
+  //   ellipsis parameters).
   

[PATCH] D129833: Use @llvm.threadlocal.address intrinsic to access TLS

2022-08-29 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu added a comment.

In D129833#3755135 , @nikic wrote:

> In D129833#3727881 , @ChuanqiXu 
> wrote:
>
>> And I am working on adding Align properties. But I meet problems since the 
>> alignment of threadlocal_address intrinsic depends on its argument so we 
>> can't set the alignment for its declaration and we probably need to set the 
>> alignment for its call, which means we need to set the alignment when in 
>> IRBuilder. Do you think this is good?
>
> I think that would be fine. Alternatively, it could be inferred in 
> InstCombine.

Thanks. I've filed an issue for it: 
https://github.com/llvm/llvm-project/issues/57438. (I'll fix it later if I had 
time)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129833

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


[PATCH] D132640: [clang-tidy] Fix modernize-use-emplace to support alias cases

2022-08-29 Thread Dong-hee Na via Phabricator via cfe-commits
corona10 added a comment.

@njames93 Can we land this patch before it occurs conflicting with other 
changes?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132640

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


[PATCH] D132352: Introduce noread_thread_id to address the thread identification problem in coroutines

2022-08-29 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu marked an inline comment as done.
ChuanqiXu added a comment.

In D132352#3755355 , @nikic wrote:

> Okay, this is a bit tricky because we have three different things:
>
> 1. The noread_thread_id attribute, the lack of which was causing issues with 
> intrinsics in the previous version
> 2. The meaning of the readnone (etc) attributes, which for pragmatic reasons 
> has to exclude thread IDs for now
> 3. The meaning of doesNotReadMemory() etc queries, which in the previous 
> version included thread ID accesses, but in the new version require a 
> separate call
>
> I think my question here would be why this did not stick with the previous 
> implementation approach that also affects doesNotReadMemory and AA queries 
> (and thus makes everything "automatically correct"), and only added the 
> noread_thread_id attribute to make intrinsic handling more precise?
>
> My general vision for this area was that after D130896 
> , we would add ThreadID as an additional 
> ModRef location, which gets removed for non-presplit-coroutines due to being 
> constant. This would follow the interpretation that the thread ID is part of 
> "memory" though, which kind of goes against the approach here.

I think the key point here is whether or not "thread_id" is part of "memory". 
According to 
https://discourse.llvm.org/t/address-thread-identification-problems-with-coroutine/62015/48,
 we agree to treat "thread_id" is not part of memory. I feel the idea is to 
make these attributes more composable. (@nhaehnle ) And it looks like @jyknight 
@fhahn @rjmccall @efriedma tend to agree the direction if I don't misread. And 
your proposed solution should be available too. I think we need to get in 
consensus that whether or not "thread_id" is part of the "memory".

And another benefit of this method is that it is helpful to solve the potential 
similar problem in green threads (which is called stackful coroutines, or 
fibers). We mention about it here: 
https://discourse.llvm.org/t/address-thread-identification-problems-with-coroutine/62015/28

(Some backgrounds for stackful coroutines: The stackful coroutines are not 
standard features and a vendor extension. the coroutine intrinsics in LLVM 
currently works for stackless coroutines. And the general implementation of 
stackful coroutine is not compiler dependent. The stackful coroutines save each 
register  manually when switching. So it is hard to detect stackful coroutines 
in compiler.)


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

https://reviews.llvm.org/D132352

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


[PATCH] D131464: [test] Make tests pass regardless of gnu++14/gnu++17 default

2022-08-29 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: clang/test/CodeGenCXX/exception-spec-decay.cpp:1
-// RUN: %clang_cc1 -fcxx-exceptions -fexceptions %s -triple=i686-unknown-linux 
-emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 %stdcxx_98- -fcxx-exceptions -fexceptions 
-Wno-dynamic-exception-spec %s -triple=i686-unknown-linux -emit-llvm -o - | 
FileCheck %s
 typedef int Array[10];

aaron.ballman wrote:
> Should we drop the `%stdcxx_98-` entirely from tests and not have any `-std` 
> flag (e.g., no such flags tells lit to run the test in all language modes, 
> eventually)?
The proposal is probably clean if we the majority of tests work with C++98, but 
I think we have accrued many tests which don't work with C++98 so we need 
directives like `%stdcxx_11-`.

Since C++98 is actually uncommon now. I prefer explicit `%stdcxx_98-` to 
indicate a test works with C++98.



Comment at: clang/test/CodeGenCXX/override-layout.cpp:1-9
+// RUN: %clang_cc1 -std=c++14 -w -fdump-record-layouts-simple %s > %t.layouts
+// RUN: %clang_cc1 -std=c++14 -w -fdump-record-layouts-simple %s > %t.before
+// RUN: %clang_cc1 -std=c++14 -w -DPACKED= -DALIGNED16= 
-fdump-record-layouts-simple -foverride-record-layout=%t.layouts %s > %t.after
 // RUN: diff -u %t.before %t.after
-// RUN: FileCheck %s < %t.after
+// RUN: FileCheck --check-prefixes=CHECK,PRE17 %s < %t.after
+
+// RUN: %clang_cc1 -std=c++17 -w -fdump-record-layouts-simple %s > %t.layouts

aaron.ballman wrote:
> Pre 14? Post 17?
Unfortunately, C++17 and C++20 have different behaviors. I haven't investigated 
why it is the case.



Comment at: clang/test/Layout/ms-x86-vtordisp.cpp:1-3
+// RUN: %clang_cc1 -std=c++14 -fno-rtti -fms-extensions -emit-llvm-only 
-triple i686-pc-win32 -fdump-record-layouts -fsyntax-only %s 2>&1 \
 // RUN:| FileCheck %s
+// RUN: %clang_cc1 -std=c++14 -fno-rtti -fms-extensions -emit-llvm-only 
-triple x86_64-pc-win32 -fdump-record-layouts -fsyntax-only %s 2>/dev/null \

aaron.ballman wrote:
> Is this test specific to C++14?
This is similar to the previous -fdump-record-layouts test that the dump order 
is different across 14, 17, 20. I do now know whether there is something which 
should be improved to add the coverage.

For now I assume it is not this patch's responsibility to address it.



Comment at: clang/test/SemaCXX/libstdcxx_is_pod_hack.cpp:1
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++14 %s
 

aaron.ballman wrote:
> Is this one only for C++14 or should there be a range used instead?
This is a hack for presumably older language dialects. Switched to a range.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131464

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


[PATCH] D131464: [test] Make tests pass regardless of gnu++14/gnu++17 default

2022-08-29 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay updated this revision to Diff 456524.
MaskRay marked 6 inline comments as done.
MaskRay added a comment.

address comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131464

Files:
  clang/test/AST/ast-dump-openmp-begin-declare-variant_11.c
  clang/test/AST/ast-dump-openmp-begin-declare-variant_template_3.cpp
  clang/test/AST/ast-dump-undeduced-expr.cpp
  clang/test/AST/sourceranges.cpp
  clang/test/Analysis/blocks.m
  clang/test/Analysis/exploded-graph-rewriter/objects_under_construction.cpp
  clang/test/CXX/basic/basic.stc/basic.stc.dynamic/p2.cpp
  clang/test/CXX/class.access/class.friend/p1.cpp
  clang/test/CXX/dcl.dcl/dcl.spec/dcl.stc/p2.cpp
  clang/test/CXX/except/except.spec/p2-dynamic-types.cpp
  clang/test/CXX/except/except.spec/p9-dynamic.cpp
  clang/test/CXX/stmt.stmt/stmt.select/p3.cpp
  clang/test/CXX/temp/temp.arg/temp.arg.nontype/p1.cpp
  clang/test/CXX/temp/temp.res/temp.local/p3.cpp
  clang/test/CodeGen/typedef_alignment_mismatch_warning.cpp
  clang/test/CodeGenCXX/align-avx-complete-objects.cpp
  clang/test/CodeGenCXX/copy-constructor-elim-2.cpp
  clang/test/CodeGenCXX/debug-info-template-parameter.cpp
  clang/test/CodeGenCXX/debug-info-template-partial-specialization.cpp
  clang/test/CodeGenCXX/exception-spec-decay.cpp
  clang/test/CodeGenCXX/exceptions-cxx-ehsc.cpp
  clang/test/CodeGenCXX/exceptions-no-rtti.cpp
  clang/test/CodeGenCXX/global-init.cpp
  clang/test/CodeGenCXX/no-exceptions.cpp
  clang/test/CodeGenCXX/override-bit-field-layout.cpp
  clang/test/CodeGenCXX/override-layout.cpp
  clang/test/CodeGenCXX/reference-temporary-ms.cpp
  clang/test/CodeGenCXX/rtti-linkage.cpp
  clang/test/Layout/ms-x86-vtordisp.cpp
  clang/test/Modules/update-exception-spec.cpp
  clang/test/OpenMP/declare_mapper_messages.cpp
  clang/test/PCH/cxx-functions.cpp
  clang/test/Parser/cxx-casting.cpp
  clang/test/Parser/cxx-class.cpp
  clang/test/Parser/cxx-template-argument.cpp
  clang/test/Parser/cxx-template-decl.cpp
  clang/test/Parser/cxx1z-nested-namespace-definition.cpp
  clang/test/Sema/ms_class_layout.cpp
  clang/test/SemaCXX/MicrosoftExtensions.cpp
  clang/test/SemaCXX/PR12778.cpp
  clang/test/SemaCXX/altivec.cpp
  clang/test/SemaCXX/bool.cpp
  clang/test/SemaCXX/default2.cpp
  clang/test/SemaCXX/exception-spec-no-exceptions.cpp
  clang/test/SemaCXX/exceptions.cpp
  clang/test/SemaCXX/expressions.cpp
  clang/test/SemaCXX/inline.cpp
  clang/test/SemaCXX/libstdcxx_is_pod_hack.cpp
  clang/test/SemaCXX/linkage2.cpp
  clang/test/SemaCXX/member-pointer.cpp
  clang/test/SemaCXX/missing-namespace-qualifier-typo-corrections.cpp
  clang/test/SemaCXX/static-data-member.cpp
  clang/test/SemaCXX/type-definition-in-specifier.cpp
  clang/test/SemaCXX/user-defined-conversions.cpp
  clang/test/SemaCXX/warn-new-overaligned-3.cpp
  clang/test/SemaCXX/warn-new-overaligned.cpp
  clang/test/SemaCXX/writable-strings-deprecated.cpp
  clang/test/SemaSYCL/zero-length-arrays.cpp
  clang/test/SemaTemplate/class-template-id.cpp
  clang/test/SemaTemplate/constructor-template.cpp
  clang/test/SemaTemplate/explicit-instantiation.cpp
  clang/test/SemaTemplate/instantiate-exception-spec.cpp
  clang/test/SemaTemplate/instantiate-non-dependent-types.cpp
  clang/test/SemaTemplate/instantiation-default-2.cpp
  clang/test/SemaTemplate/temp_arg.cpp
  clang/test/SemaTemplate/temp_arg_template.cpp
  clang/test/SemaTemplate/typename-specifier-3.cpp
  clang/unittests/AST/ASTTraverserTest.cpp
  llvm/utils/lit/lit/llvm/config.py

Index: llvm/utils/lit/lit/llvm/config.py
===
--- llvm/utils/lit/lit/llvm/config.py
+++ llvm/utils/lit/lit/llvm/config.py
@@ -567,6 +567,31 @@
 self.config.substitutions.append(
 ('%target_itanium_abi_host_triple', ''))
 
+# Many tests work across many language dialects. We provide substitutions
+# conveniently try every dialect with LIT_CLANG_STD_GROUP.
+clang_std_group = int(os.environ.get('LIT_CLANG_STD_GROUP', '0'))
+clang_std_values = ('98', '11', '14', '17', '20', '2b')
+def add_stdcxx(s):
+t = s[8:]
+if t.endswith('-'):
+t += clang_std_values[-1]
+l = clang_std_values.index(t[0:2] if t[0:2] != '23' else '2b')
+h = clang_std_values.index(t[3:5])
+# Let LIT_CLANG_STD_GROUP=0 pick the highest value (likely the most relevant
+# dialect).
+l = h - clang_std_group % (h-l+1)
+self.config.substitutions.append((s, '-std=c++' + clang_std_values[l]))
+
+add_stdcxx('%stdcxx_98-14')
+add_stdcxx('%stdcxx_98-')
+add_stdcxx('%stdcxx_11-14')
+add_stdcxx('%stdcxx_11-')
+add_stdcxx('%stdcxx_14-')
+add_stdcxx('%stdcxx_17-20')
+add_stdcxx('%stdcxx_17-')
+add_stdcxx('%stdcxx_20-')
+add_stdcxx('%stdcxx_23-')
+
 # 

[PATCH] D131469: [Clang] change default storing path of `-ftime-trace`

2022-08-29 Thread dongjunduo via Phabricator via cfe-commits
dongjunduo marked an inline comment as done.
dongjunduo added inline comments.



Comment at: clang/lib/Driver/Driver.cpp:4702
+
+  // Add or replace -ftime-trace` to the correct one to all clang jobs
+  for (auto  : C.getJobs()) {

Whitney wrote:
> dongjunduo wrote:
> > Whitney wrote:
> > > dongjunduo wrote:
> > > > Whitney wrote:
> > > > > Do you mean Add or replace the modified `-ftime-trace=` to all 
> > > > > clang jobs?
> > > > Right
> > > ic, can you please have the comment updated?
> > Done at line:4703
> Let me clarify...can you please add `=` in between `-ftime-trace` and 
> `` for the comment on line 4703?
Sorry, I may have made a spelling mistake : ( hh



Comment at: clang/lib/Driver/Driver.cpp:4739
+
+  // replace `-ftime-trace=`
+  auto  = J.getArguments();

Whitney wrote:
> dongjunduo wrote:
> > Whitney wrote:
> > > dongjunduo wrote:
> > > > Whitney wrote:
> > > > > should we also replace `-ftime-trace`?
> > > > The work before here is to infer the correct path to store the 
> > > > time-trace file.
> > > > 
> > > > After that, the  in `-ftime-trace=` should be replaced by 
> > > > the infered correct path.
> > > > 
> > > > We do not need to replace `-ftime-trace` then.
> > > What happens when `-ftime-trace` is given by the user? Do you have both 
> > > `-ftime-trace=` and `-ftime-trace` as arguments?
> > It doesn't matter that either "-ftime-trace" or "-ftime-trace=" or 
> > both of them are given by the user.
> > 
> > The TimeProfiler is switched on when either "-ftime-trace" and 
> > "-ftime-trace="  is specified. Then, 
> > 
> > * If "-ftime-trace=" is specified, the driver use .
> > * If only "-ftime-trace" is specified, the  can be infered, then a 
> > new option "-ftime-trace=" may be added to the clang.
> In the case of only "-ftime-trace" is specified, isn't it better to only pass 
>  "-ftime-trace=" to the compile step instead of both  
> "-ftime-trace=" and "-ftime-trace"?
You are right... May be it's more suitable... I wll remove the "-ftime-trace" 
in this situration then.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131469

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


[PATCH] D131469: [Clang] change default storing path of `-ftime-trace`

2022-08-29 Thread Whitney Tsang via Phabricator via cfe-commits
Whitney added inline comments.



Comment at: clang/lib/Driver/Driver.cpp:4702
+
+  // Add or replace -ftime-trace` to the correct one to all clang jobs
+  for (auto  : C.getJobs()) {

dongjunduo wrote:
> Whitney wrote:
> > dongjunduo wrote:
> > > Whitney wrote:
> > > > Do you mean Add or replace the modified `-ftime-trace=` to all 
> > > > clang jobs?
> > > Right
> > ic, can you please have the comment updated?
> Done at line:4703
Let me clarify...can you please add `=` in between `-ftime-trace` and `` 
for the comment on line 4703?



Comment at: clang/lib/Driver/Driver.cpp:4739
+
+  // replace `-ftime-trace=`
+  auto  = J.getArguments();

dongjunduo wrote:
> Whitney wrote:
> > dongjunduo wrote:
> > > Whitney wrote:
> > > > should we also replace `-ftime-trace`?
> > > The work before here is to infer the correct path to store the time-trace 
> > > file.
> > > 
> > > After that, the  in `-ftime-trace=` should be replaced by the 
> > > infered correct path.
> > > 
> > > We do not need to replace `-ftime-trace` then.
> > What happens when `-ftime-trace` is given by the user? Do you have both 
> > `-ftime-trace=` and `-ftime-trace` as arguments?
> It doesn't matter that either "-ftime-trace" or "-ftime-trace=" or both 
> of them are given by the user.
> 
> The TimeProfiler is switched on when either "-ftime-trace" and 
> "-ftime-trace="  is specified. Then, 
> 
> * If "-ftime-trace=" is specified, the driver use .
> * If only "-ftime-trace" is specified, the  can be infered, then a new 
> option "-ftime-trace=" may be added to the clang.
In the case of only "-ftime-trace" is specified, isn't it better to only pass  
"-ftime-trace=" to the compile step instead of both  
"-ftime-trace=" and "-ftime-trace"?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131469

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


[PATCH] D131469: [Clang] change default storing path of `-ftime-trace`

2022-08-29 Thread dongjunduo via Phabricator via cfe-commits
dongjunduo marked an inline comment as done.
dongjunduo added inline comments.



Comment at: clang/lib/Driver/Driver.cpp:4702
+
+  // Add or replace -ftime-trace` to the correct one to all clang jobs
+  for (auto  : C.getJobs()) {

Whitney wrote:
> dongjunduo wrote:
> > Whitney wrote:
> > > Do you mean Add or replace the modified `-ftime-trace=` to all 
> > > clang jobs?
> > Right
> ic, can you please have the comment updated?
Done at line:4703



Comment at: clang/lib/Driver/Driver.cpp:4739
+
+  // replace `-ftime-trace=`
+  auto  = J.getArguments();

Whitney wrote:
> dongjunduo wrote:
> > Whitney wrote:
> > > should we also replace `-ftime-trace`?
> > The work before here is to infer the correct path to store the time-trace 
> > file.
> > 
> > After that, the  in `-ftime-trace=` should be replaced by the 
> > infered correct path.
> > 
> > We do not need to replace `-ftime-trace` then.
> What happens when `-ftime-trace` is given by the user? Do you have both 
> `-ftime-trace=` and `-ftime-trace` as arguments?
It doesn't matter that either "-ftime-trace" or "-ftime-trace=" or both 
of them are given by the user.

The TimeProfiler is switched on when either "-ftime-trace" and 
"-ftime-trace="  is specified. Then, 

* If "-ftime-trace=" is specified, the driver use .
* If only "-ftime-trace" is specified, the  can be infered, then a new 
option "-ftime-trace=" may be added to the clang.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131469

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


[PATCH] D128490: [ODRHash diagnostics] Transform method `ASTReader::diagnoseOdrViolations` into a class `ODRDiagsEmitter`. NFC.

2022-08-29 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai added a comment.

In D128490#3689958 , @ChuanqiXu wrote:

> LGTM then.

Thanks for the review! Sorry for not answering earlier, I was on vacation. Now 
I'll rebase the change and will test it again before committing.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128490

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


[PATCH] D130096: [Clang][AMDGPU] Emit AMDGPU library control constants in clang

2022-08-29 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 updated this revision to Diff 456520.
jhuber6 added a comment.

Remove unused code gen option.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130096

Files:
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/TargetInfo.cpp
  clang/lib/CodeGen/TargetInfo.h
  clang/test/CodeGen/amdgcn-control-constants.c

Index: clang/test/CodeGen/amdgcn-control-constants.c
===
--- /dev/null
+++ clang/test/CodeGen/amdgcn-control-constants.c
@@ -0,0 +1,49 @@
+// Check that we generate all the expected default features for the target.
+// RUN: %clang_cc1 -x hip -triple amdgcn-amd-amdhsa -target-cpu gfx90a -S -emit-llvm -o - %s | FileCheck %s --check-prefix=GFX90A
+// RUN: %clang_cc1 -x hip -triple amdgcn-amd-amdhsa -target-cpu gfx1030 -S -emit-llvm -o - %s | FileCheck %s --check-prefix=GFX1030
+
+// GFX90A: @__oclc_wavefrontsize64 = private local_unnamed_addr addrspace(4) constant i8 1
+// GFX90A: @__oclc_daz_opt = private local_unnamed_addr addrspace(4) constant i8 0
+// GFX90A: @__oclc_finite_only_opt = private local_unnamed_addr addrspace(4) constant i8 0
+// GFX90A: @__oclc_unsafe_math_opt = private local_unnamed_addr addrspace(4) constant i8 0
+// GFX90A: @__oclc_correctly_rounded_sqrt32 = private local_unnamed_addr addrspace(4) constant i8 1
+// GFX90A: @__oclc_ISA_version = private local_unnamed_addr addrspace(4) constant i32 9010
+// GFX90A: @__oclc_ABI_version = private local_unnamed_addr addrspace(4) constant i32 400
+
+// GFX1030: @__oclc_wavefrontsize64 = private local_unnamed_addr addrspace(4) constant i8 0
+// GFX1030: @__oclc_daz_opt = private local_unnamed_addr addrspace(4) constant i8 0
+// GFX1030: @__oclc_finite_only_opt = private local_unnamed_addr addrspace(4) constant i8 0
+// GFX1030: @__oclc_unsafe_math_opt = private local_unnamed_addr addrspace(4) constant i8 0
+// GFX1030: @__oclc_correctly_rounded_sqrt32 = private local_unnamed_addr addrspace(4) constant i8 1
+// GFX1030: @__oclc_ISA_version = private local_unnamed_addr addrspace(4) constant i32 10048
+// GFX1030: @__oclc_ABI_version = private local_unnamed_addr addrspace(4) constant i32 400
+
+// Check that we can override the wavefront features.
+// RUN: %clang_cc1 -x hip -triple amdgcn-amd-amdhsa -target-cpu gfx1030 -target-feature +wavefrontsize64 \
+// RUN:   -S -emit-llvm -o - %s | FileCheck %s --check-prefix=WAVEFRONT
+// WAVEFRONT: @__oclc_wavefrontsize64 = private local_unnamed_addr addrspace(4) constant i8 1
+
+// Check that we can enable denormalization at zero.
+// RUN: %clang_cc1 -x hip -triple amdgcn-amd-amdhsa -target-cpu gfx90a -fdenormal-fp-math-f32=preserve-sign,preserve-sign \
+// RUN:   -S -emit-llvm -o - %s | FileCheck %s --check-prefix=DENORM-AT-ZERO
+// DENORM-AT-ZERO: @__oclc_daz_opt = private local_unnamed_addr addrspace(4) constant i8 1
+
+// Check that we can enable finite math.
+// RUN: %clang_cc1 -x hip -triple amdgcn-amd-amdhsa -target-cpu gfx90a -ffinite-math-only \
+// RUN:   -S -emit-llvm -o - %s | FileCheck %s --check-prefix=FINITE-MATH
+// FINITE-MATH: @__oclc_finite_only_opt = private local_unnamed_addr addrspace(4) constant i8 1
+// FINITE-MATH: @__oclc_unsafe_math_opt = private local_unnamed_addr addrspace(4) constant i8 0
+
+// Check that we can enable unsafe math.
+// RUN: %clang_cc1 -x hip -triple amdgcn-amd-amdhsa -target-cpu gfx90a -menable-unsafe-fp-math \
+// RUN:   -S -emit-llvm -o - %s | FileCheck %s --check-prefix=UNSAFE-MATH
+// UNSAFE-MATH: @__oclc_finite_only_opt = private local_unnamed_addr addrspace(4) constant i8 0
+// UNSAFE-MATH: @__oclc_unsafe_math_opt = private local_unnamed_addr addrspace(4) constant i8 1
+
+// Check that we can disable/enable correctly rounded square roots.
+// RUN: %clang_cc1 -x hip -triple amdgcn-amd-amdhsa -target-cpu gfx90a -fno-hip-fp32-correctly-rounded-divide-sqrt \
+// RUN:   -S -emit-llvm -o - %s | FileCheck %s --check-prefix=CORRECT-SQRT
+// CORRECT-SQRT: @__oclc_correctly_rounded_sqrt32 = private local_unnamed_addr addrspace(4) constant i8 0
+// RUN: %clang_cc1 -x cl -triple amdgcn-amd-amdhsa -target-cpu gfx90a -cl-fp32-correctly-rounded-divide-sqrt \
+// RUN:   -disable-llvm-optzns -S -emit-llvm -o - %s | FileCheck %s --check-prefix=CL-CORRECT-SQRT
+// CL-CORRECT-SQRT: @__oclc_correctly_rounded_sqrt32 = private local_unnamed_addr addrspace(4) constant i8 1
Index: clang/lib/CodeGen/TargetInfo.h
===
--- clang/lib/CodeGen/TargetInfo.h
+++ clang/lib/CodeGen/TargetInfo.h
@@ -76,6 +76,9 @@
   CodeGen::CodeGenModule ,
   const llvm::MapVector ) const {}
 
+  /// Provides a convenient hook to handle extra target-specific globals.
+  virtual void emitTargetGlobals(CodeGen::CodeGenModule ) const {}
+
   /// Any further codegen related checks that need to be done on a function call
   /// in a target specific manner.
   virtual void 

[PATCH] D132907: [msan] Add more specific messages for use-after-destroy

2022-08-29 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka created this revision.
Herald added a subscriber: Enna1.
Herald added a project: All.
vitalybuka requested review of this revision.
Herald added projects: clang, Sanitizers.
Herald added subscribers: Sanitizers, cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D132907

Files:
  clang/lib/CodeGen/CGClass.cpp
  clang/test/CodeGenCXX/sanitize-dtor-bit-field.cpp
  clang/test/CodeGenCXX/sanitize-dtor-callback.cpp
  clang/test/CodeGenCXX/sanitize-dtor-derived-class.cpp
  clang/test/CodeGenCXX/sanitize-dtor-nontrivial-virtual-base.cpp
  clang/test/CodeGenCXX/sanitize-dtor-tail-call.cpp
  clang/test/CodeGenCXX/sanitize-dtor-trivial-base.cpp
  clang/test/CodeGenCXX/sanitize-dtor-vtable.cpp
  clang/test/CodeGenCXX/sanitize-dtor-zero-size-field.cpp
  compiler-rt/include/sanitizer/msan_interface.h
  compiler-rt/lib/msan/msan.h
  compiler-rt/lib/msan/msan_interceptors.cpp
  compiler-rt/lib/msan/msan_interface_internal.h
  compiler-rt/lib/msan/msan_report.cpp
  compiler-rt/test/msan/dtor-base-access.cpp
  compiler-rt/test/msan/dtor-vtable-multiple-inheritance.cpp
  compiler-rt/test/msan/use-after-dtor.cpp

Index: compiler-rt/test/msan/use-after-dtor.cpp
===
--- compiler-rt/test/msan/use-after-dtor.cpp
+++ compiler-rt/test/msan/use-after-dtor.cpp
@@ -32,7 +32,7 @@
   // CHECK-UAD: WARNING: MemorySanitizer: use-of-uninitialized-value
   // CHECK-UAD: {{#0 0x.* in main.*use-after-dtor.cpp:}}[[@LINE-3]]
 
-  // CHECK-ORIGINS: Memory was marked as uninitialized
+  // CHECK-ORIGINS: Member fields were destroyed
   // CHECK-ORIGINS: {{#0 0x.* in __sanitizer_dtor_callback}}
   // CHECK-ORIGINS: {{#1 0x.* in .*~Simple.*cpp:}}[[@LINE-18]]:
 
Index: compiler-rt/test/msan/dtor-vtable-multiple-inheritance.cpp
===
--- compiler-rt/test/msan/dtor-vtable-multiple-inheritance.cpp
+++ compiler-rt/test/msan/dtor-vtable-multiple-inheritance.cpp
@@ -51,8 +51,8 @@
   // This fails
 #ifdef CVPTR
   c->A_Foo();
-// CVPTR: Memory was marked as uninitialized
-// CVPTR: {{#0 0x.* in __sanitizer_dtor_callback}}
+// CVPTR: Virtual table ptr was destroyed
+// CVPTR: {{#0 0x.* in __sanitizer_dtor_callback_vptr}}
 // CVPTR: {{#1 0x.* in ~C .*cpp:}}[[@LINE-28]]:
 // CVPTR: {{#2 0x.* in main .*cpp:}}[[@LINE-7]]:
 #endif
@@ -63,16 +63,16 @@
   // Both of these fail
 #ifdef EAVPTR
   e->A_Foo();
-// EAVPTR: Memory was marked as uninitialized
-// EAVPTR: {{#0 0x.* in __sanitizer_dtor_callback}}
+// EAVPTR: Virtual table ptr was destroyed
+// EAVPTR: {{#0 0x.* in __sanitizer_dtor_callback_vptr}}
 // EAVPTR: {{#1 0x.* in ~E .*cpp:}}[[@LINE-25]]:
 // EAVPTR: {{#2 0x.* in main .*cpp:}}[[@LINE-7]]:
 #endif
 
 #ifdef EDVPTR
   e->D_Foo();
-// EDVPTR: Memory was marked as uninitialized
-// EDVPTR: {{#0 0x.* in __sanitizer_dtor_callback}}
+// EDVPTR: Virtual table ptr was destroyed
+// EDVPTR: {{#0 0x.* in __sanitizer_dtor_callback_vptr}}
 // EDVPTR: {{#1 0x.* in ~E .*cpp:}}[[@LINE-33]]:
 // EDVPTR: {{#2 0x.* in main .*cpp:}}[[@LINE-15]]:
 #endif
Index: compiler-rt/test/msan/dtor-base-access.cpp
===
--- compiler-rt/test/msan/dtor-base-access.cpp
+++ compiler-rt/test/msan/dtor-base-access.cpp
@@ -66,17 +66,17 @@
   assert(__msan_test_shadow(>d, sizeof(g->d)) == 0);
 
   __msan_print_shadow(>tb0, sizeof(g->tb0));
-  // CHECK: Memory was marked as uninitialized
+  // CHECK: Member fields were destroyed
   // CHECK: {{#0 0x.* in __sanitizer_dtor_callback}}
   // CHECK: {{#1 0x.* in .*~Derived.*cpp:}}[[@LINE-20]]:
 
   __msan_print_shadow(>b, sizeof(g->b));
-  // CHECK: Memory was marked as uninitialized
+  // CHECK: Member fields were destroyed
   // CHECK: {{#0 0x.* in __sanitizer_dtor_callback}}
   // CHECK: {{#1 0x.* in .*~Base.*cpp:}}[[@LINE-33]]:
 
   __msan_print_shadow(>tb1, sizeof(g->tb1));
-  // CHECK: Memory was marked as uninitialized
+  // CHECK: Member fields were destroyed
   // CHECK: {{#0 0x.* in __sanitizer_dtor_callback}}
   // CHECK: {{#1 0x.* in .*~Derived.*cpp:}}[[@LINE-30]]:
 
Index: compiler-rt/lib/msan/msan_report.cpp
===
--- compiler-rt/lib/msan/msan_report.cpp
+++ compiler-rt/lib/msan/msan_report.cpp
@@ -81,6 +81,13 @@
 Printf("  %sMemory was marked as uninitialized%s\n", d.Origin(),
d.Default());
 break;
+  case STACK_TRACE_TAG_FIELDS:
+Printf("  %sMember fields were destroyed%s\n", d.Origin(), d.Default());
+break;
+  case STACK_TRACE_TAG_VPTR:
+Printf("  %sVirtual table ptr was destroyed%s\n", d.Origin(),
+   d.Default());
+break;
   default:
 Printf("  %sUninitialized value was created%s\n", d.Origin(),
d.Default());
Index: compiler-rt/lib/msan/msan_interface_internal.h
===

[clang] 420209b - [test][msan] Add missing Debug Info check from dtor test

2022-08-29 Thread Vitaly Buka via cfe-commits

Author: Vitaly Buka
Date: 2022-08-29T18:55:24-07:00
New Revision: 420209bb6d092bd4735c24726b934a1e4637f04d

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

LOG: [test][msan] Add missing Debug Info check from dtor test

Added: 


Modified: 
clang/test/CodeGenCXX/sanitize-dtor-nontrivial-virtual-base.cpp

Removed: 




diff  --git a/clang/test/CodeGenCXX/sanitize-dtor-nontrivial-virtual-base.cpp 
b/clang/test/CodeGenCXX/sanitize-dtor-nontrivial-virtual-base.cpp
index 75ee8d4789bc..75cee72a51df 100644
--- a/clang/test/CodeGenCXX/sanitize-dtor-nontrivial-virtual-base.cpp
+++ b/clang/test/CodeGenCXX/sanitize-dtor-nontrivial-virtual-base.cpp
@@ -47,7 +47,7 @@ Derived d;
 
 // CHECK-LABEL: define {{.*}}ZN7DerivedD1Ev
 // CHECK: call void {{.*}}ZN11VirtualBaseD2Ev
-// CHECK: call void @__sanitizer_dtor_callback({{.*}}, i64 8)
+// CHECK: call void @__sanitizer_dtor_callback({{.*}}){{.*}}, !dbg 
![[DI0:[0-9]+]]
 // CHECK: ret void
 
 // CHECK-LABEL: define {{.*}}ZN7DerivedD0Ev
@@ -86,7 +86,8 @@ Derived d;
 
 // CHECK-LABEL: !DIFile{{.*}}.cpp
 
-// CHECK: ![[DI1]] = {{.*}}line: [[@LINE-59]]
-// CHECK: ![[DI2]] = {{.*}}line: [[@LINE-70]]
-// CHECK: ![[DI3]] = {{.*}}line: [[@LINE-51]]
-// CHECK: ![[DI5]] = {{.*}}line: [[@LINE-82]]
+// CHECK: ![[DI0]] = {{.*}}line: [[@LINE-49]]
+// CHECK: ![[DI1]] = {{.*}}line: [[@LINE-60]]
+// CHECK: ![[DI2]] = {{.*}}line: [[@LINE-71]]
+// CHECK: ![[DI3]] = {{.*}}line: [[@LINE-52]]
+// CHECK: ![[DI5]] = {{.*}}line: [[@LINE-83]]



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


[PATCH] D132906: [Clang] Fix lambda CheckForDefaultedFunction(...) so that it checks the CXXMethodDecl is a special member function before attempting to call DefineDefaultedFunction(...)

2022-08-29 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik created this revision.
shafik added reviewers: erichkeane, aaron.ballman.
Herald added a project: All.
shafik requested review of this revision.

In `Sema::CheckCompletedCXXClass(...)` It used a lambda 
`CheckForDefaultedFunction` the `CXXMethodDecl` passed to 
`CheckForDefaultedFunction` may not be a special member function and so before 
attempting to apply functions that only apply to special member functions it 
needs to check. It fails to do this before calling 
`DefineDefaultedFunction(...)`. This PR adds that check and test to verify we 
no longer crash.

This fixes https://github.com/llvm/llvm-project/issues/57431


https://reviews.llvm.org/D132906

Files:
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/test/SemaCXX/constant-expression-cxx2a.cpp


Index: clang/test/SemaCXX/constant-expression-cxx2a.cpp
===
--- clang/test/SemaCXX/constant-expression-cxx2a.cpp
+++ clang/test/SemaCXX/constant-expression-cxx2a.cpp
@@ -1473,3 +1473,13 @@
   }
   static_assert(g()); // expected-error {{constant expression}} expected-note 
{{in call}}
 }
+
+namespace GH57431 {
+class B{
+  virtual int constexpr f() = 0;
+};
+
+class D : B{
+  virtual int constexpr f() = default; // expected-error {{only special member 
functions and comparison operators may be defaulted}}
+};
+}
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -6954,7 +6954,8 @@
 // Define defaulted constexpr virtual functions that override a base class
 // function right away.
 // FIXME: We can defer doing this until the vtable is marked as used.
-if (M->isDefaulted() && M->isConstexpr() && M->size_overridden_methods())
+if (CSM != CXXInvalid && M->isDefaulted() && M->isConstexpr() &&
+M->size_overridden_methods())
   DefineDefaultedFunction(*this, M, M->getLocation());
 
 if (!Incomplete)


Index: clang/test/SemaCXX/constant-expression-cxx2a.cpp
===
--- clang/test/SemaCXX/constant-expression-cxx2a.cpp
+++ clang/test/SemaCXX/constant-expression-cxx2a.cpp
@@ -1473,3 +1473,13 @@
   }
   static_assert(g()); // expected-error {{constant expression}} expected-note {{in call}}
 }
+
+namespace GH57431 {
+class B{
+  virtual int constexpr f() = 0;
+};
+
+class D : B{
+  virtual int constexpr f() = default; // expected-error {{only special member functions and comparison operators may be defaulted}}
+};
+}
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -6954,7 +6954,8 @@
 // Define defaulted constexpr virtual functions that override a base class
 // function right away.
 // FIXME: We can defer doing this until the vtable is marked as used.
-if (M->isDefaulted() && M->isConstexpr() && M->size_overridden_methods())
+if (CSM != CXXInvalid && M->isDefaulted() && M->isConstexpr() &&
+M->size_overridden_methods())
   DefineDefaultedFunction(*this, M, M->getLocation());
 
 if (!Incomplete)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D132905: [clang-format] Fix a bug in inserting braces at trailing comments

2022-08-29 Thread Owen Pan via Phabricator via cfe-commits
owenpan created this revision.
owenpan added reviewers: MyDeveloperDay, HazardyKnusperkeks, curdeius.
owenpan added a project: clang-format.
Herald added a project: All.
owenpan requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

If the style wraps control statement braces, the opening braces should be 
inserted after the trailing comments if present.

Fixes https://github.com/llvm/llvm-project/issues/57419.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D132905

Files:
  clang/lib/Format/Format.cpp
  clang/lib/Format/UnwrappedLineParser.cpp
  clang/unittests/Format/FormatTest.cpp


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -25201,6 +25201,13 @@
"  f();",
Style);
 
+  verifyFormat("if (a) { //\n"
+   "  b = 1;\n"
+   "}",
+   "if (a) //\n"
+   "  b = 1;",
+   Style);
+
   verifyFormat("if (a) { // comment\n"
"  // comment\n"
"  f();\n"
@@ -25266,6 +25273,19 @@
"if (a + b > c)\n"
"  f();",
Style);
+
+  Style.BreakBeforeBraces = FormatStyle::BS_Custom;
+  Style.BraceWrapping.AfterControlStatement = FormatStyle::BWACS_Always;
+  // TODO: Delete the following line after #57421 is fixed.
+  Style.BraceWrapping.AfterFunction = true;
+
+  verifyFormat("if (a) //\n"
+   "{\n"
+   "  b = 1;\n"
+   "}",
+   "if (a) //\n"
+   "  b = 1;",
+   Style);
 }
 
 TEST_F(FormatTest, RemoveBraces) {
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -2606,7 +2606,10 @@
 
   if (Style.InsertBraces && !Line->InPPDirective && !Line->Tokens.empty() &&
   PreprocessorDirectives.empty()) {
-Tok = getLastNonComment(*Line);
+assert(!Line->Tokens.empty());
+Tok = Style.BraceWrapping.AfterControlStatement == FormatStyle::BWACS_Never
+  ? getLastNonComment(*Line)
+  : Line->Tokens.back().Tok;
 assert(Tok);
 if (Tok->BraceCount < 0) {
   assert(Tok->BraceCount == -1);
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -1869,7 +1869,7 @@
 std::string Brace;
 if (Token->BraceCount < 0) {
   assert(Token->BraceCount == -1);
-  Brace = '{';
+  Brace = "\n{";
 } else {
   Brace = '\n' + std::string(Token->BraceCount, '}');
 }


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -25201,6 +25201,13 @@
"  f();",
Style);
 
+  verifyFormat("if (a) { //\n"
+   "  b = 1;\n"
+   "}",
+   "if (a) //\n"
+   "  b = 1;",
+   Style);
+
   verifyFormat("if (a) { // comment\n"
"  // comment\n"
"  f();\n"
@@ -25266,6 +25273,19 @@
"if (a + b > c)\n"
"  f();",
Style);
+
+  Style.BreakBeforeBraces = FormatStyle::BS_Custom;
+  Style.BraceWrapping.AfterControlStatement = FormatStyle::BWACS_Always;
+  // TODO: Delete the following line after #57421 is fixed.
+  Style.BraceWrapping.AfterFunction = true;
+
+  verifyFormat("if (a) //\n"
+   "{\n"
+   "  b = 1;\n"
+   "}",
+   "if (a) //\n"
+   "  b = 1;",
+   Style);
 }
 
 TEST_F(FormatTest, RemoveBraces) {
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -2606,7 +2606,10 @@
 
   if (Style.InsertBraces && !Line->InPPDirective && !Line->Tokens.empty() &&
   PreprocessorDirectives.empty()) {
-Tok = getLastNonComment(*Line);
+assert(!Line->Tokens.empty());
+Tok = Style.BraceWrapping.AfterControlStatement == FormatStyle::BWACS_Never
+  ? getLastNonComment(*Line)
+  : Line->Tokens.back().Tok;
 assert(Tok);
 if (Tok->BraceCount < 0) {
   assert(Tok->BraceCount == -1);
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -1869,7 +1869,7 @@
 std::string Brace;
 if (Token->BraceCount < 0) {
   assert(Token->BraceCount == -1);
-  Brace 

[clang] 582ec4b - [test][msan] Don't ignore prefix of sanitizer_dtor_callback

2022-08-29 Thread Vitaly Buka via cfe-commits

Author: Vitaly Buka
Date: 2022-08-29T18:26:04-07:00
New Revision: 582ec4b0aa55bff84490e1c89e55066bf6603212

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

LOG: [test][msan] Don't ignore prefix of sanitizer_dtor_callback

Added: 


Modified: 
clang/test/CodeGenCXX/sanitize-dtor-fn-attribute.cpp
clang/test/CodeGenCXX/sanitize-dtor-nontrivial-virtual-base.cpp

Removed: 




diff  --git a/clang/test/CodeGenCXX/sanitize-dtor-fn-attribute.cpp 
b/clang/test/CodeGenCXX/sanitize-dtor-fn-attribute.cpp
index 2817aac4ef4a..61acea458d4a 100644
--- a/clang/test/CodeGenCXX/sanitize-dtor-fn-attribute.cpp
+++ b/clang/test/CodeGenCXX/sanitize-dtor-fn-attribute.cpp
@@ -33,7 +33,7 @@ int main() {
 // CHECK: ret void
 
 // CHECK: define {{.*}}VectorIiED2Ev
-// CHECK: call void {{.*}}sanitizer_dtor_callback
+// CHECK: call void @__sanitizer_dtor_callback
 // CHECK: ret void
 
 // When attribute is repressed, the destructor does not emit any tail calls

diff  --git a/clang/test/CodeGenCXX/sanitize-dtor-nontrivial-virtual-base.cpp 
b/clang/test/CodeGenCXX/sanitize-dtor-nontrivial-virtual-base.cpp
index 3e20eede26b1..75ee8d4789bc 100644
--- a/clang/test/CodeGenCXX/sanitize-dtor-nontrivial-virtual-base.cpp
+++ b/clang/test/CodeGenCXX/sanitize-dtor-nontrivial-virtual-base.cpp
@@ -61,27 +61,27 @@ Derived d;
 
 // poison 2 ints
 // CHECK-LABEL: define {{.*}}ZN11VirtualBaseD2Ev
-// CHECK: call void {{.*}}@__sanitizer_dtor_callback({{.*}}, i64 8){{.*}}, 
!dbg ![[DI1:[0-9]+]]
-// CHECK: call void {{.*}}sanitizer_dtor_callback({{.*}}, i64 8)
+// CHECK: call void @__sanitizer_dtor_callback({{.*}}, i64 8){{.*}}, !dbg 
![[DI1:[0-9]+]]
+// CHECK: call void @__sanitizer_dtor_callback({{.*}}, i64 8)
 // CHECK: ret void
 
 // poison int and double
 // CHECK-LABEL: define {{.*}}ZN4BaseD2Ev
 // CHECK: call void @__sanitizer_dtor_callback({{.*}}{{.*}}, !dbg 
![[DI2:[0-9]+]]
-// CHECK: call void {{.*}}sanitizer_dtor_callback({{.*}}, i64 8)
+// CHECK: call void @__sanitizer_dtor_callback({{.*}}, i64 8)
 // CHECK: ret void
 
 // poison int, ignore vector, poison int
 // CHECK-LABEL: define {{.*}}ZN7DerivedD2Ev
-// CHECK: call void {{.*}}sanitizer_dtor_callback({{.*}}, i64 4){{.*}}, !dbg 
![[DI3:[0-9]+]]
+// CHECK: call void @__sanitizer_dtor_callback({{.*}}, i64 4){{.*}}, !dbg 
![[DI3:[0-9]+]]
 // CHECK: call void {{.*}}ZN6VectorIiED1Ev
-// CHECK: call void {{.*}}sanitizer_dtor_callback({{.*}}, i64 4){{.*}}, !dbg 
![[DI3]]
+// CHECK: call void @__sanitizer_dtor_callback({{.*}}, i64 4){{.*}}, !dbg 
![[DI3]]
 // CHECK: call void {{.*}}ZN4BaseD2Ev
 // CHECK: ret void
 
 // poison int
 // CHECK-LABEL: define {{.*}}ZN6VectorIiED2Ev
-// CHECK: call void {{.*}}sanitizer_dtor_callback({{.*}}, i64 4){{.*}}, !dbg 
![[DI5:[0-9]+]]
+// CHECK: call void @__sanitizer_dtor_callback({{.*}}, i64 4){{.*}}, !dbg 
![[DI5:[0-9]+]]
 // CHECK: ret void
 
 // CHECK-LABEL: !DIFile{{.*}}.cpp



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


[clang] c7df82e - [test][msan] Don't ignore the suffix if use-after-dtor callback

2022-08-29 Thread Vitaly Buka via cfe-commits

Author: Vitaly Buka
Date: 2022-08-29T18:10:57-07:00
New Revision: c7df82e4693c19e3fd2e25c83eb04d9deb7b7b59

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

LOG: [test][msan] Don't ignore the suffix if use-after-dtor callback

Added: 


Modified: 
clang/test/CodeGenCXX/sanitize-dtor-bit-field.cpp
clang/test/CodeGenCXX/sanitize-dtor-callback.cpp
clang/test/CodeGenCXX/sanitize-dtor-derived-class.cpp
clang/test/CodeGenCXX/sanitize-dtor-tail-call.cpp
clang/test/CodeGenCXX/sanitize-dtor-trivial-base.cpp
clang/test/CodeGenCXX/sanitize-dtor-trivial.cpp
clang/test/CodeGenCXX/sanitize-dtor-vtable.cpp

Removed: 




diff  --git a/clang/test/CodeGenCXX/sanitize-dtor-bit-field.cpp 
b/clang/test/CodeGenCXX/sanitize-dtor-bit-field.cpp
index f07be7212dad..71be40984644 100644
--- a/clang/test/CodeGenCXX/sanitize-dtor-bit-field.cpp
+++ b/clang/test/CodeGenCXX/sanitize-dtor-bit-field.cpp
@@ -63,22 +63,22 @@ struct Adjacent {
 Adjacent ad;
 
 // CHECK-LABEL: define {{.*}}PackedD2Ev
-// CHECK: call void @__sanitizer_dtor_callback{{.*}}i64 17{{.*}}, !dbg 
![[DI1:[0-9]+]]
+// CHECK: call void @__sanitizer_dtor_callback({{.*}}i64 17{{.*}}, !dbg 
![[DI1:[0-9]+]]
 // CHECK: ret void
 
 // CHECK-LABEL: define {{.*}}EmptyD2Ev
 // CHECK: ret void
 
 // CHECK-LABEL: define {{.*}}SimpleD2Ev
-// CHECK: call void @__sanitizer_dtor_callback{{.*}}i64 1{{.*}}, !dbg 
![[DI2:[0-9]+]]
+// CHECK: call void @__sanitizer_dtor_callback({{.*}}i64 1{{.*}}, !dbg 
![[DI2:[0-9]+]]
 // CHECK: ret void
 
 // CHECK-LABEL: define {{.*}}AnonD2Ev
-// CHECK: call void @__sanitizer_dtor_callback{{.*}}i64 5{{.*}}, !dbg 
![[DI3:[0-9]+]]
+// CHECK: call void @__sanitizer_dtor_callback({{.*}}i64 5{{.*}}, !dbg 
![[DI3:[0-9]+]]
 // CHECK: ret void
 
 // CHECK-LABEL: define {{.*}}AdjacentD2Ev
-// CHECK: call void @__sanitizer_dtor_callback{{.*}}i64 1{{.*}}, !dbg 
![[DI4:[0-9]+]]
+// CHECK: call void @__sanitizer_dtor_callback({{.*}}i64 1{{.*}}, !dbg 
![[DI4:[0-9]+]]
 // CHECK: ret void
 
 // CHECK-LABEL: !DIFile{{.*}}cpp

diff  --git a/clang/test/CodeGenCXX/sanitize-dtor-callback.cpp 
b/clang/test/CodeGenCXX/sanitize-dtor-callback.cpp
index 2aa760ad35f4..7396e0d2d2df 100644
--- a/clang/test/CodeGenCXX/sanitize-dtor-callback.cpp
+++ b/clang/test/CodeGenCXX/sanitize-dtor-callback.cpp
@@ -56,16 +56,16 @@ Defaulted_Non_Trivial def_non_trivial;
 // instrumentation inserted.
 // CHECK-LABEL: define {{.*}}SimpleD2Ev
 // CHECK-NOT: store i{{[0-9]+}} 0, {{.*}}@__msan_param_tls
-// CHECK: call void @__sanitizer_dtor_callback{{.*}}, !dbg ![[DI1:[0-9]+]]
+// CHECK: call void @__sanitizer_dtor_callback({{.*}}, !dbg ![[DI1:[0-9]+]]
 // CHECK: ret void
 
 // CHECK-LABEL: define {{.*}}InlinedD2Ev
 // CHECK-NOT: store i{{[0-9]+}} 0, {{.*}}@__msan_param_tls
-// CHECK: call void @__sanitizer_dtor_callback{{.*}}, !dbg ![[DI2:[0-9]+]]
+// CHECK: call void @__sanitizer_dtor_callback({{.*}}, !dbg ![[DI2:[0-9]+]]
 // CHECK: ret void
 
 // CHECK-LABEL: define {{.*}}Defaulted_Non_TrivialD2Ev
-// CHECK: call void @__sanitizer_dtor_callback{{.*}}, !dbg ![[DI3:[0-9]+]]
+// CHECK: call void @__sanitizer_dtor_callback({{.*}}, !dbg ![[DI3:[0-9]+]]
 // CHECK: ret void
 
 // CHECK-LABEL: !DIFile{{.*}}cpp

diff  --git a/clang/test/CodeGenCXX/sanitize-dtor-derived-class.cpp 
b/clang/test/CodeGenCXX/sanitize-dtor-derived-class.cpp
index 3292e87ea7c3..5c2bec68a5e1 100644
--- a/clang/test/CodeGenCXX/sanitize-dtor-derived-class.cpp
+++ b/clang/test/CodeGenCXX/sanitize-dtor-derived-class.cpp
@@ -49,15 +49,15 @@ Derived d;
 
 // Poison members and vtable ptr.
 // CHECK-LABEL: define {{.*}}BaseD2Ev
-// CHECK: call void @__sanitizer_dtor_callback{{.*}}, !dbg ![[DI1:[0-9]+]]
-// CHECK: call void @__sanitizer_dtor_callback{{.*}}i64 8{{.*}}, !dbg ![[DI1]]
+// CHECK: call void @__sanitizer_dtor_callback({{.*}}, !dbg ![[DI1:[0-9]+]]
+// CHECK: call void @__sanitizer_dtor_callback({{.*}}i64 8{{.*}}, !dbg ![[DI1]]
 // CHECK: ret void
 
 // Poison members and destroy non-virtual base.
 // CHECK-LABEL: define {{.*}}DerivedD2Ev
-// CHECK: call void @__sanitizer_dtor_callback{{.*}}, !dbg ![[DI3:[0-9]+]]
+// CHECK: call void @__sanitizer_dtor_callback({{.*}}, !dbg ![[DI3:[0-9]+]]
 // CHECK: call void {{.*}}BaseD2Ev
-// CHECK: call void @__sanitizer_dtor_callback{{.*}}i64 8{{.*}}, !dbg ![[DI3]]
+// CHECK: call void @__sanitizer_dtor_callback({{.*}}i64 8{{.*}}, !dbg ![[DI3]]
 // CHECK: ret void
 
 // CHECK-LABEL: !DIFile{{.*}}cpp

diff  --git a/clang/test/CodeGenCXX/sanitize-dtor-tail-call.cpp 
b/clang/test/CodeGenCXX/sanitize-dtor-tail-call.cpp
index 96e60999890c..3d52e725cc55 100644
--- a/clang/test/CodeGenCXX/sanitize-dtor-tail-call.cpp
+++ b/clang/test/CodeGenCXX/sanitize-dtor-tail-call.cpp
@@ -15,7 +15,7 @@ struct Simple {
 Simple s;
 // Simple internal member is 

[clang] 9c29bdf - [test][msan] Remov unneeded CHECK-NOT

2022-08-29 Thread Vitaly Buka via cfe-commits

Author: Vitaly Buka
Date: 2022-08-29T17:49:44-07:00
New Revision: 9c29bdf84ab1bdd89fe8c36974c3bf0543eb9763

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

LOG: [test][msan] Remov unneeded CHECK-NOT

Added: 


Modified: 
clang/test/CodeGenCXX/sanitize-no-dtor-callback.cpp

Removed: 




diff  --git a/clang/test/CodeGenCXX/sanitize-no-dtor-callback.cpp 
b/clang/test/CodeGenCXX/sanitize-no-dtor-callback.cpp
index af130faf13116..ffd573e4d251f 100644
--- a/clang/test/CodeGenCXX/sanitize-no-dtor-callback.cpp
+++ b/clang/test/CodeGenCXX/sanitize-no-dtor-callback.cpp
@@ -8,7 +8,6 @@ struct Simple {
 };
 Simple s;
 // CHECK-LABEL: define {{.*}}SimpleD1Ev
-// CHECK-NOT: call void @__sanitizer_dtor_callback
 
 struct Inlined {
   int x;



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


[clang] ed4e95c - [test][msan] Add more Debug Info use-after-dtor tests

2022-08-29 Thread Vitaly Buka via cfe-commits

Author: Vitaly Buka
Date: 2022-08-29T17:49:44-07:00
New Revision: ed4e95c1f68abe8fffe8b54139d268924d554381

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

LOG: [test][msan] Add more Debug Info use-after-dtor tests

Added: 


Modified: 
clang/test/CodeGenCXX/sanitize-dtor-bit-field.cpp
clang/test/CodeGenCXX/sanitize-dtor-callback.cpp
clang/test/CodeGenCXX/sanitize-dtor-derived-class.cpp
clang/test/CodeGenCXX/sanitize-dtor-nontrivial-virtual-base.cpp
clang/test/CodeGenCXX/sanitize-dtor-trivial-base.cpp
clang/test/CodeGenCXX/sanitize-dtor-trivial.cpp
clang/test/CodeGenCXX/sanitize-dtor-vtable.cpp

Removed: 




diff  --git a/clang/test/CodeGenCXX/sanitize-dtor-bit-field.cpp 
b/clang/test/CodeGenCXX/sanitize-dtor-bit-field.cpp
index dc84db879328..f07be7212dad 100644
--- a/clang/test/CodeGenCXX/sanitize-dtor-bit-field.cpp
+++ b/clang/test/CodeGenCXX/sanitize-dtor-bit-field.cpp
@@ -1,6 +1,6 @@
 // Test -fsanitize-memory-use-after-dtor
-// RUN: %clang_cc1 -O0 -fsanitize=memory -fsanitize-memory-use-after-dtor 
-disable-llvm-passes -std=c++11 -triple=x86_64-pc-linux -emit-llvm -o - %s | 
FileCheck %s --implicit-check-not="call void @__sanitizer_"
-// RUN: %clang_cc1 -O1 -fsanitize=memory -fsanitize-memory-use-after-dtor 
-disable-llvm-passes -std=c++11 -triple=x86_64-pc-linux -emit-llvm -o - %s | 
FileCheck %s --implicit-check-not="call void @__sanitizer_"
+// RUN: %clang_cc1 -O0 -fsanitize=memory -fsanitize-memory-use-after-dtor 
-disable-llvm-passes -std=c++11 -triple=x86_64-pc-linux -emit-llvm 
-debug-info-kind=line-tables-only -o - %s | FileCheck %s 
--implicit-check-not="call void @__sanitizer_"
+// RUN: %clang_cc1 -O1 -fsanitize=memory -fsanitize-memory-use-after-dtor 
-disable-llvm-passes -std=c++11 -triple=x86_64-pc-linux -emit-llvm 
-debug-info-kind=line-tables-only -o - %s | FileCheck %s 
--implicit-check-not="call void @__sanitizer_"
 
 // 24 bytes total
 struct Packed {
@@ -62,22 +62,28 @@ struct Adjacent {
 };
 Adjacent ad;
 
-
 // CHECK-LABEL: define {{.*}}PackedD2Ev
-// CHECK: call void @__sanitizer_dtor_callback{{.*}}i64 17
+// CHECK: call void @__sanitizer_dtor_callback{{.*}}i64 17{{.*}}, !dbg 
![[DI1:[0-9]+]]
 // CHECK: ret void
 
 // CHECK-LABEL: define {{.*}}EmptyD2Ev
 // CHECK: ret void
 
 // CHECK-LABEL: define {{.*}}SimpleD2Ev
-// CHECK: call void @__sanitizer_dtor_callback{{.*}}i64 1
+// CHECK: call void @__sanitizer_dtor_callback{{.*}}i64 1{{.*}}, !dbg 
![[DI2:[0-9]+]]
 // CHECK: ret void
 
 // CHECK-LABEL: define {{.*}}AnonD2Ev
-// CHECK: call void @__sanitizer_dtor_callback{{.*}}i64 5
+// CHECK: call void @__sanitizer_dtor_callback{{.*}}i64 5{{.*}}, !dbg 
![[DI3:[0-9]+]]
 // CHECK: ret void
 
 // CHECK-LABEL: define {{.*}}AdjacentD2Ev
-// CHECK: call void @__sanitizer_dtor_callback{{.*}}i64 1
+// CHECK: call void @__sanitizer_dtor_callback{{.*}}i64 1{{.*}}, !dbg 
![[DI4:[0-9]+]]
 // CHECK: ret void
+
+// CHECK-LABEL: !DIFile{{.*}}cpp
+
+// CHECK: ![[DI1]] = {{.*}}line: [[@LINE-68]]
+// CHECK: ![[DI2]] = {{.*}}line: [[@LINE-53]]
+// CHECK: ![[DI3]] = {{.*}}line: [[@LINE-41]]
+// CHECK: ![[DI4]] = {{.*}}line: [[@LINE-28]]

diff  --git a/clang/test/CodeGenCXX/sanitize-dtor-callback.cpp 
b/clang/test/CodeGenCXX/sanitize-dtor-callback.cpp
index f0d1e5697e7a..2aa760ad35f4 100644
--- a/clang/test/CodeGenCXX/sanitize-dtor-callback.cpp
+++ b/clang/test/CodeGenCXX/sanitize-dtor-callback.cpp
@@ -1,5 +1,5 @@
 // Test -fsanitize-memory-use-after-dtor
-// RUN: %clang_cc1 -fsanitize=memory -fsanitize-memory-use-after-dtor 
-std=c++11 -triple=x86_64-pc-linux -emit-llvm -o - %s | FileCheck %s 
--implicit-check-not="call void @__sanitizer_"
+// RUN: %clang_cc1 -fsanitize=memory -fsanitize-memory-use-after-dtor 
-std=c++11 -triple=x86_64-pc-linux -emit-llvm -debug-info-kind=line-tables-only 
-o - %s | FileCheck %s --implicit-check-not="call void @__sanitizer_"
 
 // Sanitizing dtor is emitted in dtor for every class, and only
 // poisons once.
@@ -56,14 +56,20 @@ Defaulted_Non_Trivial def_non_trivial;
 // instrumentation inserted.
 // CHECK-LABEL: define {{.*}}SimpleD2Ev
 // CHECK-NOT: store i{{[0-9]+}} 0, {{.*}}@__msan_param_tls
-// CHECK: call void @__sanitizer_dtor_callback
+// CHECK: call void @__sanitizer_dtor_callback{{.*}}, !dbg ![[DI1:[0-9]+]]
 // CHECK: ret void
 
 // CHECK-LABEL: define {{.*}}InlinedD2Ev
 // CHECK-NOT: store i{{[0-9]+}} 0, {{.*}}@__msan_param_tls
-// CHECK: call void @__sanitizer_dtor_callback
+// CHECK: call void @__sanitizer_dtor_callback{{.*}}, !dbg ![[DI2:[0-9]+]]
 // CHECK: ret void
 
 // CHECK-LABEL: define {{.*}}Defaulted_Non_TrivialD2Ev
-// CHECK: call void @__sanitizer_dtor_callback
+// CHECK: call void @__sanitizer_dtor_callback{{.*}}, !dbg ![[DI3:[0-9]+]]
 // CHECK: ret void
+
+// CHECK-LABEL: !DIFile{{.*}}cpp
+

[PATCH] D132801: [driver] Additional ignoring of module-map related flags, if modules are disabled

2022-08-29 Thread Argyrios Kyrtzidis via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
akyrtzi marked an inline comment as done.
Closed by commit rG33162a81d4c9: [driver] Additional ignoring of module-map 
related flags, if modules are… (authored by akyrtzi).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132801

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/modules.m


Index: clang/test/Driver/modules.m
===
--- clang/test/Driver/modules.m
+++ clang/test/Driver/modules.m
@@ -75,8 +75,8 @@
 // RUN: %clang -fno-modules -fbuild-session-timestamp=123 -### %s 2>&1 | 
FileCheck -check-prefix=SESSION_FLAG %s
 // SESSION_FLAG-NOT: -fbuild-session-timestamp
 
-// RUN: %clang -fno-modules -fmodules-validate-once-per-build-session -### %s 
2>&1 | FileCheck -check-prefix=VALIDATE_ONCE_FLAG %s
-// VALIDATE_ONCE_FLAG-NOT: -fmodules-validate-once-per-build-session
-
-// RUN: %clang -fno-modules -fmodules-validate-system-headers -### %s 2>&1 | 
FileCheck -check-prefix=VALIDATE_SYSTEM_FLAG %s
-// VALIDATE_SYSTEM_FLAG-NOT: -fmodules-validate-system-headers
+// RUN: %clang -fno-modules -fmodules-validate-once-per-build-session 
-fmodules-validate-system-headers -fmodule-map-file=module.modulemap \
+// RUN:   -### %s 2>&1 | FileCheck -check-prefix=IGNORED_FLAGS %s
+// IGNORED_FLAGS-NOT: -fmodules-validate-once-per-build-session
+// IGNORED_FLAGS-NOT: -fmodules-validate-system-headers
+// IGNORED_FLAGS-NOT: -fmodule-map-file
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -3726,25 +3726,29 @@
  options::OPT_fno_modules_validate_input_files_content,
  false))
   CmdArgs.push_back("-fvalidate-ast-input-files-content");
-  }
-
-  // -fmodule-name specifies the module that is currently being built (or
-  // used for header checking by -fmodule-maps).
-  Args.AddLastArg(CmdArgs, options::OPT_fmodule_name_EQ);
 
-  // -fmodule-map-file can be used to specify files containing module
-  // definitions.
-  Args.AddAllArgs(CmdArgs, options::OPT_fmodule_map_file);
-
-  // -fbuiltin-module-map can be used to load the clang
-  // builtin headers modulemap file.
-  if (Args.hasArg(options::OPT_fbuiltin_module_map)) {
-SmallString<128> BuiltinModuleMap(D.ResourceDir);
-llvm::sys::path::append(BuiltinModuleMap, "include");
-llvm::sys::path::append(BuiltinModuleMap, "module.modulemap");
-if (llvm::sys::fs::exists(BuiltinModuleMap))
-  CmdArgs.push_back(
-  Args.MakeArgString("-fmodule-map-file=" + BuiltinModuleMap));
+// -fmodule-name specifies the module that is currently being built (or
+// used for header checking by -fmodule-maps).
+Args.AddLastArg(CmdArgs, options::OPT_fmodule_name_EQ);
+
+// -fmodule-map-file can be used to specify files containing module
+// definitions.
+Args.AddAllArgs(CmdArgs, options::OPT_fmodule_map_file);
+
+// -fbuiltin-module-map can be used to load the clang
+// builtin headers modulemap file.
+if (Args.hasArg(options::OPT_fbuiltin_module_map)) {
+  SmallString<128> BuiltinModuleMap(D.ResourceDir);
+  llvm::sys::path::append(BuiltinModuleMap, "include");
+  llvm::sys::path::append(BuiltinModuleMap, "module.modulemap");
+  if (llvm::sys::fs::exists(BuiltinModuleMap))
+CmdArgs.push_back(
+Args.MakeArgString("-fmodule-map-file=" + BuiltinModuleMap));
+}
+  } else {
+Args.ClaimAllArgs(options::OPT_fmodule_name_EQ);
+Args.ClaimAllArgs(options::OPT_fmodule_map_file);
+Args.ClaimAllArgs(options::OPT_fbuiltin_module_map);
   }
 
   // The -fmodule-file== form specifies the mapping of module


Index: clang/test/Driver/modules.m
===
--- clang/test/Driver/modules.m
+++ clang/test/Driver/modules.m
@@ -75,8 +75,8 @@
 // RUN: %clang -fno-modules -fbuild-session-timestamp=123 -### %s 2>&1 | FileCheck -check-prefix=SESSION_FLAG %s
 // SESSION_FLAG-NOT: -fbuild-session-timestamp
 
-// RUN: %clang -fno-modules -fmodules-validate-once-per-build-session -### %s 2>&1 | FileCheck -check-prefix=VALIDATE_ONCE_FLAG %s
-// VALIDATE_ONCE_FLAG-NOT: -fmodules-validate-once-per-build-session
-
-// RUN: %clang -fno-modules -fmodules-validate-system-headers -### %s 2>&1 | FileCheck -check-prefix=VALIDATE_SYSTEM_FLAG %s
-// VALIDATE_SYSTEM_FLAG-NOT: -fmodules-validate-system-headers
+// RUN: %clang -fno-modules -fmodules-validate-once-per-build-session -fmodules-validate-system-headers -fmodule-map-file=module.modulemap \
+// RUN:   -### %s 2>&1 | FileCheck -check-prefix=IGNORED_FLAGS %s
+// IGNORED_FLAGS-NOT: -fmodules-validate-once-per-build-session
+// IGNORED_FLAGS-NOT: -fmodules-validate-system-headers
+// 

[clang] 33162a8 - [driver] Additional ignoring of module-map related flags, if modules are disabled

2022-08-29 Thread Argyrios Kyrtzidis via cfe-commits

Author: Argyrios Kyrtzidis
Date: 2022-08-29T17:38:00-07:00
New Revision: 33162a81d4c93a53ef847d3601b0b03830937d3c

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

LOG: [driver] Additional ignoring of module-map related flags, if modules are 
disabled

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/Clang.cpp
clang/test/Driver/modules.m

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 1fa83e7121c95..401333a39025f 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -3726,25 +3726,29 @@ static void RenderModulesOptions(Compilation , const 
Driver ,
  options::OPT_fno_modules_validate_input_files_content,
  false))
   CmdArgs.push_back("-fvalidate-ast-input-files-content");
-  }
-
-  // -fmodule-name specifies the module that is currently being built (or
-  // used for header checking by -fmodule-maps).
-  Args.AddLastArg(CmdArgs, options::OPT_fmodule_name_EQ);
 
-  // -fmodule-map-file can be used to specify files containing module
-  // definitions.
-  Args.AddAllArgs(CmdArgs, options::OPT_fmodule_map_file);
-
-  // -fbuiltin-module-map can be used to load the clang
-  // builtin headers modulemap file.
-  if (Args.hasArg(options::OPT_fbuiltin_module_map)) {
-SmallString<128> BuiltinModuleMap(D.ResourceDir);
-llvm::sys::path::append(BuiltinModuleMap, "include");
-llvm::sys::path::append(BuiltinModuleMap, "module.modulemap");
-if (llvm::sys::fs::exists(BuiltinModuleMap))
-  CmdArgs.push_back(
-  Args.MakeArgString("-fmodule-map-file=" + BuiltinModuleMap));
+// -fmodule-name specifies the module that is currently being built (or
+// used for header checking by -fmodule-maps).
+Args.AddLastArg(CmdArgs, options::OPT_fmodule_name_EQ);
+
+// -fmodule-map-file can be used to specify files containing module
+// definitions.
+Args.AddAllArgs(CmdArgs, options::OPT_fmodule_map_file);
+
+// -fbuiltin-module-map can be used to load the clang
+// builtin headers modulemap file.
+if (Args.hasArg(options::OPT_fbuiltin_module_map)) {
+  SmallString<128> BuiltinModuleMap(D.ResourceDir);
+  llvm::sys::path::append(BuiltinModuleMap, "include");
+  llvm::sys::path::append(BuiltinModuleMap, "module.modulemap");
+  if (llvm::sys::fs::exists(BuiltinModuleMap))
+CmdArgs.push_back(
+Args.MakeArgString("-fmodule-map-file=" + BuiltinModuleMap));
+}
+  } else {
+Args.ClaimAllArgs(options::OPT_fmodule_name_EQ);
+Args.ClaimAllArgs(options::OPT_fmodule_map_file);
+Args.ClaimAllArgs(options::OPT_fbuiltin_module_map);
   }
 
   // The -fmodule-file== form specifies the mapping of module

diff  --git a/clang/test/Driver/modules.m b/clang/test/Driver/modules.m
index 4b67f7c7bec4f..7eaea1da5649f 100644
--- a/clang/test/Driver/modules.m
+++ b/clang/test/Driver/modules.m
@@ -75,8 +75,8 @@
 // RUN: %clang -fno-modules -fbuild-session-timestamp=123 -### %s 2>&1 | 
FileCheck -check-prefix=SESSION_FLAG %s
 // SESSION_FLAG-NOT: -fbuild-session-timestamp
 
-// RUN: %clang -fno-modules -fmodules-validate-once-per-build-session -### %s 
2>&1 | FileCheck -check-prefix=VALIDATE_ONCE_FLAG %s
-// VALIDATE_ONCE_FLAG-NOT: -fmodules-validate-once-per-build-session
-
-// RUN: %clang -fno-modules -fmodules-validate-system-headers -### %s 2>&1 | 
FileCheck -check-prefix=VALIDATE_SYSTEM_FLAG %s
-// VALIDATE_SYSTEM_FLAG-NOT: -fmodules-validate-system-headers
+// RUN: %clang -fno-modules -fmodules-validate-once-per-build-session 
-fmodules-validate-system-headers -fmodule-map-file=module.modulemap \
+// RUN:   -### %s 2>&1 | FileCheck -check-prefix=IGNORED_FLAGS %s
+// IGNORED_FLAGS-NOT: -fmodules-validate-once-per-build-session
+// IGNORED_FLAGS-NOT: -fmodules-validate-system-headers
+// IGNORED_FLAGS-NOT: -fmodule-map-file



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


[PATCH] D128095: [clang] Improve diagnostics for expansion length mismatch

2022-08-29 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov added inline comments.



Comment at: clang/lib/Sema/SemaTemplateVariadic.cpp:860
+} else if (const auto *ND = Unexpanded[I].first.get();
+   isa(ND)) {
+  // Function parameter pack or init-capture pack.

erichkeane wrote:
> This pattern with the init + condition is a little awkward here... any reason 
> to not just use the cast around the 'ND" and just use the VD in the use 
> below? or is there a good reason to split it up like this?
> 
> Same with the above case.
No very strong reason than that just from my different perception this looked 
fine :)

Minor advantage that we don't make the variable a VarDecl pointer if we don't 
need to access it as such.

But no strong preference here, I can have another look tomorrow.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128095

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


[PATCH] D128095: [clang] Improve diagnostics for expansion length mismatch

2022-08-29 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added inline comments.



Comment at: clang/lib/Sema/SemaTemplateVariadic.cpp:860
+} else if (const auto *ND = Unexpanded[I].first.get();
+   isa(ND)) {
+  // Function parameter pack or init-capture pack.

This pattern with the init + condition is a little awkward here... any reason 
to not just use the cast around the 'ND" and just use the VD in the use below? 
or is there a good reason to split it up like this?

Same with the above case.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128095

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


[PATCH] D128095: [clang] Improve diagnostics for expansion length mismatch

2022-08-29 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov retitled this revision from "WIP: [clang] Improve diagnostics for 
expansion length mismatch" to "[clang] Improve diagnostics for expansion length 
mismatch".
mizvekov updated this revision to Diff 456495.
mizvekov marked 5 inline comments as done.
mizvekov requested review of this revision.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128095

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Sema/Sema.h
  clang/include/clang/Sema/SemaInternal.h
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/lib/Sema/SemaTemplateVariadic.cpp
  clang/test/CXX/temp/temp.decls/temp.variadic/p5.cpp
  clang/test/SemaTemplate/cxx1z-fold-expressions.cpp
  clang/test/SemaTemplate/pack-deduction.cpp

Index: clang/test/SemaTemplate/pack-deduction.cpp
===
--- clang/test/SemaTemplate/pack-deduction.cpp
+++ clang/test/SemaTemplate/pack-deduction.cpp
@@ -134,14 +134,14 @@
   template struct tuple {};
   template struct A {
 template static pair, tuple> f(pair ...p);
-// expected-note@-1 {{[with U = ]: pack expansion contains parameter pack 'U' that has a different length (2 vs. 3) from outer parameter packs}}
+// expected-note@-1 {{[with U = ]: pack expansion contains parameter packs 'T' and 'U' that have different lengths (2 vs. 3)}}
 // expected-note@-2 {{[with U = ]: pack expansion contains parameter pack 'U' that has a different length (at least 3 vs. 2) from outer parameter packs}}
 
 template static pair, tuple> g(pair ...p, ...);
-// expected-note@-1 {{[with U = ]: pack expansion contains parameter pack 'U' that has a different length (2 vs. 3) from outer parameter packs}}
+// expected-note@-1 {{[with U = ]: pack expansion contains parameter packs 'T' and 'U' that have different lengths (2 vs. 3)}}
 
 template static tuple h(tuple..., pair>);
-// expected-note@-1 {{[with U = ]: pack expansion contains parameter pack 'U' that has a different length (2 vs. 1) from outer parameter packs}}
+// expected-note@-1 {{[with U = ]: pack expansion contains parameter packs 'T' and 'U' that have different lengths (2 vs. 1)}}
   };
 
   pair, tuple> k1 = A().f(pair(), pair());
Index: clang/test/SemaTemplate/cxx1z-fold-expressions.cpp
===
--- clang/test/SemaTemplate/cxx1z-fold-expressions.cpp
+++ clang/test/SemaTemplate/cxx1z-fold-expressions.cpp
@@ -97,7 +97,7 @@
   template  struct Constant {};
 
   template  struct Sum {
-template  using type = Constant<((Is + Js) + ... + 0)>; // expected-error {{pack expansion contains parameter pack 'Js' that has a different length (1 vs. 2) from outer parameter packs}}
+template  using type = Constant<((Is + Js) + ... + 0)>; // expected-error {{pack expansion contains parameter packs 'Is' and 'Js' that have different lengths (1 vs. 2)}}
   };
 
   Sum<1>::type<1, 2> x; // expected-note {{instantiation of}}
Index: clang/test/CXX/temp/temp.decls/temp.variadic/p5.cpp
===
--- clang/test/CXX/temp/temp.decls/temp.variadic/p5.cpp
+++ clang/test/CXX/temp/temp.decls/temp.variadic/p5.cpp
@@ -473,7 +473,7 @@
 namespace pr56094 {
 template  struct D {
   template  using B = int(int (*...p)(T, U));
-  // expected-error@-1 {{pack expansion contains parameter pack 'U' that has a different length (1 vs. 2) from outer parameter packs}}
+  // expected-error@-1 {{pack expansion contains parameter packs 'T' and 'U' that have different lengths (1 vs. 2)}}
   template  D(B *);
   // expected-note@-1 {{in instantiation of template type alias 'B' requested here}}
 };
@@ -484,7 +484,7 @@
 template  struct G {};
 template  struct E {
   template  using B = G...>;
-  // expected-error@-1 {{pack expansion contains parameter pack 'U' that has a different length (1 vs. 2) from outer parameter packs}}
+  // expected-error@-1 {{pack expansion contains parameter packs 'I' and 'U' that have different lengths (1 vs. 2)}}
   template  E(B *);
   // expected-note@-1 {{in instantiation of template type alias 'B' requested here}}
 };
Index: clang/lib/Sema/SemaTemplateVariadic.cpp
===
--- clang/lib/Sema/SemaTemplateVariadic.cpp
+++ clang/lib/Sema/SemaTemplateVariadic.cpp
@@ -88,6 +88,23 @@
   return true;
 }
 
+bool
+VisitSubstTemplateTypeParmPackTypeLoc(SubstTemplateTypeParmPackTypeLoc TL) {
+  Unexpanded.push_back({TL.getTypePtr(), TL.getNameLoc()});
+  return true;
+}
+
+bool VisitSubstTemplateTypeParmPackType(SubstTemplateTypeParmPackType *T) {
+  Unexpanded.push_back({T, SourceLocation()});
+  return true;
+}
+
+bool
+VisitSubstNonTypeTemplateParmPackExpr(SubstNonTypeTemplateParmPackExpr *E) {
+  Unexpanded.push_back({E, E->getParameterPackLocation()});
+  return true;
+

[PATCH] D128095: WIP: [clang] Improve diagnostics for expansion length mismatch

2022-08-29 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov retitled this revision from "[clang] Improve diagnostics for expansion 
length mismatch" to "WIP: [clang] Improve diagnostics for expansion length 
mismatch".
mizvekov updated this revision to Diff 456494.
mizvekov planned changes to this revision.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128095

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Sema/Sema.h
  clang/include/clang/Sema/SemaInternal.h
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/lib/Sema/SemaTemplateVariadic.cpp
  clang/test/CXX/temp/temp.decls/temp.variadic/p5.cpp
  clang/test/SemaTemplate/cxx1z-fold-expressions.cpp
  clang/test/SemaTemplate/pack-deduction.cpp

Index: clang/test/SemaTemplate/pack-deduction.cpp
===
--- clang/test/SemaTemplate/pack-deduction.cpp
+++ clang/test/SemaTemplate/pack-deduction.cpp
@@ -134,14 +134,14 @@
   template struct tuple {};
   template struct A {
 template static pair, tuple> f(pair ...p);
-// expected-note@-1 {{[with U = ]: pack expansion contains parameter pack 'U' that has a different length (2 vs. 3) from outer parameter packs}}
+// expected-note@-1 {{[with U = ]: pack expansion contains parameter packs 'T' and 'U' that have different lengths (2 vs. 3)}}
 // expected-note@-2 {{[with U = ]: pack expansion contains parameter pack 'U' that has a different length (at least 3 vs. 2) from outer parameter packs}}
 
 template static pair, tuple> g(pair ...p, ...);
-// expected-note@-1 {{[with U = ]: pack expansion contains parameter pack 'U' that has a different length (2 vs. 3) from outer parameter packs}}
+// expected-note@-1 {{[with U = ]: pack expansion contains parameter packs 'T' and 'U' that have different lengths (2 vs. 3)}}
 
 template static tuple h(tuple..., pair>);
-// expected-note@-1 {{[with U = ]: pack expansion contains parameter pack 'U' that has a different length (2 vs. 1) from outer parameter packs}}
+// expected-note@-1 {{[with U = ]: pack expansion contains parameter packs 'T' and 'U' that have different lengths (2 vs. 1)}}
   };
 
   pair, tuple> k1 = A().f(pair(), pair());
Index: clang/test/SemaTemplate/cxx1z-fold-expressions.cpp
===
--- clang/test/SemaTemplate/cxx1z-fold-expressions.cpp
+++ clang/test/SemaTemplate/cxx1z-fold-expressions.cpp
@@ -97,7 +97,7 @@
   template  struct Constant {};
 
   template  struct Sum {
-template  using type = Constant<((Is + Js) + ... + 0)>; // expected-error {{pack expansion contains parameter pack 'Js' that has a different length (1 vs. 2) from outer parameter packs}}
+template  using type = Constant<((Is + Js) + ... + 0)>; // expected-error {{pack expansion contains parameter packs 'Is' and 'Js' that have different lengths (1 vs. 2)}}
   };
 
   Sum<1>::type<1, 2> x; // expected-note {{instantiation of}}
Index: clang/test/CXX/temp/temp.decls/temp.variadic/p5.cpp
===
--- clang/test/CXX/temp/temp.decls/temp.variadic/p5.cpp
+++ clang/test/CXX/temp/temp.decls/temp.variadic/p5.cpp
@@ -473,7 +473,7 @@
 namespace pr56094 {
 template  struct D {
   template  using B = int(int (*...p)(T, U));
-  // expected-error@-1 {{pack expansion contains parameter pack 'U' that has a different length (1 vs. 2) from outer parameter packs}}
+  // expected-error@-1 {{pack expansion contains parameter packs 'T' and 'U' that have different lengths (1 vs. 2)}}
   template  D(B *);
   // expected-note@-1 {{in instantiation of template type alias 'B' requested here}}
 };
@@ -484,7 +484,7 @@
 template  struct G {};
 template  struct E {
   template  using B = G...>;
-  // expected-error@-1 {{pack expansion contains parameter pack 'U' that has a different length (1 vs. 2) from outer parameter packs}}
+  // expected-error@-1 {{pack expansion contains parameter packs 'I' and 'U' that have different lengths (1 vs. 2)}}
   template  E(B *);
   // expected-note@-1 {{in instantiation of template type alias 'B' requested here}}
 };
Index: clang/lib/Sema/SemaTemplateVariadic.cpp
===
--- clang/lib/Sema/SemaTemplateVariadic.cpp
+++ clang/lib/Sema/SemaTemplateVariadic.cpp
@@ -88,6 +88,23 @@
   return true;
 }
 
+bool
+VisitSubstTemplateTypeParmPackTypeLoc(SubstTemplateTypeParmPackTypeLoc TL) {
+  Unexpanded.push_back({TL.getTypePtr(), TL.getNameLoc()});
+  return true;
+}
+
+bool VisitSubstTemplateTypeParmPackType(SubstTemplateTypeParmPackType *T) {
+  Unexpanded.push_back({T, SourceLocation()});
+  return true;
+}
+
+bool
+VisitSubstNonTypeTemplateParmPackExpr(SubstNonTypeTemplateParmPackExpr *E) {
+  Unexpanded.push_back({E, E->getParameterPackLocation()});
+  return true;
+}
+
 /// Record occurrences of function 

[PATCH] D132600: [llvm-profdata] Handle internal linkage functions in profile supplementation

2022-08-29 Thread Rong Xu 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 rGdb18f26567be: [llvm-profdata] Handle internal linkage 
functions in profile supplementation (authored by xur).
Herald added a project: clang.

Changed prior to commit:
  https://reviews.llvm.org/D132600?vs=455816=456490#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132600

Files:
  clang/lib/CodeGen/CodeGenModule.cpp
  llvm/include/llvm/ProfileData/SampleProf.h
  llvm/test/tools/llvm-profdata/Inputs/FUnique.afdotext
  llvm/test/tools/llvm-profdata/Inputs/FUnique.proftext
  llvm/test/tools/llvm-profdata/Inputs/NoFUnique.afdotext
  llvm/test/tools/llvm-profdata/Inputs/NoFUnique.proftext
  llvm/test/tools/llvm-profdata/suppl-instr-with-sample-static-func.test
  llvm/tools/llvm-profdata/llvm-profdata.cpp

Index: llvm/tools/llvm-profdata/llvm-profdata.cpp
===
--- llvm/tools/llvm-profdata/llvm-profdata.cpp
+++ llvm/tools/llvm-profdata/llvm-profdata.cpp
@@ -31,6 +31,7 @@
 #include "llvm/Support/Format.h"
 #include "llvm/Support/FormattedStream.h"
 #include "llvm/Support/InitLLVM.h"
+#include "llvm/Support/MD5.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/ThreadPool.h"
@@ -42,6 +43,10 @@
 
 using namespace llvm;
 
+// We use this string to indicate that there are
+// multiple static functions map to the same name.
+const std::string DuplicateNameStr = "";
+
 enum ProfileFormat {
   PF_None = 0,
   PF_Text,
@@ -480,7 +485,7 @@
   NumEdgeCounters = CntNum;
 }
 
-/// Either set all the counters in the instr profile entry \p IFE to -1
+// Either set all the counters in the instr profile entry \p IFE to -1
 /// in order to drop the profile or scale up the counters in \p IFP to
 /// be above hot threshold. We use the ratio of zero counters in the
 /// profile of a function to decide the profile is helpful or harmful
@@ -541,7 +546,73 @@
unsigned InstrProfColdThreshold) {
   // Function to its entry in instr profile.
   StringMap InstrProfileMap;
+  StringMap StaticFuncMap;
   InstrProfSummaryBuilder IPBuilder(ProfileSummaryBuilder::DefaultCutoffs);
+
+  auto checkSampleProfileHasFUnique = []() {
+for (const auto  : Reader->getProfiles()) {
+  auto  = PD.first;
+  if (FContext.toString().find(FunctionSamples::UniqSuffix) !=
+  std::string::npos) {
+return true;
+  }
+}
+return false;
+  };
+
+  bool SampleProfileHasFUnique = checkSampleProfileHasFUnique();
+
+  auto buildStaticFuncMap = [,
+ SampleProfileHasFUnique](const StringRef Name) {
+std::string Prefixes[] = {".cpp:", "cc:", ".c:", ".hpp:", ".h:"};
+size_t PrefixPos = StringRef::npos;
+for (auto  : Prefixes) {
+  PrefixPos = Name.find_insensitive(Prefix);
+  if (PrefixPos == StringRef::npos)
+continue;
+  PrefixPos += Prefix.size();
+  break;
+}
+
+if (PrefixPos == StringRef::npos) {
+  return;
+}
+
+StringRef NewName = Name.drop_front(PrefixPos);
+StringRef FName = Name.substr(0, PrefixPos - 1);
+if (NewName.size() == 0) {
+  return;
+}
+
+// This name should have a static linkage.
+size_t PostfixPos = NewName.find(FunctionSamples::UniqSuffix);
+bool ProfileHasFUnique = (PostfixPos != StringRef::npos);
+
+// If sample profile and instrumented profile do not agree on symbol
+// uniqification.
+if (SampleProfileHasFUnique != ProfileHasFUnique) {
+  // If instrumented profile uses -funique-internal-linakge-symbols,
+  // we need to trim the name.
+  if (ProfileHasFUnique) {
+NewName = NewName.substr(0, PostfixPos);
+  } else {
+// If sample profile uses -funique-internal-linakge-symbols,
+// we build the map.
+std::string NStr =
+NewName.str() + getUniqueInternalLinkagePostfix(FName);
+NewName = StringRef(NStr);
+StaticFuncMap[NewName] = Name;
+return;
+  }
+}
+
+if (StaticFuncMap.find(NewName) == StaticFuncMap.end()) {
+  StaticFuncMap[NewName] = Name;
+} else {
+  StaticFuncMap[NewName] = DuplicateNameStr;
+}
+  };
+
   for (auto  : WC->Writer.getProfileData()) {
 // Populate IPBuilder.
 for (const auto  : PD.getValue()) {
@@ -555,7 +626,9 @@
 
 // Initialize InstrProfileMap.
 InstrProfRecord *R = ().begin()->second;
-InstrProfileMap[PD.getKey()] = InstrProfileEntry(R);
+StringRef FullName = PD.getKey();
+InstrProfileMap[FullName] = InstrProfileEntry(R);
+buildStaticFuncMap(FullName);
   }
 
   ProfileSummary InstrPS = *IPBuilder.getSummary();
@@ -583,16 +656,28 @@
   // Find hot/warm functions in sample profile which is cold in instr profile
   // and adjust the profiles of those 

[clang] db18f26 - [llvm-profdata] Handle internal linkage functions in profile supplementation

2022-08-29 Thread Rong Xu via cfe-commits

Author: Rong Xu
Date: 2022-08-29T16:15:12-07:00
New Revision: db18f26567be47ec1da7fba48179a3001f0d34ab

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

LOG: [llvm-profdata] Handle internal linkage functions in profile 
supplementation

This patch has the following changes:
(1) Handling of internal linkage functions (static functions)
Static functions in FDO have a prefix of source file name, while they do not
have one in SampleFDO. Current implementation does not handle this and we are
not updating the profile for static functions. This patch fixes this.

(2) Handling of -funique-internal-linakge-symbols
Again this is for the internal linkage functions. Option
-funique-internal-linakge-symbols can now be applied to both FDO and SampleFDO
compilation. When it is used, it demangles internal linkage function names and
adds a hash value as the postfix.

When both SampleFDO and FDO profiles use this option, or both
not use this option, changes in (1) should handle this.

Here we also handle when the SampleFDO profile using this option while FDO
profile not using this option, or vice versa.

There is one case where this patch won't work: If one of the profiles used
mangled name and the other does not. For example, if the SampleFDO profile
uses clang c-compiler and without -funique-internal-linakge-symbols, while
the FDO profile uses -funique-internal-linakge-symbols. The SampleFDO profile
contains unmangled names while the FDO profile contains mangled names. If
both profiles use c++ compiler, this won't happen. We think this use case
is rare and does not justify the effort to fix.

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

Added: 
llvm/test/tools/llvm-profdata/Inputs/FUnique.afdotext
llvm/test/tools/llvm-profdata/Inputs/FUnique.proftext
llvm/test/tools/llvm-profdata/Inputs/NoFUnique.afdotext
llvm/test/tools/llvm-profdata/Inputs/NoFUnique.proftext
llvm/test/tools/llvm-profdata/suppl-instr-with-sample-static-func.test

Modified: 
clang/lib/CodeGen/CodeGenModule.cpp
llvm/include/llvm/ProfileData/SampleProf.h
llvm/tools/llvm-profdata/llvm-profdata.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index 62e906a87af48..bb0970e3e36fa 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -60,12 +60,12 @@
 #include "llvm/IR/Module.h"
 #include "llvm/IR/ProfileSummary.h"
 #include "llvm/ProfileData/InstrProfReader.h"
+#include "llvm/ProfileData/SampleProf.h"
 #include "llvm/Support/CRC.h"
 #include "llvm/Support/CodeGen.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/ConvertUTF.h"
 #include "llvm/Support/ErrorHandling.h"
-#include "llvm/Support/MD5.h"
 #include "llvm/Support/TimeProfiler.h"
 #include "llvm/Support/X86TargetParser.h"
 #include "llvm/Support/xxhash.h"
@@ -208,22 +208,7 @@ CodeGenModule::CodeGenModule(ASTContext ,
 Path = Entry.second + Path.substr(Entry.first.size());
 break;
   }
-llvm::MD5 Md5;
-Md5.update(Path);
-llvm::MD5::MD5Result R;
-Md5.final(R);
-SmallString<32> Str;
-llvm::MD5::stringifyResult(R, Str);
-// Convert MD5hash to Decimal. Demangler suffixes can either contain
-// numbers or characters but not both.
-llvm::APInt IntHash(128, Str.str(), 16);
-// Prepend "__uniq" before the hash for tools like profilers to understand
-// that this symbol is of internal linkage type.  The "__uniq" is the
-// pre-determined prefix that is used to tell tools that this symbol was
-// created with -funique-internal-linakge-symbols and the tools can strip 
or
-// keep the prefix as needed.
-ModuleNameHash = (Twine(".__uniq.") +
-Twine(toString(IntHash, /* Radix = */ 10, /* Signed = */false))).str();
+ModuleNameHash = llvm::getUniqueInternalLinkagePostfix(Path);
   }
 }
 

diff  --git a/llvm/include/llvm/ProfileData/SampleProf.h 
b/llvm/include/llvm/ProfileData/SampleProf.h
index 1ad83c2f5b5af..a82b4544199fc 100644
--- a/llvm/include/llvm/ProfileData/SampleProf.h
+++ b/llvm/include/llvm/ProfileData/SampleProf.h
@@ -16,6 +16,7 @@
 
 #include "llvm/ADT/DenseSet.h"
 #include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringMap.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/IR/Function.h"
@@ -1331,6 +1332,26 @@ template <> struct DenseMapInfo {
 return LHS == RHS;
   }
 };
+
+// Prepend "__uniq" before the hash for tools like profilers to understand
+// that this symbol is of internal linkage type.  The "__uniq" is the
+// pre-determined prefix that is used to tell tools that this symbol was
+// created with -funique-internal-linakge-symbols and the tools can strip or
+// keep the prefix as 

[PATCH] D130096: [Clang][AMDGPU] Emit AMDGPU library control constants in clang

2022-08-29 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

If you want to overwrite them, weak/linkonce will work (no _odr). 
Private/internal will not be overwritten but existing uses will keep the 
private/internal version, IIRC. I assume you want the former.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130096

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


[PATCH] D132801: [driver] Additional ignoring of module-map related flags, if modules are disabled

2022-08-29 Thread Argyrios Kyrtzidis via Phabricator via cfe-commits
akyrtzi marked an inline comment as done.
akyrtzi added inline comments.



Comment at: clang/test/Driver/modules.m:81
 
 // RUN: %clang -fno-modules -fmodules-validate-system-headers -### %s 2>&1 | 
FileCheck -check-prefix=VALIDATE_SYSTEM_FLAG %s
 // VALIDATE_SYSTEM_FLAG-NOT: -fmodules-validate-system-headers

MaskRay wrote:
> You may combine `-fmodule-map-file=module.modulemap` with this RUN line to 
> avoid introducing a new RUN line (every run makes testsuite slightly slower).
Good suggestion, I merged the last existing 2 `RUN` lines along with the new 
one.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132801

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


[PATCH] D132801: [driver] Additional ignoring of module-map related flags, if modules are disabled

2022-08-29 Thread Argyrios Kyrtzidis via Phabricator via cfe-commits
akyrtzi updated this revision to Diff 456483.
akyrtzi added a comment.

Merge the new `RUN` line together with the prior 2.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132801

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/modules.m


Index: clang/test/Driver/modules.m
===
--- clang/test/Driver/modules.m
+++ clang/test/Driver/modules.m
@@ -75,8 +75,8 @@
 // RUN: %clang -fno-modules -fbuild-session-timestamp=123 -### %s 2>&1 | 
FileCheck -check-prefix=SESSION_FLAG %s
 // SESSION_FLAG-NOT: -fbuild-session-timestamp
 
-// RUN: %clang -fno-modules -fmodules-validate-once-per-build-session -### %s 
2>&1 | FileCheck -check-prefix=VALIDATE_ONCE_FLAG %s
-// VALIDATE_ONCE_FLAG-NOT: -fmodules-validate-once-per-build-session
-
-// RUN: %clang -fno-modules -fmodules-validate-system-headers -### %s 2>&1 | 
FileCheck -check-prefix=VALIDATE_SYSTEM_FLAG %s
-// VALIDATE_SYSTEM_FLAG-NOT: -fmodules-validate-system-headers
+// RUN: %clang -fno-modules -fmodules-validate-once-per-build-session 
-fmodules-validate-system-headers -fmodule-map-file=module.modulemap \
+// RUN:   -### %s 2>&1 | FileCheck -check-prefix=IGNORED_FLAGS %s
+// IGNORED_FLAGS-NOT: -fmodules-validate-once-per-build-session
+// IGNORED_FLAGS-NOT: -fmodules-validate-system-headers
+// IGNORED_FLAGS-NOT: -fmodule-map-file
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -3726,25 +3726,29 @@
  options::OPT_fno_modules_validate_input_files_content,
  false))
   CmdArgs.push_back("-fvalidate-ast-input-files-content");
-  }
-
-  // -fmodule-name specifies the module that is currently being built (or
-  // used for header checking by -fmodule-maps).
-  Args.AddLastArg(CmdArgs, options::OPT_fmodule_name_EQ);
 
-  // -fmodule-map-file can be used to specify files containing module
-  // definitions.
-  Args.AddAllArgs(CmdArgs, options::OPT_fmodule_map_file);
-
-  // -fbuiltin-module-map can be used to load the clang
-  // builtin headers modulemap file.
-  if (Args.hasArg(options::OPT_fbuiltin_module_map)) {
-SmallString<128> BuiltinModuleMap(D.ResourceDir);
-llvm::sys::path::append(BuiltinModuleMap, "include");
-llvm::sys::path::append(BuiltinModuleMap, "module.modulemap");
-if (llvm::sys::fs::exists(BuiltinModuleMap))
-  CmdArgs.push_back(
-  Args.MakeArgString("-fmodule-map-file=" + BuiltinModuleMap));
+// -fmodule-name specifies the module that is currently being built (or
+// used for header checking by -fmodule-maps).
+Args.AddLastArg(CmdArgs, options::OPT_fmodule_name_EQ);
+
+// -fmodule-map-file can be used to specify files containing module
+// definitions.
+Args.AddAllArgs(CmdArgs, options::OPT_fmodule_map_file);
+
+// -fbuiltin-module-map can be used to load the clang
+// builtin headers modulemap file.
+if (Args.hasArg(options::OPT_fbuiltin_module_map)) {
+  SmallString<128> BuiltinModuleMap(D.ResourceDir);
+  llvm::sys::path::append(BuiltinModuleMap, "include");
+  llvm::sys::path::append(BuiltinModuleMap, "module.modulemap");
+  if (llvm::sys::fs::exists(BuiltinModuleMap))
+CmdArgs.push_back(
+Args.MakeArgString("-fmodule-map-file=" + BuiltinModuleMap));
+}
+  } else {
+Args.ClaimAllArgs(options::OPT_fmodule_name_EQ);
+Args.ClaimAllArgs(options::OPT_fmodule_map_file);
+Args.ClaimAllArgs(options::OPT_fbuiltin_module_map);
   }
 
   // The -fmodule-file== form specifies the mapping of module


Index: clang/test/Driver/modules.m
===
--- clang/test/Driver/modules.m
+++ clang/test/Driver/modules.m
@@ -75,8 +75,8 @@
 // RUN: %clang -fno-modules -fbuild-session-timestamp=123 -### %s 2>&1 | FileCheck -check-prefix=SESSION_FLAG %s
 // SESSION_FLAG-NOT: -fbuild-session-timestamp
 
-// RUN: %clang -fno-modules -fmodules-validate-once-per-build-session -### %s 2>&1 | FileCheck -check-prefix=VALIDATE_ONCE_FLAG %s
-// VALIDATE_ONCE_FLAG-NOT: -fmodules-validate-once-per-build-session
-
-// RUN: %clang -fno-modules -fmodules-validate-system-headers -### %s 2>&1 | FileCheck -check-prefix=VALIDATE_SYSTEM_FLAG %s
-// VALIDATE_SYSTEM_FLAG-NOT: -fmodules-validate-system-headers
+// RUN: %clang -fno-modules -fmodules-validate-once-per-build-session -fmodules-validate-system-headers -fmodule-map-file=module.modulemap \
+// RUN:   -### %s 2>&1 | FileCheck -check-prefix=IGNORED_FLAGS %s
+// IGNORED_FLAGS-NOT: -fmodules-validate-once-per-build-session
+// IGNORED_FLAGS-NOT: -fmodules-validate-system-headers
+// IGNORED_FLAGS-NOT: -fmodule-map-file
Index: clang/lib/Driver/ToolChains/Clang.cpp

[PATCH] D132762: [clang-format] Allow `throw` to be a keyword in front of casts

2022-08-29 Thread Emilia Dreamer via Phabricator via cfe-commits
rymiel updated this revision to Diff 456480.
rymiel added a comment.

Add extra tests for spacing options


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132762

Files:
  clang/lib/Format/TokenAnnotator.cpp
  clang/unittests/Format/FormatTest.cpp
  clang/unittests/Format/TokenAnnotatorTest.cpp


Index: clang/unittests/Format/TokenAnnotatorTest.cpp
===
--- clang/unittests/Format/TokenAnnotatorTest.cpp
+++ clang/unittests/Format/TokenAnnotatorTest.cpp
@@ -308,6 +308,34 @@
   EXPECT_TOKEN(Tokens[7], tok::r_paren, TT_CastRParen);
 }
 
+TEST_F(TokenAnnotatorTest, UnderstandsCasts) {
+  auto Tokens = annotate("(void)p;");
+  EXPECT_EQ(Tokens.size(), 6u) << Tokens;
+  EXPECT_TOKEN(Tokens[2], tok::r_paren, TT_CastRParen);
+
+  Tokens = annotate("auto x = (Foo)p;");
+  EXPECT_EQ(Tokens.size(), 9u) << Tokens;
+  EXPECT_TOKEN(Tokens[5], tok::r_paren, TT_CastRParen);
+
+  Tokens = annotate("(std::vector)p;");
+  EXPECT_EQ(Tokens.size(), 11u) << Tokens;
+  EXPECT_TOKEN(Tokens[7], tok::r_paren, TT_CastRParen);
+
+  Tokens = annotate("return (Foo)p;");
+  EXPECT_EQ(Tokens.size(), 7u) << Tokens;
+  EXPECT_TOKEN(Tokens[3], tok::r_paren, TT_CastRParen);
+
+  Tokens = annotate("throw (Foo)p;");
+  EXPECT_EQ(Tokens.size(), 7u) << Tokens;
+  EXPECT_TOKEN(Tokens[3], tok::r_paren, TT_CastRParen);
+}
+
+TEST_F(TokenAnnotatorTest, UnderstandsDynamicExceptionSpecifier) {
+  auto Tokens = annotate("void f() throw(int);");
+  EXPECT_EQ(Tokens.size(), 10u) << Tokens;
+  EXPECT_TOKEN(Tokens[4], tok::kw_throw, TT_Unknown);
+}
+
 TEST_F(TokenAnnotatorTest, UnderstandsFunctionRefQualifiers) {
   auto Tokens = annotate("void f() &;");
   EXPECT_EQ(Tokens.size(), 7u) << Tokens;
Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -10958,6 +10958,7 @@
   verifyFormat("my_int a = (my_int)2.0f;");
   verifyFormat("my_int a = (my_int)sizeof(int);");
   verifyFormat("return (my_int)aaa;");
+  verifyFormat("throw (my_int)aaa;");
   verifyFormat("#define x ((int)-1)");
   verifyFormat("#define LENGTH(x, y) (x) - (y) + 1");
   verifyFormat("#define p(q) ((int *))");
@@ -15650,6 +15651,7 @@
   verifyFormat("Type *A = ( Type * )P;", Spaces);
   verifyFormat("Type *A = ( vector )P;", Spaces);
   verifyFormat("x = ( int32 )y;", Spaces);
+  verifyFormat("throw ( int32 )x;", Spaces);
   verifyFormat("int a = ( int )(2.0f);", Spaces);
   verifyFormat("#define AA(X) sizeof((( X * )NULL)->a)", Spaces);
   verifyFormat("my_int a = ( my_int )sizeof(int);", Spaces);
@@ -15713,6 +15715,7 @@
   verifyFormat("#define CONF_BOOL(x) ( bool ) (x)", Spaces);
   verifyFormat("bool *y = ( bool * ) ( void * ) (x);", Spaces);
   verifyFormat("bool *y = ( bool * ) (x);", Spaces);
+  verifyFormat("throw ( int32 ) x;", Spaces);
 
   // Run subset of tests again with:
   Spaces.SpacesInCStyleCastParentheses = false;
@@ -15737,6 +15740,8 @@
   verifyFormat("bool *y = (bool *) (void *) (x);", Spaces);
   verifyFormat("bool *y = (bool *) (void *) (int) (x);", Spaces);
   verifyFormat("bool *y = (bool *) (void *) (int) foo(x);", Spaces);
+  verifyFormat("throw (int32) x;", Spaces);
+
   Spaces.ColumnLimit = 80;
   Spaces.IndentWidth = 4;
   Spaces.AlignAfterOpenBracket = FormatStyle::BAS_AlwaysBreak;
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -2153,7 +2153,7 @@
   // before the parentheses, this is unlikely to be a cast.
   if (LeftOfParens->Tok.getIdentifierInfo() &&
   !LeftOfParens->isOneOf(Keywords.kw_in, tok::kw_return, tok::kw_case,
- tok::kw_delete)) {
+ tok::kw_delete, tok::kw_throw)) {
 return false;
   }
 
@@ -3312,6 +3312,10 @@
   !Right.isOneOf(tok::semi, tok::r_paren, tok::hashhash)) {
 return true;
   }
+  if (Left.is(tok::kw_throw) && Right.is(tok::l_paren) && Right.MatchingParen 
&&
+  Right.MatchingParen->is(TT_CastRParen)) {
+return true;
+  }
   if (Style.isJson() && Left.is(tok::string_literal) && Right.is(tok::colon))
 return false;
   if (Left.is(Keywords.kw_assert) && Style.Language == FormatStyle::LK_Java)


Index: clang/unittests/Format/TokenAnnotatorTest.cpp
===
--- clang/unittests/Format/TokenAnnotatorTest.cpp
+++ clang/unittests/Format/TokenAnnotatorTest.cpp
@@ -308,6 +308,34 @@
   EXPECT_TOKEN(Tokens[7], tok::r_paren, TT_CastRParen);
 }
 
+TEST_F(TokenAnnotatorTest, UnderstandsCasts) {
+  auto Tokens = annotate("(void)p;");
+  EXPECT_EQ(Tokens.size(), 6u) << Tokens;
+  EXPECT_TOKEN(Tokens[2], tok::r_paren, TT_CastRParen);
+
+  Tokens = 

[clang] 79fe9aa - [Driver] Fix & re-enable DriverKit test

2022-08-29 Thread Julian Lettner via cfe-commits

Author: Julian Lettner
Date: 2022-08-29T15:05:22-07:00
New Revision: 79fe9aaf6a7b13e23492e900c7ff5b9659df5544

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

LOG: [Driver] Fix & re-enable DriverKit test

This reverts commit ce6989fd8a9fb2608f670de023fdd4611f47b811.

Added: 


Modified: 
clang/test/Driver/driverkit-path.c

Removed: 




diff  --git a/clang/test/Driver/driverkit-path.c 
b/clang/test/Driver/driverkit-path.c
index 0aa3e958b2908..0b752b1fc9c41 100644
--- a/clang/test/Driver/driverkit-path.c
+++ b/clang/test/Driver/driverkit-path.c
@@ -1,7 +1,7 @@
 // REQUIRES: x86-registered-target
-// REQUIRES: darwin
-// FIXME: Breaks on non-macOS:
-//http://45.33.8.238/linux/85125/step_7.txt
+// UNSUPPORTED: system-windows
+//   Windows is unsupported because we use the Unix path separator `\`.
+
 // RUN: %clang %s -target x86_64-apple-driverkit19.0 -mlinker-version=0 \
 // RUN:   -isysroot %S/Inputs/DriverKit19.0.sdk -### 2>&1   \
 // RUN: | FileCheck %s --check-prefix=LD64-OLD
@@ -25,7 +25,6 @@ int main() { return 0; }
 
 
 // RUN: %clang %s -target x86_64-apple-driverkit19.0 -isysroot 
%S/Inputs/DriverKit19.0.sdk -E -v -x c++ 2>&1 | FileCheck %s --check-prefix=INC
-// RUN: %clang %s -arch x86_64   -isysroot 
%S/Inputs/DriverKit19.0.sdk -E -v -x c++ 2>&1 | FileCheck %s --check-prefix=INC
 //
 // INC:   -isysroot [[PATH:[^ ]*/Inputs/DriverKit19.0.sdk]]
 // INC-LABEL: #include <...> search starts here:



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


[PATCH] D132550: Changes to code ownership in clang and clang-tidy

2022-08-29 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai added inline comments.



Comment at: clang/CODE_OWNERS.TXT:128
+H: Bigcheese
+D: Modules & Serialization
 

I can also help with Modules & Serialization. Maybe more with deserialization 
and incorporating the deserialized AST with existing AST.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132550

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


[PATCH] D132848: [clang] Fix checking for emulated TLS in shouldAssumeDSOLocal in CodeGen

2022-08-29 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

I'm not really happy with the way this implicitly ties the implementation of 
this function to the implementation of TargetMachine::useEmulatedTLS().  I'd 
prefer to just make clang always explicitly compute whether EmullatedTLS is 
enabled, then always set ExplicitEmulatedTLS, so the backend can't choose 
something different from what the frontend thinks it should be using.  (So we 
always call hasDefaultEmulatedTLS() if we can't find an femulated-tls flag in 
CompilerInvocation.  And the ExplicitEmulatedTLS flag in clang goes away.)

Alternatively, if you think clang really shouldn't care whether emulated TLS is 
enabled, we could just conservatively return false from shouldAssumeDSOLocal, 
and let some later optimization clean it up.  Not sure what implications that 
has for code generation.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132848

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


[PATCH] D126534: [analyzer] Deadstore static analysis: Fix false positive on C++17 assignments

2022-08-29 Thread Chris Hamilton via Phabricator via cfe-commits
chrish_ericsson_atx added a comment.

This change affected analyzer findings for C language source as well.  Mostly 
true positives, but there is one false positive we know about.  I filed 
https://github.com/llvm/llvm-project/issues/57434 to track that new false 
positive.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126534

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


[PATCH] D132131: [clang-format] Adds a formatter for aligning trailing comments over empty lines

2022-08-29 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added inline comments.



Comment at: clang/docs/ClangFormatStyleOptions.rst:785
+  - Consecutive
+  - AcrossEmptyLines
+  - AcrossComments

may be AcrossEmptyLines should be a number (to mean the number of empty lines)



Comment at: clang/docs/ClangFormatStyleOptions.rst:794
+
+AlignConsecutiveMacros: AcrossEmptyLines
+

Should this say `AlignedConsecutuveCommets`



Comment at: clang/docs/ClangFormatStyleOptions.rst:797
+AlignConsecutiveMacros:
+  Enabled: true
+  AcrossEmptyLines: true

HazardyKnusperkeks wrote:
> MyDeveloperDay wrote:
> > why do we need Enabled?
> > 
> > isn't it just
> > 
> > ```
> > false:
> > AcrossEmptyLines: false
> > AcrossComments: false
> > 
> > true:
> > AcrossEmptyLines: true
> > AcrossComments: true
> > ```
> The struct is a bit older. And we need `Enabled`, one might wish to align 
> only really consecutive comments, as the option right now does. (Same for 
> macros, assignments, etc..)
I'm still not sure I understand, plus are those use cases you describe tested, 
I couldn't see that. 

If feels like what you are saying is that AlignConsecutiveStyle is used 
elsewhere and it has options that don't pertain to aligning comments? 

I couldn't tell if feel like this documentation is describing something other 
than AligningTrailingComments, if I'm confused users could be too? 



Comment at: clang/unittests/Format/FormatTestComments.cpp:2876
+   
+  verifyFormat("#include \"a.h\"  //\n"
+   "#include \"aa.h\" //\n"

can we have real comments with different lengths?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132131

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


[PATCH] D132877: Downgrade the UAX31 diagnostic to a warning which defaults to an error

2022-08-29 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added a comment.

@aaron.ballman i am not worried about performance. The old table was fairly 
compact - as it described large ranges - so a drop in the ocean in terms of 
binary size. And we only need to check them for the case where we are only 
going to emit a warning or an error anyway.

See
https://github.com/llvm/llvm-project/commit/4e80636db71a1b6123d15ed1f9eda3979b4292de#diff-c95475d750149050c46892d3a9731fd839737a51a6f19f8e0580acee052e9b26L43


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132877

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


[PATCH] D132762: [clang-format] Allow `throw` to be a keyword in front of casts

2022-08-29 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added inline comments.



Comment at: clang/unittests/Format/FormatTest.cpp:10961
   verifyFormat("return (my_int)aaa;");
+  verifyFormat("throw (my_int)aaa;");
   verifyFormat("#define x ((int)-1)");

Can we add a test that covers the setting of SpaceAfterCStyleCast with throw? 
and SpacesInCStyleCastParentheses for completeness


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132762

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


[PATCH] D132877: Downgrade the UAX31 diagnostic to a warning which defaults to an error

2022-08-29 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman marked an inline comment as done.
aaron.ballman added a comment.

In D132877#3756458 , @cor3ntin wrote:

> I am strongly against this change. If we do want to do this, we need to 
> restore the original tables from c++11 and check against them not to extend 
> the set of characters to something much wider than was supported before 
> c++23. It should be fairly easy to extract those tables from the git history. 
> (Sorry for the very short comment, I'm currently traveling). A warning for 
> non characters, controls, pua characters and everything not previously 
> accepted isn't sufficient. A warning for things in the old set but not 23 is 
> fine as long as, as other have said, we have a depreciation period.

Thanks for this feedback! Ugh, I didn't realize we were going to need to keep 
around both sets of tables, that potentially adds more expense to this option 
than I originally realized, depending on how much extra binary size the tables 
add.

In D132877#3756475 , @efriedma wrote:

> I'm not really a fan of the argument of "this was accepted as a DR, therefore 
> new versions of clang have to reject code that old versions accepted".  
> Regardless of what the C++ committee does, our commitment to our users is to 
> ensure that code written against "-std=c++11" continues to compile in newer 
> versions of clang.

This is the status quo in Clang. When one of the committees says something is a 
DR, the expectation users have is that the feature was always specified to 
behave in the fixed way. This case is a bit special though because the old 
rules were approximately 30+ years old and were "use what you like so long as 
it's not punctuation, yolo" and the new rules are more restrictive. I think our 
commitment  is a bit weaker than "ensure code continues to compile." We've 
never promised we wouldn't fix bugs against older standards, and fixing bugs 
can break otherwise working code. (And WG21 considers this a bug, hence the DR 
designation.) However, you're definitely right that we're not *obligated* to 
make the change in older language modes just because the committee said it's a 
DR. We are obligated to implement the functionality in a conforming manner in 
newer language modes though.

It's worth noting that the code which is broken by this is largely within one 
domain (use of math symbols), so the number of users impacted is believed to be 
relatively small (small enough that we were considering closing the issue as 
Won't Fix instead of making this change). The reason I decided to propose a 
relaxation here was to give the handful of impacted users an easier upgrade 
path.

> I don't want to relitigate the whole discussion from the bug, though; just 
> wanted to make sure you considered the possibilities. If you think this is 
> best, I won't object.

Your opinions are very much appreciated on the topic, it's not one with a slam 
dunk answer (at least that we've found yet).

In D132877#3756415 , @thieta wrote:

> Hmm. 15.0.0 is just a week away - I am not planning any more RCs unless we 
> hit something critical. What's the risk of taking this specific change at 
> this point? Would it make more sense to wait for 15.0.1? (I am guessing it's 
> better if it goes into 15.0.0 or not in 15.x at all).
>
> I am just pushing back because I don't want to introduce to much risk this 
> late in the cycle - but I will defer to you guys since you are the domain 
> experts.

Given the feedback from Corentin above, I think the window for getting this 
into Clang 15 is effectively closed. It's not critical (it doesn't fix a crash 
or a regression); I was mostly hoping it would make it in 15.0 because it 
doesn't seem appropriate to introduce a new warning flag in a dot release (that 
would seem to make build systems harder to work with in practice).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132877

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


[PATCH] D132713: [clang-tidy] Skip union-like classes in use-equals-default

2022-08-29 Thread Alexander Shaposhnikov via Phabricator via cfe-commits
alexander-shaposhnikov added a comment.

ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132713

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


[PATCH] D132877: Downgrade the UAX31 diagnostic to a warning which defaults to an error

2022-08-29 Thread Tom Honermann via Phabricator via cfe-commits
tahonermann added a comment.

I don't have a strong opinion regarding when, or if, the diagnostic is reverted 
to an always-error. It looks like gcc is not even planning to diagnose 
identifiers that are ill-formed according to the new rules by default.

With regard to Corentin's opposition to the patch as is, I think it would be 
acceptable to put this patch in Clang 15 as is and then tighten things up as 
Corentin suggests for Clang 16. The patch as is is very low risk (it barely 
even qualifies as a code change). any change to address Corentin's concerns 
would add some additional risk this late in the release, and the only people 
impacted are those that opt-in to the new option. I do agree with Corentin's 
concern that suppressing the error does look like it would have the effect of 
allowing identifiers that were not previously allowed under the immutable 
identifier syntax; I think we do want to ensure that identifiers that are in 
neither immutable identifier syntax nor default identifier syntax are diagnosed 
(at least in Clang 16).




Comment at: clang/docs/ReleaseNotes.rst:119-121
+- Added the ``-Winvalid-identifier-character`` warning group to identify
+  identifier characters which are invalid according to UAX31 but were
+  previously allowed. This warning defaults to an error because these

Most people reading this won't know what UAX31 is. Linking to it would help 
some, but the document is fairly inscrutable to the uninitiated. How about 
something like the following?
  The ``-Winvalid-identifier-character`` warning group was added to manage 
diagnostics
  regarding use of invalid identifiers following the adoption of N2836 and 
P1949 by the
  C and C++ committees respectively. This warning default to an error because 
...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132877

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


[PATCH] D131306: [llvm][misexpect] Track provenance of branch weights

2022-08-29 Thread Rong Xu via Phabricator via cfe-commits
xur added a comment.

I agreed with Teresa: adding an optional string is better than using a 
separated metadata here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131306

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


[PATCH] D132874: [clang] Don't emit debug vtable information for consteval functions

2022-08-29 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik added subscribers: aprantl, shafik.
shafik added a comment.

Maybe @aprantl you want to take a look at this.




Comment at: clang/lib/CodeGen/CGDebugInfo.cpp:1761
 
-  if (Method->isVirtual()) {
+  if (Method->isVirtual() && !Method->isConsteval()) {
 if (Method->isPure())

It is not clear to me if this is the core issue or not. Can you explain this a 
little better.



Comment at: clang/test/CodeGenCXX/cxx20-consteval-crash.cpp:94
+} // namespace Issue55065
\ No newline at end of file


Please add the newline back.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132874

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


[PATCH] D128830: [Pipelines] Introduce DAE after ArgumentPromotion

2022-08-29 Thread Zequan Wu via Phabricator via cfe-commits
zequanwu added a comment.

It's causing chromium test failure.

  [ RUN  ] PartitionAllocPCScanTest.StackScanning
  ../../base/allocator/partition_allocator/starscan/pcscan_unittest.cc:682: 
Failure
  Value of: IsInFreeList(root().ObjectToSlotStart(dangling_reference))
Actual: true
  Expected: false
  Stack trace:
  #0 0x560588bd2aca 
_N15partition_alloc8internal43PartitionAllocPCScanTest_StackScanning_Test8TestBodyEvENK3$_2clEvENKUlvE_clEvENKUlvE_clEv
  #1 0x560588bd01f3 
partition_alloc::internal::PartitionAllocPCScanTest_StackScanning_Test::TestBody()::$_2::operator()()
  #2 0x560588bd0183 
partition_alloc::internal::PartitionAllocPCScanTest_StackScanning_Test::TestBody()

I'm trying to create a smaller repro.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128830

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


[PATCH] D130096: [Clang][AMDGPU] Emit AMDGPU library control constants in clang

2022-08-29 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 updated this revision to Diff 456450.
jhuber6 added a comment.

Changing to private linkage.

For OpenMP we could either make this use `weak_odr` so we have a single
definition surviving until link time for us to use. Or we could change OpenMP to
link in the bitcode libraries per-TU via `-mlink-builtin-bitcode`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130096

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/TargetInfo.cpp
  clang/lib/CodeGen/TargetInfo.h
  clang/test/CodeGen/amdgcn-control-constants.c

Index: clang/test/CodeGen/amdgcn-control-constants.c
===
--- /dev/null
+++ clang/test/CodeGen/amdgcn-control-constants.c
@@ -0,0 +1,49 @@
+// Check that we generate all the expected default features for the target.
+// RUN: %clang_cc1 -x hip -triple amdgcn-amd-amdhsa -target-cpu gfx90a -S -emit-llvm -o - %s | FileCheck %s --check-prefix=GFX90A
+// RUN: %clang_cc1 -x hip -triple amdgcn-amd-amdhsa -target-cpu gfx1030 -S -emit-llvm -o - %s | FileCheck %s --check-prefix=GFX1030
+
+// GFX90A: @__oclc_wavefrontsize64 = private local_unnamed_addr addrspace(4) constant i8 1
+// GFX90A: @__oclc_daz_opt = private local_unnamed_addr addrspace(4) constant i8 0
+// GFX90A: @__oclc_finite_only_opt = private local_unnamed_addr addrspace(4) constant i8 0
+// GFX90A: @__oclc_unsafe_math_opt = private local_unnamed_addr addrspace(4) constant i8 0
+// GFX90A: @__oclc_correctly_rounded_sqrt32 = private local_unnamed_addr addrspace(4) constant i8 1
+// GFX90A: @__oclc_ISA_version = private local_unnamed_addr addrspace(4) constant i32 9010
+// GFX90A: @__oclc_ABI_version = private local_unnamed_addr addrspace(4) constant i32 400
+
+// GFX1030: @__oclc_wavefrontsize64 = private local_unnamed_addr addrspace(4) constant i8 0
+// GFX1030: @__oclc_daz_opt = private local_unnamed_addr addrspace(4) constant i8 0
+// GFX1030: @__oclc_finite_only_opt = private local_unnamed_addr addrspace(4) constant i8 0
+// GFX1030: @__oclc_unsafe_math_opt = private local_unnamed_addr addrspace(4) constant i8 0
+// GFX1030: @__oclc_correctly_rounded_sqrt32 = private local_unnamed_addr addrspace(4) constant i8 1
+// GFX1030: @__oclc_ISA_version = private local_unnamed_addr addrspace(4) constant i32 10048
+// GFX1030: @__oclc_ABI_version = private local_unnamed_addr addrspace(4) constant i32 400
+
+// Check that we can override the wavefront features.
+// RUN: %clang_cc1 -x hip -triple amdgcn-amd-amdhsa -target-cpu gfx1030 -target-feature +wavefrontsize64 \
+// RUN:   -S -emit-llvm -o - %s | FileCheck %s --check-prefix=WAVEFRONT
+// WAVEFRONT: @__oclc_wavefrontsize64 = private local_unnamed_addr addrspace(4) constant i8 1
+
+// Check that we can enable denormalization at zero.
+// RUN: %clang_cc1 -x hip -triple amdgcn-amd-amdhsa -target-cpu gfx90a -fdenormal-fp-math-f32=preserve-sign,preserve-sign \
+// RUN:   -S -emit-llvm -o - %s | FileCheck %s --check-prefix=DENORM-AT-ZERO
+// DENORM-AT-ZERO: @__oclc_daz_opt = private local_unnamed_addr addrspace(4) constant i8 1
+
+// Check that we can enable finite math.
+// RUN: %clang_cc1 -x hip -triple amdgcn-amd-amdhsa -target-cpu gfx90a -ffinite-math-only \
+// RUN:   -S -emit-llvm -o - %s | FileCheck %s --check-prefix=FINITE-MATH
+// FINITE-MATH: @__oclc_finite_only_opt = private local_unnamed_addr addrspace(4) constant i8 1
+// FINITE-MATH: @__oclc_unsafe_math_opt = private local_unnamed_addr addrspace(4) constant i8 0
+
+// Check that we can enable unsafe math.
+// RUN: %clang_cc1 -x hip -triple amdgcn-amd-amdhsa -target-cpu gfx90a -menable-unsafe-fp-math \
+// RUN:   -S -emit-llvm -o - %s | FileCheck %s --check-prefix=UNSAFE-MATH
+// UNSAFE-MATH: @__oclc_finite_only_opt = private local_unnamed_addr addrspace(4) constant i8 0
+// UNSAFE-MATH: @__oclc_unsafe_math_opt = private local_unnamed_addr addrspace(4) constant i8 1
+
+// Check that we can disable/enable correctly rounded square roots.
+// RUN: %clang_cc1 -x hip -triple amdgcn-amd-amdhsa -target-cpu gfx90a -fno-hip-fp32-correctly-rounded-divide-sqrt \
+// RUN:   -S -emit-llvm -o - %s | FileCheck %s --check-prefix=CORRECT-SQRT
+// CORRECT-SQRT: @__oclc_correctly_rounded_sqrt32 = private local_unnamed_addr addrspace(4) constant i8 0
+// RUN: %clang_cc1 -x cl -triple amdgcn-amd-amdhsa -target-cpu gfx90a -cl-fp32-correctly-rounded-divide-sqrt \
+// RUN:   -disable-llvm-optzns -S -emit-llvm -o - %s | FileCheck %s --check-prefix=CL-CORRECT-SQRT
+// CL-CORRECT-SQRT: @__oclc_correctly_rounded_sqrt32 = private local_unnamed_addr addrspace(4) constant i8 1
Index: clang/lib/CodeGen/TargetInfo.h
===
--- clang/lib/CodeGen/TargetInfo.h
+++ clang/lib/CodeGen/TargetInfo.h
@@ -76,6 +76,9 @@
   CodeGen::CodeGenModule ,
   const llvm::MapVector ) const {}
 
+  /// Provides a 

[PATCH] D132843: [RISCV] Ensure target features get passed to the LTO linker for RISC-V

2022-08-29 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

I'd prefer to use an approach with less moving parts: the bitcode should 
contain enough information to generate code without specifying anything on the 
command-line that wouldn't normally be passed to the linker.  Among other 
issues, it's hard to understand the intended meaning if the flags contradict 
information encoded in the bitcode.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132843

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


[PATCH] D132831: [clang][Interp] Handle SubstNonTypeTemplateParmExprs

2022-08-29 Thread Tom Honermann via Phabricator via cfe-commits
tahonermann added inline comments.



Comment at: clang/lib/AST/Interp/ByteCodeExprGen.cpp:273
+const SubstNonTypeTemplateParmExpr *E) {
+  return this->visit(E->getReplacement());
+}

erichkeane wrote:
> tbaeder wrote:
> > erichkeane wrote:
> > > Is there nothing special that has to happen when these are reference 
> > > parameters?  Can you at least add a test for that?
> > Umm, I don't really do references yet (I haven't tested them at all and I 
> > don't think they are implemented).
> Hmm... that is unfortunate.  We really should be doing references ASAP, as 
> they are going to be a pretty critical/oft-needed during testing kinda thing. 
>  I'd at least want a commented-out test that you can re-enable ASAP.
Are not-yet-implemented features consistently implemented such that constant 
evaluation will fail with a (possibly unhelpful) diagnostic? As in 
https://godbolt.org/z/8vvdca9Ma? If so, can tests be added ahead of time with 
annotations for expected errors (essentially false positives to be addressed 
later)?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132831

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


[PATCH] D130096: [Clang][AMDGPU] Emit AMDGPU library control constants in clang

2022-08-29 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 added inline comments.



Comment at: clang/lib/CodeGen/TargetInfo.cpp:9436
+CGM.getModule(), Type, true,
+llvm::GlobalValue::LinkageTypes::LinkOnceODRLinkage,
+llvm::ConstantInt::get(Type, Value), Name, nullptr,

yaxunl wrote:
> yaxunl wrote:
> > jhuber6 wrote:
> > > yaxunl wrote:
> > > > This does not support per-TU control variables. Probably should use 
> > > > internal linkage.
> > > The AMDGPU device libraries use `linkone_odr` so I figured it was the 
> > > most appropriate here. It should mean that we can have multiple identical 
> > > definitions and they don't clash. There's also no requirement for these 
> > > to be emitted as symbols AFAIK.
> > > The AMDGPU device libraries use `linkone_odr` so I figured it was the 
> > > most appropriate here. It should mean that we can have multiple identical 
> > > definitions and they don't clash. There's also no requirement for these 
> > > to be emitted as symbols AFAIK.
> > 
> > clang uses  -mlink-builtin-bitcode to link these device libraries for HIP 
> > and OpenCL. Then the linkage of these variables becomes internal linkage. 
> > That's why it works for per-TU control.
> > > The AMDGPU device libraries use `linkone_odr` so I figured it was the 
> > > most appropriate here. It should mean that we can have multiple identical 
> > > definitions and they don't clash. There's also no requirement for these 
> > > to be emitted as symbols AFAIK.
> > 
> > clang uses  -mlink-builtin-bitcode to link these device libraries for HIP 
> > and OpenCL. Then the linkage of these variables becomes internal linkage. 
> > That's why it works for per-TU control.
> 
> You may let HIP and OpenCL use internal linkage and C/C++/OpenMP use 
> linkonce_odr since only HIP and OpenCL toolchain use -mlink-builtin-bitcode 
> to link these device libraries 
I see, `linkonce_odr` implies that these should all have the same value which 
isn't necessarily true after linking. I'll change it to use private linkage.

OpenMP right now links everything late which means that we don't allow these to 
be defined differently per-TU. This may be incorrect given this new method as 
each TU will have different things set. I can change OpenMP to use the `mlink` 
method after this patch which may be more strictly correct.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130096

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


[PATCH] D130096: [Clang][AMDGPU] Emit AMDGPU library control constants in clang

2022-08-29 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added inline comments.



Comment at: clang/lib/CodeGen/TargetInfo.cpp:9436
+CGM.getModule(), Type, true,
+llvm::GlobalValue::LinkageTypes::LinkOnceODRLinkage,
+llvm::ConstantInt::get(Type, Value), Name, nullptr,

yaxunl wrote:
> jhuber6 wrote:
> > yaxunl wrote:
> > > This does not support per-TU control variables. Probably should use 
> > > internal linkage.
> > The AMDGPU device libraries use `linkone_odr` so I figured it was the most 
> > appropriate here. It should mean that we can have multiple identical 
> > definitions and they don't clash. There's also no requirement for these to 
> > be emitted as symbols AFAIK.
> > The AMDGPU device libraries use `linkone_odr` so I figured it was the most 
> > appropriate here. It should mean that we can have multiple identical 
> > definitions and they don't clash. There's also no requirement for these to 
> > be emitted as symbols AFAIK.
> 
> clang uses  -mlink-builtin-bitcode to link these device libraries for HIP and 
> OpenCL. Then the linkage of these variables becomes internal linkage. That's 
> why it works for per-TU control.
> > The AMDGPU device libraries use `linkone_odr` so I figured it was the most 
> > appropriate here. It should mean that we can have multiple identical 
> > definitions and they don't clash. There's also no requirement for these to 
> > be emitted as symbols AFAIK.
> 
> clang uses  -mlink-builtin-bitcode to link these device libraries for HIP and 
> OpenCL. Then the linkage of these variables becomes internal linkage. That's 
> why it works for per-TU control.

You may let HIP and OpenCL use internal linkage and C/C++/OpenMP use 
linkonce_odr since only HIP and OpenCL toolchain use -mlink-builtin-bitcode to 
link these device libraries 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130096

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


[PATCH] D130096: [Clang][AMDGPU] Emit AMDGPU library control constants in clang

2022-08-29 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added inline comments.



Comment at: clang/lib/CodeGen/TargetInfo.cpp:9436
+CGM.getModule(), Type, true,
+llvm::GlobalValue::LinkageTypes::LinkOnceODRLinkage,
+llvm::ConstantInt::get(Type, Value), Name, nullptr,

jhuber6 wrote:
> yaxunl wrote:
> > This does not support per-TU control variables. Probably should use 
> > internal linkage.
> The AMDGPU device libraries use `linkone_odr` so I figured it was the most 
> appropriate here. It should mean that we can have multiple identical 
> definitions and they don't clash. There's also no requirement for these to be 
> emitted as symbols AFAIK.
> The AMDGPU device libraries use `linkone_odr` so I figured it was the most 
> appropriate here. It should mean that we can have multiple identical 
> definitions and they don't clash. There's also no requirement for these to be 
> emitted as symbols AFAIK.

clang uses  -mlink-builtin-bitcode to link these device libraries for HIP and 
OpenCL. Then the linkage of these variables becomes internal linkage. That's 
why it works for per-TU control.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130096

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


[PATCH] D132131: [clang-format] Adds a formatter for aligning trailing comments over empty lines

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



Comment at: clang/docs/ClangFormatStyleOptions.rst:797
+AlignConsecutiveMacros:
+  Enabled: true
+  AcrossEmptyLines: true

MyDeveloperDay wrote:
> why do we need Enabled?
> 
> isn't it just
> 
> ```
> false:
> AcrossEmptyLines: false
> AcrossComments: false
> 
> true:
> AcrossEmptyLines: true
> AcrossComments: true
> ```
The struct is a bit older. And we need `Enabled`, one might wish to align only 
really consecutive comments, as the option right now does. (Same for macros, 
assignments, etc..)



Comment at: clang/lib/Format/Format.cpp:649
 IO.mapOptional("AlignOperands", Style.AlignOperands);
-IO.mapOptional("AlignTrailingComments", Style.AlignTrailingComments);
 IO.mapOptional("AllowAllArgumentsOnNextLine",

MyDeveloperDay wrote:
> HazardyKnusperkeks wrote:
> > MyDeveloperDay wrote:
> > > you can't remove an option, otherwise you'll break everyones .clang-format
> > That's not correct. We have done it:
> > D108752 -> D108882 -> D127390
> > 
> > You can remove (and in this case should), but you still need to parse it 
> > and act accordingly. Which is done as far as I can see.
> sorry thats what I meant, you can remove it, but you have to make it turn on 
> the correct new style that keeps exactly the old user case, and you can't 
> remove it from the configuration parsing otherwise anyone who has it in their 
> .clang-format is immediately broken with an unknown option.
> 
> to be honest this is an annoyance for introducing new features, which at some 
> point I'd like to drop, you can't have a new option which is not read
> 
> For me, when we introduced new languages, or new features like InsertBraces 
> etc.. I want to put it in my .clang-format even though other people they 
> aren't using a version that uses it. (becuase it won't impact them), i.e. it 
> won't add braces or correct QualifierOrder that doesn't bother me
> 
Do you disagree that it actually is parsed?

But that compatibility parsing has nothing to do with ignoring unknown (new) 
options.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132131

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


[PATCH] D132877: Downgrade the UAX31 diagnostic to a warning which defaults to an error

2022-08-29 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

I'm not really a fan of the argument of "this was accepted as a DR, therefore 
new versions of clang have to reject code that old versions accepted".  
Regardless of what the C++ committee does, our commitment to our users is to 
ensure that code written against "-std=c++11" continues to compile in newer 
versions of clang.

I don't want to relitigate the whole discussion from the bug, though; just 
wanted to make sure you considered the possibilities.  If you think this is 
best, I won't object.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132877

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


[PATCH] D131979: [clang][UBSan] Fix __builtin_assume_aligned crash

2022-08-29 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

In D131979#3756067 , @yihanaa wrote:

> In D131979#3756006 , @rjmccall 
> wrote:
>
>> In D131979#3753358 , @yihanaa 
>> wrote:
>>
>>> In D131979#3752208 , @rjmccall 
>>> wrote:
>>>
 From the test case, it looks like the builtin just ignores pointers to 
 volatile types, which should be preserved by the conversions you're now 
 doing in Sema.  That is, you should be able to just check 
 `Ptr->getType()->castAs()->getPointeeType().isVolatile()`.

 It would be different if it ignored pointers loaded out of volatile 
 l-values or something, but that's explicitly not what it's doing.
>>>
>>> Thanks for your tips John, form the test case global constants and 
>>> compiler-rt ubsan class TypeDescriptor, it looks like pass an type 
>>> description to __ubsan_handle_alignment_assumption, so, we have to use 
>>> getSubExprAsWritten to get the origin(user written arg type) type 
>>> description of 1st arg, but not 'const void *', for example,   in 
>>> catch-alignment-assumption-builtin_assume_aligned-three-params.cpp, the 1st 
>>> arg type description is 'char **', but if we don't use getSubExprAsWritten, 
>>> all the type description will be 'const void *'
>>
>> The version of this patch which changed the builtin to use custom 
>> type-checking didn't need to worry about this because doing that will stop 
>> Sema from converting to `const void *`.  You seem to have taken all of that  
>> code out and reverted to an earlier approach, though, and I don't see 
>> anything in this review explaining why.
>>
>> Also, please don't ping for review on Monday when you submitted a new 
>> version of the patch on Saturday.  Not only is that a very short period to 
>> be demanding review during, but a lot of reviewers keep up with review as 
>> part of their normal workday and cannot be expected to review over the 
>> weekend.
>
> Thanks for your reply John, the patch of the previous version which will emit 
> an error when 1st arg is volatile-qualified, we're  worried about the shift 
> to emit an unconditional error on `volatile`. So, I'll try to separate that 
> into its own patch and just fix the bug in this one. and I'm so sorry about 
> have 'pin' too often, this is due to time zone, I will pay attention to it 
> later, and thanks for your tips!

Hmm.  I think you can take the previous version of the patch and either (1) 
remove the place where it explicitly emits an error or (2) make it only emit an 
error in C++ mode.

I think the type descriptor for something that starts as an array reference 
should probably be a pointer, i.e. you should apply array decay and then derive 
the type from that.  That's one of the things that'll just fall out naturally 
if you do what the previous version of the patch was doing.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131979

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


[PATCH] D132877: Downgrade the UAX31 diagnostic to a warning which defaults to an error

2022-08-29 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added a comment.

I am strongly against this change. If we do want to do this, we need to restore 
the original tables from c++11 and check against them not to extend the set to 
something much wider than was supported before c++23. It should be fairly easy 
to extract those tables from the git history.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132877

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


[PATCH] D130096: [Clang][AMDGPU] Emit AMDGPU library control constants in clang

2022-08-29 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 added inline comments.



Comment at: clang/lib/CodeGen/TargetInfo.cpp:9436
+CGM.getModule(), Type, true,
+llvm::GlobalValue::LinkageTypes::LinkOnceODRLinkage,
+llvm::ConstantInt::get(Type, Value), Name, nullptr,

yaxunl wrote:
> This does not support per-TU control variables. Probably should use internal 
> linkage.
The AMDGPU device libraries use `linkone_odr` so I figured it was the most 
appropriate here. It should mean that we can have multiple identical 
definitions and they don't clash. There's also no requirement for these to be 
emitted as symbols AFAIK.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130096

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


[PATCH] D130096: [Clang][AMDGPU] Emit AMDGPU library control constants in clang

2022-08-29 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 updated this revision to Diff 456441.
jhuber6 added a comment.

Updating. I realized all of the math-related ones are already covered by driver 
options for AMDGPU passing the appropriate fp contract to the frontend. This 
patch gets rid of most of that handling and just uses those directly. Also 
makes it easier to test.

We also check if the `+wavefront64` feature was explicitly turned on as part of 
@yaxunl's suggestion.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130096

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/TargetInfo.cpp
  clang/lib/CodeGen/TargetInfo.h
  clang/test/CodeGen/amdgcn-control-constants.c

Index: clang/test/CodeGen/amdgcn-control-constants.c
===
--- /dev/null
+++ clang/test/CodeGen/amdgcn-control-constants.c
@@ -0,0 +1,49 @@
+// Check that we generate all the expected default features for the target.
+// RUN: %clang_cc1 -x hip -triple amdgcn-amd-amdhsa -target-cpu gfx90a -S -emit-llvm -o - %s | FileCheck %s --check-prefix=GFX90A
+// RUN: %clang_cc1 -x hip -triple amdgcn-amd-amdhsa -target-cpu gfx1030 -S -emit-llvm -o - %s | FileCheck %s --check-prefix=GFX1030
+
+// GFX90A: @__oclc_wavefrontsize64 = linkonce_odr hidden local_unnamed_addr addrspace(4) constant i8 1
+// GFX90A: @__oclc_daz_opt = linkonce_odr hidden local_unnamed_addr addrspace(4) constant i8 0
+// GFX90A: @__oclc_finite_only_opt = linkonce_odr hidden local_unnamed_addr addrspace(4) constant i8 0
+// GFX90A: @__oclc_unsafe_math_opt = linkonce_odr hidden local_unnamed_addr addrspace(4) constant i8 0
+// GFX90A: @__oclc_correctly_rounded_sqrt32 = linkonce_odr hidden local_unnamed_addr addrspace(4) constant i8 1
+// GFX90A: @__oclc_ISA_version = linkonce_odr hidden local_unnamed_addr addrspace(4) constant i32 9010
+// GFX90A: @__oclc_ABI_version = linkonce_odr hidden local_unnamed_addr addrspace(4) constant i32 400
+
+// GFX1030: @__oclc_wavefrontsize64 = linkonce_odr hidden local_unnamed_addr addrspace(4) constant i8 0
+// GFX1030: @__oclc_daz_opt = linkonce_odr hidden local_unnamed_addr addrspace(4) constant i8 0
+// GFX1030: @__oclc_finite_only_opt = linkonce_odr hidden local_unnamed_addr addrspace(4) constant i8 0
+// GFX1030: @__oclc_unsafe_math_opt = linkonce_odr hidden local_unnamed_addr addrspace(4) constant i8 0
+// GFX1030: @__oclc_correctly_rounded_sqrt32 = linkonce_odr hidden local_unnamed_addr addrspace(4) constant i8 1
+// GFX1030: @__oclc_ISA_version = linkonce_odr hidden local_unnamed_addr addrspace(4) constant i32 10048
+// GFX1030: @__oclc_ABI_version = linkonce_odr hidden local_unnamed_addr addrspace(4) constant i32 400
+
+// Check that we can override the wavefront features.
+// RUN: %clang_cc1 -x hip -triple amdgcn-amd-amdhsa -target-cpu gfx1030 -target-feature +wavefrontsize64 \
+// RUN:   -S -emit-llvm -o - %s | FileCheck %s --check-prefix=WAVEFRONT
+// WAVEFRONT: @__oclc_wavefrontsize64 = linkonce_odr hidden local_unnamed_addr addrspace(4) constant i8 1
+
+// Check that we can enable denormalization at zero.
+// RUN: %clang_cc1 -x hip -triple amdgcn-amd-amdhsa -target-cpu gfx90a -fdenormal-fp-math-f32=preserve-sign,preserve-sign \
+// RUN:   -S -emit-llvm -o - %s | FileCheck %s --check-prefix=DENORM-AT-ZERO
+// DENORM-AT-ZERO: @__oclc_daz_opt = linkonce_odr hidden local_unnamed_addr addrspace(4) constant i8 1
+
+// Check that we can enable finite math.
+// RUN: %clang_cc1 -x hip -triple amdgcn-amd-amdhsa -target-cpu gfx90a -ffinite-math-only \
+// RUN:   -S -emit-llvm -o - %s | FileCheck %s --check-prefix=FINITE-MATH
+// FINITE-MATH: @__oclc_finite_only_opt = linkonce_odr hidden local_unnamed_addr addrspace(4) constant i8 1
+// FINITE-MATH: @__oclc_unsafe_math_opt = linkonce_odr hidden local_unnamed_addr addrspace(4) constant i8 0
+
+// Check that we can enable unsafe math.
+// RUN: %clang_cc1 -x hip -triple amdgcn-amd-amdhsa -target-cpu gfx90a -menable-unsafe-fp-math \
+// RUN:   -S -emit-llvm -o - %s | FileCheck %s --check-prefix=UNSAFE-MATH
+// UNSAFE-MATH: @__oclc_finite_only_opt = linkonce_odr hidden local_unnamed_addr addrspace(4) constant i8 0
+// UNSAFE-MATH: @__oclc_unsafe_math_opt = linkonce_odr hidden local_unnamed_addr addrspace(4) constant i8 1
+
+// Check that we can disable correctly rounded square roots.
+// RUN: %clang_cc1 -x hip -triple amdgcn-amd-amdhsa -target-cpu gfx90a -fno-hip-fp32-correctly-rounded-divide-sqrt \
+// RUN:   -S -emit-llvm -o - %s | FileCheck %s --check-prefix=CORRECT-SQRT
+// CORRECT-SQRT: @__oclc_correctly_rounded_sqrt32 = linkonce_odr hidden local_unnamed_addr addrspace(4) constant i8 0
+// RUN: %clang_cc1 -x cl -triple amdgcn-amd-amdhsa -target-cpu gfx90a -cl-fp32-correctly-rounded-divide-sqrt \
+// RUN:   -disable-llvm-optzns -S -emit-llvm -o - %s | FileCheck %s --check-prefix=CL-CORRECT-SQRT
+// CL-CORRECT-SQRT: 

[PATCH] D132877: Downgrade the UAX31 diagnostic to a warning which defaults to an error

2022-08-29 Thread Tobias Hieta via Phabricator via cfe-commits
thieta added a comment.

Hmm. 15.0.0 is just a week away - I am not planning any more RCs unless we hit 
something critical. What's the risk of taking this specific change at this 
point? Would it make more sense to wait for 15.0.1? (I am guessing it's better 
if it goes into 15.0.0 or not in 15.x at all).

I am just pushing back because I don't want to introduce to much risk this late 
in the cycle - but I will defer to you guys since you are the domain experts.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132877

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


[PATCH] D131820: [PS4][driver] make -fjmc work with LTO driver linking stage

2022-08-29 Thread Yuanfang Chen 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 rG288576f474f2: [PS4][driver] make -fjmc work with LTO driver 
linking stage (authored by ychen).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131820

Files:
  clang/lib/Driver/ToolChains/PS4CPU.cpp
  clang/test/Driver/ps4-ps5-linker-jmc.c


Index: clang/test/Driver/ps4-ps5-linker-jmc.c
===
--- /dev/null
+++ clang/test/Driver/ps4-ps5-linker-jmc.c
@@ -0,0 +1,20 @@
+// Test the driver's control over the JustMyCode behavior with linker flags.
+
+// RUN: %clang --target=x86_64-scei-ps4 -fjmc %s -### 2>&1 | FileCheck 
--check-prefixes=CHECK-PS4,CHECK-PS4-LIB %s
+// RUN: %clang --target=x86_64-scei-ps4 -flto=thin -fjmc %s -### 2>&1 | 
FileCheck --check-prefixes=CHECK-PS4-THIN-LTO,CHECK-PS4-LIB %s
+// RUN: %clang --target=x86_64-scei-ps4 -flto=full -fjmc %s -### 2>&1 | 
FileCheck --check-prefixes=CHECK-PS4-FULL-LTO,CHECK-PS4-LIB %s
+// RUN: %clang --target=x86_64-scei-ps5 -fjmc %s -### 2>&1 | FileCheck 
--check-prefixes=CHECK-PS5,CHECK-PS5-LIB %s
+// RUN: %clang --target=x86_64-scei-ps5 -flto -fjmc %s -### 2>&1 | FileCheck 
--check-prefixes=CHECK-PS5-LTO,CHECK-PS5-LIB %s
+
+// CHECK-PS4-NOT: "-enable-jmc-instrument"
+
+// CHECK-PS4-THIN-LTO: "-lto-thin-debug-options=-enable-jmc-instrument"
+// CHECK-PS4-FULL-LTO: "-lto-debug-options=-enable-jmc-instrument"
+
+// CHECK-PS5-NOT: "-enable-jmc-instrument"
+
+// CHECK-PS5-LTO: "-mllvm" "-enable-jmc-instrument"
+
+// Check the default library name.
+// CHECK-PS4-LIB: "--whole-archive" "-lSceDbgJmc" "--no-whole-archive"
+// CHECK-PS5-LIB: "--whole-archive" "-lSceJmc_nosubmission" 
"--no-whole-archive"
Index: clang/lib/Driver/ToolChains/PS4CPU.cpp
===
--- clang/lib/Driver/ToolChains/PS4CPU.cpp
+++ clang/lib/Driver/ToolChains/PS4CPU.cpp
@@ -152,6 +152,26 @@
 assert(Output.isNothing() && "Invalid output.");
   }
 
+  const bool UseLTO = D.isUsingLTO();
+  const bool UseJMC =
+  Args.hasFlag(options::OPT_fjmc, options::OPT_fno_jmc, false);
+  const bool IsPS4 = TC.getTriple().isPS4();
+  const bool IsPS5 = TC.getTriple().isPS5();
+  assert(IsPS4 || IsPS5);
+
+  // This tells LTO to perform JustMyCode instrumentation.
+  if (UseLTO && UseJMC) {
+if (IsPS4 && D.getLTOMode() == LTOK_Thin) {
+  CmdArgs.push_back("-lto-thin-debug-options=-enable-jmc-instrument");
+} else if (IsPS4 && D.getLTOMode() == LTOK_Full) {
+  CmdArgs.push_back("-lto-debug-options=-enable-jmc-instrument");
+} else if (IsPS5) {
+  CmdArgs.push_back("-mllvm");
+  CmdArgs.push_back("-enable-jmc-instrument");
+} else
+  llvm_unreachable("new LTO mode?");
+  }
+
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs))
 TC.addSanitizerArgs(Args, CmdArgs, "-l", "");
 
@@ -171,6 +191,15 @@
 CmdArgs.push_back("-lpthread");
   }
 
+  if (UseJMC) {
+CmdArgs.push_back("--whole-archive");
+if (IsPS4)
+  CmdArgs.push_back("-lSceDbgJmc");
+else
+  CmdArgs.push_back("-lSceJmc_nosubmission");
+CmdArgs.push_back("--no-whole-archive");
+  }
+
   if (Args.hasArg(options::OPT_fuse_ld_EQ)) {
 D.Diag(diag::err_drv_unsupported_opt_for_target)
 << "-fuse-ld" << TC.getTriple().str();


Index: clang/test/Driver/ps4-ps5-linker-jmc.c
===
--- /dev/null
+++ clang/test/Driver/ps4-ps5-linker-jmc.c
@@ -0,0 +1,20 @@
+// Test the driver's control over the JustMyCode behavior with linker flags.
+
+// RUN: %clang --target=x86_64-scei-ps4 -fjmc %s -### 2>&1 | FileCheck --check-prefixes=CHECK-PS4,CHECK-PS4-LIB %s
+// RUN: %clang --target=x86_64-scei-ps4 -flto=thin -fjmc %s -### 2>&1 | FileCheck --check-prefixes=CHECK-PS4-THIN-LTO,CHECK-PS4-LIB %s
+// RUN: %clang --target=x86_64-scei-ps4 -flto=full -fjmc %s -### 2>&1 | FileCheck --check-prefixes=CHECK-PS4-FULL-LTO,CHECK-PS4-LIB %s
+// RUN: %clang --target=x86_64-scei-ps5 -fjmc %s -### 2>&1 | FileCheck --check-prefixes=CHECK-PS5,CHECK-PS5-LIB %s
+// RUN: %clang --target=x86_64-scei-ps5 -flto -fjmc %s -### 2>&1 | FileCheck --check-prefixes=CHECK-PS5-LTO,CHECK-PS5-LIB %s
+
+// CHECK-PS4-NOT: "-enable-jmc-instrument"
+
+// CHECK-PS4-THIN-LTO: "-lto-thin-debug-options=-enable-jmc-instrument"
+// CHECK-PS4-FULL-LTO: "-lto-debug-options=-enable-jmc-instrument"
+
+// CHECK-PS5-NOT: "-enable-jmc-instrument"
+
+// CHECK-PS5-LTO: "-mllvm" "-enable-jmc-instrument"
+
+// Check the default library name.
+// CHECK-PS4-LIB: "--whole-archive" "-lSceDbgJmc" "--no-whole-archive"
+// CHECK-PS5-LIB: "--whole-archive" "-lSceJmc_nosubmission" "--no-whole-archive"
Index: clang/lib/Driver/ToolChains/PS4CPU.cpp
===
--- 

[PATCH] D132592: [Clang] Implement function attribute nouwtable

2022-08-29 Thread Yuanfang Chen 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 rG70248bfdea6c: [Clang] Implement function attribute nouwtable 
(authored by ychen).

Changed prior to commit:
  https://reviews.llvm.org/D132592?vs=456403=456433#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132592

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/test/CodeGen/attr-nouwtable.c
  clang/test/Misc/pragma-attribute-supported-attributes-list.test


Index: clang/test/Misc/pragma-attribute-supported-attributes-list.test
===
--- clang/test/Misc/pragma-attribute-supported-attributes-list.test
+++ clang/test/Misc/pragma-attribute-supported-attributes-list.test
@@ -115,6 +115,7 @@
 // CHECK-NEXT: NoStackProtector (SubjectMatchRule_function)
 // CHECK-NEXT: NoThreadSafetyAnalysis (SubjectMatchRule_function)
 // CHECK-NEXT: NoThrow (SubjectMatchRule_hasType_functionType)
+// CHECK-NEXT: NoUwtable (SubjectMatchRule_hasType_functionType)
 // CHECK-NEXT: NotTailCalled (SubjectMatchRule_function)
 // CHECK-NEXT: OSConsumed (SubjectMatchRule_variable_is_parameter)
 // CHECK-NEXT: OSReturnsNotRetained (SubjectMatchRule_function, 
SubjectMatchRule_objc_method, SubjectMatchRule_objc_property, 
SubjectMatchRule_variable_is_parameter)
Index: clang/test/CodeGen/attr-nouwtable.c
===
--- /dev/null
+++ clang/test/CodeGen/attr-nouwtable.c
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -funwind-tables=2 -S -emit-llvm %s -o - | FileCheck %s
+
+__attribute__((nouwtable))
+int test1(void) { return 0; }
+
+// CHECK: @test1{{.*}}[[ATTR1:#[0-9]+]]
+// CHECK: attributes [[ATTR1]] = {
+// CHECK-NOT: uwtable
+// CHECK: }
Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -1963,7 +1963,7 @@
llvm::Function *F) {
   llvm::AttrBuilder B(F->getContext());
 
-  if (CodeGenOpts.UnwindTables)
+  if ((!D || !D->hasAttr()) && CodeGenOpts.UnwindTables)
 B.addUWTableAttr(llvm::UWTableKind(CodeGenOpts.UnwindTables));
 
   if (CodeGenOpts.StackClashProtector)
Index: clang/include/clang/Basic/AttrDocs.td
===
--- clang/include/clang/Basic/AttrDocs.td
+++ clang/include/clang/Basic/AttrDocs.td
@@ -4537,6 +4537,16 @@
 }];
 }
 
+def NoUwtableDocs : Documentation {
+  let Category = DocCatFunction;
+  let Content = [{
+Clang supports the ``nouwtable`` attribute which skips emitting
+the unwind table entry for the specified function. This attribute is useful for
+selectively emitting the unwind table entry on some functions when building 
with
+``-funwind-tables`` compiler option.
+}];
+}
+
 def InternalLinkageDocs : Documentation {
   let Category = DocCatFunction;
   let Content = [{
Index: clang/include/clang/Basic/Attr.td
===
--- clang/include/clang/Basic/Attr.td
+++ clang/include/clang/Basic/Attr.td
@@ -2092,6 +2092,13 @@
   let Documentation = [NoThrowDocs];
 }
 
+def NoUwtable : InheritableAttr {
+  let Spellings = [Clang<"nouwtable">];
+  let Subjects = SubjectList<[FunctionLike]>;
+  let Documentation = [NoUwtableDocs];
+  let SimpleHandler = 1;
+}
+
 def NvWeak : IgnoredAttr {
   // No Declspec spelling of this attribute; the CUDA headers use
   // __attribute__((nv_weak)) unconditionally. Does not receive an [[]]
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -149,6 +149,9 @@
   using the MinGW environment. This attribute is only available for Windows
   targets.
 
+- Introduced a new function attribute ``__attribute__((nouwtable))`` to 
suppress
+  LLVM IR ``uwtable`` function attribute.
+
 Windows Support
 ---
 


Index: clang/test/Misc/pragma-attribute-supported-attributes-list.test
===
--- clang/test/Misc/pragma-attribute-supported-attributes-list.test
+++ clang/test/Misc/pragma-attribute-supported-attributes-list.test
@@ -115,6 +115,7 @@
 // CHECK-NEXT: NoStackProtector (SubjectMatchRule_function)
 // CHECK-NEXT: NoThreadSafetyAnalysis (SubjectMatchRule_function)
 // CHECK-NEXT: NoThrow (SubjectMatchRule_hasType_functionType)
+// CHECK-NEXT: NoUwtable (SubjectMatchRule_hasType_functionType)
 // CHECK-NEXT: NotTailCalled (SubjectMatchRule_function)
 // CHECK-NEXT: OSConsumed (SubjectMatchRule_variable_is_parameter)
 // CHECK-NEXT: 

[clang] 288576f - [PS4][driver] make -fjmc work with LTO driver linking stage

2022-08-29 Thread Yuanfang Chen via cfe-commits

Author: Yuanfang Chen
Date: 2022-08-29T12:12:19-07:00
New Revision: 288576f474f260c77beb6f5d1029101626f776f0

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

LOG: [PS4][driver] make -fjmc work with LTO driver linking stage

Reviewed By: probinson

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

Added: 
clang/test/Driver/ps4-ps5-linker-jmc.c

Modified: 
clang/lib/Driver/ToolChains/PS4CPU.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/PS4CPU.cpp 
b/clang/lib/Driver/ToolChains/PS4CPU.cpp
index 35a83d79abfd1..97688470008fa 100644
--- a/clang/lib/Driver/ToolChains/PS4CPU.cpp
+++ b/clang/lib/Driver/ToolChains/PS4CPU.cpp
@@ -152,6 +152,26 @@ void tools::PScpu::Linker::ConstructJob(Compilation , 
const JobAction ,
 assert(Output.isNothing() && "Invalid output.");
   }
 
+  const bool UseLTO = D.isUsingLTO();
+  const bool UseJMC =
+  Args.hasFlag(options::OPT_fjmc, options::OPT_fno_jmc, false);
+  const bool IsPS4 = TC.getTriple().isPS4();
+  const bool IsPS5 = TC.getTriple().isPS5();
+  assert(IsPS4 || IsPS5);
+
+  // This tells LTO to perform JustMyCode instrumentation.
+  if (UseLTO && UseJMC) {
+if (IsPS4 && D.getLTOMode() == LTOK_Thin) {
+  CmdArgs.push_back("-lto-thin-debug-options=-enable-jmc-instrument");
+} else if (IsPS4 && D.getLTOMode() == LTOK_Full) {
+  CmdArgs.push_back("-lto-debug-options=-enable-jmc-instrument");
+} else if (IsPS5) {
+  CmdArgs.push_back("-mllvm");
+  CmdArgs.push_back("-enable-jmc-instrument");
+} else
+  llvm_unreachable("new LTO mode?");
+  }
+
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs))
 TC.addSanitizerArgs(Args, CmdArgs, "-l", "");
 
@@ -171,6 +191,15 @@ void tools::PScpu::Linker::ConstructJob(Compilation , 
const JobAction ,
 CmdArgs.push_back("-lpthread");
   }
 
+  if (UseJMC) {
+CmdArgs.push_back("--whole-archive");
+if (IsPS4)
+  CmdArgs.push_back("-lSceDbgJmc");
+else
+  CmdArgs.push_back("-lSceJmc_nosubmission");
+CmdArgs.push_back("--no-whole-archive");
+  }
+
   if (Args.hasArg(options::OPT_fuse_ld_EQ)) {
 D.Diag(diag::err_drv_unsupported_opt_for_target)
 << "-fuse-ld" << TC.getTriple().str();

diff  --git a/clang/test/Driver/ps4-ps5-linker-jmc.c 
b/clang/test/Driver/ps4-ps5-linker-jmc.c
new file mode 100644
index 0..3d308d13e64fc
--- /dev/null
+++ b/clang/test/Driver/ps4-ps5-linker-jmc.c
@@ -0,0 +1,20 @@
+// Test the driver's control over the JustMyCode behavior with linker flags.
+
+// RUN: %clang --target=x86_64-scei-ps4 -fjmc %s -### 2>&1 | FileCheck 
--check-prefixes=CHECK-PS4,CHECK-PS4-LIB %s
+// RUN: %clang --target=x86_64-scei-ps4 -flto=thin -fjmc %s -### 2>&1 | 
FileCheck --check-prefixes=CHECK-PS4-THIN-LTO,CHECK-PS4-LIB %s
+// RUN: %clang --target=x86_64-scei-ps4 -flto=full -fjmc %s -### 2>&1 | 
FileCheck --check-prefixes=CHECK-PS4-FULL-LTO,CHECK-PS4-LIB %s
+// RUN: %clang --target=x86_64-scei-ps5 -fjmc %s -### 2>&1 | FileCheck 
--check-prefixes=CHECK-PS5,CHECK-PS5-LIB %s
+// RUN: %clang --target=x86_64-scei-ps5 -flto -fjmc %s -### 2>&1 | FileCheck 
--check-prefixes=CHECK-PS5-LTO,CHECK-PS5-LIB %s
+
+// CHECK-PS4-NOT: "-enable-jmc-instrument"
+
+// CHECK-PS4-THIN-LTO: "-lto-thin-debug-options=-enable-jmc-instrument"
+// CHECK-PS4-FULL-LTO: "-lto-debug-options=-enable-jmc-instrument"
+
+// CHECK-PS5-NOT: "-enable-jmc-instrument"
+
+// CHECK-PS5-LTO: "-mllvm" "-enable-jmc-instrument"
+
+// Check the default library name.
+// CHECK-PS4-LIB: "--whole-archive" "-lSceDbgJmc" "--no-whole-archive"
+// CHECK-PS5-LIB: "--whole-archive" "-lSceJmc_nosubmission" 
"--no-whole-archive"



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


[clang] 70248bf - [Clang] Implement function attribute nouwtable

2022-08-29 Thread Yuanfang Chen via cfe-commits

Author: Yuanfang Chen
Date: 2022-08-29T12:12:19-07:00
New Revision: 70248bfdea6c70008ca42bf03bb28ebdee252744

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

LOG: [Clang] Implement function attribute nouwtable

To have finer control of IR uwtable attribute generation. For target code 
generation,
IR nounwind and uwtable may have some interaction. However, for frontend, there 
are
no semantic interactions so the this new `nouwtable` is marked "SimpleHandler = 
1".

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

Added: 
clang/test/CodeGen/attr-nouwtable.c

Modified: 
clang/docs/ReleaseNotes.rst
clang/include/clang/Basic/Attr.td
clang/include/clang/Basic/AttrDocs.td
clang/lib/CodeGen/CodeGenModule.cpp
clang/test/Misc/pragma-attribute-supported-attributes-list.test

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index ef3950501f963..92b52b8998b4f 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -149,6 +149,9 @@ Attribute Changes in Clang
   using the MinGW environment. This attribute is only available for Windows
   targets.
 
+- Introduced a new function attribute ``__attribute__((nouwtable))`` to 
suppress
+  LLVM IR ``uwtable`` function attribute.
+
 Windows Support
 ---
 

diff  --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index 3b0e3e2971803..0ad59b2c153ae 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -2092,6 +2092,13 @@ def NoThrow : InheritableAttr {
   let Documentation = [NoThrowDocs];
 }
 
+def NoUwtable : InheritableAttr {
+  let Spellings = [Clang<"nouwtable">];
+  let Subjects = SubjectList<[FunctionLike]>;
+  let Documentation = [NoUwtableDocs];
+  let SimpleHandler = 1;
+}
+
 def NvWeak : IgnoredAttr {
   // No Declspec spelling of this attribute; the CUDA headers use
   // __attribute__((nv_weak)) unconditionally. Does not receive an [[]]

diff  --git a/clang/include/clang/Basic/AttrDocs.td 
b/clang/include/clang/Basic/AttrDocs.td
index 32084bf512bc1..68f1268ed7da9 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -4537,6 +4537,16 @@ guaranteed to not throw an exception.
 }];
 }
 
+def NoUwtableDocs : Documentation {
+  let Category = DocCatFunction;
+  let Content = [{
+Clang supports the ``nouwtable`` attribute which skips emitting
+the unwind table entry for the specified function. This attribute is useful for
+selectively emitting the unwind table entry on some functions when building 
with
+``-funwind-tables`` compiler option.
+}];
+}
+
 def InternalLinkageDocs : Documentation {
   let Category = DocCatFunction;
   let Content = [{

diff  --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index 6294fe9e87d32..62e906a87af48 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -1963,7 +1963,7 @@ void 
CodeGenModule::SetLLVMFunctionAttributesForDefinition(const Decl *D,
llvm::Function *F) {
   llvm::AttrBuilder B(F->getContext());
 
-  if (CodeGenOpts.UnwindTables)
+  if ((!D || !D->hasAttr()) && CodeGenOpts.UnwindTables)
 B.addUWTableAttr(llvm::UWTableKind(CodeGenOpts.UnwindTables));
 
   if (CodeGenOpts.StackClashProtector)

diff  --git a/clang/test/CodeGen/attr-nouwtable.c 
b/clang/test/CodeGen/attr-nouwtable.c
new file mode 100644
index 0..a0c6d9232ef30
--- /dev/null
+++ b/clang/test/CodeGen/attr-nouwtable.c
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -funwind-tables=2 -S -emit-llvm %s -o - | FileCheck %s
+
+__attribute__((nouwtable))
+int test1(void) { return 0; }
+
+// CHECK: @test1{{.*}}[[ATTR1:#[0-9]+]]
+// CHECK: attributes [[ATTR1]] = {
+// CHECK-NOT: uwtable
+// CHECK: }

diff  --git a/clang/test/Misc/pragma-attribute-supported-attributes-list.test 
b/clang/test/Misc/pragma-attribute-supported-attributes-list.test
index bde9505009934..b6a52832dadde 100644
--- a/clang/test/Misc/pragma-attribute-supported-attributes-list.test
+++ b/clang/test/Misc/pragma-attribute-supported-attributes-list.test
@@ -115,6 +115,7 @@
 // CHECK-NEXT: NoStackProtector (SubjectMatchRule_function)
 // CHECK-NEXT: NoThreadSafetyAnalysis (SubjectMatchRule_function)
 // CHECK-NEXT: NoThrow (SubjectMatchRule_hasType_functionType)
+// CHECK-NEXT: NoUwtable (SubjectMatchRule_hasType_functionType)
 // CHECK-NEXT: NotTailCalled (SubjectMatchRule_function)
 // CHECK-NEXT: OSConsumed (SubjectMatchRule_variable_is_parameter)
 // CHECK-NEXT: OSReturnsNotRetained (SubjectMatchRule_function, 
SubjectMatchRule_objc_method, SubjectMatchRule_objc_property, 
SubjectMatchRule_variable_is_parameter)




[PATCH] D132762: [clang-format] Allow `throw` to be a keyword in front of casts

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

In D132762#3756072 , @rymiel wrote:

> Add a few token annotator tests

Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132762

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


[PATCH] D132877: Downgrade the UAX31 diagnostic to a warning which defaults to an error

2022-08-29 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman marked an inline comment as done.
aaron.ballman added a comment.

In D132877#3756328 , @efriedma wrote:

> If we don't specifically call out the deprecation period in the diagnostic, 
> usage will grow beyond what we expect.  (Most people don't read the release 
> notes; they'll just see it's possible to turn off the error message, and turn 
> it off.)

I'm okay with that approach (I definitely agree putting the info in the 
diagnostic will get more eyeballs on it than putting it in the release notes), 
but at the same time, we use downgradable errors with the intent to turn them 
into a hard error in the future somewhat frequently and don't add any notice of 
pending doom for them. These diagnostics are all exposed in a way that makes it 
clear the code is an error, so anyone who blanket disables the error should not 
be too terribly surprised when it becomes a hard error later. (Putting the 
deprecation message into the warning itself has the same problem -- users who 
disable the warning entirely won't remember what the text of the warning was 
anyway, and users who inherit build system flags from may never even see the 
diagnostic messages at all.) So personally, I'm also fine not rewording the 
diagnostic.

> If we're okay with people deciding their own rules for what they want to 
> allow in identifiers, we can just make the flag permanently available, 
> though, and just drop the whole "deprecation period" discussion.  Or 
> alternatively, we could add a separate diagnostic specifically for older 
> standard modes: allow only the characters that were allowed by the older 
> standards, and don't emit it for C++23 and newer.  That way, usage naturally 
> goes away as people upgrade their code to newer standard modes.

There's quite a bit of discussion on the issue thread that goes into this, but 
there's pretty strong sentiment from Clang maintainers against making the flag 
permanently available. This behavior is controlled by standards bodies and 
allowing users to ignore that effectively makes a custom language subset (goes 
against our usual policy for language extensions). As Erich mentions, this was 
adopted as a DR in C++ so there's no older standards there. WG14 doesn't have 
the notion of DRs any longer and our replacement mechanism wasn't in place when 
the paper was adopted into C23. Technically that makes it a C23-only change, 
but I don't see any value to making this a DR in C++ but not in C given that 
both languages implement the same identifier rules and there's a reasonable 
user expectation that a valid identifier in C is also valid in C++ and vice 
versa (otherwise you run into problems linking C and C++ together).




Comment at: clang/docs/ReleaseNotes.rst:128
+  advised because we intend to turn the warning back into a hard error in Clang
+  18 after giving users a chance to update their code.
 

efriedma wrote:
> If this makes it into clang 15, we don't want to relnote it for clang 16.
Agreed -- I added the release note so folks could review it, but the plan is to 
either add it directly to the 15.x release notes or if we don't want to 
backport they'll be typical Clang 16 release notes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132877

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


[clang] ce6989f - Revert "[Driver] Fix & re-enable DriverKit test"

2022-08-29 Thread Julian Lettner via cfe-commits

Author: Julian Lettner
Date: 2022-08-29T11:59:01-07:00
New Revision: ce6989fd8a9fb2608f670de023fdd4611f47b811

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

LOG: Revert "[Driver] Fix & re-enable DriverKit test"

This reverts commit 2d66571729a2ffcd88398a77508b0d6432ed7ba0 due to
test failure:

http://45.33.8.238/win/65224/step_7.txt

Added: 


Modified: 
clang/test/Driver/driverkit-path.c

Removed: 




diff  --git a/clang/test/Driver/driverkit-path.c 
b/clang/test/Driver/driverkit-path.c
index c061a1b1c5ed9..0aa3e958b2908 100644
--- a/clang/test/Driver/driverkit-path.c
+++ b/clang/test/Driver/driverkit-path.c
@@ -1,4 +1,7 @@
 // REQUIRES: x86-registered-target
+// REQUIRES: darwin
+// FIXME: Breaks on non-macOS:
+//http://45.33.8.238/linux/85125/step_7.txt
 // RUN: %clang %s -target x86_64-apple-driverkit19.0 -mlinker-version=0 \
 // RUN:   -isysroot %S/Inputs/DriverKit19.0.sdk -### 2>&1   \
 // RUN: | FileCheck %s --check-prefix=LD64-OLD
@@ -22,6 +25,7 @@ int main() { return 0; }
 
 
 // RUN: %clang %s -target x86_64-apple-driverkit19.0 -isysroot 
%S/Inputs/DriverKit19.0.sdk -E -v -x c++ 2>&1 | FileCheck %s --check-prefix=INC
+// RUN: %clang %s -arch x86_64   -isysroot 
%S/Inputs/DriverKit19.0.sdk -E -v -x c++ 2>&1 | FileCheck %s --check-prefix=INC
 //
 // INC:   -isysroot [[PATH:[^ ]*/Inputs/DriverKit19.0.sdk]]
 // INC-LABEL: #include <...> search starts here:



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


[PATCH] D132877: Downgrade the UAX31 diagnostic to a warning which defaults to an error

2022-08-29 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

In D132877#3756328 , @efriedma wrote:

> If we don't specifically call out the deprecation period in the diagnostic, 
> usage will grow beyond what we expect.  (Most people don't read the release 
> notes; they'll just see it's possible to turn off the error message, and turn 
> it off.)
>
> If we're okay with people deciding their own rules for what they want to 
> allow in identifiers, we can just make the flag permanently available, 
> though, and just drop the whole "deprecation period" discussion.  Or 
> alternatively, we could add a separate diagnostic specifically for older 
> standard modes: allow only the characters that were allowed by the older 
> standards, and don't emit it for C++23 and newer.  That way, usage naturally 
> goes away as people upgrade their code to newer standard modes.

IIRC, this was accepted as DR, so there are NO 'older standards' of C++ in 
which allow these characters.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132877

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


[PATCH] D132877: Downgrade the UAX31 diagnostic to a warning which defaults to an error

2022-08-29 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

If we don't specifically call out the deprecation period in the diagnostic, 
usage will grow beyond what we expect.  (Most people don't read the release 
notes; they'll just see it's possible to turn off the error message, and turn 
it off.)

If we're okay with people deciding their own rules for what they want to allow 
in identifiers, we can just make the flag permanently available, though, and 
just drop the whole "deprecation period" discussion.  Or alternatively, we 
could add a separate diagnostic specifically for older standard modes: allow 
only the characters that were allowed by the older standards, and don't emit it 
for C++23 and newer.  That way, usage naturally goes away as people upgrade 
their code to newer standard modes.




Comment at: clang/docs/ReleaseNotes.rst:128
+  advised because we intend to turn the warning back into a hard error in Clang
+  18 after giving users a chance to update their code.
 

If this makes it into clang 15, we don't want to relnote it for clang 16.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132877

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


[PATCH] D131820: [PS4][driver] make -fjmc work with LTO driver linking stage

2022-08-29 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen updated this revision to Diff 456427.
ychen added a comment.

- update


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131820

Files:
  clang/lib/Driver/ToolChains/PS4CPU.cpp
  clang/test/Driver/ps4-ps5-linker-jmc.c


Index: clang/test/Driver/ps4-ps5-linker-jmc.c
===
--- /dev/null
+++ clang/test/Driver/ps4-ps5-linker-jmc.c
@@ -0,0 +1,20 @@
+// Test the driver's control over the JustMyCode behavior with linker flags.
+
+// RUN: %clang --target=x86_64-scei-ps4 -fjmc %s -### 2>&1 | FileCheck 
--check-prefixes=CHECK-PS4,CHECK-PS4-LIB %s
+// RUN: %clang --target=x86_64-scei-ps4 -flto=thin -fjmc %s -### 2>&1 | 
FileCheck --check-prefixes=CHECK-PS4-THIN-LTO,CHECK-PS4-LIB %s
+// RUN: %clang --target=x86_64-scei-ps4 -flto=full -fjmc %s -### 2>&1 | 
FileCheck --check-prefixes=CHECK-PS4-FULL-LTO,CHECK-PS4-LIB %s
+// RUN: %clang --target=x86_64-scei-ps5 -fjmc %s -### 2>&1 | FileCheck 
--check-prefixes=CHECK-PS5,CHECK-PS5-LIB %s
+// RUN: %clang --target=x86_64-scei-ps5 -flto -fjmc %s -### 2>&1 | FileCheck 
--check-prefixes=CHECK-PS5-LTO,CHECK-PS5-LIB %s
+
+// CHECK-PS4-NOT: "-enable-jmc-instrument"
+
+// CHECK-PS4-THIN-LTO: "-lto-thin-debug-options=-enable-jmc-instrument"
+// CHECK-PS4-FULL-LTO: "-lto-debug-options=-enable-jmc-instrument"
+
+// CHECK-PS5-NOT: "-enable-jmc-instrument"
+
+// CHECK-PS5-LTO: "-mllvm" "-enable-jmc-instrument"
+
+// Check the default library name.
+// CHECK-PS4-LIB: "--whole-archive" "-lSceDbgJmc" "--no-whole-archive"
+// CHECK-PS5-LIB: "--whole-archive" "-lSceJmc_nosubmission" 
"--no-whole-archive"
Index: clang/lib/Driver/ToolChains/PS4CPU.cpp
===
--- clang/lib/Driver/ToolChains/PS4CPU.cpp
+++ clang/lib/Driver/ToolChains/PS4CPU.cpp
@@ -152,6 +152,26 @@
 assert(Output.isNothing() && "Invalid output.");
   }
 
+  const bool UseLTO = D.isUsingLTO();
+  const bool UseJMC =
+  Args.hasFlag(options::OPT_fjmc, options::OPT_fno_jmc, false);
+  const bool IsPS4 = TC.getTriple().isPS4();
+  const bool IsPS5 = TC.getTriple().isPS5();
+  assert(IsPS4 || IsPS5);
+
+  // This tells LTO to perform JustMyCode instrumentation.
+  if (UseLTO && UseJMC) {
+if (IsPS4 && D.getLTOMode() == LTOK_Thin) {
+  CmdArgs.push_back("-lto-thin-debug-options=-enable-jmc-instrument");
+} else if (IsPS4 && D.getLTOMode() == LTOK_Full) {
+  CmdArgs.push_back("-lto-debug-options=-enable-jmc-instrument");
+} else if (IsPS5) {
+  CmdArgs.push_back("-mllvm");
+  CmdArgs.push_back("-enable-jmc-instrument");
+} else
+  llvm_unreachable("new LTO mode?");
+  }
+
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs))
 TC.addSanitizerArgs(Args, CmdArgs, "-l", "");
 
@@ -171,6 +191,15 @@
 CmdArgs.push_back("-lpthread");
   }
 
+  if (UseJMC) {
+CmdArgs.push_back("--whole-archive");
+if (IsPS4)
+  CmdArgs.push_back("-lSceDbgJmc");
+else
+  CmdArgs.push_back("-lSceJmc_nosubmission");
+CmdArgs.push_back("--no-whole-archive");
+  }
+
   if (Args.hasArg(options::OPT_fuse_ld_EQ)) {
 D.Diag(diag::err_drv_unsupported_opt_for_target)
 << "-fuse-ld" << TC.getTriple().str();


Index: clang/test/Driver/ps4-ps5-linker-jmc.c
===
--- /dev/null
+++ clang/test/Driver/ps4-ps5-linker-jmc.c
@@ -0,0 +1,20 @@
+// Test the driver's control over the JustMyCode behavior with linker flags.
+
+// RUN: %clang --target=x86_64-scei-ps4 -fjmc %s -### 2>&1 | FileCheck --check-prefixes=CHECK-PS4,CHECK-PS4-LIB %s
+// RUN: %clang --target=x86_64-scei-ps4 -flto=thin -fjmc %s -### 2>&1 | FileCheck --check-prefixes=CHECK-PS4-THIN-LTO,CHECK-PS4-LIB %s
+// RUN: %clang --target=x86_64-scei-ps4 -flto=full -fjmc %s -### 2>&1 | FileCheck --check-prefixes=CHECK-PS4-FULL-LTO,CHECK-PS4-LIB %s
+// RUN: %clang --target=x86_64-scei-ps5 -fjmc %s -### 2>&1 | FileCheck --check-prefixes=CHECK-PS5,CHECK-PS5-LIB %s
+// RUN: %clang --target=x86_64-scei-ps5 -flto -fjmc %s -### 2>&1 | FileCheck --check-prefixes=CHECK-PS5-LTO,CHECK-PS5-LIB %s
+
+// CHECK-PS4-NOT: "-enable-jmc-instrument"
+
+// CHECK-PS4-THIN-LTO: "-lto-thin-debug-options=-enable-jmc-instrument"
+// CHECK-PS4-FULL-LTO: "-lto-debug-options=-enable-jmc-instrument"
+
+// CHECK-PS5-NOT: "-enable-jmc-instrument"
+
+// CHECK-PS5-LTO: "-mllvm" "-enable-jmc-instrument"
+
+// Check the default library name.
+// CHECK-PS4-LIB: "--whole-archive" "-lSceDbgJmc" "--no-whole-archive"
+// CHECK-PS5-LIB: "--whole-archive" "-lSceJmc_nosubmission" "--no-whole-archive"
Index: clang/lib/Driver/ToolChains/PS4CPU.cpp
===
--- clang/lib/Driver/ToolChains/PS4CPU.cpp
+++ clang/lib/Driver/ToolChains/PS4CPU.cpp
@@ -152,6 +152,26 @@
 assert(Output.isNothing() && "Invalid output.");
   }
 
+  const bool UseLTO 

[PATCH] D131306: [llvm][misexpect] Track provenance of branch weights

2022-08-29 Thread Paul Kirth via Phabricator via cfe-commits
paulkirth added a comment.

I think that may be a better approach. Let me investigate a bit and see what 
the exact tradeoffs are.

If anyone else has a suggestion or thought on another way to handle this, I'm 
all ears.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131306

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


[PATCH] D131820: [PS4][driver] make -fjmc work with LTO driver linking stage

2022-08-29 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen updated this revision to Diff 456426.
ychen added a comment.

- use `--target`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131820

Files:
  clang/lib/Driver/ToolChains/PS4CPU.cpp
  clang/test/Driver/ps4-ps5-linker-jmc.c


Index: clang/test/Driver/ps4-ps5-linker-jmc.c
===
--- /dev/null
+++ clang/test/Driver/ps4-ps5-linker-jmc.c
@@ -0,0 +1,20 @@
+// Test the driver's control over the JustMyCode behavior with linker flags.
+
+// RUN: %clang --target x86_64-scei-ps4 -fjmc %s -### 2>&1 | FileCheck 
--check-prefixes=CHECK-PS4,CHECK-PS4-LIB %s
+// RUN: %clang --target x86_64-scei-ps4 -flto=thin -fjmc %s -### 2>&1 | 
FileCheck --check-prefixes=CHECK-PS4-THIN-LTO,CHECK-PS4-LIB %s
+// RUN: %clang --target x86_64-scei-ps4 -flto=full -fjmc %s -### 2>&1 | 
FileCheck --check-prefixes=CHECK-PS4-FULL-LTO,CHECK-PS4-LIB %s
+// RUN: %clang --target x86_64-scei-ps5 -fjmc %s -### 2>&1 | FileCheck 
--check-prefixes=CHECK-PS5,CHECK-PS5-LIB %s
+// RUN: %clang --target x86_64-scei-ps5 -flto -fjmc %s -### 2>&1 | FileCheck 
--check-prefixes=CHECK-PS5-LTO,CHECK-PS5-LIB %s
+
+// CHECK-PS4-NOT: "-enable-jmc-instrument"
+
+// CHECK-PS4-THIN-LTO: "-lto-thin-debug-options=-enable-jmc-instrument"
+// CHECK-PS4-FULL-LTO: "-lto-debug-options=-enable-jmc-instrument"
+
+// CHECK-PS5-NOT: "-enable-jmc-instrument"
+
+// CHECK-PS5-LTO: "-mllvm" "-enable-jmc-instrument"
+
+// Check the default library name.
+// CHECK-PS4-LIB: "--whole-archive" "-lSceDbgJmc" "--no-whole-archive"
+// CHECK-PS5-LIB: "--whole-archive" "-lSceJmc_nosubmission" 
"--no-whole-archive"
Index: clang/lib/Driver/ToolChains/PS4CPU.cpp
===
--- clang/lib/Driver/ToolChains/PS4CPU.cpp
+++ clang/lib/Driver/ToolChains/PS4CPU.cpp
@@ -152,6 +152,26 @@
 assert(Output.isNothing() && "Invalid output.");
   }
 
+  const bool UseLTO = D.isUsingLTO();
+  const bool UseJMC =
+  Args.hasFlag(options::OPT_fjmc, options::OPT_fno_jmc, false);
+  const bool IsPS4 = TC.getTriple().isPS4();
+  const bool IsPS5 = TC.getTriple().isPS5();
+  assert(IsPS4 || IsPS5);
+
+  // This tells LTO to perform JustMyCode instrumentation.
+  if (UseLTO && UseJMC) {
+if (IsPS4 && D.getLTOMode() == LTOK_Thin) {
+  CmdArgs.push_back("-lto-thin-debug-options=-enable-jmc-instrument");
+} else if (IsPS4 && D.getLTOMode() == LTOK_Full) {
+  CmdArgs.push_back("-lto-debug-options=-enable-jmc-instrument");
+} else if (IsPS5) {
+  CmdArgs.push_back("-mllvm");
+  CmdArgs.push_back("-enable-jmc-instrument");
+} else
+  llvm_unreachable("new LTO mode?");
+  }
+
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs))
 TC.addSanitizerArgs(Args, CmdArgs, "-l", "");
 
@@ -171,6 +191,15 @@
 CmdArgs.push_back("-lpthread");
   }
 
+  if (UseJMC) {
+CmdArgs.push_back("--whole-archive");
+if (IsPS4)
+  CmdArgs.push_back("-lSceDbgJmc");
+else
+  CmdArgs.push_back("-lSceJmc_nosubmission");
+CmdArgs.push_back("--no-whole-archive");
+  }
+
   if (Args.hasArg(options::OPT_fuse_ld_EQ)) {
 D.Diag(diag::err_drv_unsupported_opt_for_target)
 << "-fuse-ld" << TC.getTriple().str();


Index: clang/test/Driver/ps4-ps5-linker-jmc.c
===
--- /dev/null
+++ clang/test/Driver/ps4-ps5-linker-jmc.c
@@ -0,0 +1,20 @@
+// Test the driver's control over the JustMyCode behavior with linker flags.
+
+// RUN: %clang --target x86_64-scei-ps4 -fjmc %s -### 2>&1 | FileCheck --check-prefixes=CHECK-PS4,CHECK-PS4-LIB %s
+// RUN: %clang --target x86_64-scei-ps4 -flto=thin -fjmc %s -### 2>&1 | FileCheck --check-prefixes=CHECK-PS4-THIN-LTO,CHECK-PS4-LIB %s
+// RUN: %clang --target x86_64-scei-ps4 -flto=full -fjmc %s -### 2>&1 | FileCheck --check-prefixes=CHECK-PS4-FULL-LTO,CHECK-PS4-LIB %s
+// RUN: %clang --target x86_64-scei-ps5 -fjmc %s -### 2>&1 | FileCheck --check-prefixes=CHECK-PS5,CHECK-PS5-LIB %s
+// RUN: %clang --target x86_64-scei-ps5 -flto -fjmc %s -### 2>&1 | FileCheck --check-prefixes=CHECK-PS5-LTO,CHECK-PS5-LIB %s
+
+// CHECK-PS4-NOT: "-enable-jmc-instrument"
+
+// CHECK-PS4-THIN-LTO: "-lto-thin-debug-options=-enable-jmc-instrument"
+// CHECK-PS4-FULL-LTO: "-lto-debug-options=-enable-jmc-instrument"
+
+// CHECK-PS5-NOT: "-enable-jmc-instrument"
+
+// CHECK-PS5-LTO: "-mllvm" "-enable-jmc-instrument"
+
+// Check the default library name.
+// CHECK-PS4-LIB: "--whole-archive" "-lSceDbgJmc" "--no-whole-archive"
+// CHECK-PS5-LIB: "--whole-archive" "-lSceJmc_nosubmission" "--no-whole-archive"
Index: clang/lib/Driver/ToolChains/PS4CPU.cpp
===
--- clang/lib/Driver/ToolChains/PS4CPU.cpp
+++ clang/lib/Driver/ToolChains/PS4CPU.cpp
@@ -152,6 +152,26 @@
 assert(Output.isNothing() && "Invalid output.");
   }
 
+  const bool 

[PATCH] D131820: [PS4][driver] make -fjmc work with LTO driver linking stage

2022-08-29 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: clang/test/Driver/ps4-ps5-linker-jmc.c:3
+
+// RUN: %clang -target x86_64-scei-ps4 -fjmc %s -### 2>&1 | FileCheck 
--check-prefixes=CHECK-PS4,CHECK-PS4-LIB %s
+// RUN: %clang -target x86_64-scei-ps4 -flto=thin -fjmc %s -### 2>&1 | 
FileCheck --check-prefixes=CHECK-PS4-THIN-LTO,CHECK-PS4-LIB %s

`-target ` is legacy. Use `--target=`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131820

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


[PATCH] D131306: [llvm][misexpect] Track provenance of branch weights

2022-08-29 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson added a comment.

In D131306#3756153 , @paulkirth wrote:

> In D131306#3756087 , @tejohnson 
> wrote:
>
>> Well I was thinking the extra field would be optional as well and could be 
>> removed. But understood that this requires more changes (although maybe not 
>> if it is optional, and after your recent changes to centralize some of the 
>> prof metadata handling in the compiler).
>
> Hmm, I don't think I considered that a field in the metadata could be 
> optional. Do you mean something like this?
>
>   !{!"branch_weights", !10, i32 1717986918, i32 429496731}
>
> where `!10` is just some optional metadata, and we'd just ensure things that 
> parse the MD_prof data skip it correctly? Given that we've mostly 
> consolidated how branch weights are extracted and manipulated that might only 
> require a limited number of updates to the code and tests.

Yep! Or a string. I was thinking it might be easier at the end of the list of 
fields, but either way.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131306

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


[PATCH] D132877: Downgrade the UAX31 diagnostic to a warning which defaults to an error

2022-08-29 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added subscribers: thieta, tstellar.
aaron.ballman added a comment.

CC @tstellar and @thieta for any early backporting concerns.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132877

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


[clang-tools-extra] 7df0f0b - [clang-tidy] Fixing a bug in `InfiniteLoopCheck` that raises false alarms on finite loops

2022-08-29 Thread via cfe-commits

Author: ziqingluo-90
Date: 2022-08-29T11:18:44-07:00
New Revision: 7df0f0b410674437f0b56262043e22b177709161

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

LOG: [clang-tidy] Fixing a bug in `InfiniteLoopCheck` that raises false alarms 
on finite loops

A loop can recursively increase/decrease a function local static
variable and make itself finite.  For example,

```
void f() {
  static int i = 0;
  i++;
  while (i < 10)
 f();
}

```

Such cases are not considered by `InfiniteLoopCheck`.  This commit
fixes this problem by detecting usages of static local variables
and recursions.

Reviewed by: NoQ, njames93
Differential Revision: https://reviews.llvm.org/D128401

Added: 


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

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/bugprone/InfiniteLoopCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/InfiniteLoopCheck.cpp
index e2401ff7ec0c0..5d4b828233321 100644
--- a/clang-tools-extra/clang-tidy/bugprone/InfiniteLoopCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/InfiniteLoopCheck.cpp
@@ -11,6 +11,9 @@
 #include "clang/AST/ASTContext.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 #include "clang/Analysis/Analyses/ExprMutationAnalyzer.h"
+#include "clang/Analysis/CallGraph.h"
+#include "llvm/ADT/SCCIterator.h"
+#include "llvm/ADT/SmallVector.h"
 
 using namespace clang::ast_matchers;
 using clang::tidy::utils::hasPtrOrReferenceInFunc;
@@ -166,6 +169,110 @@ static bool isKnownToHaveValue(const Expr , const 
ASTContext ,
   return false;
 }
 
+/// populates the set `Callees` with all function (and objc method) 
declarations
+/// called in `StmtNode` if all visited call sites have resolved call targets.
+///
+/// \return true iff all `CallExprs` visited have callees; false otherwise
+/// indicating there is an unresolved indirect call.
+static bool populateCallees(const Stmt *StmtNode,
+llvm::SmallSet ) {
+  if (const auto *Call = dyn_cast(StmtNode)) {
+const Decl *Callee = Call->getDirectCallee();
+
+if (!Callee)
+  return false; // unresolved call
+Callees.insert(Callee->getCanonicalDecl());
+  }
+  if (const auto *Call = dyn_cast(StmtNode)) {
+const Decl *Callee = Call->getMethodDecl();
+
+if (!Callee)
+  return false; // unresolved call
+Callees.insert(Callee->getCanonicalDecl());
+  }
+  for (const Stmt *Child : StmtNode->children())
+if (Child && !populateCallees(Child, Callees))
+  return false;
+  return true;
+}
+
+/// returns true iff `SCC` contains `Func` and its' function set overlaps with
+/// `Callees`
+static bool overlap(ArrayRef SCC,
+const llvm::SmallSet ,
+const Decl *Func) {
+  bool ContainsFunc = false, Overlap = false;
+
+  for (const CallGraphNode *GNode : SCC) {
+const Decl *CanDecl = GNode->getDecl()->getCanonicalDecl();
+
+ContainsFunc = ContainsFunc || (CanDecl == Func);
+Overlap = Overlap || Callees.contains(CanDecl);
+if (ContainsFunc && Overlap)
+  return true;
+  }
+  return false;
+}
+
+/// returns true iff `Cond` involves at least one static local variable.
+static bool hasStaticLocalVariable(const Stmt *Cond) {
+  if (const auto *DRE = dyn_cast(Cond))
+if (const auto *VD = dyn_cast(DRE->getDecl()))
+  if (VD->isStaticLocal())
+return true;
+  for (const Stmt *Child : Cond->children())
+if (Child && hasStaticLocalVariable(Child))
+  return true;
+  return false;
+}
+
+/// Tests if the loop condition `Cond` involves static local variables and
+/// the enclosing function `Func` is recursive.
+///
+///  \code
+///void f() {
+///   static int i = 10;
+///   i--;
+///   while (i >= 0) f();
+///}
+///  \endcode
+///  The example above is NOT an infinite loop.
+static bool hasRecursionOverStaticLoopCondVariables(const Expr *Cond,
+const Stmt *LoopStmt,
+const Decl *Func,
+const ASTContext *Ctx) {
+  if (!hasStaticLocalVariable(Cond))
+return false;
+
+  llvm::SmallSet CalleesInLoop;
+
+  if (!populateCallees(LoopStmt, CalleesInLoop)) {
+// If there are unresolved indirect calls, we assume there could
+// be recursion so to avoid false alarm.
+return true;
+  }
+  if (CalleesInLoop.empty())
+return false;
+
+  TranslationUnitDecl *TUDecl = Ctx->getTranslationUnitDecl();
+  CallGraph CG;
+
+  CG.addToCallGraph(TUDecl);
+  // For each `SCC` containing `Func`, if functions in 

[PATCH] D128401: [clang-tidy] Fixing a bug raising false alarms on static local variables in the Infinite Loop Checker

2022-08-29 Thread Ziqing Luo via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rG7df0f0b41067: [clang-tidy] Fixing a bug in 
`InfiniteLoopCheck` that raises false alarms on… (authored by ziqingluo-90).

Changed prior to commit:
  https://reviews.llvm.org/D128401?vs=439903=456422#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128401

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

Index: clang-tools-extra/test/clang-tidy/checkers/bugprone/infinite-loop.mm
===
--- clang-tools-extra/test/clang-tidy/checkers/bugprone/infinite-loop.mm
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone/infinite-loop.mm
@@ -44,6 +44,27 @@
 j++;
   }
 }
+
++ (void)recursiveMethod {
+  static int i = 0;
+
+  i++;
+  while (i < 10) {
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: this loop is infinite; none of its condition variables (i) are updated in the loop body [bugprone-infinite-loop]
+[I classMethod];
+  }
+
+  id x = [[I alloc] init];
+
+  while (i < 10) {
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: this loop is infinite; none of its condition variables (i) are updated in the loop body [bugprone-infinite-loop]
+[x instanceMethod];
+  }
+  while (i < 10) {
+// no warning, there is a recursive call that can mutate the static local variable
+[I recursiveMethod];
+  }
+}
 @end
 
 void testArrayCount() {
Index: clang-tools-extra/test/clang-tidy/checkers/bugprone/infinite-loop.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/bugprone/infinite-loop.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone/infinite-loop.cpp
@@ -685,3 +685,29 @@
 0;
   }) x;
 }
+
+void test_local_static_recursion() {
+  static int i = 10;
+  int j = 0;
+
+  i--;
+  while (i >= 0)
+test_local_static_recursion(); // no warning, recursively decrement i
+  for (; i >= 0;)
+test_local_static_recursion(); // no warning, recursively decrement i
+  for (; i + j >= 0;)
+test_local_static_recursion(); // no warning, recursively decrement i
+  for (; i >= 0; i--)
+; // no warning, i decrements
+  while (j >= 0)
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: this loop is infinite; none of its condition variables (j) are updated in the loop body [bugprone-infinite-loop]
+test_local_static_recursion();
+
+  int (*p)(int) = 0;
+
+  while (i >= 0)
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: this loop is infinite; none of its condition variables (i) are updated in the loop body [bugprone-infinite-loop]
+p = 0;
+  while (i >= 0)
+p(0); // we don't know what p points to so no warning
+}
Index: clang-tools-extra/clang-tidy/bugprone/InfiniteLoopCheck.cpp
===
--- clang-tools-extra/clang-tidy/bugprone/InfiniteLoopCheck.cpp
+++ clang-tools-extra/clang-tidy/bugprone/InfiniteLoopCheck.cpp
@@ -11,6 +11,9 @@
 #include "clang/AST/ASTContext.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 #include "clang/Analysis/Analyses/ExprMutationAnalyzer.h"
+#include "clang/Analysis/CallGraph.h"
+#include "llvm/ADT/SCCIterator.h"
+#include "llvm/ADT/SmallVector.h"
 
 using namespace clang::ast_matchers;
 using clang::tidy::utils::hasPtrOrReferenceInFunc;
@@ -166,6 +169,110 @@
   return false;
 }
 
+/// populates the set `Callees` with all function (and objc method) declarations
+/// called in `StmtNode` if all visited call sites have resolved call targets.
+///
+/// \return true iff all `CallExprs` visited have callees; false otherwise
+/// indicating there is an unresolved indirect call.
+static bool populateCallees(const Stmt *StmtNode,
+llvm::SmallSet ) {
+  if (const auto *Call = dyn_cast(StmtNode)) {
+const Decl *Callee = Call->getDirectCallee();
+
+if (!Callee)
+  return false; // unresolved call
+Callees.insert(Callee->getCanonicalDecl());
+  }
+  if (const auto *Call = dyn_cast(StmtNode)) {
+const Decl *Callee = Call->getMethodDecl();
+
+if (!Callee)
+  return false; // unresolved call
+Callees.insert(Callee->getCanonicalDecl());
+  }
+  for (const Stmt *Child : StmtNode->children())
+if (Child && !populateCallees(Child, Callees))
+  return false;
+  return true;
+}
+
+/// returns true iff `SCC` contains `Func` and its' function set overlaps with
+/// `Callees`
+static bool overlap(ArrayRef SCC,
+const llvm::SmallSet ,
+const Decl *Func) {
+  bool ContainsFunc = false, Overlap = false;
+
+  for (const CallGraphNode *GNode : SCC) {
+const Decl *CanDecl = 

[PATCH] D132877: Downgrade the UAX31 diagnostic to a warning which defaults to an error

2022-08-29 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman created this revision.
aaron.ballman added reviewers: tahonermann, cor3ntin, clang-language-wg.
Herald added a project: All.
aaron.ballman requested review of this revision.
Herald added a project: clang.

WG21 P1949  and WG14 N2836 were both adopted 
without any deprecation period for users who were making use of now-invalid 
characters in their identifiers. This caused some amount of pain for people, 
especially folks using mathematical symbols in their identifiers, which makes 
it hard to upgrade to newer Clang versions with this diagnostic as an error.

This patch downgrades the error to be a warning which defaults to an error. 
This continues to signal to users that the identifiers are in fact invalid, but 
it gives a grace period for people to update their code bases to the new rules 
(or, alternatively, time for the Unicode consortium to determine whether some 
of these characters should be allowed in an identifier in the immutable set). I 
am tentatively documenting that grace period as being until we ship Clang 18 
(which should give users a year or two to migrate their code).

Note, because we implemented the UAX31 rules in Clang 14, I would like to try 
to land this patch and backport it to Clang 15 so that we avoid having *two* 
releases with no easy migration path for this subset of users. I think this is 
reasonable because we're not altering the implementation logic at all, just 
modifying what diagnostic kind is emitted by default. If someone has a concern 
about wanting to cherry pick this so late in the cycle, please share those 
concerns ASAP.

Fixes #54732


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D132877

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/DiagnosticLexKinds.td
  clang/test/Preprocessor/utf8-allowed-chars.c

Index: clang/test/Preprocessor/utf8-allowed-chars.c
===
--- clang/test/Preprocessor/utf8-allowed-chars.c
+++ clang/test/Preprocessor/utf8-allowed-chars.c
@@ -1,58 +1,32 @@
-// RUN: %clang_cc1 %s -fsyntax-only -std=c99 -verify
-// RUN: %clang_cc1 %s -fsyntax-only -std=c11 -Wc99-compat -verify
-// RUN: %clang_cc1 %s -fsyntax-only -x c++ -std=c++03 -Wc++11-compat -verify
-// RUN: %clang_cc1 %s -fsyntax-only -x c++ -std=c++11 -Wc++98-compat -verify
+// RUN: %clang_cc1 %s -fsyntax-only -std=c99 -verify=expected,c99
+// RUN: %clang_cc1 %s -fsyntax-only -std=c11 -Wc99-compat -verify=expected,c11
+// RUN: %clang_cc1 %s -fsyntax-only -x c++ -std=c++03 -Wc++11-compat -verify=expected,cpp
+// RUN: %clang_cc1 %s -fsyntax-only -x c++ -std=c++11 -Wc++98-compat -verify=expected,cpp
+// RUN: %clang_cc1 %s -fsyntax-only -Wno-invalid-identifier-character -std=c2x -verify=off
+// RUN: %clang_cc1 %s -fsyntax-only -Wno-invalid-identifier-character -x c++ -std=c++2b -verify=off
 
 // Note: This file contains Unicode characters; please do not remove them!
 
 // Identifier characters
-extern char aǶ; // C11, C++11
+extern char aǶ; // c11-warning {{using this character in an identifier is incompatible with C99}} \
+   c99-error {{not allowed in an identifier}}
 extern char aª; // C99, C11, C++11
-extern char a΄; // C++03, C11, C++11
+extern char a΄; // cpp-error {{not allowed in an identifier}} \
+   c11-warning {{using this character in an identifier is incompatible with C99}} \
+   c99-error {{not allowed in an identifier}}
 extern char a๐; // C99, C++03, C11, C++11
-extern char a﹅; // none
-extern char x̀; // C11, C++11. Note that this does not have a composed form.
-
-
+extern char a﹅; // expected-error {{not allowed in an identifier}}
 
+// Note that this does not have a composed form.
+extern char x̀; // c11-warning {{using this character in an identifier is incompatible with C99}} \
+   c99-error {{not allowed in an identifier}}
 
 // Identifier initial characters
-extern char ๐; // C++03, C11, C++11
-extern char ̀; // disallowed initially in C11/C++, always in C99
-
-
-
-
-#if __cplusplus
-// expected-error@11 {{not allowed in an identifier}}
-// expected-error@13 {{not allowed in an identifier}}
-// expected-error@20 {{character  not allowed at the start of an identifier}}
-// expected-error@21 {{character  not allowed at the start of an identifier}}
-// expected-warning@20 {{declaration does not declare anything}}
-// expected-warning@21 {{declaration does not declare anything}}
-
-#else
-# if __STDC_VERSION__ >= 201112L
-// C11
-// expected-warning@9 {{using this character in an identifier is incompatible with C99}}
-// expected-warning@11 {{using this character in an identifier is incompatible with C99}}
-// expected-error@13 {{not allowed in an identifier}}
-// expected-warning@14 {{using this character in an identifier is incompatible with C99}}
-// expected-warning@20 {{starting an identifier with this character is incompatible with C99}}
-// 

[PATCH] D132874: [clang] Don't emit debug vtable information for consteval functions

2022-08-29 Thread Luke Nihlen via Phabricator via cfe-commits
luken-google added reviewers: aaron.ballman, ilya-biryukov.
luken-google added a comment.

Note that there's still an underlying issue where the linker complains of 
missing vtable information for both Base and Derived, which I'm treating as a 
separate issue and will either file or de-dup against an existing issue.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132874

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


[PATCH] D125418: [Arm64EC 6/?] Implement C/C++ mangling for Arm64EC function definitions.

2022-08-29 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

There's no way the calling convention can change based on whether you're 
calling a function vs. a function pointer.  I can't explain why MSVC is 
generating different code.  I think we should just ignore it, at least for now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125418

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


[PATCH] D132874: [clang] Don't emit debug vtable information for consteval functions

2022-08-29 Thread Luke Nihlen via Phabricator via cfe-commits
luken-google created this revision.
Herald added a project: All.
luken-google requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Fixes https://github.com/llvm/llvm-project/issues/55065


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D132874

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/test/CodeGenCXX/cxx20-consteval-crash.cpp


Index: clang/test/CodeGenCXX/cxx20-consteval-crash.cpp
===
--- clang/test/CodeGenCXX/cxx20-consteval-crash.cpp
+++ clang/test/CodeGenCXX/cxx20-consteval-crash.cpp
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -no-opaque-pointers -triple x86_64-unknown-linux-gnu 
-std=c++20 %s -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -emit-obj -debug-info-kind=constructor -std=c++20 %s -o -
 
 namespace PR50787 {
 // This code would previously cause a crash.
@@ -71,3 +72,22 @@
   return function(Item{'a'}, Item{'a'});
 }
 } // namespace Issue58871
+
+namespace Issue55065 {
+struct Base {
+  consteval virtual int Get() const = 0;
+};
+
+struct Derived : Base {
+  consteval int Get() const override {
+return 42;
+  }
+};
+
+int foo() {
+  constexpr Derived a;
+
+  auto val = a.Get();
+  return val;
+}
+} // namespace Issue55065
\ No newline at end of file
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -1758,7 +1758,7 @@
   llvm::DISubprogram::DISPFlags SPFlags = llvm::DISubprogram::SPFlagZero;
   int ThisAdjustment = 0;
 
-  if (Method->isVirtual()) {
+  if (Method->isVirtual() && !Method->isConsteval()) {
 if (Method->isPure())
   SPFlags |= llvm::DISubprogram::SPFlagPureVirtual;
 else
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -188,10 +188,11 @@
   and `DR1734 
`_.
 - Class member variables are now in scope when parsing a ``requires`` clause. 
Fixes
   `GH55216 `_.
-
 - Correctly set expression evaluation context as 'immediate function context' 
in
   consteval functions.
   This fixes `GH51182 `
+- Fixes an assert crash caused by looking up missing vtable information on 
``consteval``
+  virtual functions. Fixes `GH55065 
`_.
 
 
 C++2b Feature Support


Index: clang/test/CodeGenCXX/cxx20-consteval-crash.cpp
===
--- clang/test/CodeGenCXX/cxx20-consteval-crash.cpp
+++ clang/test/CodeGenCXX/cxx20-consteval-crash.cpp
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -no-opaque-pointers -triple x86_64-unknown-linux-gnu -std=c++20 %s -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -emit-obj -debug-info-kind=constructor -std=c++20 %s -o -
 
 namespace PR50787 {
 // This code would previously cause a crash.
@@ -71,3 +72,22 @@
   return function(Item{'a'}, Item{'a'});
 }
 } // namespace Issue58871
+
+namespace Issue55065 {
+struct Base {
+  consteval virtual int Get() const = 0;
+};
+
+struct Derived : Base {
+  consteval int Get() const override {
+return 42;
+  }
+};
+
+int foo() {
+  constexpr Derived a;
+
+  auto val = a.Get();
+  return val;
+}
+} // namespace Issue55065
\ No newline at end of file
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -1758,7 +1758,7 @@
   llvm::DISubprogram::DISPFlags SPFlags = llvm::DISubprogram::SPFlagZero;
   int ThisAdjustment = 0;
 
-  if (Method->isVirtual()) {
+  if (Method->isVirtual() && !Method->isConsteval()) {
 if (Method->isPure())
   SPFlags |= llvm::DISubprogram::SPFlagPureVirtual;
 else
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -188,10 +188,11 @@
   and `DR1734 `_.
 - Class member variables are now in scope when parsing a ``requires`` clause. Fixes
   `GH55216 `_.
-
 - Correctly set expression evaluation context as 'immediate function context' in
   consteval functions.
   This fixes `GH51182 `
+- Fixes an assert crash caused by looking up missing vtable information on ``consteval``
+  virtual functions. Fixes `GH55065 `_.
 
 
 C++2b Feature Support
___
cfe-commits mailing list

[PATCH] D131820: [PS4][driver] make -fjmc work with LTO driver linking stage

2022-08-29 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen updated this revision to Diff 456415.
ychen added a comment.

- update


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131820

Files:
  clang/lib/Driver/ToolChains/PS4CPU.cpp
  clang/test/Driver/ps4-ps5-linker-jmc.c


Index: clang/test/Driver/ps4-ps5-linker-jmc.c
===
--- /dev/null
+++ clang/test/Driver/ps4-ps5-linker-jmc.c
@@ -0,0 +1,20 @@
+// Test the driver's control over the JustMyCode behavior with linker flags.
+
+// RUN: %clang -target x86_64-scei-ps4 -fjmc %s -### 2>&1 | FileCheck 
--check-prefixes=CHECK-PS4,CHECK-PS4-LIB %s
+// RUN: %clang -target x86_64-scei-ps4 -flto=thin -fjmc %s -### 2>&1 | 
FileCheck --check-prefixes=CHECK-PS4-THIN-LTO,CHECK-PS4-LIB %s
+// RUN: %clang -target x86_64-scei-ps4 -flto=full -fjmc %s -### 2>&1 | 
FileCheck --check-prefixes=CHECK-PS4-FULL-LTO,CHECK-PS4-LIB %s
+// RUN: %clang -target x86_64-scei-ps5 -fjmc %s -### 2>&1 | FileCheck 
--check-prefixes=CHECK-PS5,CHECK-PS5-LIB %s
+// RUN: %clang -target x86_64-scei-ps5 -flto -fjmc %s -### 2>&1 | FileCheck 
--check-prefixes=CHECK-PS5-LTO,CHECK-PS5-LIB %s
+
+// CHECK-PS4-NOT: "-enable-jmc-instrument"
+
+// CHECK-PS4-THIN-LTO: "-lto-thin-debug-options=-enable-jmc-instrument"
+// CHECK-PS4-FULL-LTO: "-lto-debug-options=-enable-jmc-instrument"
+
+// CHECK-PS5-NOT: "-enable-jmc-instrument"
+
+// CHECK-PS5-LTO: "-mllvm" "-enable-jmc-instrument"
+
+// Check the default library name.
+// CHECK-PS4-LIB: "--whole-archive" "-lSceDbgJmc" "--no-whole-archive"
+// CHECK-PS5-LIB: "--whole-archive" "-lSceJmc_nosubmission" 
"--no-whole-archive"
Index: clang/lib/Driver/ToolChains/PS4CPU.cpp
===
--- clang/lib/Driver/ToolChains/PS4CPU.cpp
+++ clang/lib/Driver/ToolChains/PS4CPU.cpp
@@ -152,6 +152,26 @@
 assert(Output.isNothing() && "Invalid output.");
   }
 
+  const bool UseLTO = D.isUsingLTO();
+  const bool UseJMC =
+  Args.hasFlag(options::OPT_fjmc, options::OPT_fno_jmc, false);
+  const bool IsPS4 = TC.getTriple().isPS4();
+  const bool IsPS5 = TC.getTriple().isPS5();
+  assert(IsPS4 || IsPS5);
+
+  // This tells LTO to perform JustMyCode instrumentation.
+  if (UseLTO && UseJMC) {
+if (IsPS4 && D.getLTOMode() == LTOK_Thin) {
+  CmdArgs.push_back("-lto-thin-debug-options=-enable-jmc-instrument");
+} else if (IsPS4 && D.getLTOMode() == LTOK_Full) {
+  CmdArgs.push_back("-lto-debug-options=-enable-jmc-instrument");
+} else if (IsPS5) {
+  CmdArgs.push_back("-mllvm");
+  CmdArgs.push_back("-enable-jmc-instrument");
+} else
+  llvm_unreachable("new LTO mode?");
+  }
+
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs))
 TC.addSanitizerArgs(Args, CmdArgs, "-l", "");
 
@@ -171,6 +191,15 @@
 CmdArgs.push_back("-lpthread");
   }
 
+  if (UseJMC) {
+CmdArgs.push_back("--whole-archive");
+if (IsPS4)
+  CmdArgs.push_back("-lSceDbgJmc");
+else
+  CmdArgs.push_back("-lSceJmc_nosubmission");
+CmdArgs.push_back("--no-whole-archive");
+  }
+
   if (Args.hasArg(options::OPT_fuse_ld_EQ)) {
 D.Diag(diag::err_drv_unsupported_opt_for_target)
 << "-fuse-ld" << TC.getTriple().str();


Index: clang/test/Driver/ps4-ps5-linker-jmc.c
===
--- /dev/null
+++ clang/test/Driver/ps4-ps5-linker-jmc.c
@@ -0,0 +1,20 @@
+// Test the driver's control over the JustMyCode behavior with linker flags.
+
+// RUN: %clang -target x86_64-scei-ps4 -fjmc %s -### 2>&1 | FileCheck --check-prefixes=CHECK-PS4,CHECK-PS4-LIB %s
+// RUN: %clang -target x86_64-scei-ps4 -flto=thin -fjmc %s -### 2>&1 | FileCheck --check-prefixes=CHECK-PS4-THIN-LTO,CHECK-PS4-LIB %s
+// RUN: %clang -target x86_64-scei-ps4 -flto=full -fjmc %s -### 2>&1 | FileCheck --check-prefixes=CHECK-PS4-FULL-LTO,CHECK-PS4-LIB %s
+// RUN: %clang -target x86_64-scei-ps5 -fjmc %s -### 2>&1 | FileCheck --check-prefixes=CHECK-PS5,CHECK-PS5-LIB %s
+// RUN: %clang -target x86_64-scei-ps5 -flto -fjmc %s -### 2>&1 | FileCheck --check-prefixes=CHECK-PS5-LTO,CHECK-PS5-LIB %s
+
+// CHECK-PS4-NOT: "-enable-jmc-instrument"
+
+// CHECK-PS4-THIN-LTO: "-lto-thin-debug-options=-enable-jmc-instrument"
+// CHECK-PS4-FULL-LTO: "-lto-debug-options=-enable-jmc-instrument"
+
+// CHECK-PS5-NOT: "-enable-jmc-instrument"
+
+// CHECK-PS5-LTO: "-mllvm" "-enable-jmc-instrument"
+
+// Check the default library name.
+// CHECK-PS4-LIB: "--whole-archive" "-lSceDbgJmc" "--no-whole-archive"
+// CHECK-PS5-LIB: "--whole-archive" "-lSceJmc_nosubmission" "--no-whole-archive"
Index: clang/lib/Driver/ToolChains/PS4CPU.cpp
===
--- clang/lib/Driver/ToolChains/PS4CPU.cpp
+++ clang/lib/Driver/ToolChains/PS4CPU.cpp
@@ -152,6 +152,26 @@
 assert(Output.isNothing() && "Invalid output.");
   }
 
+  const bool UseLTO = 

[PATCH] D131306: [llvm][misexpect] Track provenance of branch weights

2022-08-29 Thread Paul Kirth via Phabricator via cfe-commits
paulkirth added a comment.

In D131306#3756087 , @tejohnson wrote:

> Well I was thinking the extra field would be optional as well and could be 
> removed. But understood that this requires more changes (although maybe not 
> if it is optional, and after your recent changes to centralize some of the 
> prof metadata handling in the compiler).

Hmm, I don't think I considered that a field in the metadata could be optional. 
Do you mean something like this?

  !{!"branch_weights", !10, i32 1717986918, i32 429496731}

where `!10` is just some optional metadata, and we'd just ensure things that 
parse the MD_prof data skip it correctly? Given that we've mostly consolidated 
how branch weights are extracted and manipulated that might only require a 
limited number of updates to the code and tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131306

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


[PATCH] D132791: Fix formatting in release notes

2022-08-29 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert closed this revision.
aaronpuchert added a comment.

Landed in 0c5ce1d7fba38948c27ed6b875f962cd60895574 
.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132791

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


[PATCH] D131618: [WIP][Do NOT review] LLD related changes for -ffat-lto-objects support

2022-08-29 Thread Arda Unal via Phabricator via cfe-commits
arda marked an inline comment as done.
arda added inline comments.



Comment at: llvm/lib/Bitcode/Writer/EmbedBitcodePass.cpp:26
+
+PreservedAnalyses EmbedBitcodePass::run(Module , ModuleAnalysisManager ) {
+  if (M.getGlobalVariable("llvm.embedded.module", true))

arda wrote:
> sfertile wrote:
> > From the discourse discussion:
> > 1) it was suggested that we remove the existing -fembed-bitcode 
> > functionality as Apple has stop supporting it.
> > 2) mentioned that MLGO uses the option to embed the bitcode at various 
> > points in the pipeline depending on if its using LTO our not.
> > 
> > Do we want the pass to be a bit more generic and be able to specify the 
> > global to use for embedding, and the section name to use as arguments? That 
> > way MLGO can keep using the section name it uses now . It also helps 
> > consuming tools to disambiguate between bitcode embedded for lto purpose 
> > from bitcode embedded for other purposes.
> I should have an answer in a couple of days. I will keep you updated.
We have talked to folks at MLGO and reached a decision that their use case is 
sufficiently different from ours that it should be handled separately. More 
detailed discussion here:

[[ https://discourse.llvm.org/t/rfc-ffat-lto-objects-support/63977/15?u=arda | 
[RFC] -ffat-lto-objects support on Discours ]]


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131618

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


[PATCH] D131979: [clang][UBSan] Fix __builtin_assume_aligned crash

2022-08-29 Thread Wang Yihan via Phabricator via cfe-commits
yihanaa added a comment.

In D131979#3753706 , @yihanaa wrote:

> Keep same behavior with current clang, don't emit an error when 1st arg is 
> volatile qualified.
>
> Ignore the implicit cast from user-written-type to 'const void *' on the 1st 
> arg, because CodeGen need user-written-type to generate correct 
> TypeDescriptor (this class in compiler-rt/UBSan), then, clang will emit cast 
> instruction which cast type from user-written-type to VoidPtr in CodeGen.
>
> But I still have some questions, for example: if someone pass a array 
> type(e.g. char[1]) as the 1st arg, what should the correct TypeDescriptor? 
> char[1] OR char *, clang will generate char * in this patch, you are experts 
> and what do you all think?

Hi John, can you please look at here, this is current version of patch's 
comment, and probably folded by Phabricator because of too many comments. 
Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131979

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


[PATCH] D132592: [Clang] Implement function attribute nouwtable

2022-08-29 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen updated this revision to Diff 456403.
ychen added a comment.

- add a release note.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132592

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/test/CodeGen/attr-nouwtable.c
  clang/test/Misc/pragma-attribute-supported-attributes-list.test


Index: clang/test/Misc/pragma-attribute-supported-attributes-list.test
===
--- clang/test/Misc/pragma-attribute-supported-attributes-list.test
+++ clang/test/Misc/pragma-attribute-supported-attributes-list.test
@@ -114,6 +114,7 @@
 // CHECK-NEXT: NoStackProtector (SubjectMatchRule_function)
 // CHECK-NEXT: NoThreadSafetyAnalysis (SubjectMatchRule_function)
 // CHECK-NEXT: NoThrow (SubjectMatchRule_hasType_functionType)
+// CHECK-NEXT: NoUwtable (SubjectMatchRule_hasType_functionType)
 // CHECK-NEXT: NotTailCalled (SubjectMatchRule_function)
 // CHECK-NEXT: OSConsumed (SubjectMatchRule_variable_is_parameter)
 // CHECK-NEXT: OSReturnsNotRetained (SubjectMatchRule_function, 
SubjectMatchRule_objc_method, SubjectMatchRule_objc_property, 
SubjectMatchRule_variable_is_parameter)
Index: clang/test/CodeGen/attr-nouwtable.c
===
--- /dev/null
+++ clang/test/CodeGen/attr-nouwtable.c
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -funwind-tables=2 -S -emit-llvm %s -o - | FileCheck %s
+
+__attribute__((nouwtable))
+int test1(void) { return 0; }
+
+// CHECK: @test1{{.*}}[[ATTR1:#[0-9]+]]
+// CHECK: attributes [[ATTR1]] = {
+// CHECK-NOT: uwtable
+// CHECK: }
Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -1942,7 +1942,7 @@
llvm::Function *F) {
   llvm::AttrBuilder B(F->getContext());
 
-  if (CodeGenOpts.UnwindTables)
+  if ((!D || !D->hasAttr()) && CodeGenOpts.UnwindTables)
 B.addUWTableAttr(llvm::UWTableKind(CodeGenOpts.UnwindTables));
 
   if (CodeGenOpts.StackClashProtector)
Index: clang/include/clang/Basic/AttrDocs.td
===
--- clang/include/clang/Basic/AttrDocs.td
+++ clang/include/clang/Basic/AttrDocs.td
@@ -4537,6 +4537,16 @@
 }];
 }
 
+def NoUwtableDocs : Documentation {
+  let Category = DocCatFunction;
+  let Content = [{
+Clang supports the ``nouwtable`` attribute which skips emitting
+the unwind table entry for the specified function. This attribute is useful for
+selectively emitting the unwind table entry on some functions when building 
with
+``-funwind-tables`` compiler option.
+}];
+}
+
 def InternalLinkageDocs : Documentation {
   let Category = DocCatFunction;
   let Content = [{
Index: clang/include/clang/Basic/Attr.td
===
--- clang/include/clang/Basic/Attr.td
+++ clang/include/clang/Basic/Attr.td
@@ -2086,6 +2086,13 @@
   let Documentation = [NoThrowDocs];
 }
 
+def NoUwtable : InheritableAttr {
+  let Spellings = [Clang<"nouwtable">];
+  let Subjects = SubjectList<[FunctionLike]>;
+  let Documentation = [NoUwtableDocs];
+  let SimpleHandler = 1;
+}
+
 def NvWeak : IgnoredAttr {
   // No Declspec spelling of this attribute; the CUDA headers use
   // __attribute__((nv_weak)) unconditionally. Does not receive an [[]]
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -129,6 +129,9 @@
 Attribute Changes in Clang
 --
 
+- Introduced a new function attribute ``__attribute__((nouwtable))`` to 
suppress
+  LLVM IR ``uwtable`` function attribute.
+
 Windows Support
 ---
 


Index: clang/test/Misc/pragma-attribute-supported-attributes-list.test
===
--- clang/test/Misc/pragma-attribute-supported-attributes-list.test
+++ clang/test/Misc/pragma-attribute-supported-attributes-list.test
@@ -114,6 +114,7 @@
 // CHECK-NEXT: NoStackProtector (SubjectMatchRule_function)
 // CHECK-NEXT: NoThreadSafetyAnalysis (SubjectMatchRule_function)
 // CHECK-NEXT: NoThrow (SubjectMatchRule_hasType_functionType)
+// CHECK-NEXT: NoUwtable (SubjectMatchRule_hasType_functionType)
 // CHECK-NEXT: NotTailCalled (SubjectMatchRule_function)
 // CHECK-NEXT: OSConsumed (SubjectMatchRule_variable_is_parameter)
 // CHECK-NEXT: OSReturnsNotRetained (SubjectMatchRule_function, SubjectMatchRule_objc_method, SubjectMatchRule_objc_property, SubjectMatchRule_variable_is_parameter)
Index: clang/test/CodeGen/attr-nouwtable.c
===
--- 

  1   2   3   >