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

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

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


Repository:
  rT test-suite

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

https://reviews.llvm.org/D106804

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


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

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

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


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93298

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

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

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

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



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

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


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108621

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


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

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

support zfinx-1.0-rc


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93298

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

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

[PATCH] D108567: Implement #pragma clang final extension

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

Updates based on feedback from @aaron.ballman.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108567

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

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

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

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

LGTM, thanks :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109635

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


[PATCH] D108567: Implement #pragma clang final extension

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



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

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



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

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

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



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

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


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108567

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


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

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

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


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95588

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


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

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

add another FIXME.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109800

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

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

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

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

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


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D109865

Files:
  clang/lib/Frontend/FrontendAction.cpp

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

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

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

.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109800

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

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

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

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

typo


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109800

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

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

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

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

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


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109800

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

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

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

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

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


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109800

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


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

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

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

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

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

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


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109800

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


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

2021-09-15 Thread Chi Chun Chen via Phabricator via cfe-commits
cchen updated this revision to Diff 372843.
cchen added a comment.

Add tests and fix coding style


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109635

Files:
  clang/include/clang/AST/OpenMPClause.h
  clang/lib/AST/OpenMPClause.cpp
  clang/lib/Parse/ParseOpenMP.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/OpenMP/declare_variant_ast_print.c
  clang/test/OpenMP/declare_variant_ast_print.cpp
  clang/test/OpenMP/declare_variant_construct_codegen_1.c
  clang/test/OpenMP/declare_variant_messages.c

Index: clang/test/OpenMP/declare_variant_messages.c
===
--- clang/test/OpenMP/declare_variant_messages.c
+++ clang/test/OpenMP/declare_variant_messages.c
@@ -57,6 +57,12 @@
 #pragma omp declare variant(foo) match(user = {condition()}) // expected-error {{expected expression}} expected-error {{use of undeclared identifier 'expr'}} expected-error {{expected expression}} expected-note {{the ignored selector spans until here}}
 int score_and_cond_non_const();
 
+#pragma omp declare variant(foo) match(construct={teams,parallel,for,simd})
+#pragma omp declare variant(foo) match(construct={target teams}) // expected-error {{expected ')'}} expected-warning {{expected '}' after the context selectors for the context set "construct"; '}' assumed}} expected-note {{to match this '('}}
+#pragma omp declare variant(foo) match(construct={parallel for}) // expected-error {{expected ')'}} expected-warning {{expected '}' after the context selectors for the context set "construct"; '}' assumed}} expected-note {{to match this '('}}
+#pragma omp declare variant(foo) match(construct={for simd}) // expected-error {{expected ')'}} expected-warning {{expected '}' after the context selectors for the context set "construct"; '}' assumed}} expected-note {{to match this '('}}
+int construct(void);
+
 #pragma omp declare variant(foo) match(xxx={}) // expected-warning {{'xxx' is not a valid context set in a `declare variant`; set ignored}} expected-note {{context set options are: 'construct' 'device' 'implementation' 'user'}} expected-note {{the ignored set spans until here}}
 int a; // expected-error {{'#pragma omp declare variant' can only be applied to functions}}
 
Index: clang/test/OpenMP/declare_variant_construct_codegen_1.c
===
--- /dev/null
+++ clang/test/OpenMP/declare_variant_construct_codegen_1.c
@@ -0,0 +1,334 @@
+// expected-no-diagnostics
+
+#ifndef HEADER
+#define HEADER
+
+// RUN: %clang_cc1 -DCK1 -verify -fopenmp -triple x86_64-unknown-linux -emit-llvm %s -o - | FileCheck %s --check-prefix=CK1
+// RUN: %clang_cc1 -DCK1 -fopenmp -x c -triple x86_64-unknown-linux -emit-pch -o %t -fopenmp-version=45 %s
+// RUN: %clang_cc1 -DCK1 -fopenmp -x c -triple x86_64-unknown-linux -include-pch %t -verify %s -emit-llvm -o - -fopenmp-version=45 | FileCheck %s --check-prefix=CK1
+// RUN: %clang_cc1 -DCK1 -fopenmp -fopenmp-version=50 -x c -triple x86_64-unknown-linux -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -o - | FileCheck %s --check-prefix=CK1
+// RUN: %clang_cc1 -DCK1 -fopenmp -fopenmp-version=50 -x c -triple x86_64-unknown-linux -fopenmp-targets=amdgcn-amd-amdhsa -emit-llvm %s -o - | FileCheck %s --check-prefix=CK1
+// RUN: %clang_cc1 -DCK1 -fopenmp -fopenmp-version=50 -x c -triple x86_64-unknown-linux -fopenmp-targets=amdgcn-amd-amdhsa -emit-pch -o %t %s
+// RUN: %clang_cc1 -DCK1 -fopenmp -fopenmp-version=50 -x c -triple x86_64-unknown-linux -fopenmp-targets=amdgcn-amd-amdhsa -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --check-prefix=CK1
+
+// RUN: %clang_cc1 -DCK1 -verify -fopenmp-simd -triple x86_64-unknown-linux -emit-llvm %s -o - | FileCheck %s --implicit-check-not="{{__kmpc|__tgt}}"
+// RUN: %clang_cc1 -DCK1 -fopenmp-simd -x c -triple x86_64-unknown-linux -emit-pch -o %t -fopenmp-version=45 %s
+// RUN: %clang_cc1 -DCK1 -fopenmp-simd -x c -triple x86_64-unknown-linux -include-pch %t -verify %s -emit-llvm -o - -fopenmp-version=45 | FileCheck %s --implicit-check-not="{{__kmpc|__tgt}}"
+// RUN: %clang_cc1 -DCK1 -fopenmp-simd -fopenmp-version=50 -x c -triple x86_64-unknown-linux -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -o - | FileCheck %s --implicit-check-not="{{__kmpc|__tgt}}"
+// RUN: %clang_cc1 -DCK1 -fopenmp-simd -fopenmp-version=50 -x c -triple x86_64-unknown-linux -fopenmp-targets=amdgcn-amd-amdhsa -emit-llvm %s -o - | FileCheck %s --implicit-check-not="{{__kmpc|__tgt}}"
+// RUN: %clang_cc1 -DCK1 -fopenmp-simd -fopenmp-version=50 -x c -triple x86_64-unknown-linux -fopenmp-targets=amdgcn-amd-amdhsa -emit-pch -o %t %s
+// RUN: %clang_cc1 -DCK1 -fopenmp-simd -fopenmp-version=50 -x c -triple x86_64-unknown-linux -fopenmp-targets=amdgcn-amd-amdhsa -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --implicit-check-not="{{__kmpc|__tgt}}"
+
+#ifdef CK1
+
+#define N 100
+
+void p_vxv(int 

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

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

.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109800

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

Index: clang/test/CodeGen/nrvo-tracking.cpp
===
--- clang/test/CodeGen/nrvo-tracking.cpp
+++ clang/test/CodeGen/nrvo-tracking.cpp
@@ -282,3 +282,40 @@
 }
 
 } // namespace test_alignas
+
+namespace PR51862 {
+
+template  T test() {
+  T a;
+  T b;
+  if (0)
+return a;
+  return b;
+}
+
+struct A {
+  A();
+  A(A &);
+  A(int);
+  operator int();
+};
+
+// CHECK-LABEL: define{{.*}} void @_ZN7PR518624testINS_1AEEET_v
+// CHECK:   call i32 @_ZN7PR518621AcviEv
+// CHECK-NEXT:  call void @_ZN7PR518621AC1Ei
+// CHECK-NEXT:  call void @llvm.lifetime.end
+template A test();
+
+struct BSub {};
+struct B : BSub {
+  B();
+  B(B &);
+  B(const BSub &);
+};
+
+// CHECK-LABEL: define{{.*}} void @_ZN7PR518624testINS_1BEEET_v
+// CHECK:   call void @_ZN7PR518621BC1ERKNS_4BSubE
+// CHECK-NEXT:  call void @llvm.lifetime.end
+template B test();
+
+} // namespace PR51862
Index: clang/lib/Sema/SemaStmt.cpp
===
--- clang/lib/Sema/SemaStmt.cpp
+++ clang/lib/Sema/SemaStmt.cpp
@@ -3653,8 +3653,8 @@
 
 // In C++ the return statement is handled via a copy initialization.
 // the C version of which boils down to CheckSingleAssignmentConstraints.
-InitializedEntity Entity = InitializedEntity::InitializeResult(
-ReturnLoc, FnRetType, NRVOCandidate != nullptr);
+InitializedEntity Entity =
+InitializedEntity::InitializeResult(ReturnLoc, FnRetType);
 ExprResult Res = PerformMoveOrCopyInitialization(
 Entity, NRInfo, RetValExp, SupressSimplerImplicitMoves);
 if (Res.isInvalid()) {
@@ -4085,8 +4085,8 @@
 // the C version of which boils down to CheckSingleAssignmentConstraints.
 if (!HasDependentReturnType && !RetValExp->isTypeDependent()) {
   // we have a non-void function with an expression, continue checking
-  InitializedEntity Entity = InitializedEntity::InitializeResult(
-  ReturnLoc, RetType, NRVOCandidate != nullptr);
+  InitializedEntity Entity =
+  InitializedEntity::InitializeResult(ReturnLoc, RetType);
   ExprResult Res = PerformMoveOrCopyInitialization(
   Entity, NRInfo, RetValExp, SupressSimplerImplicitMoves);
   if (Res.isInvalid()) {
Index: clang/lib/Sema/SemaObjCProperty.cpp
===
--- clang/lib/Sema/SemaObjCProperty.cpp
+++ clang/lib/Sema/SemaObjCProperty.cpp
@@ -1467,8 +1467,7 @@
   LoadSelfExpr, true, true);
   ExprResult Res = PerformCopyInitialization(
   InitializedEntity::InitializeResult(PropertyDiagLoc,
-  getterMethod->getReturnType(),
-  /*NRVO=*/false),
+  getterMethod->getReturnType()),
   PropertyDiagLoc, IvarRefExpr);
   if (!Res.isInvalid()) {
 Expr *ResExpr = Res.getAs();
Index: clang/lib/Sema/SemaLambda.cpp
===
--- clang/lib/Sema/SemaLambda.cpp
+++ clang/lib/Sema/SemaLambda.cpp
@@ -1978,8 +1978,7 @@
   CallOperator->markUsed(Context);
 
   ExprResult Init = PerformCopyInitialization(
-  InitializedEntity::InitializeLambdaToBlock(ConvLocation, Src->getType(),
- /*NRVO=*/false),
+  InitializedEntity::InitializeLambdaToBlock(ConvLocation, Src->getType()),
   CurrentLocation, Src);
   if (!Init.isInvalid())
 Init = ActOnFinishFullExpr(Init.get(), /*DiscardedValue*/ false);
Index: clang/lib/Sema/SemaExprCXX.cpp
===
--- clang/lib/Sema/SemaExprCXX.cpp
+++ clang/lib/Sema/SemaExprCXX.cpp
@@ -893,9 +893,8 @@
 if (CheckCXXThrowOperand(OpLoc, ExceptionObjectTy, Ex))
   return ExprError();
 
-InitializedEntity Entity = InitializedEntity::InitializeException(
-OpLoc, ExceptionObjectTy,
-/*NRVO=*/NRInfo.isCopyElidable());
+InitializedEntity Entity =
+InitializedEntity::InitializeException(OpLoc, ExceptionObjectTy);
 ExprResult Res = PerformMoveOrCopyInitialization(Entity, NRInfo, Ex);
 if (Res.isInvalid())
   return ExprError();
Index: clang/lib/Sema/SemaExpr.cpp
===

[PATCH] D109857: [test] Fix test failure in Clang :: Lexer/char-escapes-delimited.c

2021-09-15 Thread Matthew Voss via Phabricator via cfe-commits
ormris added a comment.

I think the test fix is all that's needed for now. This is somewhat urgent for 
us.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109857

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


[PATCH] D109857: [test] Fix test failure in Clang :: Lexer/char-escapes-delimited.c

2021-09-15 Thread Matthew Voss via Phabricator via cfe-commits
ormris updated this revision to Diff 372839.
ormris added a comment.

- Downgrade to C11 and C++11


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109857

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


Index: clang/test/Lexer/char-escapes-delimited.c
===
--- clang/test/Lexer/char-escapes-delimited.c
+++ clang/test/Lexer/char-escapes-delimited.c
@@ -1,7 +1,7 @@
-// RUN: %clang_cc1 -fsyntax-only -pedantic -verify %s
-// RUN: %clang_cc1 -x c -fsyntax-only -pedantic -verify %s
-// RUN: %clang_cc1 -fwchar-type=short -fno-signed-wchar -fsyntax-only 
-pedantic -verify %s
-// RUN: %clang_cc1 -x c -fwchar-type=short -fno-signed-wchar -fsyntax-only 
-pedantic -verify %s
+// RUN: %clang_cc1 -x c++ -std=gnu++11 -fsyntax-only -pedantic -verify %s
+// RUN: %clang_cc1 -x c -std=gnu11 -fsyntax-only -pedantic -verify %s
+// RUN: %clang_cc1 -x c++ -std=gnu++11 -fwchar-type=short -fno-signed-wchar 
-fsyntax-only -pedantic -verify %s
+// RUN: %clang_cc1 -x c -std=gnu11 -fwchar-type=short -fno-signed-wchar 
-fsyntax-only -pedantic -verify %s
 
 const char *errors =
 "\u{}"  //expected-error {{delimited escape sequence cannot be empty}}


Index: clang/test/Lexer/char-escapes-delimited.c
===
--- clang/test/Lexer/char-escapes-delimited.c
+++ clang/test/Lexer/char-escapes-delimited.c
@@ -1,7 +1,7 @@
-// RUN: %clang_cc1 -fsyntax-only -pedantic -verify %s
-// RUN: %clang_cc1 -x c -fsyntax-only -pedantic -verify %s
-// RUN: %clang_cc1 -fwchar-type=short -fno-signed-wchar -fsyntax-only -pedantic -verify %s
-// RUN: %clang_cc1 -x c -fwchar-type=short -fno-signed-wchar -fsyntax-only -pedantic -verify %s
+// RUN: %clang_cc1 -x c++ -std=gnu++11 -fsyntax-only -pedantic -verify %s
+// RUN: %clang_cc1 -x c -std=gnu11 -fsyntax-only -pedantic -verify %s
+// RUN: %clang_cc1 -x c++ -std=gnu++11 -fwchar-type=short -fno-signed-wchar -fsyntax-only -pedantic -verify %s
+// RUN: %clang_cc1 -x c -std=gnu11 -fwchar-type=short -fno-signed-wchar -fsyntax-only -pedantic -verify %s
 
 const char *errors =
 "\u{}"  //expected-error {{delimited escape sequence cannot be empty}}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D109862: Don't diagnose unused but set when the Cleanup attribute is used.

2021-09-15 Thread Michael Benfield via Phabricator via cfe-commits
mbenfield created this revision.
mbenfield added a reviewer: dblaikie.
mbenfield requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This applies to -Wunused-but-set-variable and
-Wunused-but-set-parameter.

This addresses bug 51865.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D109862

Files:
  clang/lib/Sema/SemaDecl.cpp


Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -1921,8 +1921,10 @@
 }
 
 void Sema::DiagnoseUnusedButSetDecl(const VarDecl *VD) {
-  // If it's not referenced, it can't be set.
-  if (!VD->isReferenced() || !VD->getDeclName() || VD->hasAttr())
+  // If it's not referenced, it can't be set. If it has the Cleanup attribute,
+  // it's not really unused.
+  if (!VD->isReferenced() || !VD->getDeclName() || VD->hasAttr() ||
+  VD->hasAttr())
 return;
 
   const auto *Ty = VD->getType().getTypePtr()->getBaseElementTypeUnsafe();


Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -1921,8 +1921,10 @@
 }
 
 void Sema::DiagnoseUnusedButSetDecl(const VarDecl *VD) {
-  // If it's not referenced, it can't be set.
-  if (!VD->isReferenced() || !VD->getDeclName() || VD->hasAttr())
+  // If it's not referenced, it can't be set. If it has the Cleanup attribute,
+  // it's not really unused.
+  if (!VD->isReferenced() || !VD->getDeclName() || VD->hasAttr() ||
+  VD->hasAttr())
 return;
 
   const auto *Ty = VD->getType().getTypePtr()->getBaseElementTypeUnsafe();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2021-09-15 Thread Alf via Phabricator via cfe-commits
gAlfonso-bit updated this revision to Diff 372834.

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

https://reviews.llvm.org/D107775

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


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


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

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

2021-09-15 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov created this revision.
mizvekov updated this revision to Diff 372616.
mizvekov added a comment.
mizvekov updated this revision to Diff 372828.
mizvekov retitled this revision from "test commit." to "[clang] don't mark as 
Elidable CXXConstruct expressions used in NRVO".
mizvekov edited the summary of this revision.
Herald added a subscriber: lxfind.
mizvekov published this revision for review.
mizvekov added reviewers: rsmith, rjmccall.
mizvekov added a subscriber: Quuxplusone.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

.


mizvekov added a comment.

.


See PR51862.

The consumers of the Elidable flag in CXXConstructExpr assume that
an elidable construction just goes through a single copy/move construction,
so that the source object is immediately passed as an argument and is the same
type as the parameter itself.

With the implementation of P2266  and after 
some adjustments to the
implementation of P1825 , we started 
(correctly, as per standard)
allowing more cases where the copy initialization goes through
converting constructors and user defined conversions.

With this patch we stop using this flag in NRVO contexts, to preserve code
that relies on that assumption.
This causes no known functional changes, we just stop firing some asserts
in a cople of included test cases.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D109800

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

Index: clang/test/CodeGen/nrvo-tracking.cpp
===
--- clang/test/CodeGen/nrvo-tracking.cpp
+++ clang/test/CodeGen/nrvo-tracking.cpp
@@ -282,3 +282,40 @@
 }
 
 } // namespace test_alignas
+
+namespace PR51862 {
+
+template T test() {
+  T a;
+  T b;
+  if (0)
+return a;
+  return b;
+}
+
+struct A {
+  A();
+  A(A &);
+  A(int);
+  operator int();
+};
+
+// CHECK-LABEL: define{{.*}} void @_ZN7PR518624testINS_1AEEET_v
+// CHECK:   call i32 @_ZN7PR518621AcviEv
+// CHECK-NEXT:  call void @_ZN7PR518621AC1Ei
+// CHECK-NEXT:  call void @llvm.lifetime.end
+template A test();
+
+struct BSub {};
+struct B : BSub {
+  B();
+  B(B &);
+  B(const BSub &);
+};
+
+// CHECK-LABEL: define{{.*}} void @_ZN7PR518624testINS_1BEEET_v
+// CHECK:   call void @_ZN7PR518621BC1ERKNS_4BSubE
+// CHECK-NEXT:  call void @llvm.lifetime.end
+template B test();
+
+} // namespace PR51862
Index: clang/lib/Sema/SemaStmt.cpp
===
--- clang/lib/Sema/SemaStmt.cpp
+++ clang/lib/Sema/SemaStmt.cpp
@@ -3653,8 +3653,8 @@
 
 // In C++ the return statement is handled via a copy initialization.
 // the C version of which boils down to CheckSingleAssignmentConstraints.
-InitializedEntity Entity = InitializedEntity::InitializeResult(
-ReturnLoc, FnRetType, NRVOCandidate != nullptr);
+InitializedEntity Entity =
+InitializedEntity::InitializeResult(ReturnLoc, FnRetType);
 ExprResult Res = PerformMoveOrCopyInitialization(
 Entity, NRInfo, RetValExp, SupressSimplerImplicitMoves);
 if (Res.isInvalid()) {
@@ -4085,8 +4085,8 @@
 // the C version of which boils down to CheckSingleAssignmentConstraints.
 if (!HasDependentReturnType && !RetValExp->isTypeDependent()) {
   // we have a non-void function with an expression, continue checking
-  InitializedEntity Entity = InitializedEntity::InitializeResult(
-  ReturnLoc, RetType, NRVOCandidate != nullptr);
+  InitializedEntity Entity =
+  InitializedEntity::InitializeResult(ReturnLoc, RetType);
   ExprResult Res = PerformMoveOrCopyInitialization(
   Entity, NRInfo, RetValExp, SupressSimplerImplicitMoves);
   if (Res.isInvalid()) {
Index: clang/lib/Sema/SemaObjCProperty.cpp
===
--- clang/lib/Sema/SemaObjCProperty.cpp
+++ clang/lib/Sema/SemaObjCProperty.cpp
@@ -1467,8 +1467,7 @@
   LoadSelfExpr, true, true);
   ExprResult Res = PerformCopyInitialization(
   InitializedEntity::InitializeResult(PropertyDiagLoc,
-  getterMethod->getReturnType(),
-  /*NRVO=*/false),
+  getterMethod->getReturnType()),
   PropertyDiagLoc, IvarRefExpr);
   if (!Res.isInvalid()) {
 Expr *ResExpr = Res.getAs();
Index: clang/lib/Sema/SemaLambda.cpp
===
--- clang/lib/Sema/SemaLambda.cpp
+++ 

[PATCH] D109654: [clang] disable implicit moves when not in CPlusPLus

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

I bet my issue is due to D108243  and not 
this change. Sorry for the noise!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109654

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


[PATCH] D109654: [clang] disable implicit moves when not in CPlusPLus

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

In D109654#3002862 , @thakis wrote:

> Yes, https://bugs.chromium.org/p/chromium/issues/detail?id=1250052 I haven't 
> yet verified it's definitely due to this change, but it's the most 
> related-looking change in the regression range.

Okay, I assumed any regressions here would be covered by at least 
`clang\test\SemaObjCXX\block-capture.mm`, but it's possible the test invocation 
is wrong.
We definitely need to improve the test coverage for ObjC++ if we missed this 
otherwise :-(


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109654

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


[PATCH] D109557: Adds a BreakBeforeClosingParen option

2021-09-15 Thread Cameron Mulhern via Phabricator via cfe-commits
csmulhern marked an inline comment as done.
csmulhern added inline comments.



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

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


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109557

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


[PATCH] D109557: Adds a BreakBeforeClosingParen option

2021-09-15 Thread Cameron Mulhern via Phabricator via cfe-commits
csmulhern updated this revision to Diff 372829.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109557

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

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

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

2021-09-15 Thread Alf via Phabricator via cfe-commits
gAlfonso-bit updated this revision to Diff 372827.

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

https://reviews.llvm.org/D107775

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


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


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

[PATCH] D109654: [clang] disable implicit moves when not in CPlusPLus

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

Yes, https://bugs.chromium.org/p/chromium/issues/detail?id=1250052 I haven't 
yet verified it's definitely due to this change, but it's the most 
related-looking change in the regression range.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109654

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


[PATCH] D109857: [test] Fix test failure in Clang :: Lexer/char-escapes-delimited.c

2021-09-15 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added a comment.

Okay, what's happening is that utf literals are only available for c++11 onward 
and the tests do not account for that.
Would you mind dropping the minimum version to C++11 and C11? I think that 
would be reasonable.

I could do a more extensive fix but I don't know how urgent this is for you


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109857

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


[clang] 699da98 - PR51874: Fix diagnostics for defaulted, implicitly deleted 'operator!='.

2021-09-15 Thread Richard Smith via cfe-commits

Author: Richard Smith
Date: 2021-09-15T15:43:02-07:00
New Revision: 699da98739b0f88c27f75adbe8295c7e1dfd0188

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

LOG: PR51874: Fix diagnostics for defaulted, implicitly deleted 'operator!='.

Don't say we couldn't find an 'operator<=>' when we were actually
looking for an 'operator=='. Also fix a crash when attempting to
diagnose if we select a built-in 'operator!=' in this lookup.

Added: 
clang/test/CXX/class/class.compare/class.compare.secondary/p2.cpp

Modified: 
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/Sema/SemaDeclCXX.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 824d9bf469360..cef82aba6c2f1 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -9156,14 +9156,18 @@ def note_defaulted_comparison_calls_deleted : Note<
   "defaulted %0 is implicitly deleted because it would invoke a deleted "
   "comparison function%select{| for member %2| for base class %2}1">;
 def note_defaulted_comparison_no_viable_function : Note<
-  "defaulted %0 is implicitly deleted because there is no viable three-way "
-  "comparison function for%select{| member| base class}1 %2">;
+  "defaulted %0 is implicitly deleted because there is no viable "
+  "%select{three-way comparison function|'operator=='}1 for "
+  "%select{|member |base class }2%3">;
 def note_defaulted_comparison_no_viable_function_synthesized : Note<
   "three-way comparison cannot be synthesized because there is no viable "
   "function for %select{'=='|'<'}0 comparison">;
 def note_defaulted_comparison_not_rewritten_callee : Note<
   "defaulted %0 is implicitly deleted because this non-rewritten comparison "
   "function would be the best match for the comparison">;
+def note_defaulted_comparison_not_rewritten_conversion : Note<
+  "defaulted %0 is implicitly deleted because a builtin comparison function "
+  "using this conversion would be the best match for the comparison">;
 def note_defaulted_comparison_cannot_deduce : Note<
   "return type of defaulted 'operator<=>' cannot be deduced because "
   "return type %2 of three-way comparison for %select{|member|base class}0 %1 "

diff  --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index d980869a3b067..ecafab99424fc 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -7804,9 +7804,21 @@ class DefaultedComparisonAnalyzer
DCK == DefaultedComparisonKind::Relational) &&
   !Best->RewriteKind) {
 if (Diagnose == ExplainDeleted) {
-  S.Diag(Best->Function->getLocation(),
- diag::note_defaulted_comparison_not_rewritten_callee)
-  << FD;
+  if (Best->Function) {
+S.Diag(Best->Function->getLocation(),
+   diag::note_defaulted_comparison_not_rewritten_callee)
+<< FD;
+  } else {
+assert(Best->Conversions.size() == 2 &&
+   Best->Conversions[0].isUserDefined() &&
+   "non-user-defined conversion from class to built-in "
+   "comparison");
+S.Diag(Best->Conversions[0]
+   .UserDefined.FoundConversionFunction.getDecl()
+   ->getLocation(),
+   diag::note_defaulted_comparison_not_rewritten_conversion)
+<< FD;
+  }
 }
 return Result::deleted();
   }
@@ -7962,7 +7974,7 @@ class DefaultedComparisonAnalyzer
 
   if (Diagnose == ExplainDeleted) {
 S.Diag(Subobj.Loc, diag::note_defaulted_comparison_no_viable_function)
-<< FD << Subobj.Kind << Subobj.Decl;
+<< FD << (OO == OO_ExclaimEqual) << Subobj.Kind << Subobj.Decl;
 
 // For a three-way comparison, list both the candidates for the
 // original operator and the candidates for the synthesized operator.

diff  --git a/clang/test/CXX/class/class.compare/class.compare.secondary/p2.cpp 
b/clang/test/CXX/class/class.compare/class.compare.secondary/p2.cpp
new file mode 100644
index 0..7226d565b6c3e
--- /dev/null
+++ b/clang/test/CXX/class/class.compare/class.compare.secondary/p2.cpp
@@ -0,0 +1,47 @@
+// RUN: %clang_cc1 -std=c++20 -verify %s
+
+struct A {
+  bool operator!=(const A&) const = default; // expected-warning {{explicitly 
defaulted equality comparison operator is implicitly deleted}}
+  // expected-note@-1 {{defaulted 'operator!=' is implicitly deleted because 
there is no viable 'operator==' for 'A'}}
+};
+
+struct Q {};
+bool operator!=(Q, Q); // expected-note {{defaulted 'operator!=' is implicitly 
deleted 

[PATCH] D109857: [test] Fix test failure in Clang :: Lexer/char-escapes-delimited.c

2021-09-15 Thread Matthew Voss via Phabricator via cfe-commits
ormris added a comment.

We saw this failure for our internal SIE (PlayStation) platform. I just tested 
on x86_64-unknown-linux-gnu using C99 and C++98, though, and the test fails. It 
looks like this feature is restricted to more recent standard versions somehow.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109857

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


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

2021-09-15 Thread Balázs Benics via Phabricator via cfe-commits
steakhal accepted this revision.
steakhal added a comment.
This revision is now accepted and ready to land.

LGTM.
Thanks for fixing this.

Should this checker remain in alpha in its current form?
WDYT? @all


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109836

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


[PATCH] D109857: [test] Fix test failure in Clang :: Lexer/char-escapes-delimited.c

2021-09-15 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added a comment.

Thanks!

For which platforms did you had issue?
This is suppose to work in all language modes (we might want to use C99/C++98 
to make sure that's the case)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109857

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


[PATCH] D109857: [test] Fix test failure in Clang :: Lexer/char-escapes-delimited.c

2021-09-15 Thread Matthew Voss via Phabricator via cfe-commits
ormris created this revision.
ormris added reviewers: cor3ntin, aaron.ballman.
ormris requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Specify the C and C++ standards explicitly for this test. This avoids failures 
for drivers that default to older standards.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D109857

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


Index: clang/test/Lexer/char-escapes-delimited.c
===
--- clang/test/Lexer/char-escapes-delimited.c
+++ clang/test/Lexer/char-escapes-delimited.c
@@ -1,7 +1,7 @@
-// RUN: %clang_cc1 -fsyntax-only -pedantic -verify %s
-// RUN: %clang_cc1 -x c -fsyntax-only -pedantic -verify %s
-// RUN: %clang_cc1 -fwchar-type=short -fno-signed-wchar -fsyntax-only 
-pedantic -verify %s
-// RUN: %clang_cc1 -x c -fwchar-type=short -fno-signed-wchar -fsyntax-only 
-pedantic -verify %s
+// RUN: %clang_cc1 -x c++ -std=gnu++20 -fsyntax-only -pedantic -verify %s
+// RUN: %clang_cc1 -x c -std=gnu2x -fsyntax-only -pedantic -verify %s
+// RUN: %clang_cc1 -x c++ -std=gnu++20 -fwchar-type=short -fno-signed-wchar 
-fsyntax-only -pedantic -verify %s
+// RUN: %clang_cc1 -x c -std=gnu2x -fwchar-type=short -fno-signed-wchar 
-fsyntax-only -pedantic -verify %s
 
 const char *errors =
 "\u{}"  //expected-error {{delimited escape sequence cannot be empty}}


Index: clang/test/Lexer/char-escapes-delimited.c
===
--- clang/test/Lexer/char-escapes-delimited.c
+++ clang/test/Lexer/char-escapes-delimited.c
@@ -1,7 +1,7 @@
-// RUN: %clang_cc1 -fsyntax-only -pedantic -verify %s
-// RUN: %clang_cc1 -x c -fsyntax-only -pedantic -verify %s
-// RUN: %clang_cc1 -fwchar-type=short -fno-signed-wchar -fsyntax-only -pedantic -verify %s
-// RUN: %clang_cc1 -x c -fwchar-type=short -fno-signed-wchar -fsyntax-only -pedantic -verify %s
+// RUN: %clang_cc1 -x c++ -std=gnu++20 -fsyntax-only -pedantic -verify %s
+// RUN: %clang_cc1 -x c -std=gnu2x -fsyntax-only -pedantic -verify %s
+// RUN: %clang_cc1 -x c++ -std=gnu++20 -fwchar-type=short -fno-signed-wchar -fsyntax-only -pedantic -verify %s
+// RUN: %clang_cc1 -x c -std=gnu2x -fwchar-type=short -fno-signed-wchar -fsyntax-only -pedantic -verify %s
 
 const char *errors =
 "\u{}"  //expected-error {{delimited escape sequence cannot be empty}}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2021-09-15 Thread Owen Pan via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG8025c03f70ee: [clang-format] Top-level unwrapped lines 
dont follow a left brace (authored by owenpan).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109752

Files:
  clang/lib/Format/UnwrappedLineParser.cpp


Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -431,7 +431,7 @@
   }
   LLVM_FALLTHROUGH;
 default:
-  parseStructuralElement(/*IsTopLevel=*/true);
+  parseStructuralElement(!HasOpeningBrace);
   break;
 }
   } while (!eof());


Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -431,7 +431,7 @@
   }
   LLVM_FALLTHROUGH;
 default:
-  parseStructuralElement(/*IsTopLevel=*/true);
+  parseStructuralElement(!HasOpeningBrace);
   break;
 }
   } while (!eof());
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 8025c03 - [clang-format] Top-level unwrapped lines don't follow a left brace

2021-09-15 Thread via cfe-commits

Author: owenca
Date: 2021-09-15T14:52:07-07:00
New Revision: 8025c03f70ee9b92e8599519b5ee34b54c9a80da

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

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

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

Added: 


Modified: 
clang/lib/Format/UnwrappedLineParser.cpp

Removed: 




diff  --git a/clang/lib/Format/UnwrappedLineParser.cpp 
b/clang/lib/Format/UnwrappedLineParser.cpp
index 18dc5c424470..d629a20fb089 100644
--- a/clang/lib/Format/UnwrappedLineParser.cpp
+++ b/clang/lib/Format/UnwrappedLineParser.cpp
@@ -431,7 +431,7 @@ void UnwrappedLineParser::parseLevel(bool HasOpeningBrace) {
   }
   LLVM_FALLTHROUGH;
 default:
-  parseStructuralElement(/*IsTopLevel=*/true);
+  parseStructuralElement(!HasOpeningBrace);
   break;
 }
   } while (!eof());



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


[PATCH] D109841: Fix vtbl field addr space

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

LGTM


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

https://reviews.llvm.org/D109841

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


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

2021-09-15 Thread Owen Pan via Phabricator via cfe-commits
owenpan added a comment.

It will prevent them from even being checked in `parseStructuralElement` as 
`IsTopLevel` is now `false`:

  case tok::l_paren: {
parseParens();
// Break the unwrapped line if a K C function definition has a parameter
// declaration.
if (!IsTopLevel || !Style.isCpp() || !Previous || FormatTok->is(tok::eof))
  break;
const unsigned Position = Tokens->getPosition() + 1;
assert(Position < AllTokens.size());
if (isC78ParameterDecl(FormatTok, AllTokens[Position], Previous)) {
  addUnwrappedLine();
  return;
}
break;
  }


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109752

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


[PATCH] D109654: [clang] disable implicit moves when not in CPlusPLus

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

In D109654#3002632 , @thakis wrote:

> Is it possible that this disabled this for Objective-C++ too?

As far as I understand, CPlusPLus will be set on ObjectiveC++ as well, and I 
think we do have test coverage there, but I haven't personally manually tested 
this.
Do you see any indications this is a problem?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109654

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


[PATCH] D109854: Support Unicode 14 identifiers This update the UAX tables to support new Unicode 14 identifiers

2021-09-15 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin created this revision.
cor3ntin requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D109854

Files:
  clang/lib/Lex/UnicodeCharSets.h

Index: clang/lib/Lex/UnicodeCharSets.h
===
--- clang/lib/Lex/UnicodeCharSets.h
+++ clang/lib/Lex/UnicodeCharSets.h
@@ -28,94 +28,94 @@
 {0x07B1, 0x07B1},   {0x07CA, 0x07EA},   {0x07F4, 0x07F5},
 {0x07FA, 0x07FA},   {0x0800, 0x0815},   {0x081A, 0x081A},
 {0x0824, 0x0824},   {0x0828, 0x0828},   {0x0840, 0x0858},
-{0x0860, 0x086A},   {0x08A0, 0x08B4},   {0x08B6, 0x08C7},
-{0x0904, 0x0939},   {0x093D, 0x093D},   {0x0950, 0x0950},
-{0x0958, 0x0961},   {0x0971, 0x0980},   {0x0985, 0x098C},
-{0x098F, 0x0990},   {0x0993, 0x09A8},   {0x09AA, 0x09B0},
-{0x09B2, 0x09B2},   {0x09B6, 0x09B9},   {0x09BD, 0x09BD},
-{0x09CE, 0x09CE},   {0x09DC, 0x09DD},   {0x09DF, 0x09E1},
-{0x09F0, 0x09F1},   {0x09FC, 0x09FC},   {0x0A05, 0x0A0A},
-{0x0A0F, 0x0A10},   {0x0A13, 0x0A28},   {0x0A2A, 0x0A30},
-{0x0A32, 0x0A33},   {0x0A35, 0x0A36},   {0x0A38, 0x0A39},
-{0x0A59, 0x0A5C},   {0x0A5E, 0x0A5E},   {0x0A72, 0x0A74},
-{0x0A85, 0x0A8D},   {0x0A8F, 0x0A91},   {0x0A93, 0x0AA8},
-{0x0AAA, 0x0AB0},   {0x0AB2, 0x0AB3},   {0x0AB5, 0x0AB9},
-{0x0ABD, 0x0ABD},   {0x0AD0, 0x0AD0},   {0x0AE0, 0x0AE1},
-{0x0AF9, 0x0AF9},   {0x0B05, 0x0B0C},   {0x0B0F, 0x0B10},
-{0x0B13, 0x0B28},   {0x0B2A, 0x0B30},   {0x0B32, 0x0B33},
-{0x0B35, 0x0B39},   {0x0B3D, 0x0B3D},   {0x0B5C, 0x0B5D},
-{0x0B5F, 0x0B61},   {0x0B71, 0x0B71},   {0x0B83, 0x0B83},
-{0x0B85, 0x0B8A},   {0x0B8E, 0x0B90},   {0x0B92, 0x0B95},
-{0x0B99, 0x0B9A},   {0x0B9C, 0x0B9C},   {0x0B9E, 0x0B9F},
-{0x0BA3, 0x0BA4},   {0x0BA8, 0x0BAA},   {0x0BAE, 0x0BB9},
-{0x0BD0, 0x0BD0},   {0x0C05, 0x0C0C},   {0x0C0E, 0x0C10},
-{0x0C12, 0x0C28},   {0x0C2A, 0x0C39},   {0x0C3D, 0x0C3D},
-{0x0C58, 0x0C5A},   {0x0C60, 0x0C61},   {0x0C80, 0x0C80},
-{0x0C85, 0x0C8C},   {0x0C8E, 0x0C90},   {0x0C92, 0x0CA8},
-{0x0CAA, 0x0CB3},   {0x0CB5, 0x0CB9},   {0x0CBD, 0x0CBD},
-{0x0CDE, 0x0CDE},   {0x0CE0, 0x0CE1},   {0x0CF1, 0x0CF2},
-{0x0D04, 0x0D0C},   {0x0D0E, 0x0D10},   {0x0D12, 0x0D3A},
-{0x0D3D, 0x0D3D},   {0x0D4E, 0x0D4E},   {0x0D54, 0x0D56},
-{0x0D5F, 0x0D61},   {0x0D7A, 0x0D7F},   {0x0D85, 0x0D96},
-{0x0D9A, 0x0DB1},   {0x0DB3, 0x0DBB},   {0x0DBD, 0x0DBD},
-{0x0DC0, 0x0DC6},   {0x0E01, 0x0E30},   {0x0E32, 0x0E32},
-{0x0E40, 0x0E46},   {0x0E81, 0x0E82},   {0x0E84, 0x0E84},
-{0x0E86, 0x0E8A},   {0x0E8C, 0x0EA3},   {0x0EA5, 0x0EA5},
-{0x0EA7, 0x0EB0},   {0x0EB2, 0x0EB2},   {0x0EBD, 0x0EBD},
-{0x0EC0, 0x0EC4},   {0x0EC6, 0x0EC6},   {0x0EDC, 0x0EDF},
-{0x0F00, 0x0F00},   {0x0F40, 0x0F47},   {0x0F49, 0x0F6C},
-{0x0F88, 0x0F8C},   {0x1000, 0x102A},   {0x103F, 0x103F},
-{0x1050, 0x1055},   {0x105A, 0x105D},   {0x1061, 0x1061},
-{0x1065, 0x1066},   {0x106E, 0x1070},   {0x1075, 0x1081},
-{0x108E, 0x108E},   {0x10A0, 0x10C5},   {0x10C7, 0x10C7},
-{0x10CD, 0x10CD},   {0x10D0, 0x10FA},   {0x10FC, 0x1248},
-{0x124A, 0x124D},   {0x1250, 0x1256},   {0x1258, 0x1258},
-{0x125A, 0x125D},   {0x1260, 0x1288},   {0x128A, 0x128D},
-{0x1290, 0x12B0},   {0x12B2, 0x12B5},   {0x12B8, 0x12BE},
-{0x12C0, 0x12C0},   {0x12C2, 0x12C5},   {0x12C8, 0x12D6},
-{0x12D8, 0x1310},   {0x1312, 0x1315},   {0x1318, 0x135A},
-{0x1380, 0x138F},   {0x13A0, 0x13F5},   {0x13F8, 0x13FD},
-{0x1401, 0x166C},   {0x166F, 0x167F},   {0x1681, 0x169A},
-{0x16A0, 0x16EA},   {0x16EE, 0x16F8},   {0x1700, 0x170C},
-{0x170E, 0x1711},   {0x1720, 0x1731},   {0x1740, 0x1751},
-{0x1760, 0x176C},   {0x176E, 0x1770},   {0x1780, 0x17B3},
-{0x17D7, 0x17D7},   {0x17DC, 0x17DC},   {0x1820, 0x1878},
-{0x1880, 0x18A8},   {0x18AA, 0x18AA},   {0x18B0, 0x18F5},
-{0x1900, 0x191E},   {0x1950, 0x196D},   {0x1970, 0x1974},
-{0x1980, 0x19AB},   {0x19B0, 0x19C9},   {0x1A00, 0x1A16},
-{0x1A20, 0x1A54},   {0x1AA7, 0x1AA7},   {0x1B05, 0x1B33},
-{0x1B45, 0x1B4B},   {0x1B83, 0x1BA0},   {0x1BAE, 0x1BAF},
-{0x1BBA, 0x1BE5},   {0x1C00, 0x1C23},   {0x1C4D, 0x1C4F},
-{0x1C5A, 0x1C7D},   {0x1C80, 0x1C88},   {0x1C90, 0x1CBA},
-{0x1CBD, 0x1CBF},   {0x1CE9, 0x1CEC},   {0x1CEE, 0x1CF3},
-{0x1CF5, 0x1CF6},   {0x1CFA, 0x1CFA},   {0x1D00, 0x1DBF},
-{0x1E00, 0x1F15},   {0x1F18, 0x1F1D},   {0x1F20, 0x1F45},
-{0x1F48, 0x1F4D},   {0x1F50, 0x1F57},   {0x1F59, 0x1F59},
-{0x1F5B, 0x1F5B},   {0x1F5D, 0x1F5D},   {0x1F5F, 0x1F7D},
-{0x1F80, 0x1FB4},   {0x1FB6, 0x1FBC},   {0x1FBE, 0x1FBE},
-{0x1FC2, 0x1FC4},   {0x1FC6, 0x1FCC},   {0x1FD0, 0x1FD3},
-{0x1FD6, 0x1FDB},   {0x1FE0, 0x1FEC},   {0x1FF2, 0x1FF4},
-{0x1FF6, 0x1FFC},   {0x2071, 0x2071},   {0x207F, 0x207F},
-{0x2090, 0x209C},   {0x2102, 0x2102},   {0x2107, 0x2107},

[PATCH] D109654: [clang] disable implicit moves when not in CPlusPLus

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

Is it possible that this disabled this for Objective-C++ too?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109654

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


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

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

In D105756#3001045 , @NoQ wrote:

> I guess I'm confused about the exact meaning of the AST. I'm not sure whether 
> it's actively incorrect or just changed meaning. I'll definitely be debugging 
> this further.
>
> My backstory here is that the static analyzer can be thought of as 
> (primitivized down to) an AST "interpreter". It arranges AST nodes in the 
> order in which they're "executed" at run-time (aka "Clang CFG") and then 
> processes them one node at a time in that order - unlike CodeGen that 
> processes the nodes more or less recursively. This causes us static analyzer 
> people to have an exotic taste for the good AST as we're required to 
> understand every node literally in isolation from other nodes. Every time the 
> nodes make sense together/recursively but not individually our life becomes 
> much harder.
>
> So in the new AST (which wouldn't exist with your fix so we may be talking 
> about vacuous truths here, as I'm still to look at the C++ variant of the 
> same AST) I'm confused about the seemingly brand-new AST node that you 
> introduced, `ImplicitCastExpr xvalue ` - a cast that changes value kind 
> from prvalue to glvalue and in this regard appears to behave exactly like 
> `MaterializeTemporaryExpr` - which was hard enough to support the first time 
> (due to its deep recursive nature where it extracts the storage address that 
> was already "lost" in the operand), I really don't want to do it again :) And 
> I'm also confused by the situation where `ImplicitCastExpr ` 
> does not correspond to a memory load like it typically does.

The xvalue cast used in NRVO should never apply to a prvalue, as they are used 
only in expressions that refer to a variable / parameter, which are always 
lvalues, so it's really only changing categories while still staying within 
glvalues.

The NoOp cast, as far as code generation / execution is concerned, does nothing 
really. The purpose of a NoOp cast which changes value category lies in 
semantic analysis, where it will help things like deciding what kind overload 
will be selected or what kinds of references an expression can be bound to. 
Seeing those casts in the middle of a complete AST can only help make sense of 
why certain overloads where selected, but it would not aid in interpreting how 
the program should be executed.

> If I understand correctly, in C++ the innermost lvalue-to-rvalue cast 
> wouldn't exist, therefore the double memory load concern will be eliminated. 
> I.e., it'll probably be something like

As far as the clang CodeGen is concerned, there is no double memory load here, 
when starting from 
the left in the "LValueToRValue -> NoOp -> LValueToRValue" sequence, the code 
that implements this in CGExpr EmitLValue function will just recursively eat 
the NoOp cast (EmitCastLValue) and then go back where it started recursively 
calling EmitLValue again, making this equivalent to just a single 
`LValueToRValue`, as far as what code is actually emitted.

>   ReturnStmt
>   `- ImplicitCastExpr 
>  `- ImplicitCastExpr  xvalue  // MaterializeTemporaryExpr xvalue?
> `- CXXConstructExpr

I think that is not correct, in C++ when dealing with classes, the 
CXXConstructExpr would stand for the LValueToRValue cast there.
The implicit cast to xvalue would also stand between the DeclRef and the 
CXXConstruct / LValueToRValue.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105756

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


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

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

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

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

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

Based on feedback from Paul Robinson.

Added: 


Modified: 
clang/lib/CodeGen/CGDebugInfo.cpp

Removed: 




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



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


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

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

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

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

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

This reverts commit 626586fc253c6f032aedb325dba6b1ff3f11875e.

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

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

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

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

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

Removed: 




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

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

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

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

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

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

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

Details from the commit:

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

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

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

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

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

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

const [n]".

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

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

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

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



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

[PATCH] D109841: Fix vtbl field addr space

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

fix comments and casts


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

https://reviews.llvm.org/D109841

Files:
  clang/lib/CodeGen/CGClass.cpp


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


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


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

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

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

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

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

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

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

Added: 


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

Removed: 




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

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

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

 };
-



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


[PATCH] D109841: Fix vtbl field addr space

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

In D109841#3002404 , @arichardson 
wrote:

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

will do




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

arichardson wrote:
> Maybe this is clearer?
will do



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

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

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


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

https://reviews.llvm.org/D109841

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


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

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

In D109828#3002114 , @hans wrote:

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



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




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

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


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

https://reviews.llvm.org/D109828

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


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

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

LGTM.




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

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


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106393

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


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

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

move arch functions


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

https://reviews.llvm.org/D109828

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

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

[PATCH] D109841: Fix vtbl field addr space

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

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

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




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

Maybe this is clearer?



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

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


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

https://reviews.llvm.org/D109841

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


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

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

Rebased to main


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

https://reviews.llvm.org/D107717

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

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

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

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

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


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

https://reviews.llvm.org/D107717

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


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

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

@dgoldman I did it!


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

https://reviews.llvm.org/D107775

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


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

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

git-format


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

https://reviews.llvm.org/D107775

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


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


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

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

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

In D108469#2957652 , @jfb wrote:

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

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

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

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




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

Per coding conventions.



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

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

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



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

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



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

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



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




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108469

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


[PATCH] D109557: Adds a BreakBeforeClosingParen option

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



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

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


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109557

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


[PATCH] D109841: Fix vtbl field addr space

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

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


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

https://reviews.llvm.org/D109841

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


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

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

https://reviews.llvm.org/D109841


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103835

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


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

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

I'll fix the tests


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108469

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


[PATCH] D109841: Fix vtbl field addr space

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

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


https://reviews.llvm.org/D109841

Files:
  clang/lib/CodeGen/CGClass.cpp


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


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


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

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

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


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103835

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


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

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

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




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

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

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


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

https://reviews.llvm.org/D109828

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


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

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

lgtm, thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109234

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


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

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

In D103835#3001011 , @rjmccall wrote:

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

Sorry my previous description was not accurate.

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

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


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103835

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


[PATCH] D109557: Adds a BreakBeforeClosingParen option

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

In D109557#3000152 , 
@HazardyKnusperkeks wrote:

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

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

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

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


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109557

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


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

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

- Modify test to correctly indicate old/new PM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109234

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


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


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

[PATCH] D109557: Adds a BreakBeforeClosingParen option

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

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109557

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

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

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

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



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

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

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

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



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109632

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


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

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

LGTM. Thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108787

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


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

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

This LGTM now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109362

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


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

2021-09-15 Thread Yaxun Liu via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGab5f2b505a07: [HIP] Diagnose -fopenmp-targets for HIP 
programs (authored by yaxunl).
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109718

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


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


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

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

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

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

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

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

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

Reviewed by: Artem Belevich

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

Added: 


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

Removed: 




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

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

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



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


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

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

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109175

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


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

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

In D106393#3000122 , @sfertile wrote:

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

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


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106393

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


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

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

In D109175#2989997 , @yaxunl wrote:

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

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

Thanks. @jdoerfert. Could you approve this?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109175

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


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

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

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


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109362

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

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

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

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

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


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106393

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

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

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

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



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

Comment needs to be update now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109362

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


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

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

In D109362#3001294 , @uweigand wrote:

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

Nope. I'll update the patch.

In D109362#3001294 , @uweigand wrote:

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

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


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109362

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


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

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

- Introduce separate label prefix for `MM_GOFF`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109362

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

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

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

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

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


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D109836

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


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


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

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

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



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

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


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109234

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


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

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

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109812

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


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


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


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

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

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

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

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

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


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

https://reviews.llvm.org/D108138

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


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

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

In D104556#3001497 , @catenacyber 
wrote:

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

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


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104556

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


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

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

- Modify test to correctly indicate old/new PM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109234

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


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


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

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

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

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

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


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

https://reviews.llvm.org/D108138

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


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

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

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


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

https://reviews.llvm.org/D108138

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

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

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

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



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

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



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

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


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109234

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


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

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

LGTM.  Thank you.


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

https://reviews.llvm.org/D109812

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


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

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

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109078

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

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

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

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

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

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

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

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

Reviewed By: ZarkoCA

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

Added: 


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

Removed: 




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

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

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

diff  --git a/clang/test/Driver/aix-toolchain-include.cpp 
b/clang/test/Driver/aix-toolchain-include.cpp
index dc8b272936a48..2ea60b2722977 100644
--- a/clang/test/Driver/aix-toolchain-include.cpp
+++ b/clang/test/Driver/aix-toolchain-include.cpp
@@ -5,13 +5,13 @@
 // RUN:-target 

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

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

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

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

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

out\gn\bin\clang-cl ^

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

---

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

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


https://reviews.llvm.org/D109828

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

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

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

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

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


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109607

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


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

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

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

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

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

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

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

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

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

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


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105191

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


[clang] 274adcb - Implement delimited escape sequences.

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

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

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

LOG: Implement delimited escape sequences.

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

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

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

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

Removed: 




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

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

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

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

In D109825#3001622 , @dmgreen wrote:

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

Very good point!

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


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

https://reviews.llvm.org/D109825

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


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

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

Updated release notes to solve a merge conflict.


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

https://reviews.llvm.org/D109825

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

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

  1   2   >