[PATCH] D56353: Replace cc1 options '-mdisable-fp-elim' and '-momit-leaf-frame-pointer' with'-mframe-pointer='

2019-01-11 Thread Yuanfang Chen via Phabricator via cfe-commits
tabloid.adroit added a comment.

gentle ping


Repository:
  rC Clang

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

https://reviews.llvm.org/D56353



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


[PATCH] D56353: Replace cc1 options '-mdisable-fp-elim' and '-momit-leaf-frame-pointer' with'-mframe-pointer='

2019-01-16 Thread Yuanfang Chen via Phabricator via cfe-commits
tabloid.adroit updated this revision to Diff 182213.
tabloid.adroit marked an inline comment as done.
tabloid.adroit added a comment.

Thanks for the review!

- address comments


Repository:
  rC Clang

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

https://reviews.llvm.org/D56353

Files:
  include/clang/Basic/CodeGenOptions.def
  include/clang/Basic/CodeGenOptions.h
  include/clang/Driver/CC1Options.td
  include/clang/Driver/Options.td
  lib/CodeGen/CGCall.cpp
  lib/Driver/ToolChains/Clang.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/CodeGen/x86_64-profiling-keep-fp.c
  test/CodeGenCXX/global-init.cpp
  test/CodeGenObjCXX/msabi-stret.mm
  test/Driver/cl-options.c
  test/Driver/clang-translation.c
  test/Driver/frame-pointer-elim.c
  test/Driver/frame-pointer.c
  test/Driver/woa-fp.c
  test/Driver/xcore-opts.c

Index: test/Driver/xcore-opts.c
===
--- test/Driver/xcore-opts.c
+++ test/Driver/xcore-opts.c
@@ -3,9 +3,8 @@
 // RUN: %clang -target xcore -x c++ %s -fexceptions -### -o %t.o 2>&1 | FileCheck -check-prefix CHECK-EXCEP %s
 // RUN: %clang -target xcore %s -g0 -### -o %t.o 2>&1 | FileCheck -check-prefix CHECK-G0 %s
 
+// CHECK: "-mframe-pointer=none"
 // CHECK: "-nostdsysteminc"
-// CHECK: "-momit-leaf-frame-pointer"
-// CHECK-NOT: "-mdisable-fp-elim"
 // CHECK: "-fno-signed-char"
 // CHECK: "-fno-use-cxa-atexit"
 // CHECK-NOT: "-fcxx-exceptions"
Index: test/Driver/woa-fp.c
===
--- test/Driver/woa-fp.c
+++ test/Driver/woa-fp.c
@@ -34,7 +34,7 @@
 // RUN: %clang -target armv7-windows-itanium -fno-omit-frame-pointer -### -S %s -O3 -o /dev/null 2>&1 | FileCheck %s -check-prefix CHECK-NO-FPO
 // RUN: %clang -target armv7-windows-itanium -fno-omit-frame-pointer -### -S %s -Os -o /dev/null 2>&1 | FileCheck %s -check-prefix CHECK-NO-FPO
 
-// CHECK-DEFAULT: "-mdisable-fp-elim"
-// CHECK-FPO-NOT: "-mdisable-fp-elim"
-// CHECK-NO-FPO: "-mdisable-fp-elim"
+// CHECK-DEFAULT: "-mframe-pointer=all"
+// CHECK-FPO-NOT: "-mframe-pointer=all"
+// CHECK-NO-FPO: "-mframe-pointer=all"
 
Index: test/Driver/frame-pointer.c
===
--- test/Driver/frame-pointer.c
+++ test/Driver/frame-pointer.c
@@ -57,15 +57,15 @@
 // RUN: %clang -target riscv64-unknown-linux-gnu -### -S -O3 %s -o %t.s 2>&1 | FileCheck -check-prefix=CHECK3-64 %s
 // RUN: %clang -target riscv64-unknown-linux-gnu -### -S -Os %s -o %t.s 2>&1 | FileCheck -check-prefix=CHECKs-64 %s
 
-// CHECK0-32: -mdisable-fp-elim
-// CHECK1-32-NOT: -mdisable-fp-elim
-// CHECK2-32-NOT: -mdisable-fp-elim
-// CHECK3-32-NOT: -mdisable-fp-elim
-// CHECKs-32-NOT: -mdisable-fp-elim
+// CHECK0-32: -mframe-pointer=all
+// CHECK1-32-NOT: -mframe-pointer=all
+// CHECK2-32-NOT: -mframe-pointer=all
+// CHECK3-32-NOT: -mframe-pointer=all
+// CHECKs-32-NOT: -mframe-pointer=all
 
-// CHECK0-64: -mdisable-fp-elim
-// CHECK1-64-NOT: -mdisable-fp-elim
-// CHECK2-64-NOT: -mdisable-fp-elim
-// CHECK3-64-NOT: -mdisable-fp-elim
-// CHECKs-64-NOT: -mdisable-fp-elim
-// CHECK-MACHO-64: -mdisable-fp-elim
+// CHECK0-64: -mframe-pointer=all
+// CHECK1-64-NOT: -mframe-pointer=all
+// CHECK2-64-NOT: -mframe-pointer=all
+// CHECK3-64-NOT: -mframe-pointer=all
+// CHECKs-64-NOT: -mframe-pointer=all
+// CHECK-MACHO-64: -mframe-pointer=all
Index: test/Driver/frame-pointer-elim.c
===
--- test/Driver/frame-pointer-elim.c
+++ test/Driver/frame-pointer-elim.c
@@ -2,65 +2,62 @@
 // pointer, for unoptimized we should have a leaf frame pointer.
 // RUN: %clang -### -target i386-pc-linux-gnu -S -O1 %s 2>&1 | \
 // RUN:   FileCheck --check-prefix=LINUX-OPT %s
-// LINUX-OPT: "-momit-leaf-frame-pointer"
+// LINUX-OPT: "-mframe-pointer=none"
 
 // RUN: %clang -### -target i386-pc-linux-gnu -S %s 2>&1 | \
 // RUN:   FileCheck --check-prefix=LINUX %s
-// LINUX-NOT: "-momit-leaf-frame-pointer"
+// LINUX: "-mframe-pointer=all"
 
 // CloudABI follows the same rules as Linux.
 // RUN: %clang -### -target x86_64-unknown-cloudabi -S -O1 %s 2>&1 | \
 // RUN:   FileCheck --check-prefix=CLOUDABI-OPT %s
-// CLOUDABI-OPT: "-momit-leaf-frame-pointer"
+// CLOUDABI-OPT: "-mframe-pointer=none"
 
 // RUN: %clang -### -target x86_64-unknown-cloudabi -S %s 2>&1 | \
 // RUN:   FileCheck --check-prefix=CLOUDABI %s
-// CLOUDABI-NOT: "-momit-leaf-frame-pointer"
+// CLOUDABI: "-mframe-pointer=all"
 
 // NetBSD follows the same rules as Linux.
 // RUN: %clang -### -target x86_64-unknown-netbsd -S -O1 %s 2>&1 | \
 // RUN:   FileCheck --check-prefix=NETBSD-OPT %s
-// NETBSD-OPT: "-momit-leaf-frame-pointer"
+// NETBSD-OPT: "-mframe-pointer=none"
 
 // RUN: %clang -### -target x86_64-unknown-netbsd -S %s 2>&1 | \
 // RUN:   FileCheck --check-prefix=NETBSD %s
-// NETBSD-NOT: "-momit-leaf-frame-pointer"
+// NETBSD: "-mframe-pointer=all"
 
 // Darwin disables omitting the leaf frame p

[PATCH] D56353: Replace cc1 options '-mdisable-fp-elim' and '-momit-leaf-frame-pointer' with'-mframe-pointer='

2019-01-16 Thread Yuanfang Chen via Phabricator via cfe-commits
tabloid.adroit marked 2 inline comments as done.
tabloid.adroit added inline comments.



Comment at: lib/Driver/ToolChains/Clang.cpp:576-579
+  Arg *FP = Args.getLastArg(options::OPT_fno_omit_frame_pointer,
+options::OPT_fomit_frame_pointer);
+  Arg *LeafFP = Args.getLastArg(options::OPT_mno_omit_leaf_frame_pointer,
+options::OPT_momit_leaf_frame_pointer);

chandlerc wrote:
> This still doesn't make sense to me...
> 
> If the user specifies `-fomit-frame-point` or `-fno-omit-frame-pointer` 
> *after* `-momit-leaf-frame-pointer` or `-mno-omit-leaf-frame-pointer`, then 
> that last flag should win...
> 
> I think you need to first get the "base" FP state by checking the main two 
> flags. Then you need to get the "last" FP state by checking *all four flags*. 
> When the last flag is a leaf flag, then the state is determined by the base + 
> the last. When the last flag is not one of the leaf flags, then the last flag 
> fully specifies the result.
> 
> I think you can also process these variables into something simpler to test 
> below, essentially handling all the matching logic in one place.
I see the point here. I didn't do it since it deviates from GCC/intel compiler 
behavior. Could you please confirm we really want that?

One example from here is : ` -momit-leaf-frame-pointer -fno-omit-frame-pointer`
(https://software.intel.com/en-us/cpp-compiler-developer-guide-and-reference-momit-leaf-frame-pointer)

For GCC/intel, this is frame-pointer=non-leaf, for us, it will be 
frame-pointer=all


Repository:
  rC Clang

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

https://reviews.llvm.org/D56353



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


[PATCH] D56353: Replace cc1 options '-mdisable-fp-elim' and '-momit-leaf-frame-pointer' with'-mframe-pointer='

2019-02-02 Thread Yuanfang Chen via Phabricator via cfe-commits
tabloid.adroit added a comment.
Herald added a project: clang.

ping


Repository:
  rC Clang

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

https://reviews.llvm.org/D56353



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


[PATCH] D56353: Replace cc1 options '-mdisable-fp-elim' and '-momit-leaf-frame-pointer' with'-mframe-pointer='

2019-07-12 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen updated this revision to Diff 209550.
ychen added a comment.

- rebase after D64294 .


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D56353

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Basic/CodeGenOptions.h
  clang/include/clang/Driver/CC1Options.td
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/msp430-fp-elim.c
  clang/test/CodeGen/x86_64-profiling-keep-fp.c
  clang/test/CodeGen/xcore-abi.c
  clang/test/CodeGen/xcore-abi.cpp
  clang/test/CodeGenCXX/global-init.cpp
  clang/test/CodeGenObjCXX/msabi-stret.mm
  clang/test/Driver/cl-options.c
  clang/test/Driver/clang-translation.c
  clang/test/Driver/frame-pointer-elim.c
  clang/test/Driver/frame-pointer.c
  clang/test/Driver/woa-fp.c
  clang/test/Driver/xcore-opts.c

Index: clang/test/Driver/xcore-opts.c
===
--- clang/test/Driver/xcore-opts.c
+++ clang/test/Driver/xcore-opts.c
@@ -3,9 +3,8 @@
 // RUN: %clang -target xcore -x c++ %s -fexceptions -### -o %t.o 2>&1 | FileCheck -check-prefix CHECK-EXCEP %s
 // RUN: %clang -target xcore %s -g0 -### -o %t.o 2>&1 | FileCheck -check-prefix CHECK-G0 %s
 
+// CHECK: "-mframe-pointer=none"
 // CHECK: "-nostdsysteminc"
-// CHECK-NOT: "-mdisable-fp-elim"
-// CHECK-NOT: "-momit-leaf-frame-pointer"
 // CHECK: "-fno-signed-char"
 // CHECK: "-fno-use-cxa-atexit"
 // CHECK-NOT: "-fcxx-exceptions"
Index: clang/test/Driver/woa-fp.c
===
--- clang/test/Driver/woa-fp.c
+++ clang/test/Driver/woa-fp.c
@@ -34,7 +34,7 @@
 // RUN: %clang -target armv7-windows-itanium -fno-omit-frame-pointer -### -S %s -O3 -o /dev/null 2>&1 | FileCheck %s -check-prefix CHECK-NO-FPO
 // RUN: %clang -target armv7-windows-itanium -fno-omit-frame-pointer -### -S %s -Os -o /dev/null 2>&1 | FileCheck %s -check-prefix CHECK-NO-FPO
 
-// CHECK-DEFAULT: "-mdisable-fp-elim"
-// CHECK-FPO-NOT: "-mdisable-fp-elim"
-// CHECK-NO-FPO: "-mdisable-fp-elim"
+// CHECK-DEFAULT: "-mframe-pointer=all"
+// CHECK-FPO-NOT: "-mframe-pointer=all"
+// CHECK-NO-FPO: "-mframe-pointer=all"
 
Index: clang/test/Driver/frame-pointer.c
===
--- clang/test/Driver/frame-pointer.c
+++ clang/test/Driver/frame-pointer.c
@@ -57,15 +57,15 @@
 // RUN: %clang -target riscv64-unknown-linux-gnu -### -S -O3 %s -o %t.s 2>&1 | FileCheck -check-prefix=CHECK3-64 %s
 // RUN: %clang -target riscv64-unknown-linux-gnu -### -S -Os %s -o %t.s 2>&1 | FileCheck -check-prefix=CHECKs-64 %s
 
-// CHECK0-32: -mdisable-fp-elim
-// CHECK1-32-NOT: -mdisable-fp-elim
-// CHECK2-32-NOT: -mdisable-fp-elim
-// CHECK3-32-NOT: -mdisable-fp-elim
-// CHECKs-32-NOT: -mdisable-fp-elim
+// CHECK0-32: -mframe-pointer=all
+// CHECK1-32-NOT: -mframe-pointer=all
+// CHECK2-32-NOT: -mframe-pointer=all
+// CHECK3-32-NOT: -mframe-pointer=all
+// CHECKs-32-NOT: -mframe-pointer=all
 
-// CHECK0-64: -mdisable-fp-elim
-// CHECK1-64-NOT: -mdisable-fp-elim
-// CHECK2-64-NOT: -mdisable-fp-elim
-// CHECK3-64-NOT: -mdisable-fp-elim
-// CHECKs-64-NOT: -mdisable-fp-elim
-// CHECK-MACHO-64: -mdisable-fp-elim
+// CHECK0-64: -mframe-pointer=all
+// CHECK1-64-NOT: -mframe-pointer=all
+// CHECK2-64-NOT: -mframe-pointer=all
+// CHECK3-64-NOT: -mframe-pointer=all
+// CHECKs-64-NOT: -mframe-pointer=all
+// CHECK-MACHO-64: -mframe-pointer=all
Index: clang/test/Driver/frame-pointer-elim.c
===
--- clang/test/Driver/frame-pointer-elim.c
+++ clang/test/Driver/frame-pointer-elim.c
@@ -1,11 +1,6 @@
-// KEEP-ALL: "-mdisable-fp-elim"
-// KEEP-ALL-NOT: "-momit-leaf-frame-pointer"
-
-// KEEP-NON-LEAF: "-mdisable-fp-elim"
-// KEEP-NON-LEAF: "-momit-leaf-frame-pointer"
-
-// KEEP-NONE-NOT: "-mdisable-fp-elim"
-// KEEP-NONE-NOT: "-momit-leaf-frame-pointer"
+// KEEP-ALL:  "-mframe-pointer=all"
+// KEEP-NON-LEAF: "-mframe-pointer=non-leaf"
+// KEEP-NONE: "-mframe-pointer=none"
 
 // On Linux x86, omit frame pointer when optimization is enabled.
 // RUN: %clang -### -target i386-linux -S -fomit-frame-pointer %s 2>&1 | \
@@ -73,20 +68,17 @@
 // RUN: %clang -### -target armv7s-apple-ios -fomit-frame-pointer %s 2>&1 | \
 // RUN:   FileCheck --check-prefix=WARN-OMIT-7S %s
 // WARN-OMIT-7S: warning: optimization flag '-fomit-frame-pointer' is not supported for target 'armv7s'
-// WARN-OMIT-7S: "-mdisable-fp-elim"
-// WARN-OMIT-7S-NOT: "-momit-leaf-frame-pointer"
+// WARN-OMIT-7S: "-mframe-pointer=all"
 
 // RUN: %clang -### -target armv7k-apple-watchos -fomit-frame-pointer %s 2>&1 | \
 // RUN:   FileCheck --check-prefix=WARN-OMIT-7K %s
 // WARN-OMIT-7K: warning: optimization flag '-fomit-frame-pointer' is not supported for target 'armv7k'

[PATCH] D56353: Replace cc1 options '-mdisable-fp-elim' and '-momit-leaf-frame-pointer' with '-mframe-pointer'

2019-07-15 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen marked an inline comment as done and an inline comment as not done.
ychen added inline comments.



Comment at: clang/lib/Frontend/CompilerInvocation.cpp:845
+  if (Args.hasArg(OPT_pg))
+Opts.setFramePointer(CodeGenOptions::FP_All);
+

MaskRay wrote:
> I guess this can be deleted now.
> 
> `-pg` + FramePointerKind::None is rejected by the driver.
> 
> ```
>   if (Arg *A = Args.getLastArg(options::OPT_pg))
> if (FPKeepKind == FramePointerKind::None)
>   D.Diag(diag::err_drv_argument_not_allowed_with) << 
> "-fomit-frame-pointer"
>   << A->getAsString(Args);
> ```
This is still needed for `clang/test/CodeGen/x86_64-profiling-keep-fp.c` to 
pass.

We could have another patch to address this and update the test.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D56353



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


[PATCH] D56353: Replace cc1 options '-mdisable-fp-elim' and '-momit-leaf-frame-pointer' with '-mframe-pointer'

2019-07-15 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen updated this revision to Diff 209973.
ychen marked an inline comment as not done.
ychen edited the summary of this revision.
ychen added a comment.

- Make `FramePointerKind` enum class.
- Replace two if-else-if blocks to switch statements.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D56353

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Basic/CodeGenOptions.h
  clang/include/clang/Driver/CC1Options.td
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/msp430-fp-elim.c
  clang/test/CodeGen/x86_64-profiling-keep-fp.c
  clang/test/CodeGen/xcore-abi.c
  clang/test/CodeGen/xcore-abi.cpp
  clang/test/CodeGenCXX/global-init.cpp
  clang/test/CodeGenObjCXX/msabi-stret.mm
  clang/test/Driver/cl-options.c
  clang/test/Driver/clang-translation.c
  clang/test/Driver/frame-pointer-elim.c
  clang/test/Driver/frame-pointer.c
  clang/test/Driver/woa-fp.c
  clang/test/Driver/xcore-opts.c

Index: clang/test/Driver/xcore-opts.c
===
--- clang/test/Driver/xcore-opts.c
+++ clang/test/Driver/xcore-opts.c
@@ -3,9 +3,8 @@
 // RUN: %clang -target xcore -x c++ %s -fexceptions -### -o %t.o 2>&1 | FileCheck -check-prefix CHECK-EXCEP %s
 // RUN: %clang -target xcore %s -g0 -### -o %t.o 2>&1 | FileCheck -check-prefix CHECK-G0 %s
 
+// CHECK: "-mframe-pointer=none"
 // CHECK: "-nostdsysteminc"
-// CHECK-NOT: "-mdisable-fp-elim"
-// CHECK-NOT: "-momit-leaf-frame-pointer"
 // CHECK: "-fno-signed-char"
 // CHECK: "-fno-use-cxa-atexit"
 // CHECK-NOT: "-fcxx-exceptions"
Index: clang/test/Driver/woa-fp.c
===
--- clang/test/Driver/woa-fp.c
+++ clang/test/Driver/woa-fp.c
@@ -34,7 +34,7 @@
 // RUN: %clang -target armv7-windows-itanium -fno-omit-frame-pointer -### -S %s -O3 -o /dev/null 2>&1 | FileCheck %s -check-prefix CHECK-NO-FPO
 // RUN: %clang -target armv7-windows-itanium -fno-omit-frame-pointer -### -S %s -Os -o /dev/null 2>&1 | FileCheck %s -check-prefix CHECK-NO-FPO
 
-// CHECK-DEFAULT: "-mdisable-fp-elim"
-// CHECK-FPO-NOT: "-mdisable-fp-elim"
-// CHECK-NO-FPO: "-mdisable-fp-elim"
+// CHECK-DEFAULT: "-mframe-pointer=all"
+// CHECK-FPO-NOT: "-mframe-pointer=all"
+// CHECK-NO-FPO: "-mframe-pointer=all"
 
Index: clang/test/Driver/frame-pointer.c
===
--- clang/test/Driver/frame-pointer.c
+++ clang/test/Driver/frame-pointer.c
@@ -57,15 +57,15 @@
 // RUN: %clang -target riscv64-unknown-linux-gnu -### -S -O3 %s -o %t.s 2>&1 | FileCheck -check-prefix=CHECK3-64 %s
 // RUN: %clang -target riscv64-unknown-linux-gnu -### -S -Os %s -o %t.s 2>&1 | FileCheck -check-prefix=CHECKs-64 %s
 
-// CHECK0-32: -mdisable-fp-elim
-// CHECK1-32-NOT: -mdisable-fp-elim
-// CHECK2-32-NOT: -mdisable-fp-elim
-// CHECK3-32-NOT: -mdisable-fp-elim
-// CHECKs-32-NOT: -mdisable-fp-elim
+// CHECK0-32: -mframe-pointer=all
+// CHECK1-32-NOT: -mframe-pointer=all
+// CHECK2-32-NOT: -mframe-pointer=all
+// CHECK3-32-NOT: -mframe-pointer=all
+// CHECKs-32-NOT: -mframe-pointer=all
 
-// CHECK0-64: -mdisable-fp-elim
-// CHECK1-64-NOT: -mdisable-fp-elim
-// CHECK2-64-NOT: -mdisable-fp-elim
-// CHECK3-64-NOT: -mdisable-fp-elim
-// CHECKs-64-NOT: -mdisable-fp-elim
-// CHECK-MACHO-64: -mdisable-fp-elim
+// CHECK0-64: -mframe-pointer=all
+// CHECK1-64-NOT: -mframe-pointer=all
+// CHECK2-64-NOT: -mframe-pointer=all
+// CHECK3-64-NOT: -mframe-pointer=all
+// CHECKs-64-NOT: -mframe-pointer=all
+// CHECK-MACHO-64: -mframe-pointer=all
Index: clang/test/Driver/frame-pointer-elim.c
===
--- clang/test/Driver/frame-pointer-elim.c
+++ clang/test/Driver/frame-pointer-elim.c
@@ -1,11 +1,6 @@
-// KEEP-ALL: "-mdisable-fp-elim"
-// KEEP-ALL-NOT: "-momit-leaf-frame-pointer"
-
-// KEEP-NON-LEAF: "-mdisable-fp-elim"
-// KEEP-NON-LEAF: "-momit-leaf-frame-pointer"
-
-// KEEP-NONE-NOT: "-mdisable-fp-elim"
-// KEEP-NONE-NOT: "-momit-leaf-frame-pointer"
+// KEEP-ALL:  "-mframe-pointer=all"
+// KEEP-NON-LEAF: "-mframe-pointer=non-leaf"
+// KEEP-NONE: "-mframe-pointer=none"
 
 // On Linux x86, omit frame pointer when optimization is enabled.
 // RUN: %clang -### -target i386-linux -S -fomit-frame-pointer %s 2>&1 | \
@@ -73,20 +68,17 @@
 // RUN: %clang -### -target armv7s-apple-ios -fomit-frame-pointer %s 2>&1 | \
 // RUN:   FileCheck --check-prefix=WARN-OMIT-7S %s
 // WARN-OMIT-7S: warning: optimization flag '-fomit-frame-pointer' is not supported for target 'armv7s'
-// WARN-OMIT-7S: "-mdisable-fp-elim"
-// WARN-OMIT-7S-NOT: "-momit-leaf-frame-pointer"
+// WARN-OMIT-7S: "-mframe-pointer=all"
 
 // RUN: %clang -### -target armv7k-apple-watchos -fomit-frame-pointer %s 2>&1 | \
 // RUN:   FileCheck --check-prefi

[PATCH] D56353: Replace cc1 options '-mdisable-fp-elim' and '-momit-leaf-frame-pointer' with '-mframe-pointer'

2019-07-15 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen updated this revision to Diff 210014.
ychen marked an inline comment as done.
ychen added a comment.

- update


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D56353

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Basic/CodeGenOptions.h
  clang/include/clang/Driver/CC1Options.td
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/msp430-fp-elim.c
  clang/test/CodeGen/x86_64-profiling-keep-fp.c
  clang/test/CodeGen/xcore-abi.c
  clang/test/CodeGen/xcore-abi.cpp
  clang/test/CodeGenCXX/global-init.cpp
  clang/test/CodeGenObjCXX/msabi-stret.mm
  clang/test/Driver/cl-options.c
  clang/test/Driver/clang-translation.c
  clang/test/Driver/frame-pointer-elim.c
  clang/test/Driver/frame-pointer.c
  clang/test/Driver/woa-fp.c
  clang/test/Driver/xcore-opts.c

Index: clang/test/Driver/xcore-opts.c
===
--- clang/test/Driver/xcore-opts.c
+++ clang/test/Driver/xcore-opts.c
@@ -3,9 +3,8 @@
 // RUN: %clang -target xcore -x c++ %s -fexceptions -### -o %t.o 2>&1 | FileCheck -check-prefix CHECK-EXCEP %s
 // RUN: %clang -target xcore %s -g0 -### -o %t.o 2>&1 | FileCheck -check-prefix CHECK-G0 %s
 
+// CHECK: "-mframe-pointer=none"
 // CHECK: "-nostdsysteminc"
-// CHECK-NOT: "-mdisable-fp-elim"
-// CHECK-NOT: "-momit-leaf-frame-pointer"
 // CHECK: "-fno-signed-char"
 // CHECK: "-fno-use-cxa-atexit"
 // CHECK-NOT: "-fcxx-exceptions"
Index: clang/test/Driver/woa-fp.c
===
--- clang/test/Driver/woa-fp.c
+++ clang/test/Driver/woa-fp.c
@@ -34,7 +34,7 @@
 // RUN: %clang -target armv7-windows-itanium -fno-omit-frame-pointer -### -S %s -O3 -o /dev/null 2>&1 | FileCheck %s -check-prefix CHECK-NO-FPO
 // RUN: %clang -target armv7-windows-itanium -fno-omit-frame-pointer -### -S %s -Os -o /dev/null 2>&1 | FileCheck %s -check-prefix CHECK-NO-FPO
 
-// CHECK-DEFAULT: "-mdisable-fp-elim"
-// CHECK-FPO-NOT: "-mdisable-fp-elim"
-// CHECK-NO-FPO: "-mdisable-fp-elim"
+// CHECK-DEFAULT: "-mframe-pointer=all"
+// CHECK-FPO-NOT: "-mframe-pointer=all"
+// CHECK-NO-FPO: "-mframe-pointer=all"
 
Index: clang/test/Driver/frame-pointer.c
===
--- clang/test/Driver/frame-pointer.c
+++ clang/test/Driver/frame-pointer.c
@@ -57,15 +57,15 @@
 // RUN: %clang -target riscv64-unknown-linux-gnu -### -S -O3 %s -o %t.s 2>&1 | FileCheck -check-prefix=CHECK3-64 %s
 // RUN: %clang -target riscv64-unknown-linux-gnu -### -S -Os %s -o %t.s 2>&1 | FileCheck -check-prefix=CHECKs-64 %s
 
-// CHECK0-32: -mdisable-fp-elim
-// CHECK1-32-NOT: -mdisable-fp-elim
-// CHECK2-32-NOT: -mdisable-fp-elim
-// CHECK3-32-NOT: -mdisable-fp-elim
-// CHECKs-32-NOT: -mdisable-fp-elim
+// CHECK0-32: -mframe-pointer=all
+// CHECK1-32-NOT: -mframe-pointer=all
+// CHECK2-32-NOT: -mframe-pointer=all
+// CHECK3-32-NOT: -mframe-pointer=all
+// CHECKs-32-NOT: -mframe-pointer=all
 
-// CHECK0-64: -mdisable-fp-elim
-// CHECK1-64-NOT: -mdisable-fp-elim
-// CHECK2-64-NOT: -mdisable-fp-elim
-// CHECK3-64-NOT: -mdisable-fp-elim
-// CHECKs-64-NOT: -mdisable-fp-elim
-// CHECK-MACHO-64: -mdisable-fp-elim
+// CHECK0-64: -mframe-pointer=all
+// CHECK1-64-NOT: -mframe-pointer=all
+// CHECK2-64-NOT: -mframe-pointer=all
+// CHECK3-64-NOT: -mframe-pointer=all
+// CHECKs-64-NOT: -mframe-pointer=all
+// CHECK-MACHO-64: -mframe-pointer=all
Index: clang/test/Driver/frame-pointer-elim.c
===
--- clang/test/Driver/frame-pointer-elim.c
+++ clang/test/Driver/frame-pointer-elim.c
@@ -1,11 +1,6 @@
-// KEEP-ALL: "-mdisable-fp-elim"
-// KEEP-ALL-NOT: "-momit-leaf-frame-pointer"
-
-// KEEP-NON-LEAF: "-mdisable-fp-elim"
-// KEEP-NON-LEAF: "-momit-leaf-frame-pointer"
-
-// KEEP-NONE-NOT: "-mdisable-fp-elim"
-// KEEP-NONE-NOT: "-momit-leaf-frame-pointer"
+// KEEP-ALL:  "-mframe-pointer=all"
+// KEEP-NON-LEAF: "-mframe-pointer=non-leaf"
+// KEEP-NONE: "-mframe-pointer=none"
 
 // On Linux x86, omit frame pointer when optimization is enabled.
 // RUN: %clang -### -target i386-linux -S -fomit-frame-pointer %s 2>&1 | \
@@ -73,20 +68,17 @@
 // RUN: %clang -### -target armv7s-apple-ios -fomit-frame-pointer %s 2>&1 | \
 // RUN:   FileCheck --check-prefix=WARN-OMIT-7S %s
 // WARN-OMIT-7S: warning: optimization flag '-fomit-frame-pointer' is not supported for target 'armv7s'
-// WARN-OMIT-7S: "-mdisable-fp-elim"
-// WARN-OMIT-7S-NOT: "-momit-leaf-frame-pointer"
+// WARN-OMIT-7S: "-mframe-pointer=all"
 
 // RUN: %clang -### -target armv7k-apple-watchos -fomit-frame-pointer %s 2>&1 | \
 // RUN:   FileCheck --check-prefix=WARN-OMIT-7K %s
 // WARN-OMIT-7K: warning: optimization flag '-fomit-frame-pointer' is not supported for target 'armv7k'
-// WAR

[PATCH] D56353: Replace cc1 options '-mdisable-fp-elim' and '-momit-leaf-frame-pointer' with '-mframe-pointer'

2019-07-18 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added a comment.

@chandlerc ping?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D56353



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


[PATCH] D65527: Avoid assemble step in verbose-output-quoting.c

2019-07-31 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen created this revision.
ychen added a reviewer: hans.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D65527

Files:
  clang/test/Driver/verbose-output-quoting.c


Index: clang/test/Driver/verbose-output-quoting.c
===
--- clang/test/Driver/verbose-output-quoting.c
+++ clang/test/Driver/verbose-output-quoting.c
@@ -1,8 +1,8 @@
 // REQUIRES: shell
-// RUN: %clang --verbose -DSPACE="a b"  -c %s 2>&1 | FileCheck 
-check-prefix=SPACE -strict-whitespace %s
-// RUN: %clang --verbose -DQUOTES=\"\"  -c %s 2>&1 | FileCheck 
-check-prefix=QUOTES-strict-whitespace %s
-// RUN: %clang --verbose -DBACKSLASH=\\ -c %s 2>&1 | FileCheck 
-check-prefix=BACKSLASH -strict-whitespace %s
-// RUN: %clang --verbose -DDOLLAR=\$-c %s 2>&1 | FileCheck 
-check-prefix=DOLLAR-strict-whitespace %s
+// RUN: %clang --verbose -DSPACE="a b"  -S %s 2>&1 | FileCheck 
-check-prefix=SPACE -strict-whitespace %s
+// RUN: %clang --verbose -DQUOTES=\"\"  -S %s 2>&1 | FileCheck 
-check-prefix=QUOTES-strict-whitespace %s
+// RUN: %clang --verbose -DBACKSLASH=\\ -S %s 2>&1 | FileCheck 
-check-prefix=BACKSLASH -strict-whitespace %s
+// RUN: %clang --verbose -DDOLLAR=\$-S %s 2>&1 | FileCheck 
-check-prefix=DOLLAR-strict-whitespace %s
 
 // SPACE: -cc1 {{.*}} -D "SPACE=a b"
 // QUOTES: -cc1 {{.*}} -D "QUOTES=\"\""


Index: clang/test/Driver/verbose-output-quoting.c
===
--- clang/test/Driver/verbose-output-quoting.c
+++ clang/test/Driver/verbose-output-quoting.c
@@ -1,8 +1,8 @@
 // REQUIRES: shell
-// RUN: %clang --verbose -DSPACE="a b"  -c %s 2>&1 | FileCheck -check-prefix=SPACE -strict-whitespace %s
-// RUN: %clang --verbose -DQUOTES=\"\"  -c %s 2>&1 | FileCheck -check-prefix=QUOTES-strict-whitespace %s
-// RUN: %clang --verbose -DBACKSLASH=\\ -c %s 2>&1 | FileCheck -check-prefix=BACKSLASH -strict-whitespace %s
-// RUN: %clang --verbose -DDOLLAR=\$-c %s 2>&1 | FileCheck -check-prefix=DOLLAR-strict-whitespace %s
+// RUN: %clang --verbose -DSPACE="a b"  -S %s 2>&1 | FileCheck -check-prefix=SPACE -strict-whitespace %s
+// RUN: %clang --verbose -DQUOTES=\"\"  -S %s 2>&1 | FileCheck -check-prefix=QUOTES-strict-whitespace %s
+// RUN: %clang --verbose -DBACKSLASH=\\ -S %s 2>&1 | FileCheck -check-prefix=BACKSLASH -strict-whitespace %s
+// RUN: %clang --verbose -DDOLLAR=\$-S %s 2>&1 | FileCheck -check-prefix=DOLLAR-strict-whitespace %s
 
 // SPACE: -cc1 {{.*}} -D "SPACE=a b"
 // QUOTES: -cc1 {{.*}} -D "QUOTES=\"\""
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D64294: [Driver] Consolidate shouldUseFramePointer() and shouldUseLeafFramePointer()

2019-07-08 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added a comment.

In D56353 , I remember @chandlerc thought 
`-f(no-)omit-frame-pointer` should win over `-m(no-)omit-leaf-frame-pointer`. 
I'm not sure what his thoughts on this now. @chandlerc ?


Repository:
  rC Clang

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

https://reviews.llvm.org/D64294



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


[PATCH] D64294: [Driver] Consolidate shouldUseFramePointer() and shouldUseLeafFramePointer()

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



Comment at: lib/Driver/ToolChains/Clang.cpp:579
 
-static bool shouldUseFramePointer(const ArgList &Args,
-  const llvm::Triple &Triple) {
-  if (Arg *A = Args.getLastArg(options::OPT_fno_omit_frame_pointer,
-   options::OPT_fomit_frame_pointer))
-return A->getOption().matches(options::OPT_fno_omit_frame_pointer) ||
-   mustUseNonLeafFramePointerForTarget(Triple);
-
-  if (Args.hasArg(options::OPT_pg))
-return true;
-
-  return useFramePointerForTargetByDefault(Args, Triple);
-}
-
-static bool shouldUseLeafFramePointer(const ArgList &Args,
-  const llvm::Triple &Triple) {
-  if (Arg *A = Args.getLastArg(options::OPT_mno_omit_leaf_frame_pointer,
-   options::OPT_momit_leaf_frame_pointer))
-return A->getOption().matches(options::OPT_mno_omit_leaf_frame_pointer);
-
-  if (Args.hasArg(options::OPT_pg))
-return true;
-
-  if (Triple.isPS4CPU())
-return false;
-
-  return useFramePointerForTargetByDefault(Args, Triple);
+static FramePointerKind getFramePointerKind(const ArgList &Args,
+const llvm::Triple &Triple) {

`getFramePointerKind` -> `decideFramePointerKind` / `determineFramePointerKind` 
? 



Comment at: lib/Driver/ToolChains/Clang.cpp:585
+  (A && A->getOption().matches(options::OPT_fno_omit_frame_pointer)) ||
+  (!(A && A->getOption().matches(options::OPT_fomit_frame_pointer)) &&
+   (Args.hasArg(options::OPT_pg) ||

It looks better if  `frame_pointer` is represented using tri-state. Something 
like this?

It would be great to have comments for conditions that are not obvious such as 
the overriding rules.

```
  // There are three states for frame_pointer.
  enum class FpFlag {true, false, none};
  FpFlag FPF = FpFlag::none;
  if (Arg *A = Args.getLastArg(options::OPT_fomit_frame_pointer,
   options::OPT_fno_omit_frame_pointer))
FPF = A->getOption().matches(options::OPT_fno_omit_frame_pointer)) ?
 FpFlag::true : FpFlag::false;

  if (!mustUseNonLeaf && FPF == FpFlag::false)
return FramePointerKind::None;

  if (mustUseNonLeaf || FPF == FpFlag::true || Args.hasArg(options::OPT_pg) ||
  useFramePointerForTargetByDefault(Args, Triple)) {
if (Args.hasFlag(options::OPT_momit_leaf_frame_pointer,
 options::OPT_mno_omit_leaf_frame_pointer,
 Triple.isPS4CPU()))
  return FramePointerKind::NonLeaf;
return FramePointerKind::All;
  }
  return FramePointerKind::None;
```


Repository:
  rC Clang

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

https://reviews.llvm.org/D64294



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


[PATCH] D64294: [Driver] Consolidate shouldUseFramePointer() and shouldUseLeafFramePointer()

2019-07-10 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added inline comments.



Comment at: lib/Driver/ToolChains/Clang.cpp:585
+  (A && A->getOption().matches(options::OPT_fno_omit_frame_pointer)) ||
+  (!(A && A->getOption().matches(options::OPT_fomit_frame_pointer)) &&
+   (Args.hasArg(options::OPT_pg) ||

MaskRay wrote:
> ychen wrote:
> > It looks better if  `frame_pointer` is represented using tri-state. 
> > Something like this?
> > 
> > It would be great to have comments for conditions that are not obvious such 
> > as the overriding rules.
> > 
> > ```
> >   // There are three states for frame_pointer.
> >   enum class FpFlag {true, false, none};
> >   FpFlag FPF = FpFlag::none;
> >   if (Arg *A = Args.getLastArg(options::OPT_fomit_frame_pointer,
> >options::OPT_fno_omit_frame_pointer))
> > FPF = A->getOption().matches(options::OPT_fno_omit_frame_pointer)) ?
> >  FpFlag::true : FpFlag::false;
> > 
> >   if (!mustUseNonLeaf && FPF == FpFlag::false)
> > return FramePointerKind::None;
> > 
> >   if (mustUseNonLeaf || FPF == FpFlag::true || Args.hasArg(options::OPT_pg) 
> > ||
> >   useFramePointerForTargetByDefault(Args, Triple)) {
> > if (Args.hasFlag(options::OPT_momit_leaf_frame_pointer,
> >  options::OPT_mno_omit_leaf_frame_pointer,
> >  Triple.isPS4CPU()))
> >   return FramePointerKind::NonLeaf;
> > return FramePointerKind::All;
> >   }
> >   return FramePointerKind::None;
> > ```
> I actually think the current version is clearer.. The local `enum class 
> FpFlag {true, false, none};` doesn't improve readability in my opinion.
> 
> 
> I can define separate variables for:
> 
> * A && A->getOption().matches(options::OPT_fno_omit_frame_pointer)
> * A && A->getOption().matches(options::OPT_fomit_frame_pointer)
> 
> If reviewers think that makes the code easier to read.
I think local enum may be optional.

Say 
  - `Fp  = A && A->getOption().matches(options::OPT_fno_omit_frame_pointer)`
  - `NoFp = A && A->getOption().matches(options::OPT_fomit_frame_pointer)`

The `!(A && A->getOption().matches(options::OPT_fomit_frame_pointer))` in the 
current revision could be `!A`. The implicit logic is `NoFp`  could only be 
overriden by `mustUseNonLeaf`.

This block helps to make the implicit logic explicit and simplify the rest of 
the code.

```
if (!mustUseNonLeaf && NoFp)
  return FramePointerKind::None;
}
```




Repository:
  rC Clang

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

https://reviews.llvm.org/D64294



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


[PATCH] D64294: [Driver] Consolidate shouldUseFramePointer() and shouldUseLeafFramePointer()

2019-07-11 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen accepted this revision.
ychen added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rC Clang

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

https://reviews.llvm.org/D64294



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


[PATCH] D55915: [Driver] Make -fno-omit-frame-pointer imply -mno-omit-leaf-frame-pointerand make -fomit-frame-pointer imply -momit-leaf-frame-pointer.This matches GCC's behavior.

2018-12-19 Thread Yuanfang Chen via Phabricator via cfe-commits
tabloid.adroit created this revision.
Herald added a subscriber: cfe-commits.

llvm.org/PR9825


Repository:
  rC Clang

https://reviews.llvm.org/D55915

Files:
  lib/CodeGen/CGCall.cpp
  lib/Driver/ToolChains/Clang.cpp
  test/Driver/cl-options.c
  test/Driver/frame-pointer-elim.c


Index: test/Driver/frame-pointer-elim.c
===
--- test/Driver/frame-pointer-elim.c
+++ test/Driver/frame-pointer-elim.c
@@ -69,5 +69,20 @@
 // RUN: %clang -### -target x86_64-scei-ps4 -S -O2 %s 2>&1 | \
 // RUN:   FileCheck --check-prefix=OMIT_LEAF %s
 
+// RUN: %clang -### -S -Os -fno-omit-frame-pointer %s 2>&1 | \
+// RUN:   FileCheck --check-prefix=NO-OMIT-ALL %s
+// NO-OMIT-ALL: "-mdisable-fp-elim"
+// NO-OMIT-ALL-NOT: "-momit-leaf-frame-pointer"
+
+// RUN: %clang -### -S -Os -fno-omit-frame-pointer -momit-leaf-frame-pointer 
%s 2>&1 | \
+// RUN:   FileCheck --check-prefix=NO-OMIT-NONLEAF %s
+// NO-OMIT-NONLEAF: "-mdisable-fp-elim"
+// NO-OMIT-NONLEAF: "-momit-leaf-frame-pointer"
+
+// RUN: %clang -### -S -Os -fomit-frame-pointer %s 2>&1 | \
+// RUN:   FileCheck --check-prefix=OMIT-ALL %s
+// OMIT-ALL-NOT: "-mdisable-fp-elim"
+// OMIT-ALL: "-momit-leaf-frame-pointer"
+
 void f0() {}
 void f1() { f0(); }
Index: test/Driver/cl-options.c
===
--- test/Driver/cl-options.c
+++ test/Driver/cl-options.c
@@ -171,11 +171,10 @@
 
 // RUN: %clang_cl --target=i686-pc-win32 /O2sy- -### -- %s 2>&1 | FileCheck 
-check-prefix=PR24003 %s
 // PR24003: -mdisable-fp-elim
-// PR24003: -momit-leaf-frame-pointer
 // PR24003: -Os
 
 // RUN: %clang_cl --target=i686-pc-win32 -Werror /Oy- /O2 -### -- %s 2>&1 | 
FileCheck -check-prefix=Oy_2 %s
-// Oy_2: -momit-leaf-frame-pointer
+// Oy_2: -mdisable-fp-elim
 // Oy_2: -O2
 
 // RUN: %clang_cl --target=i686-pc-win32 -Werror /O2 /O2 -### -- %s 2>&1 | 
FileCheck -check-prefix=O2O2 %s
Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -498,7 +498,7 @@
   return codegenoptions::LimitedDebugInfo;
 }
 
-static bool mustUseNonLeafFramePointerForTarget(const llvm::Triple &Triple) {
+static bool mustUseFramePointerForTarget(const llvm::Triple &Triple) {
   switch (Triple.getArch()){
   default:
 return false;
@@ -575,7 +575,7 @@
   if (Arg *A = Args.getLastArg(options::OPT_fno_omit_frame_pointer,
options::OPT_fomit_frame_pointer))
 return A->getOption().matches(options::OPT_fno_omit_frame_pointer) ||
-   mustUseNonLeafFramePointerForTarget(Triple);
+   mustUseFramePointerForTarget(Triple);
 
   if (Args.hasArg(options::OPT_pg))
 return true;
@@ -589,6 +589,11 @@
options::OPT_momit_leaf_frame_pointer))
 return A->getOption().matches(options::OPT_mno_omit_leaf_frame_pointer);
 
+  if (Arg *A = Args.getLastArg(options::OPT_fno_omit_frame_pointer,
+   options::OPT_fomit_frame_pointer))
+return A->getOption().matches(options::OPT_fno_omit_frame_pointer) ||
+   mustUseFramePointerForTarget(Triple);
+
   if (Args.hasArg(options::OPT_pg))
 return true;
 
Index: lib/CodeGen/CGCall.cpp
===
--- lib/CodeGen/CGCall.cpp
+++ lib/CodeGen/CGCall.cpp
@@ -1736,7 +1736,6 @@
   FuncAttrs.addAttribute("no-frame-pointer-elim-non-leaf");
 } else {
   FuncAttrs.addAttribute("no-frame-pointer-elim", "true");
-  FuncAttrs.addAttribute("no-frame-pointer-elim-non-leaf");
 }
 
 FuncAttrs.addAttribute("less-precise-fpmad",


Index: test/Driver/frame-pointer-elim.c
===
--- test/Driver/frame-pointer-elim.c
+++ test/Driver/frame-pointer-elim.c
@@ -69,5 +69,20 @@
 // RUN: %clang -### -target x86_64-scei-ps4 -S -O2 %s 2>&1 | \
 // RUN:   FileCheck --check-prefix=OMIT_LEAF %s
 
+// RUN: %clang -### -S -Os -fno-omit-frame-pointer %s 2>&1 | \
+// RUN:   FileCheck --check-prefix=NO-OMIT-ALL %s
+// NO-OMIT-ALL: "-mdisable-fp-elim"
+// NO-OMIT-ALL-NOT: "-momit-leaf-frame-pointer"
+
+// RUN: %clang -### -S -Os -fno-omit-frame-pointer -momit-leaf-frame-pointer %s 2>&1 | \
+// RUN:   FileCheck --check-prefix=NO-OMIT-NONLEAF %s
+// NO-OMIT-NONLEAF: "-mdisable-fp-elim"
+// NO-OMIT-NONLEAF: "-momit-leaf-frame-pointer"
+
+// RUN: %clang -### -S -Os -fomit-frame-pointer %s 2>&1 | \
+// RUN:   FileCheck --check-prefix=OMIT-ALL %s
+// OMIT-ALL-NOT: "-mdisable-fp-elim"
+// OMIT-ALL: "-momit-leaf-frame-pointer"
+
 void f0() {}
 void f1() { f0(); }
Index: test/Driver/cl-options.c
===
--- test/Driver/cl-options.c
+++ test/Driver/cl-options.c
@@ -171,11 +171,10 @@
 
 // RUN: %clang_cl --target=i686-pc-win32 /O2sy- -### -- %s 2>&1 | FileCheck -check-prefix=PR24003 %s
 /

[PATCH] D55915: [Driver] Make -fno-omit-frame-pointer imply -mno-omit-leaf-frame-pointer

2018-12-21 Thread Yuanfang Chen via Phabricator via cfe-commits
tabloid.adroit updated this revision to Diff 179325.
tabloid.adroit added a comment.

- [Driver] Make -fno-omit-frame-pointer imply -mno-omit-leaf-frame-pointer
- add test
- update


Repository:
  rC Clang

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

https://reviews.llvm.org/D55915

Files:
  lib/CodeGen/CGCall.cpp
  lib/Driver/ToolChains/Clang.cpp
  test/Driver/cl-options.c
  test/Driver/frame-pointer-elim.c


Index: test/Driver/frame-pointer-elim.c
===
--- test/Driver/frame-pointer-elim.c
+++ test/Driver/frame-pointer-elim.c
@@ -69,5 +69,30 @@
 // RUN: %clang -### -target x86_64-scei-ps4 -S -O2 %s 2>&1 | \
 // RUN:   FileCheck --check-prefix=OMIT_LEAF %s
 
+// RUN: %clang -### -S -Os -fno-omit-frame-pointer %s 2>&1 | \
+// RUN:   FileCheck --check-prefix=NO-OMIT-ALL %s
+// NO-OMIT-ALL: "-mdisable-fp-elim"
+// NO-OMIT-ALL-NOT: "-momit-leaf-frame-pointer"
+
+// RUN: %clang -### -S -Os -fno-omit-frame-pointer -momit-leaf-frame-pointer 
%s 2>&1 | \
+// RUN:   FileCheck --check-prefix=NO-OMIT-NONLEAF %s
+// NO-OMIT-NONLEAF: "-mdisable-fp-elim"
+// NO-OMIT-NONLEAF: "-momit-leaf-frame-pointer"
+
+// RUN: %clang -### -S -Os -fomit-frame-pointer %s 2>&1 | \
+// RUN:   FileCheck --check-prefix=OMIT-ALL %s
+// OMIT-ALL-NOT: "-mdisable-fp-elim"
+// OMIT-ALL: "-momit-leaf-frame-pointer"
+
+// RUN: %clang -### -S -Os -fomit-frame-pointer -momit-leaf-frame-pointer %s 
2>&1 | \
+// RUN:   FileCheck --check-prefix=OMIT-ALL2 %s
+// OMIT-ALL2-NOT: "-mdisable-fp-elim"
+// OMIT-ALL2: "-momit-leaf-frame-pointer"
+
+// RUN: %clang -### -S -Os -fno-omit-frame-pointer 
-mno-omit-leaf-frame-pointer %s 2>&1 | \
+// RUN:   FileCheck --check-prefix=NO-OMIT-ALL2 %s
+// NO-OMIT-ALL2: "-mdisable-fp-elim"
+// NO-OMIT-ALL2-NOT: "-momit-leaf-frame-pointer"
+
 void f0() {}
 void f1() { f0(); }
Index: test/Driver/cl-options.c
===
--- test/Driver/cl-options.c
+++ test/Driver/cl-options.c
@@ -171,11 +171,10 @@
 
 // RUN: %clang_cl --target=i686-pc-win32 /O2sy- -### -- %s 2>&1 | FileCheck 
-check-prefix=PR24003 %s
 // PR24003: -mdisable-fp-elim
-// PR24003: -momit-leaf-frame-pointer
 // PR24003: -Os
 
 // RUN: %clang_cl --target=i686-pc-win32 -Werror /Oy- /O2 -### -- %s 2>&1 | 
FileCheck -check-prefix=Oy_2 %s
-// Oy_2: -momit-leaf-frame-pointer
+// Oy_2: -mdisable-fp-elim
 // Oy_2: -O2
 
 // RUN: %clang_cl --target=i686-pc-win32 -Werror /O2 /O2 -### -- %s 2>&1 | 
FileCheck -check-prefix=O2O2 %s
Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -498,7 +498,7 @@
   return codegenoptions::LimitedDebugInfo;
 }
 
-static bool mustUseNonLeafFramePointerForTarget(const llvm::Triple &Triple) {
+static bool mustUseFramePointerForTarget(const llvm::Triple &Triple) {
   switch (Triple.getArch()){
   default:
 return false;
@@ -575,7 +575,7 @@
   if (Arg *A = Args.getLastArg(options::OPT_fno_omit_frame_pointer,
options::OPT_fomit_frame_pointer))
 return A->getOption().matches(options::OPT_fno_omit_frame_pointer) ||
-   mustUseNonLeafFramePointerForTarget(Triple);
+   mustUseFramePointerForTarget(Triple);
 
   if (Args.hasArg(options::OPT_pg))
 return true;
@@ -589,6 +589,11 @@
options::OPT_momit_leaf_frame_pointer))
 return A->getOption().matches(options::OPT_mno_omit_leaf_frame_pointer);
 
+  if (Arg *A = Args.getLastArg(options::OPT_fno_omit_frame_pointer,
+   options::OPT_fomit_frame_pointer))
+return A->getOption().matches(options::OPT_fno_omit_frame_pointer) ||
+   mustUseFramePointerForTarget(Triple);
+
   if (Args.hasArg(options::OPT_pg))
 return true;
 
Index: lib/CodeGen/CGCall.cpp
===
--- lib/CodeGen/CGCall.cpp
+++ lib/CodeGen/CGCall.cpp
@@ -1736,7 +1736,6 @@
   FuncAttrs.addAttribute("no-frame-pointer-elim-non-leaf");
 } else {
   FuncAttrs.addAttribute("no-frame-pointer-elim", "true");
-  FuncAttrs.addAttribute("no-frame-pointer-elim-non-leaf");
 }
 
 FuncAttrs.addAttribute("less-precise-fpmad",


Index: test/Driver/frame-pointer-elim.c
===
--- test/Driver/frame-pointer-elim.c
+++ test/Driver/frame-pointer-elim.c
@@ -69,5 +69,30 @@
 // RUN: %clang -### -target x86_64-scei-ps4 -S -O2 %s 2>&1 | \
 // RUN:   FileCheck --check-prefix=OMIT_LEAF %s
 
+// RUN: %clang -### -S -Os -fno-omit-frame-pointer %s 2>&1 | \
+// RUN:   FileCheck --check-prefix=NO-OMIT-ALL %s
+// NO-OMIT-ALL: "-mdisable-fp-elim"
+// NO-OMIT-ALL-NOT: "-momit-leaf-frame-pointer"
+
+// RUN: %clang -### -S -Os -fno-omit-frame-pointer -momit-leaf-frame-pointer %s 2>&1 | \
+// RUN:   FileCheck --check-prefix=NO-OMIT-NONLEA

[PATCH] D55915: [Driver] Make -fno-omit-frame-pointer imply -mno-omit-leaf-frame-pointer

2018-12-23 Thread Yuanfang Chen via Phabricator via cfe-commits
tabloid.adroit updated this revision to Diff 179447.
tabloid.adroit marked an inline comment as done.
tabloid.adroit added a comment.

- update test


Repository:
  rC Clang

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

https://reviews.llvm.org/D55915

Files:
  lib/CodeGen/CGCall.cpp
  lib/Driver/ToolChains/Clang.cpp
  test/Driver/cl-options.c
  test/Driver/frame-pointer-elim.c

Index: test/Driver/frame-pointer-elim.c
===
--- test/Driver/frame-pointer-elim.c
+++ test/Driver/frame-pointer-elim.c
@@ -69,5 +69,55 @@
 // RUN: %clang -### -target x86_64-scei-ps4 -S -O2 %s 2>&1 | \
 // RUN:   FileCheck --check-prefix=OMIT_LEAF %s
 
+// RUN: %clang -### -S -Os -fno-omit-frame-pointer %s 2>&1 | \
+// RUN:   FileCheck --check-prefix=NO-OMIT-ALL %s
+// NO-OMIT-ALL: "-mdisable-fp-elim"
+// NO-OMIT-ALL-NOT: "-momit-leaf-frame-pointer"
+
+// RUN: %clang -### -S -Os -fomit-frame-pointer %s 2>&1 | \
+// RUN:   FileCheck --check-prefix=OMIT-ALL %s
+// OMIT-ALL-NOT: "-mdisable-fp-elim"
+// OMIT-ALL: "-momit-leaf-frame-pointer"
+
+// RUN: %clang -### -S -Os -fno-omit-frame-pointer -momit-leaf-frame-pointer %s 2>&1 | \
+// RUN:   FileCheck --check-prefix=NO-OMIT-NONLEAF %s
+// NO-OMIT-NONLEAF: "-mdisable-fp-elim"
+// NO-OMIT-NONLEAF: "-momit-leaf-frame-pointer"
+
+// RUN: %clang -### -S -Os -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer %s 2>&1 | \
+// RUN:   FileCheck --check-prefix=NO-OMIT-ALL2 %s
+// NO-OMIT-ALL2: "-mdisable-fp-elim"
+// NO-OMIT-ALL2-NOT: "-momit-leaf-frame-pointer"
+
+// RUN: %clang -### -S -Os -fomit-frame-pointer -momit-leaf-frame-pointer %s 2>&1 | \
+// RUN:   FileCheck --check-prefix=OMIT-ALL2 %s
+// OMIT-ALL2-NOT: "-mdisable-fp-elim"
+// OMIT-ALL2: "-momit-leaf-frame-pointer"
+
+// RUN: %clang -### -S -Os -fomit-frame-pointer -mno-omit-leaf-frame-pointer %s 2>&1 | \
+// RUN:   FileCheck --check-prefix=OMIT-ALL3 %s
+// OMIT-ALL3-NOT: "-mdisable-fp-elim"
+// OMIT-ALL3-NOT: "-momit-leaf-frame-pointer"
+
+// RUN: %clang -### -S -Os -momit-leaf-frame-pointer -fomit-frame-pointer %s 2>&1 | \
+// RUN:   FileCheck --check-prefix=OMIT-ALL4 %s
+// OMIT-ALL4-NOT: "-mdisable-fp-elim"
+// OMIT-ALL4: "-momit-leaf-frame-pointer"
+
+// RUN: %clang -### -S -Os -momit-leaf-frame-pointer -fno-omit-frame-pointer %s 2>&1 | \
+// RUN:   FileCheck --check-prefix=NO-OMIT-NONLEAF2 %s
+// NO-OMIT-NONLEAF2: "-mdisable-fp-elim"
+// NO-OMIT-NONLEAF2: "-momit-leaf-frame-pointer"
+
+// RUN: %clang -### -S -Os -mno-omit-leaf-frame-pointer -fomit-frame-pointer %s 2>&1 | \
+// RUN:   FileCheck --check-prefix=OMIT-ALL5 %s
+// OMIT-ALL5-NOT: "-mdisable-fp-elim"
+// OMIT-ALL5-NOT: "-momit-leaf-frame-pointer"
+
+// RUN: %clang -### -S -Os -mno-omit-leaf-frame-pointer -fno-omit-frame-pointer %s 2>&1 | \
+// RUN:   FileCheck --check-prefix=NO-OMIT-ALL3 %s
+// NO-OMIT-ALL3: "-mdisable-fp-elim"
+// NO-OMIT-ALL3-NOT: "-momit-leaf-frame-pointer"
+
 void f0() {}
 void f1() { f0(); }
Index: test/Driver/cl-options.c
===
--- test/Driver/cl-options.c
+++ test/Driver/cl-options.c
@@ -171,11 +171,10 @@
 
 // RUN: %clang_cl --target=i686-pc-win32 /O2sy- -### -- %s 2>&1 | FileCheck -check-prefix=PR24003 %s
 // PR24003: -mdisable-fp-elim
-// PR24003: -momit-leaf-frame-pointer
 // PR24003: -Os
 
 // RUN: %clang_cl --target=i686-pc-win32 -Werror /Oy- /O2 -### -- %s 2>&1 | FileCheck -check-prefix=Oy_2 %s
-// Oy_2: -momit-leaf-frame-pointer
+// Oy_2: -mdisable-fp-elim
 // Oy_2: -O2
 
 // RUN: %clang_cl --target=i686-pc-win32 -Werror /O2 /O2 -### -- %s 2>&1 | FileCheck -check-prefix=O2O2 %s
Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -498,7 +498,7 @@
   return codegenoptions::LimitedDebugInfo;
 }
 
-static bool mustUseNonLeafFramePointerForTarget(const llvm::Triple &Triple) {
+static bool mustUseFramePointerForTarget(const llvm::Triple &Triple) {
   switch (Triple.getArch()){
   default:
 return false;
@@ -575,7 +575,7 @@
   if (Arg *A = Args.getLastArg(options::OPT_fno_omit_frame_pointer,
options::OPT_fomit_frame_pointer))
 return A->getOption().matches(options::OPT_fno_omit_frame_pointer) ||
-   mustUseNonLeafFramePointerForTarget(Triple);
+   mustUseFramePointerForTarget(Triple);
 
   if (Args.hasArg(options::OPT_pg))
 return true;
@@ -589,6 +589,11 @@
options::OPT_momit_leaf_frame_pointer))
 return A->getOption().matches(options::OPT_mno_omit_leaf_frame_pointer);
 
+  if (Arg *A = Args.getLastArg(options::OPT_fno_omit_frame_pointer,
+   options::OPT_fomit_frame_pointer))
+return A->getOption().matches(options::OPT_fno_omit_frame_pointer) ||
+   mustUseFramePointerForTarget(Triple);
+
   if (Args.hasArg(options::OPT_pg))
 return 

[PATCH] D55915: [Driver] Make -fno-omit-frame-pointer imply -mno-omit-leaf-frame-pointer

2018-12-23 Thread Yuanfang Chen via Phabricator via cfe-commits
tabloid.adroit marked 2 inline comments as done.
tabloid.adroit added a comment.

Thanks for the review! Comments inline.




Comment at: lib/CodeGen/CGCall.cpp:1739
   FuncAttrs.addAttribute("no-frame-pointer-elim", "true");
-  FuncAttrs.addAttribute("no-frame-pointer-elim-non-leaf");
 }

chandlerc wrote:
> This seems like an unrelated change?
The only user of "no-frame-pointer-elim-non-leaf" is 
TargetOptions::DisableFramePointerElim where "no-frame-pointer-elim-non-leaf" 
matters only if "no-frame-pointer-elim" is "false".  This is to make it less 
confusing.



Comment at: lib/Driver/ToolChains/Clang.cpp:592-595
+  if (Arg *A = Args.getLastArg(options::OPT_fno_omit_frame_pointer,
+   options::OPT_fomit_frame_pointer))
+return A->getOption().matches(options::OPT_fno_omit_frame_pointer) ||
+   mustUseFramePointerForTarget(Triple);

chandlerc wrote:
> This doesn't correctly handle "last-flag-wins". Consider the case of 
> `-mno-omit-leaf-frame-pointer -fomit-frame-pointer`. That should omit the 
> leaf frame pointer, but if I read this correctly the logic here will use a 
> leaf frame pointer.
Updated test with this case along with some other cases.

// RUN: %clang -### -S -Os -mno-omit-leaf-frame-pointer -fomit-frame-pointer %s 
2>&1 | \
// RUN:   FileCheck --check-prefix=OMIT-ALL5 %s
// OMIT-ALL5-NOT: "-mdisable-fp-elim"
// OMIT-ALL5-NOT: "-momit-leaf-frame-pointer"

This falls into lib/CodeGen/CGCall.cpp:1733, which causes 
TargetOptions::DisableFramePointerElim returns false for all frames.




Repository:
  rC Clang

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

https://reviews.llvm.org/D55915



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


[PATCH] D55915: [Driver] Make -fno-omit-frame-pointer imply -mno-omit-leaf-frame-pointer

2018-12-26 Thread Yuanfang Chen via Phabricator via cfe-commits
tabloid.adroit marked 3 inline comments as done.
tabloid.adroit added inline comments.



Comment at: lib/CodeGen/CGCall.cpp:1739
   FuncAttrs.addAttribute("no-frame-pointer-elim", "true");
-  FuncAttrs.addAttribute("no-frame-pointer-elim-non-leaf");
 }

chandlerc wrote:
> tabloid.adroit wrote:
> > chandlerc wrote:
> > > This seems like an unrelated change?
> > The only user of "no-frame-pointer-elim-non-leaf" is 
> > TargetOptions::DisableFramePointerElim where 
> > "no-frame-pointer-elim-non-leaf" matters only if "no-frame-pointer-elim" is 
> > "false".  This is to make it less confusing.
> Yes, but that's kind of my point. This change is unrelated to the rest of the 
> patch.
> 
> I would go ahead and land *just* this change and explain that it doesn't 
> change behavior. Then the actual behavior change  can be landed independently.
Got you. Will do.



Comment at: lib/Driver/ToolChains/Clang.cpp:592-595
+  if (Arg *A = Args.getLastArg(options::OPT_fno_omit_frame_pointer,
+   options::OPT_fomit_frame_pointer))
+return A->getOption().matches(options::OPT_fno_omit_frame_pointer) ||
+   mustUseFramePointerForTarget(Triple);

chandlerc wrote:
> tabloid.adroit wrote:
> > chandlerc wrote:
> > > This doesn't correctly handle "last-flag-wins". Consider the case of 
> > > `-mno-omit-leaf-frame-pointer -fomit-frame-pointer`. That should omit the 
> > > leaf frame pointer, but if I read this correctly the logic here will use 
> > > a leaf frame pointer.
> > Updated test with this case along with some other cases.
> > 
> > // RUN: %clang -### -S -Os -mno-omit-leaf-frame-pointer 
> > -fomit-frame-pointer %s 2>&1 | \
> > // RUN:   FileCheck --check-prefix=OMIT-ALL5 %s
> > // OMIT-ALL5-NOT: "-mdisable-fp-elim"
> > // OMIT-ALL5-NOT: "-momit-leaf-frame-pointer"
> > 
> > This falls into lib/CodeGen/CGCall.cpp:1733, which causes 
> > TargetOptions::DisableFramePointerElim returns false for all frames.
> > 
> > 
> Then I don't understand what this change is doing.
> 
> This function, when called with arguments `-mno-omit-leaf-frame-pointer 
> -fomit-frame-pointer` will not hit the code you've added here, and will 
> instead return `true`. That doesn't seem like a sensible result given the 
> desired change to these flags. If something *else* is causing us to still not 
> use leaf frame pointers, that doesn't make the code here correct, it makes me 
> question how this works at all (and how we are testing it).
I see your point here. The logic is very confusing indeed.

It looks better if
s/shouldUseFramePointer/addFlagDisableFPElim
s/shouldUseLeafFramePointer/addFlagOmitLeafFramePointer

to show that here only decides compiler flag instead of the final code.

I think the correct way to handle these is to replace `-mdisable-fp-elim` and 
`-momit-leaf-frame-pointer` compiler flags with one, say `frame-pointer-model` 
= {KeepAll, OmitAll, KeepNonLeaf}, and let the driver decide 
`frame-pointer-model` here. The downside is that it affects compiler user 
unless we bridge deprecating flags on to new flag with some rules.




Comment at: test/Driver/cl-options.c:177
 // RUN: %clang_cl --target=i686-pc-win32 -Werror /Oy- /O2 -### -- %s 2>&1 | 
FileCheck -check-prefix=Oy_2 %s
-// Oy_2: -momit-leaf-frame-pointer
+// Oy_2: -mdisable-fp-elim
 // Oy_2: -O2

chandlerc wrote:
> Do we want to also change behavior for the CL options? We should discuss this 
> w/ the Windows folks at least
Sure. It would be great to have them to confirm.



Repository:
  rC Clang

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

https://reviews.llvm.org/D55915



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


[PATCH] D56353: Replace cc1 options '-mdisable-fp-elim' and '-momit-leaf-frame-pointer' with'-mframe-pointer='

2019-01-05 Thread Yuanfang Chen via Phabricator via cfe-commits
tabloid.adroit created this revision.
tabloid.adroit added reviewers: chandlerc, rnk, t.p.northover.
Herald added a subscriber: cfe-commits.

set cc1 '-mframe-pointer=' according to driver options 
m(no-)omit-leaf-frame-pointer
and f(no-)omit-frame-pointer

This makes -fomit-frame-pointer imply -momit-leaf-frame-pointer.
This matches GCC's behavior. PR9825

following up
https://reviews.llvm.org/D56351

related:
https://reviews.llvm.org/D55915


Repository:
  rC Clang

https://reviews.llvm.org/D56353

Files:
  include/clang/Basic/CodeGenOptions.def
  include/clang/Basic/CodeGenOptions.h
  include/clang/Driver/CC1Options.td
  include/clang/Driver/Options.td
  lib/CodeGen/CGCall.cpp
  lib/Driver/ToolChains/Clang.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/CodeGen/x86_64-profiling-keep-fp.c
  test/CodeGenCXX/global-init.cpp
  test/CodeGenObjCXX/msabi-stret.mm
  test/Driver/cl-options.c
  test/Driver/clang-translation.c
  test/Driver/frame-pointer-elim.c
  test/Driver/frame-pointer.c
  test/Driver/woa-fp.c
  test/Driver/xcore-opts.c

Index: test/Driver/xcore-opts.c
===
--- test/Driver/xcore-opts.c
+++ test/Driver/xcore-opts.c
@@ -3,9 +3,8 @@
 // RUN: %clang -target xcore -x c++ %s -fexceptions -### -o %t.o 2>&1 | FileCheck -check-prefix CHECK-EXCEP %s
 // RUN: %clang -target xcore %s -g0 -### -o %t.o 2>&1 | FileCheck -check-prefix CHECK-G0 %s
 
+// CHECK: "-mframe-pointer=none"
 // CHECK: "-nostdsysteminc"
-// CHECK: "-momit-leaf-frame-pointer"
-// CHECK-NOT: "-mdisable-fp-elim"
 // CHECK: "-fno-signed-char"
 // CHECK: "-fno-use-cxa-atexit"
 // CHECK-NOT: "-fcxx-exceptions"
Index: test/Driver/woa-fp.c
===
--- test/Driver/woa-fp.c
+++ test/Driver/woa-fp.c
@@ -34,7 +34,7 @@
 // RUN: %clang -target armv7-windows-itanium -fno-omit-frame-pointer -### -S %s -O3 -o /dev/null 2>&1 | FileCheck %s -check-prefix CHECK-NO-FPO
 // RUN: %clang -target armv7-windows-itanium -fno-omit-frame-pointer -### -S %s -Os -o /dev/null 2>&1 | FileCheck %s -check-prefix CHECK-NO-FPO
 
-// CHECK-DEFAULT: "-mdisable-fp-elim"
-// CHECK-FPO-NOT: "-mdisable-fp-elim"
-// CHECK-NO-FPO: "-mdisable-fp-elim"
+// CHECK-DEFAULT: "-mframe-pointer=all"
+// CHECK-FPO-NOT: "-mframe-pointer=all"
+// CHECK-NO-FPO: "-mframe-pointer=all"
 
Index: test/Driver/frame-pointer.c
===
--- test/Driver/frame-pointer.c
+++ test/Driver/frame-pointer.c
@@ -57,15 +57,15 @@
 // RUN: %clang -target riscv64-unknown-linux-gnu -### -S -O3 %s -o %t.s 2>&1 | FileCheck -check-prefix=CHECK3-64 %s
 // RUN: %clang -target riscv64-unknown-linux-gnu -### -S -Os %s -o %t.s 2>&1 | FileCheck -check-prefix=CHECKs-64 %s
 
-// CHECK0-32: -mdisable-fp-elim
-// CHECK1-32-NOT: -mdisable-fp-elim
-// CHECK2-32-NOT: -mdisable-fp-elim
-// CHECK3-32-NOT: -mdisable-fp-elim
-// CHECKs-32-NOT: -mdisable-fp-elim
+// CHECK0-32: -mframe-pointer=all
+// CHECK1-32-NOT: -mframe-pointer=all
+// CHECK2-32-NOT: -mframe-pointer=all
+// CHECK3-32-NOT: -mframe-pointer=all
+// CHECKs-32-NOT: -mframe-pointer=all
 
-// CHECK0-64: -mdisable-fp-elim
-// CHECK1-64-NOT: -mdisable-fp-elim
-// CHECK2-64-NOT: -mdisable-fp-elim
-// CHECK3-64-NOT: -mdisable-fp-elim
-// CHECKs-64-NOT: -mdisable-fp-elim
-// CHECK-MACHO-64: -mdisable-fp-elim
+// CHECK0-64: -mframe-pointer=all
+// CHECK1-64-NOT: -mframe-pointer=all
+// CHECK2-64-NOT: -mframe-pointer=all
+// CHECK3-64-NOT: -mframe-pointer=all
+// CHECKs-64-NOT: -mframe-pointer=all
+// CHECK-MACHO-64: -mframe-pointer=all
Index: test/Driver/frame-pointer-elim.c
===
--- test/Driver/frame-pointer-elim.c
+++ test/Driver/frame-pointer-elim.c
@@ -2,65 +2,62 @@
 // pointer, for unoptimized we should have a leaf frame pointer.
 // RUN: %clang -### -target i386-pc-linux-gnu -S -O1 %s 2>&1 | \
 // RUN:   FileCheck --check-prefix=LINUX-OPT %s
-// LINUX-OPT: "-momit-leaf-frame-pointer"
+// LINUX-OPT: "-mframe-pointer=none"
 
 // RUN: %clang -### -target i386-pc-linux-gnu -S %s 2>&1 | \
 // RUN:   FileCheck --check-prefix=LINUX %s
-// LINUX-NOT: "-momit-leaf-frame-pointer"
+// LINUX: "-mframe-pointer=all"
 
 // CloudABI follows the same rules as Linux.
 // RUN: %clang -### -target x86_64-unknown-cloudabi -S -O1 %s 2>&1 | \
 // RUN:   FileCheck --check-prefix=CLOUDABI-OPT %s
-// CLOUDABI-OPT: "-momit-leaf-frame-pointer"
+// CLOUDABI-OPT: "-mframe-pointer=none"
 
 // RUN: %clang -### -target x86_64-unknown-cloudabi -S %s 2>&1 | \
 // RUN:   FileCheck --check-prefix=CLOUDABI %s
-// CLOUDABI-NOT: "-momit-leaf-frame-pointer"
+// CLOUDABI: "-mframe-pointer=all"
 
 // NetBSD follows the same rules as Linux.
 // RUN: %clang -### -target x86_64-unknown-netbsd -S -O1 %s 2>&1 | \
 // RUN:   FileCheck --check-prefix=NETBSD-OPT %s
-// NETBSD-OPT: "-momit-leaf-frame-pointer"
+// NETBSD-OPT: "-mframe-pointer=none"
 
 // RUN: %clang -### -target x86_6

[PATCH] D55915: [Driver] Make -fno-omit-frame-pointer imply -mno-omit-leaf-frame-pointer

2019-01-05 Thread Yuanfang Chen via Phabricator via cfe-commits
tabloid.adroit added a comment.

https://reviews.llvm.org/D56351
https://reviews.llvm.org/D56353


Repository:
  rC Clang

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

https://reviews.llvm.org/D55915



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


[PATCH] D67847: [Support] make report_fatal_error `abort` instead of `exit`

2019-10-03 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added a comment.

In D67847#1691898 , @jyknight wrote:

> The `abort()` function raises SIGABRT, for which the default behavior is to 
> trigger a coredump. Do we actually want that behavior?
>
> Either `_exit()` (long available extension, which lld already uses) or 
> `quick_exit()` (the new C standard way) seem possibly preferable?


I think this patch is more for the purpose of making error handling better than 
for fixing PR35547. Fixing PR35547 is probably just a side effect. Apologies 
that I should have updated the summary to reflect that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67847



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


[PATCH] D68482: [clang] fix a typo from r372531

2019-10-04 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen created this revision.
ychen added a reviewer: xbolva00.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D68482

Files:
  clang/lib/Sema/SemaChecking.cpp
  clang/test/Sema/warn-integer-constants-in-ternary.c


Index: clang/test/Sema/warn-integer-constants-in-ternary.c
===
--- clang/test/Sema/warn-integer-constants-in-ternary.c
+++ clang/test/Sema/warn-integer-constants-in-ternary.c
@@ -18,7 +18,7 @@
   boolean r;
   r = a ? (1) : TWO;
   r = a ? 3 : TWO; // expected-warning {{converting the result of '?:' with 
integer constants to a boolean always evaluates to 'true'}}
-  r = a ? -2 : 0;  // expected-warning {{converting the result of '?:' with 
integer constants to a boolean always evaluates to 'true'}}
+  r = a ? -2 : 0;
   r = a ? 3 : -2;  // expected-warning {{converting the result of '?:' with 
integer constants to a boolean always evaluates to 'true'}}
   r = a ? 0 : TWO;
   r = a ? 3 : ONE; // expected-warning {{converting the result of '?:' with 
integer constants to a boolean always evaluates to 'true'}}
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -11366,7 +11366,7 @@
 (RHS->getValue() == 0 || RHS->getValue() == 1))
   // Do not diagnose common idioms.
   return;
-if (LHS->getValue() != 0 && LHS->getValue() != 0)
+if (LHS->getValue() != 0 && RHS->getValue() != 0)
   S.Diag(ExprLoc, diag::warn_integer_constants_in_conditional_always_true);
   }
 }


Index: clang/test/Sema/warn-integer-constants-in-ternary.c
===
--- clang/test/Sema/warn-integer-constants-in-ternary.c
+++ clang/test/Sema/warn-integer-constants-in-ternary.c
@@ -18,7 +18,7 @@
   boolean r;
   r = a ? (1) : TWO;
   r = a ? 3 : TWO; // expected-warning {{converting the result of '?:' with integer constants to a boolean always evaluates to 'true'}}
-  r = a ? -2 : 0;  // expected-warning {{converting the result of '?:' with integer constants to a boolean always evaluates to 'true'}}
+  r = a ? -2 : 0;
   r = a ? 3 : -2;  // expected-warning {{converting the result of '?:' with integer constants to a boolean always evaluates to 'true'}}
   r = a ? 0 : TWO;
   r = a ? 3 : ONE; // expected-warning {{converting the result of '?:' with integer constants to a boolean always evaluates to 'true'}}
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -11366,7 +11366,7 @@
 (RHS->getValue() == 0 || RHS->getValue() == 1))
   // Do not diagnose common idioms.
   return;
-if (LHS->getValue() != 0 && LHS->getValue() != 0)
+if (LHS->getValue() != 0 && RHS->getValue() != 0)
   S.Diag(ExprLoc, diag::warn_integer_constants_in_conditional_always_true);
   }
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D69327: [Clang][ThinLTO] Add a cache for compile phase output.

2019-10-23 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen created this revision.
ychen added reviewers: mehdi_amini, pcc, tejohnson.
Herald added subscribers: llvm-commits, cfe-commits, dang, dexonsmith, 
steven_wu, aheejin, hiraditya, inglorion.
Herald added projects: clang, LLVM.

Currently the link phase has a object file cache whereas the compile phase 
always
perform optimizations (most likely happen for large source files and O2 
 or above)
which could potentially waste time optimizing a file that finally hit the 
object file cache.
For example, with Intel W-2133 and 64GB memory, compile X86ISelLowering.cpp 
with -flto=thin -O3
takes about 40s (takes about 10s with caching implemented by this patch).
The patch makes sure bitcodes that hit LTO cache also skip IR optimizations.

Add a driver/cc1 flag (-fthinlto-cache-dir, default off) to cache the minimized 
or regular ThinLTO bitcode file.
The caching is only trigger if the input is large than 
`-fthinlto-cache-min-filesize=`. Default minimum is 1024 IR instructions.
Cache pruning (`-fthinlto-cache-policy=`) shares the implementation with `lld 
--thinlto-cache-policy`.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D69327

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Basic/CodeGenOptions.h
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/thin_link_bitcode.c
  llvm/include/llvm/LTO/Caching.h
  llvm/lib/LTO/Caching.cpp

Index: llvm/lib/LTO/Caching.cpp
===
--- llvm/lib/LTO/Caching.cpp
+++ llvm/lib/LTO/Caching.cpp
@@ -28,7 +28,8 @@
 using namespace llvm::lto;
 
 Expected lto::localCache(StringRef CacheDirectoryPath,
-AddBufferFn AddBuffer) {
+AddBufferFn AddBuffer,
+StringRef Prefix) {
   if (std::error_code EC = sys::fs::create_directories(CacheDirectoryPath))
 return errorCodeToError(EC);
 
@@ -36,7 +37,7 @@
 // This choice of file name allows the cache to be pruned (see pruneCache()
 // in include/llvm/Support/CachePruning.h).
 SmallString<64> EntryPath;
-sys::path::append(EntryPath, CacheDirectoryPath, "llvmcache-" + Key);
+sys::path::append(EntryPath, CacheDirectoryPath, Prefix + Key);
 // First, see if we have a cache hit.
 SmallString<64> ResultPath;
 Expected FDOrErr = sys::fs::openNativeFileForRead(
Index: llvm/include/llvm/LTO/Caching.h
===
--- llvm/include/llvm/LTO/Caching.h
+++ llvm/include/llvm/LTO/Caching.h
@@ -31,7 +31,8 @@
 /// file callback. This function also creates the cache directory if it does not
 /// already exist.
 Expected localCache(StringRef CacheDirectoryPath,
-   AddBufferFn AddBuffer);
+   AddBufferFn AddBuffer,
+   StringRef Prefix = "llvmcache-");
 
 } // namespace lto
 } // namespace llvm
Index: clang/test/CodeGen/thin_link_bitcode.c
===
--- clang/test/CodeGen/thin_link_bitcode.c
+++ clang/test/CodeGen/thin_link_bitcode.c
@@ -6,6 +6,17 @@
 // RUN: %clang_cc1 -o %t.newpm -flto=thin -fexperimental-new-pass-manager -fthin-link-bitcode=%t.newpm.nodebug -triple x86_64-unknown-linux-gnu -emit-llvm-bc -debug-info-kind=limited  %s
 // RUN: llvm-bcanalyzer -dump %t.newpm | FileCheck %s
 // RUN: llvm-bcanalyzer -dump %t.newpm.nodebug | FileCheck %s --check-prefix=NO_DEBUG
+
+// Test optimized bitcode files caching
+// RUN: rm -Rf %t.cache && mkdir %t.cache
+// RUN: %clang_cc1 -o %t -flto=thin -fthin-link-bitcode=%t.nodebug -fthinlto-cache-dir=%t.cache -fthinlto-cache-min-filesize=1 -triple x86_64-unknown-linux-gnu -emit-llvm-bc -debug-info-kind=limited %s
+// RUN: ls %t.cache | count 3
+// RUN: llvm-bcanalyzer -dump %t.cache/llvmcache-bc-* | FileCheck %s
+// RUN: llvm-bcanalyzer -dump %t.cache/llvmcache-thinlink-* | FileCheck %s --check-prefix=NO_DEBUG
+
+// RUN: rm -Rf %t.cache && mkdir %t.cache
+// RUN: %clang_cc1 -o %t -flto=thin -fthin-link-bitcode=%t.nodebug -fthinlto-cache-dir=%t.cache -fthinlto-cache-min-filesize=100 -triple x86_64-unknown-linux-gnu -emit-llvm-bc -debug-info-kind=limited %s
+// RUN: ls %t.cache | count 0
 int main (void) {
   return 0;
 }
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -991,6 +991,11 @@
 
   Opts.ThinLinkBitcodeFile = Args.getLastArgValue(OPT_fthin_link_bitcode_EQ);
 
+  Opts.ThinLTOCacheDir = Args.getLastArgValue(OPT_fthinlto_cache_dir_EQ);
+  Opts.ThinLTOCachePolicy = Args.getLastArgValue(OPT_fthinl

[PATCH] D69327: [Clang][ThinLTO] Add a cache for compile phase output.

2019-10-23 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added a comment.

In D69327#1719109 , @tejohnson wrote:

> I haven't read through the patch in detail yet, but from the description it 
> sounds like a cache is being added for the compile step outputs, e.g. the 
> bitcode output object of the "clang -flto=thin -c" step? Typically the build 
> system takes care of incremental build handling for these explicit outputs, 
> just as it would for a non-LTO clang compile output. Can you clarify the 
> motivation?


Hi Teresa, thanks for the feedback. I think the motivation is to provide an 
option that reliably caches thinLTO compile output regardless of the external 
setup of compiler cache or the platform is used. I'm not sure if compiler cache 
such as ccache could save `-fthin-link-bitcode` output and if there is a ccache 
equivalence on windows? Even if such tool exists, having linking phase caching 
managed by toolchain/linker and the compile phase by an external tool feels 
awkward and fragile. This patch mostly shares the implementation with linke 
phase caching.

Additionally, this also has a small benefit of trigging a little bit more 
caching because it is hashing IR instead of preprocessor output or even literal 
source file.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69327



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


[PATCH] D69327: [Clang][ThinLTO] Add a cache for compile phase output.

2019-10-23 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added a comment.

Thanks for the inputs @steven_wu @tejohnson. Totally agree with the points you 
brought up. One last thing I'm not quite sure is the caching of 
`-fthin-link-bitcode`. It is a `-cc1` option since it is a kind of 
implementation of ThinLTO, right? I'm a little hesitant to begin writing up 
patches to teach build system/caching tool (I could think of at least three for 
our workload) to recognize this option because of that. If there are any 
changes to the option, the same thing needs to be done again. Do you have any 
thoughts on that? Is the option in use for your workload and do you think it is 
stable enough to have build systems caching for it? (Another option is to 
produce `-fthin-link-bitcode` output post compile time which I assume having 
total build time impact to some degree).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69327



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


[PATCH] D69327: [Clang][ThinLTO] Add a cache for compile phase output.

2019-10-24 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added a comment.

In D69327#1719419 , @steven_wu wrote:

> In D69327#1719411 , @ychen wrote:
>
> > Thanks for the inputs @steven_wu @tejohnson. Totally agree with the points 
> > you brought up. One last thing I'm not quite sure is the caching of 
> > `-fthin-link-bitcode`. It is a `-cc1` option since it is a kind of 
> > implementation of ThinLTO, right? I'm a little hesitant to begin writing up 
> > patches to teach build system/caching tool (I could think of at least three 
> > for our workload) to recognize this option because of that. If there are 
> > any changes to the option, the same thing needs to be done again. Do you 
> > have any thoughts on that? Is the option in use for your workload and do 
> > you think it is stable enough to have build systems caching for it? 
> > (Another option is to produce `-fthin-link-bitcode` output post compile 
> > time which I assume having total build time impact to some degree).
>
>
> `-fthin-link-bitcode` option is used to run distributed thin link. The format 
> is not stable but it is deterministic for a fixed compiler version. You 
> should be able to cache the thin-link-bitcode and expected it to be used only 
> by the same compiler version.
>
> For any build system that implements caching, it must take compiler version 
> into consideration because different compiler will produce different output. 
> I don't think the rule to cache thin-link-bitcode is any different from any 
> other output during the build.


I tried ccache, it does not cache `-fthin-link-bitcode` output.

From this link, it seems ccache only cares about "-o" output. 
https://github.com/ccache/ccache/blob/ac9911b47b8a3777d20a3c481f90f877e8f9a81d/src/ccache.cpp#L2616


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69327



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


[PATCH] D69327: [Clang][ThinLTO] Add a cache for compile phase output.

2019-10-24 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added a comment.

Sorry for the confusion @steven_wu. By `stable` I mean the probability that the 
`-fthin-link-bitcode` option is replaced with some other thinlink mechanism 
under the distributed build environment. Since at least for ccache, the 
compilation output caching depends on the semantics of options ("-o" is assumed 
to be compilation output). For the case of  `-fthin-link-bitcode`,  both 
`-Xclang -fthin-link-bitcode` and `-o` are the output. I'm not familiar with 
compiler cache tools, but having the caching depends on a cc1 option feels not 
right since it is not an option of any other compilers, so most caching tools 
don't recognize it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69327



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


[PATCH] D69327: [Clang][ThinLTO] Add a cache for compile phase output.

2019-10-24 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added a comment.

Thank you @steven_wu @tejohnson. I created D69406 
 to promote the flag to the driver.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69327



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


[PATCH] D69406: [clang][ThinLTO] Promote cc1 -fthin_link_bitcode to driver -fthinlto_link_bitcode

2019-10-24 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen created this revision.
ychen added reviewers: tejohnson, steven_wu.
Herald added subscribers: cfe-commits, dexonsmith, inglorion, mehdi_amini.
Herald added a project: clang.

A necessary step to let build system caching work for its output.
I renamed it to match existing driver options for ThinLTO. Let me know if you
prefer keeping the name.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D69406

Files:
  clang/include/clang/Driver/CC1Options.td
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/thin_link_bitcode.c


Index: clang/test/CodeGen/thin_link_bitcode.c
===
--- clang/test/CodeGen/thin_link_bitcode.c
+++ clang/test/CodeGen/thin_link_bitcode.c
@@ -1,14 +1,18 @@
 // REQUIRES: x86-registered-target
 //
-// RUN: %clang_cc1 -o %t -flto=thin -fthin-link-bitcode=%t.nodebug -triple 
x86_64-unknown-linux-gnu -emit-llvm-bc -debug-info-kind=limited %s
+// RUN: %clang -flto=thin -fthinlto-link-bitcode=%t.bc -target 
x86_64-unknown-linux-gnu -### %s 2>&1 | FileCheck %s --check-prefix=LINKBC
+//
+// RUN: %clang_cc1 -o %t -flto=thin -fthinlto-link-bitcode=%t.nodebug -triple 
x86_64-unknown-linux-gnu -emit-llvm-bc -debug-info-kind=limited %s
 // RUN: llvm-bcanalyzer -dump %t | FileCheck %s
 // RUN: llvm-bcanalyzer -dump %t.nodebug | FileCheck %s --check-prefix=NO_DEBUG
-// RUN: %clang_cc1 -o %t.newpm -flto=thin -fexperimental-new-pass-manager 
-fthin-link-bitcode=%t.newpm.nodebug -triple x86_64-unknown-linux-gnu 
-emit-llvm-bc -debug-info-kind=limited  %s
+// RUN: %clang_cc1 -o %t.newpm -flto=thin -fexperimental-new-pass-manager 
-fthinlto-link-bitcode=%t.newpm.nodebug -triple x86_64-unknown-linux-gnu 
-emit-llvm-bc -debug-info-kind=limited  %s
 // RUN: llvm-bcanalyzer -dump %t.newpm | FileCheck %s
 // RUN: llvm-bcanalyzer -dump %t.newpm.nodebug | FileCheck %s 
--check-prefix=NO_DEBUG
 int main (void) {
   return 0;
 }
 
+// LINKBC: -fthinlto-link-bitcode=
+
 // CHECK: COMPILE_UNIT
 // NO_DEBUG-NOT: COMPILE_UNIT
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -989,7 +989,7 @@
 .Case("obj", FrontendOpts.OutputFile)
 .Default(llvm::sys::path::filename(FrontendOpts.OutputFile).str());
 
-  Opts.ThinLinkBitcodeFile = Args.getLastArgValue(OPT_fthin_link_bitcode_EQ);
+  Opts.ThinLinkBitcodeFile = 
Args.getLastArgValue(OPT_fthinlto_link_bitcode_EQ);
 
   Opts.MSVolatile = Args.hasArg(OPT_fms_volatile);
 
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -3647,6 +3647,9 @@
 Args.AddLastArg(CmdArgs, options::OPT_fthinlto_index_EQ);
   }
 
+  if (Args.getLastArg(options::OPT_fthinlto_link_bitcode_EQ))
+Args.AddLastArg(CmdArgs, options::OPT_fthinlto_link_bitcode_EQ);
+
   if (Args.getLastArg(options::OPT_save_temps_EQ))
 Args.AddLastArg(CmdArgs, options::OPT_save_temps_EQ);
 
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -1309,6 +1309,9 @@
 def fthinlto_index_EQ : Joined<["-"], "fthinlto-index=">,
   Flags<[CoreOption, CC1Option]>, Group,
   HelpText<"Perform ThinLTO importing using provided function summary index">;
+def fthinlto_link_bitcode_EQ : Joined<["-"], "fthinlto-link-bitcode=">,
+  Flags<[CoreOption, CC1Option]>, Group,
+  HelpText<"Write minimized bitcode to  for the ThinLTO thin link only">;
 def fmacro_backtrace_limit_EQ : Joined<["-"], "fmacro-backtrace-limit=">,
 Group, Flags<[DriverOption, 
CoreOption]>;
 def fmerge_all_constants : Flag<["-"], "fmerge-all-constants">, Group,
Index: clang/include/clang/Driver/CC1Options.td
===
--- clang/include/clang/Driver/CC1Options.td
+++ clang/include/clang/Driver/CC1Options.td
@@ -387,8 +387,6 @@
 def flto_unit: Flag<["-"], "flto-unit">,
 HelpText<"Emit IR to support LTO unit features (CFI, whole program vtable 
opt)">;
 def fno_lto_unit: Flag<["-"], "fno-lto-unit">;
-def fthin_link_bitcode_EQ : Joined<["-"], "fthin-link-bitcode=">,
-HelpText<"Write minimized bitcode to  for the ThinLTO thin link 
only">;
 def femit_debug_entry_values : Flag<["-"], "femit-debug-entry-values">,
 HelpText<"Enables debug info about call site parameter's entry values">;
 def fdebug_pass_manager : Flag<["-"], "fdebug-pass-manager">,


Index: clang/test/CodeGen/thin_link_bitcode.c
===
--- clang/test/CodeGen/thin_link_bitcode.c
+++ clang/test/CodeGen/thi

[PATCH] D69406: [clang][ThinLTO] Promote cc1 -fthin_link_bitcode to driver -fthinlto_link_bitcode

2019-10-24 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen updated this revision to Diff 226347.
ychen added a comment.

Address reviewer's comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69406

Files:
  clang/include/clang/Driver/CC1Options.td
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/CodeGen/thin_link_bitcode.c


Index: clang/test/CodeGen/thin_link_bitcode.c
===
--- clang/test/CodeGen/thin_link_bitcode.c
+++ clang/test/CodeGen/thin_link_bitcode.c
@@ -1,5 +1,7 @@
 // REQUIRES: x86-registered-target
 //
+// RUN: %clang -flto=thin -fthin-link-bitcode=%t.bc -target 
x86_64-unknown-linux-gnu -### %s 2>&1 | FileCheck %s --check-prefix=LINKBC
+//
 // RUN: %clang_cc1 -o %t -flto=thin -fthin-link-bitcode=%t.nodebug -triple 
x86_64-unknown-linux-gnu -emit-llvm-bc -debug-info-kind=limited %s
 // RUN: llvm-bcanalyzer -dump %t | FileCheck %s
 // RUN: llvm-bcanalyzer -dump %t.nodebug | FileCheck %s --check-prefix=NO_DEBUG
@@ -10,5 +12,7 @@
   return 0;
 }
 
+// LINKBC: -fthin-link-bitcode=
+
 // CHECK: COMPILE_UNIT
 // NO_DEBUG-NOT: COMPILE_UNIT
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -3647,6 +3647,9 @@
 Args.AddLastArg(CmdArgs, options::OPT_fthinlto_index_EQ);
   }
 
+  if (Args.getLastArg(options::OPT_fthin_link_bitcode_EQ))
+Args.AddLastArg(CmdArgs, options::OPT_fthin_link_bitcode_EQ);
+
   if (Args.getLastArg(options::OPT_save_temps_EQ))
 Args.AddLastArg(CmdArgs, options::OPT_save_temps_EQ);
 
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -1309,6 +1309,9 @@
 def fthinlto_index_EQ : Joined<["-"], "fthinlto-index=">,
   Flags<[CoreOption, CC1Option]>, Group,
   HelpText<"Perform ThinLTO importing using provided function summary index">;
+def fthin_link_bitcode_EQ : Joined<["-"], "fthin-link-bitcode=">,
+  Flags<[CoreOption, CC1Option]>, Group,
+  HelpText<"Write minimized bitcode to  for the ThinLTO thin link only">;
 def fmacro_backtrace_limit_EQ : Joined<["-"], "fmacro-backtrace-limit=">,
 Group, Flags<[DriverOption, 
CoreOption]>;
 def fmerge_all_constants : Flag<["-"], "fmerge-all-constants">, Group,
Index: clang/include/clang/Driver/CC1Options.td
===
--- clang/include/clang/Driver/CC1Options.td
+++ clang/include/clang/Driver/CC1Options.td
@@ -387,8 +387,6 @@
 def flto_unit: Flag<["-"], "flto-unit">,
 HelpText<"Emit IR to support LTO unit features (CFI, whole program vtable 
opt)">;
 def fno_lto_unit: Flag<["-"], "fno-lto-unit">;
-def fthin_link_bitcode_EQ : Joined<["-"], "fthin-link-bitcode=">,
-HelpText<"Write minimized bitcode to  for the ThinLTO thin link 
only">;
 def femit_debug_entry_values : Flag<["-"], "femit-debug-entry-values">,
 HelpText<"Enables debug info about call site parameter's entry values">;
 def fdebug_pass_manager : Flag<["-"], "fdebug-pass-manager">,


Index: clang/test/CodeGen/thin_link_bitcode.c
===
--- clang/test/CodeGen/thin_link_bitcode.c
+++ clang/test/CodeGen/thin_link_bitcode.c
@@ -1,5 +1,7 @@
 // REQUIRES: x86-registered-target
 //
+// RUN: %clang -flto=thin -fthin-link-bitcode=%t.bc -target x86_64-unknown-linux-gnu -### %s 2>&1 | FileCheck %s --check-prefix=LINKBC
+//
 // RUN: %clang_cc1 -o %t -flto=thin -fthin-link-bitcode=%t.nodebug -triple x86_64-unknown-linux-gnu -emit-llvm-bc -debug-info-kind=limited %s
 // RUN: llvm-bcanalyzer -dump %t | FileCheck %s
 // RUN: llvm-bcanalyzer -dump %t.nodebug | FileCheck %s --check-prefix=NO_DEBUG
@@ -10,5 +12,7 @@
   return 0;
 }
 
+// LINKBC: -fthin-link-bitcode=
+
 // CHECK: COMPILE_UNIT
 // NO_DEBUG-NOT: COMPILE_UNIT
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -3647,6 +3647,9 @@
 Args.AddLastArg(CmdArgs, options::OPT_fthinlto_index_EQ);
   }
 
+  if (Args.getLastArg(options::OPT_fthin_link_bitcode_EQ))
+Args.AddLastArg(CmdArgs, options::OPT_fthin_link_bitcode_EQ);
+
   if (Args.getLastArg(options::OPT_save_temps_EQ))
 Args.AddLastArg(CmdArgs, options::OPT_save_temps_EQ);
 
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -1309,6 +1309,9 @@
 def fthinlto_index_EQ : Joined<["-"], "fthinlto-index=">,
   Flags<[CoreOption, CC1Option]>, Group,
   HelpText<"Perform ThinLTO importing usin

[PATCH] D69406: [clang][ThinLTO] Promote cc1 -fthin_link_bitcode to driver -fthinlto_link_bitcode

2019-10-24 Thread Yuanfang Chen via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGef7a154d17f2: [clang][ThinLTO] Promote cc1 
-fthin_link_bitcode to driver… (authored by ychen).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69406

Files:
  clang/include/clang/Driver/CC1Options.td
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/CodeGen/thin_link_bitcode.c


Index: clang/test/CodeGen/thin_link_bitcode.c
===
--- clang/test/CodeGen/thin_link_bitcode.c
+++ clang/test/CodeGen/thin_link_bitcode.c
@@ -1,5 +1,7 @@
 // REQUIRES: x86-registered-target
 //
+// RUN: %clang -flto=thin -fthin-link-bitcode=%t.bc -target 
x86_64-unknown-linux-gnu -### %s 2>&1 | FileCheck %s --check-prefix=LINKBC
+//
 // RUN: %clang_cc1 -o %t -flto=thin -fthin-link-bitcode=%t.nodebug -triple 
x86_64-unknown-linux-gnu -emit-llvm-bc -debug-info-kind=limited %s
 // RUN: llvm-bcanalyzer -dump %t | FileCheck %s
 // RUN: llvm-bcanalyzer -dump %t.nodebug | FileCheck %s --check-prefix=NO_DEBUG
@@ -10,5 +12,7 @@
   return 0;
 }
 
+// LINKBC: -fthin-link-bitcode=
+
 // CHECK: COMPILE_UNIT
 // NO_DEBUG-NOT: COMPILE_UNIT
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -3641,6 +3641,9 @@
 Args.AddLastArg(CmdArgs, options::OPT_fthinlto_index_EQ);
   }
 
+  if (Args.getLastArg(options::OPT_fthin_link_bitcode_EQ))
+Args.AddLastArg(CmdArgs, options::OPT_fthin_link_bitcode_EQ);
+
   if (Args.getLastArg(options::OPT_save_temps_EQ))
 Args.AddLastArg(CmdArgs, options::OPT_save_temps_EQ);
 
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -1312,6 +1312,9 @@
 def fthinlto_index_EQ : Joined<["-"], "fthinlto-index=">,
   Flags<[CoreOption, CC1Option]>, Group,
   HelpText<"Perform ThinLTO importing using provided function summary index">;
+def fthin_link_bitcode_EQ : Joined<["-"], "fthin-link-bitcode=">,
+  Flags<[CoreOption, CC1Option]>, Group,
+  HelpText<"Write minimized bitcode to  for the ThinLTO thin link only">;
 def fmacro_backtrace_limit_EQ : Joined<["-"], "fmacro-backtrace-limit=">,
 Group, Flags<[DriverOption, 
CoreOption]>;
 def fmerge_all_constants : Flag<["-"], "fmerge-all-constants">, Group,
Index: clang/include/clang/Driver/CC1Options.td
===
--- clang/include/clang/Driver/CC1Options.td
+++ clang/include/clang/Driver/CC1Options.td
@@ -387,8 +387,6 @@
 def flto_unit: Flag<["-"], "flto-unit">,
 HelpText<"Emit IR to support LTO unit features (CFI, whole program vtable 
opt)">;
 def fno_lto_unit: Flag<["-"], "fno-lto-unit">;
-def fthin_link_bitcode_EQ : Joined<["-"], "fthin-link-bitcode=">,
-HelpText<"Write minimized bitcode to  for the ThinLTO thin link 
only">;
 def femit_debug_entry_values : Flag<["-"], "femit-debug-entry-values">,
 HelpText<"Enables debug info about call site parameter's entry values">;
 def fdebug_pass_manager : Flag<["-"], "fdebug-pass-manager">,


Index: clang/test/CodeGen/thin_link_bitcode.c
===
--- clang/test/CodeGen/thin_link_bitcode.c
+++ clang/test/CodeGen/thin_link_bitcode.c
@@ -1,5 +1,7 @@
 // REQUIRES: x86-registered-target
 //
+// RUN: %clang -flto=thin -fthin-link-bitcode=%t.bc -target x86_64-unknown-linux-gnu -### %s 2>&1 | FileCheck %s --check-prefix=LINKBC
+//
 // RUN: %clang_cc1 -o %t -flto=thin -fthin-link-bitcode=%t.nodebug -triple x86_64-unknown-linux-gnu -emit-llvm-bc -debug-info-kind=limited %s
 // RUN: llvm-bcanalyzer -dump %t | FileCheck %s
 // RUN: llvm-bcanalyzer -dump %t.nodebug | FileCheck %s --check-prefix=NO_DEBUG
@@ -10,5 +12,7 @@
   return 0;
 }
 
+// LINKBC: -fthin-link-bitcode=
+
 // CHECK: COMPILE_UNIT
 // NO_DEBUG-NOT: COMPILE_UNIT
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -3641,6 +3641,9 @@
 Args.AddLastArg(CmdArgs, options::OPT_fthinlto_index_EQ);
   }
 
+  if (Args.getLastArg(options::OPT_fthin_link_bitcode_EQ))
+Args.AddLastArg(CmdArgs, options::OPT_fthin_link_bitcode_EQ);
+
   if (Args.getLastArg(options::OPT_save_temps_EQ))
 Args.AddLastArg(CmdArgs, options::OPT_save_temps_EQ);
 
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -1312,6 +1312,9 @@
 def fthinlto_index_EQ : Joined<["-"], "fthinlto-inde

[PATCH] D80356: `cc1as -fdebug-compilation-dir` needs -integrated-as

2020-05-20 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen created this revision.
ychen added a reviewer: thakis.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D80356

Files:
  clang/test/Driver/clang_f_opts.c


Index: clang/test/Driver/clang_f_opts.c
===
--- clang/test/Driver/clang_f_opts.c
+++ clang/test/Driver/clang_f_opts.c
@@ -510,8 +510,8 @@
 
 // RUN: %clang -### -S -fdebug-compilation-dir . %s 2>&1 | FileCheck 
-check-prefix=CHECK-DEBUG-COMPILATION-DIR %s
 // RUN: %clang -### -S -fdebug-compilation-dir=. %s 2>&1 | FileCheck 
-check-prefix=CHECK-DEBUG-COMPILATION-DIR %s
-// RUN: %clang -### -fdebug-compilation-dir . -x assembler %s 2>&1 | FileCheck 
-check-prefix=CHECK-DEBUG-COMPILATION-DIR %s
-// RUN: %clang -### -fdebug-compilation-dir=. -x assembler %s 2>&1 | FileCheck 
-check-prefix=CHECK-DEBUG-COMPILATION-DIR %s
+// RUN: %clang -### -fdebug-compilation-dir . -integrated-as -x assembler %s 
2>&1 | FileCheck -check-prefix=CHECK-DEBUG-COMPILATION-DIR %s
+// RUN: %clang -### -fdebug-compilation-dir=. -integrated-as -x assembler %s 
2>&1 | FileCheck -check-prefix=CHECK-DEBUG-COMPILATION-DIR %s
 // CHECK-DEBUG-COMPILATION-DIR: "-fdebug-compilation-dir" "."
 
 // RUN: %clang -### -S -fdiscard-value-names %s 2>&1 | FileCheck 
-check-prefix=CHECK-DISCARD-NAMES %s


Index: clang/test/Driver/clang_f_opts.c
===
--- clang/test/Driver/clang_f_opts.c
+++ clang/test/Driver/clang_f_opts.c
@@ -510,8 +510,8 @@
 
 // RUN: %clang -### -S -fdebug-compilation-dir . %s 2>&1 | FileCheck -check-prefix=CHECK-DEBUG-COMPILATION-DIR %s
 // RUN: %clang -### -S -fdebug-compilation-dir=. %s 2>&1 | FileCheck -check-prefix=CHECK-DEBUG-COMPILATION-DIR %s
-// RUN: %clang -### -fdebug-compilation-dir . -x assembler %s 2>&1 | FileCheck -check-prefix=CHECK-DEBUG-COMPILATION-DIR %s
-// RUN: %clang -### -fdebug-compilation-dir=. -x assembler %s 2>&1 | FileCheck -check-prefix=CHECK-DEBUG-COMPILATION-DIR %s
+// RUN: %clang -### -fdebug-compilation-dir . -integrated-as -x assembler %s 2>&1 | FileCheck -check-prefix=CHECK-DEBUG-COMPILATION-DIR %s
+// RUN: %clang -### -fdebug-compilation-dir=. -integrated-as -x assembler %s 2>&1 | FileCheck -check-prefix=CHECK-DEBUG-COMPILATION-DIR %s
 // CHECK-DEBUG-COMPILATION-DIR: "-fdebug-compilation-dir" "."
 
 // RUN: %clang -### -S -fdiscard-value-names %s 2>&1 | FileCheck -check-prefix=CHECK-DISCARD-NAMES %s
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D80454: [Clang] fix limiting -fintegrated-cc1 to only one TU

2020-05-22 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen planned changes to this revision.
ychen added a comment.

This may not be complete.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80454



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


[PATCH] D80454: [Clang] fix limiting -fintegrated-cc1 to only one TU

2020-05-22 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen created this revision.
ychen added a reviewer: aganea.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
ychen planned changes to this revision.
ychen added a comment.

This may not be complete.


For D74490 . For cases like where external 
assembler is used, counting the
job number is not exactly right.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D80454

Files:
  clang/lib/Driver/Driver.cpp


Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -3763,7 +3763,8 @@
   }
 
   // If we have more than one job, then disable integrated-cc1 for now.
-  if (C.getJobs().size() > 1)
+  if (std::count_if(C.getActions().begin(), C.getActions().end(),
+[](Action *A) { return isa(A); }) > 1)
 for (auto &J : C.getJobs())
   J.InProcess = false;
 


Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -3763,7 +3763,8 @@
   }
 
   // If we have more than one job, then disable integrated-cc1 for now.
-  if (C.getJobs().size() > 1)
+  if (std::count_if(C.getActions().begin(), C.getActions().end(),
+[](Action *A) { return isa(A); }) > 1)
 for (auto &J : C.getJobs())
   J.InProcess = false;
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D80454: [Clang][test] fix tests when using external assembler

2020-05-22 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen updated this revision to Diff 265791.
ychen added a comment.

- update


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80454

Files:
  clang/test/Driver/cc1-spawnprocess.c


Index: clang/test/Driver/cc1-spawnprocess.c
===
--- clang/test/Driver/cc1-spawnprocess.c
+++ clang/test/Driver/cc1-spawnprocess.c
@@ -1,18 +1,18 @@
-// RUN: %clang -fintegrated-cc1 -c -### %s 2>&1 | FileCheck %s 
--check-prefix=YES
+// RUN: %clang -fintegrated-cc1 -fintegrated-as -c -### %s 2>&1 | FileCheck %s 
--check-prefix=YES
 // RUN: %clang -fno-integrated-cc1 -c -### %s 2>&1 | FileCheck %s 
--check-prefix=NO
 
 // RUN: %clang -fintegrated-cc1 -fno-integrated-cc1 -c -### %s 2>&1 \
 // RUN: | FileCheck %s --check-prefix=NO
-// RUN: %clang -fno-integrated-cc1 -fintegrated-cc1 -c -### %s 2>&1 \
+// RUN: %clang -fno-integrated-cc1 -fintegrated-as -fintegrated-cc1 -c -### %s 
2>&1 \
 // RUN: | FileCheck %s --check-prefix=YES
 
-// RUN: %clang_cl -fintegrated-cc1 -c -### -- %s 2>&1 \
+// RUN: %clang_cl -fintegrated-cc1 -fintegrated-as -c -### -- %s 2>&1 \
 // RUN: | FileCheck %s --check-prefix=YES
 // RUN: %clang_cl -fno-integrated-cc1 -c -### -- %s 2>&1 \
 // RUN: | FileCheck %s --check-prefix=NO
 
 // RUN: env CCC_OVERRIDE_OPTIONS=+-fintegrated-cc1 \
-// RUN: %clang -fintegrated-cc1 -c -### %s 2>&1 \
+// RUN: %clang -fintegrated-cc1 -fintegrated-as -c -### %s 2>&1 \
 // RUN: | FileCheck %s --check-prefix=YES
 // RUN: env CCC_OVERRIDE_OPTIONS=+-fno-integrated-cc1 \
 // RUN: %clang -fintegrated-cc1 -c -### %s 2>&1 \
@@ -24,7 +24,7 @@
 // The following tests ensure that only one integrated-cc1 is executed.
 
 // Only one TU, one job, thus integrated-cc1 is enabled.
-// RUN: %clang -fintegrated-cc1 -c %s -### 2>&1 | FileCheck %s 
--check-prefix=YES
+// RUN: %clang -fintegrated-cc1 -fintegrated-as -c %s -### 2>&1 | FileCheck %s 
--check-prefix=YES
 
 // Only one TU, but we're linking, two jobs, thus integrated-cc1 is disabled.
 // RUN: %clang -fintegrated-cc1 %s -### 2>&1 | FileCheck %s --check-prefix=NO


Index: clang/test/Driver/cc1-spawnprocess.c
===
--- clang/test/Driver/cc1-spawnprocess.c
+++ clang/test/Driver/cc1-spawnprocess.c
@@ -1,18 +1,18 @@
-// RUN: %clang -fintegrated-cc1 -c -### %s 2>&1 | FileCheck %s --check-prefix=YES
+// RUN: %clang -fintegrated-cc1 -fintegrated-as -c -### %s 2>&1 | FileCheck %s --check-prefix=YES
 // RUN: %clang -fno-integrated-cc1 -c -### %s 2>&1 | FileCheck %s --check-prefix=NO
 
 // RUN: %clang -fintegrated-cc1 -fno-integrated-cc1 -c -### %s 2>&1 \
 // RUN: | FileCheck %s --check-prefix=NO
-// RUN: %clang -fno-integrated-cc1 -fintegrated-cc1 -c -### %s 2>&1 \
+// RUN: %clang -fno-integrated-cc1 -fintegrated-as -fintegrated-cc1 -c -### %s 2>&1 \
 // RUN: | FileCheck %s --check-prefix=YES
 
-// RUN: %clang_cl -fintegrated-cc1 -c -### -- %s 2>&1 \
+// RUN: %clang_cl -fintegrated-cc1 -fintegrated-as -c -### -- %s 2>&1 \
 // RUN: | FileCheck %s --check-prefix=YES
 // RUN: %clang_cl -fno-integrated-cc1 -c -### -- %s 2>&1 \
 // RUN: | FileCheck %s --check-prefix=NO
 
 // RUN: env CCC_OVERRIDE_OPTIONS=+-fintegrated-cc1 \
-// RUN: %clang -fintegrated-cc1 -c -### %s 2>&1 \
+// RUN: %clang -fintegrated-cc1 -fintegrated-as -c -### %s 2>&1 \
 // RUN: | FileCheck %s --check-prefix=YES
 // RUN: env CCC_OVERRIDE_OPTIONS=+-fno-integrated-cc1 \
 // RUN: %clang -fintegrated-cc1 -c -### %s 2>&1 \
@@ -24,7 +24,7 @@
 // The following tests ensure that only one integrated-cc1 is executed.
 
 // Only one TU, one job, thus integrated-cc1 is enabled.
-// RUN: %clang -fintegrated-cc1 -c %s -### 2>&1 | FileCheck %s --check-prefix=YES
+// RUN: %clang -fintegrated-cc1 -fintegrated-as -c %s -### 2>&1 | FileCheck %s --check-prefix=YES
 
 // Only one TU, but we're linking, two jobs, thus integrated-cc1 is disabled.
 // RUN: %clang -fintegrated-cc1 %s -### 2>&1 | FileCheck %s --check-prefix=NO
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D80454: [Clang][test] fix tests when using external assembler

2020-05-22 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added a comment.

In D80454#2051524 , @aganea wrote:

> Could you please attach a test to demonstrate the issue?


When a toolchain is not using integrated-as, the test would fail because using 
external assember would increase job counts. Most toolchains in tree use 
integrated-as, but we still support external assembler. So this is just making 
it explicit.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80454



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


[PATCH] D80454: [Clang][test] fix tests when using external assembler

2020-05-22 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen updated this revision to Diff 265792.
ychen added a comment.

- update


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80454

Files:
  clang/test/Driver/cc1-spawnprocess.c


Index: clang/test/Driver/cc1-spawnprocess.c
===
--- clang/test/Driver/cc1-spawnprocess.c
+++ clang/test/Driver/cc1-spawnprocess.c
@@ -1,18 +1,18 @@
-// RUN: %clang -fintegrated-cc1 -c -### %s 2>&1 | FileCheck %s 
--check-prefix=YES
+// RUN: %clang -fintegrated-cc1 -fintegrated-as -c -### %s 2>&1 | FileCheck %s 
--check-prefix=YES
 // RUN: %clang -fno-integrated-cc1 -c -### %s 2>&1 | FileCheck %s 
--check-prefix=NO
 
 // RUN: %clang -fintegrated-cc1 -fno-integrated-cc1 -c -### %s 2>&1 \
 // RUN: | FileCheck %s --check-prefix=NO
-// RUN: %clang -fno-integrated-cc1 -fintegrated-cc1 -c -### %s 2>&1 \
+// RUN: %clang -fno-integrated-cc1 -fintegrated-cc1 -fintegrated-as -c -### %s 
2>&1 \
 // RUN: | FileCheck %s --check-prefix=YES
 
-// RUN: %clang_cl -fintegrated-cc1 -c -### -- %s 2>&1 \
+// RUN: %clang_cl -fintegrated-cc1 -fintegrated-as -c -### -- %s 2>&1 \
 // RUN: | FileCheck %s --check-prefix=YES
 // RUN: %clang_cl -fno-integrated-cc1 -c -### -- %s 2>&1 \
 // RUN: | FileCheck %s --check-prefix=NO
 
 // RUN: env CCC_OVERRIDE_OPTIONS=+-fintegrated-cc1 \
-// RUN: %clang -fintegrated-cc1 -c -### %s 2>&1 \
+// RUN: %clang -fintegrated-cc1 -fintegrated-as -c -### %s 2>&1 \
 // RUN: | FileCheck %s --check-prefix=YES
 // RUN: env CCC_OVERRIDE_OPTIONS=+-fno-integrated-cc1 \
 // RUN: %clang -fintegrated-cc1 -c -### %s 2>&1 \
@@ -24,7 +24,7 @@
 // The following tests ensure that only one integrated-cc1 is executed.
 
 // Only one TU, one job, thus integrated-cc1 is enabled.
-// RUN: %clang -fintegrated-cc1 -c %s -### 2>&1 | FileCheck %s 
--check-prefix=YES
+// RUN: %clang -fintegrated-cc1 -fintegrated-as -c %s -### 2>&1 | FileCheck %s 
--check-prefix=YES
 
 // Only one TU, but we're linking, two jobs, thus integrated-cc1 is disabled.
 // RUN: %clang -fintegrated-cc1 %s -### 2>&1 | FileCheck %s --check-prefix=NO


Index: clang/test/Driver/cc1-spawnprocess.c
===
--- clang/test/Driver/cc1-spawnprocess.c
+++ clang/test/Driver/cc1-spawnprocess.c
@@ -1,18 +1,18 @@
-// RUN: %clang -fintegrated-cc1 -c -### %s 2>&1 | FileCheck %s --check-prefix=YES
+// RUN: %clang -fintegrated-cc1 -fintegrated-as -c -### %s 2>&1 | FileCheck %s --check-prefix=YES
 // RUN: %clang -fno-integrated-cc1 -c -### %s 2>&1 | FileCheck %s --check-prefix=NO
 
 // RUN: %clang -fintegrated-cc1 -fno-integrated-cc1 -c -### %s 2>&1 \
 // RUN: | FileCheck %s --check-prefix=NO
-// RUN: %clang -fno-integrated-cc1 -fintegrated-cc1 -c -### %s 2>&1 \
+// RUN: %clang -fno-integrated-cc1 -fintegrated-cc1 -fintegrated-as -c -### %s 2>&1 \
 // RUN: | FileCheck %s --check-prefix=YES
 
-// RUN: %clang_cl -fintegrated-cc1 -c -### -- %s 2>&1 \
+// RUN: %clang_cl -fintegrated-cc1 -fintegrated-as -c -### -- %s 2>&1 \
 // RUN: | FileCheck %s --check-prefix=YES
 // RUN: %clang_cl -fno-integrated-cc1 -c -### -- %s 2>&1 \
 // RUN: | FileCheck %s --check-prefix=NO
 
 // RUN: env CCC_OVERRIDE_OPTIONS=+-fintegrated-cc1 \
-// RUN: %clang -fintegrated-cc1 -c -### %s 2>&1 \
+// RUN: %clang -fintegrated-cc1 -fintegrated-as -c -### %s 2>&1 \
 // RUN: | FileCheck %s --check-prefix=YES
 // RUN: env CCC_OVERRIDE_OPTIONS=+-fno-integrated-cc1 \
 // RUN: %clang -fintegrated-cc1 -c -### %s 2>&1 \
@@ -24,7 +24,7 @@
 // The following tests ensure that only one integrated-cc1 is executed.
 
 // Only one TU, one job, thus integrated-cc1 is enabled.
-// RUN: %clang -fintegrated-cc1 -c %s -### 2>&1 | FileCheck %s --check-prefix=YES
+// RUN: %clang -fintegrated-cc1 -fintegrated-as -c %s -### 2>&1 | FileCheck %s --check-prefix=YES
 
 // Only one TU, but we're linking, two jobs, thus integrated-cc1 is disabled.
 // RUN: %clang -fintegrated-cc1 %s -### 2>&1 | FileCheck %s --check-prefix=NO
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D80454: [Clang][test] fix tests when using external assembler

2020-05-22 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added a comment.

In D80454#2051668 , @MaskRay wrote:

> In D80454#2051527 , @ychen wrote:
>
> > In D80454#2051524 , @aganea wrote:
> >
> > > Could you please attach a test to demonstrate the issue?
> >
> >
> > When a toolchain is not using integrated-as, the test would fail because 
> > using external assember would increase job counts. Most toolchains in tree 
> > use integrated-as, but we still support external assembler. So this is just 
> > making it explicit.
>
>
> This point deserves a comment in the test.


Will do.

> @ychen What is your LLVM_DEFAULT_TARGET_TRIPLE?

All I could say is that it is not a in-tree toolchain and it uses external 
assembler.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80454



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


[PATCH] D80454: [Clang][test] fix tests when using external assembler

2020-05-22 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added a comment.

In D80454#2051637 , @aganea wrote:

> LGTM.
>
> Are you planning on adding another patch for the change that you've sent 
> initially? Ideally, I'd like to relax a bit that constraint in `Driver.cpp`, 
> as in D74447 , but that requires first to 
> disable `-disable-free` to ensure we exit cleanly, at least when runing the 
> tests (a bit like the `LLD_IN_TEST` env var).


Oh, that's not my plan. I think the motivation of D74447 
 makes great sense.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80454



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


[PATCH] D74447: [Clang] After integrated-cc1, ignore -disable-free when there are more than one job in the queue

2020-05-22 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added a comment.

In D74447#1872211 , @thakis wrote:

> I'd think that everyone debugging clang always passes a single TU to it, so 
> I'm not sure debuggability does much here :)
>
> The `-disable-free` code has never been used in normal compilations, so we 
> didn't have to worry about this path. This patch here brings us to 3 modes 
> (in-process cc1 with and without disable-free, out-of-process cc1). My 
> suggestion keeps us to two modes (in-process cc1, out-of-process cc1).


What is the downside of 3 modes except maintaining one more mode in the future?


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

https://reviews.llvm.org/D74447



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


[PATCH] D80454: [Clang][test] fix tests when using external assembler

2020-05-25 Thread Yuanfang Chen via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG3a2df3bad07f: [Clang][test] fix tests when using external 
assembler. (authored by ychen).

Changed prior to commit:
  https://reviews.llvm.org/D80454?vs=265792&id=266088#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80454

Files:
  clang/test/Driver/cc1-spawnprocess.c


Index: clang/test/Driver/cc1-spawnprocess.c
===
--- clang/test/Driver/cc1-spawnprocess.c
+++ clang/test/Driver/cc1-spawnprocess.c
@@ -1,18 +1,23 @@
-// RUN: %clang -fintegrated-cc1 -c -### %s 2>&1 | FileCheck %s 
--check-prefix=YES
+// If a toolchain uses an external assembler, the test would fail because using
+// an external assember would increase job counts. Most toolchains in tree
+// use integrated assembler, but we still support external assembler.
+// So -fintegrated-as is specified explicitly when applicable.
+
+// RUN: %clang -fintegrated-cc1 -fintegrated-as -c -### %s 2>&1 | FileCheck %s 
--check-prefix=YES
 // RUN: %clang -fno-integrated-cc1 -c -### %s 2>&1 | FileCheck %s 
--check-prefix=NO
 
 // RUN: %clang -fintegrated-cc1 -fno-integrated-cc1 -c -### %s 2>&1 \
 // RUN: | FileCheck %s --check-prefix=NO
-// RUN: %clang -fno-integrated-cc1 -fintegrated-cc1 -c -### %s 2>&1 \
+// RUN: %clang -fno-integrated-cc1 -fintegrated-cc1 -fintegrated-as -c -### %s 
2>&1 \
 // RUN: | FileCheck %s --check-prefix=YES
 
-// RUN: %clang_cl -fintegrated-cc1 -c -### -- %s 2>&1 \
+// RUN: %clang_cl -fintegrated-cc1 -fintegrated-as -c -### -- %s 2>&1 \
 // RUN: | FileCheck %s --check-prefix=YES
 // RUN: %clang_cl -fno-integrated-cc1 -c -### -- %s 2>&1 \
 // RUN: | FileCheck %s --check-prefix=NO
 
 // RUN: env CCC_OVERRIDE_OPTIONS=+-fintegrated-cc1 \
-// RUN: %clang -fintegrated-cc1 -c -### %s 2>&1 \
+// RUN: %clang -fintegrated-cc1 -fintegrated-as -c -### %s 2>&1 \
 // RUN: | FileCheck %s --check-prefix=YES
 // RUN: env CCC_OVERRIDE_OPTIONS=+-fno-integrated-cc1 \
 // RUN: %clang -fintegrated-cc1 -c -### %s 2>&1 \
@@ -24,7 +29,7 @@
 // The following tests ensure that only one integrated-cc1 is executed.
 
 // Only one TU, one job, thus integrated-cc1 is enabled.
-// RUN: %clang -fintegrated-cc1 -c %s -### 2>&1 | FileCheck %s 
--check-prefix=YES
+// RUN: %clang -fintegrated-cc1 -fintegrated-as -c %s -### 2>&1 | FileCheck %s 
--check-prefix=YES
 
 // Only one TU, but we're linking, two jobs, thus integrated-cc1 is disabled.
 // RUN: %clang -fintegrated-cc1 %s -### 2>&1 | FileCheck %s --check-prefix=NO


Index: clang/test/Driver/cc1-spawnprocess.c
===
--- clang/test/Driver/cc1-spawnprocess.c
+++ clang/test/Driver/cc1-spawnprocess.c
@@ -1,18 +1,23 @@
-// RUN: %clang -fintegrated-cc1 -c -### %s 2>&1 | FileCheck %s --check-prefix=YES
+// If a toolchain uses an external assembler, the test would fail because using
+// an external assember would increase job counts. Most toolchains in tree
+// use integrated assembler, but we still support external assembler.
+// So -fintegrated-as is specified explicitly when applicable.
+
+// RUN: %clang -fintegrated-cc1 -fintegrated-as -c -### %s 2>&1 | FileCheck %s --check-prefix=YES
 // RUN: %clang -fno-integrated-cc1 -c -### %s 2>&1 | FileCheck %s --check-prefix=NO
 
 // RUN: %clang -fintegrated-cc1 -fno-integrated-cc1 -c -### %s 2>&1 \
 // RUN: | FileCheck %s --check-prefix=NO
-// RUN: %clang -fno-integrated-cc1 -fintegrated-cc1 -c -### %s 2>&1 \
+// RUN: %clang -fno-integrated-cc1 -fintegrated-cc1 -fintegrated-as -c -### %s 2>&1 \
 // RUN: | FileCheck %s --check-prefix=YES
 
-// RUN: %clang_cl -fintegrated-cc1 -c -### -- %s 2>&1 \
+// RUN: %clang_cl -fintegrated-cc1 -fintegrated-as -c -### -- %s 2>&1 \
 // RUN: | FileCheck %s --check-prefix=YES
 // RUN: %clang_cl -fno-integrated-cc1 -c -### -- %s 2>&1 \
 // RUN: | FileCheck %s --check-prefix=NO
 
 // RUN: env CCC_OVERRIDE_OPTIONS=+-fintegrated-cc1 \
-// RUN: %clang -fintegrated-cc1 -c -### %s 2>&1 \
+// RUN: %clang -fintegrated-cc1 -fintegrated-as -c -### %s 2>&1 \
 // RUN: | FileCheck %s --check-prefix=YES
 // RUN: env CCC_OVERRIDE_OPTIONS=+-fno-integrated-cc1 \
 // RUN: %clang -fintegrated-cc1 -c -### %s 2>&1 \
@@ -24,7 +29,7 @@
 // The following tests ensure that only one integrated-cc1 is executed.
 
 // Only one TU, one job, thus integrated-cc1 is enabled.
-// RUN: %clang -fintegrated-cc1 -c %s -### 2>&1 | FileCheck %s --check-prefix=YES
+// RUN: %clang -fintegrated-cc1 -fintegrated-as -c %s -### 2>&1 | FileCheck %s --check-prefix=YES
 
 // Only one TU, but we're linking, two jobs, thus integrated-cc1 is disabled.
 // RUN: %clang -fintegrated-cc1 %s -### 2>&1 | FileCheck %s --check-prefix=NO
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http

[PATCH] D80944: Add begin source location for the attributed statement created from PragmaLoopHint decorated loop

2020-06-01 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen created this revision.
ychen added reviewers: ABataev, jdenny, lebedev.ri, aaron.ballman.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Right now it is a '' for cases like this.
CounterCoverageMappingBuilder relies on the information to decide the
region for a attributed loop.

Fix PR40971


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D80944

Files:
  clang/lib/Parse/ParsePragma.cpp
  clang/lib/Parse/ParseStmt.cpp
  clang/test/AST/sourceranges.cpp


Index: clang/test/AST/sourceranges.cpp
===
--- clang/test/AST/sourceranges.cpp
+++ clang/test/AST/sourceranges.cpp
@@ -108,6 +108,28 @@
   }
 }
 
+// CHECK: NamespaceDecl {{.*}} attributed_stmt
+namespace attributed_stmt {
+  #define DO_PRAGMA(x) _Pragma (#x)
+
+  void f() {
+// CHECK: AttributedStmt {{.*}} 
+// CHECK: LoopHintAttr {{.*}} 
+#pragma unroll(2)
+// CHECK: LoopHintAttr {{.*}} 
+#pragma clang loop vectorize(enable)
+for (int i = 0; i < 10; ++i);
+
+// CHECK: AttributedStmt {{.*}} 
+_Pragma("unroll(2)")
+for (int j = 0; j < 10; ++j);
+
+// CHECK: AttributedStmt {{.*}} 
+DO_PRAGMA (unroll(2))
+for (int k = 0; k < 10; ++k);
+  }
+}
+
 #if __cplusplus >= 201703L
 // CHECK-1Z: FunctionDecl {{.*}} construct_with_init_list
 std::map construct_with_init_list() {
Index: clang/lib/Parse/ParseStmt.cpp
===
--- clang/lib/Parse/ParseStmt.cpp
+++ clang/lib/Parse/ParseStmt.cpp
@@ -2163,6 +2163,9 @@
   // Create temporary attribute list.
   ParsedAttributesWithRange TempAttrs(AttrFactory);
 
+  SourceLocation StartLoc =
+  PP.getSourceManager().getExpansionLoc(Tok.getLocation());
+
   // Get loop hints and consume annotated token.
   while (Tok.is(tok::annot_pragma_loop_hint)) {
 LoopHint Hint;
@@ -2183,6 +2186,9 @@
   Stmts, StmtCtx, TrailingElseLoc, Attrs);
 
   Attrs.takeAllFrom(TempAttrs);
+
+  assert(!Attrs.Range.getBegin().isValid());
+  Attrs.Range.setBegin(StartLoc);
   return S;
 }
 
Index: clang/lib/Parse/ParsePragma.cpp
===
--- clang/lib/Parse/ParsePragma.cpp
+++ clang/lib/Parse/ParsePragma.cpp
@@ -2938,7 +2938,7 @@
 Token LoopHintTok;
 LoopHintTok.startToken();
 LoopHintTok.setKind(tok::annot_pragma_loop_hint);
-LoopHintTok.setLocation(PragmaName.getLocation());
+LoopHintTok.setLocation(Introducer.Loc);
 LoopHintTok.setAnnotationEndLoc(PragmaName.getLocation());
 LoopHintTok.setAnnotationValue(static_cast(Info));
 TokenList.push_back(LoopHintTok);
@@ -3025,7 +3025,7 @@
   auto TokenArray = std::make_unique(1);
   TokenArray[0].startToken();
   TokenArray[0].setKind(tok::annot_pragma_loop_hint);
-  TokenArray[0].setLocation(PragmaName.getLocation());
+  TokenArray[0].setLocation(Introducer.Loc);
   TokenArray[0].setAnnotationEndLoc(PragmaName.getLocation());
   TokenArray[0].setAnnotationValue(static_cast(Info));
   PP.EnterTokenStream(std::move(TokenArray), 1,


Index: clang/test/AST/sourceranges.cpp
===
--- clang/test/AST/sourceranges.cpp
+++ clang/test/AST/sourceranges.cpp
@@ -108,6 +108,28 @@
   }
 }
 
+// CHECK: NamespaceDecl {{.*}} attributed_stmt
+namespace attributed_stmt {
+  #define DO_PRAGMA(x) _Pragma (#x)
+
+  void f() {
+// CHECK: AttributedStmt {{.*}} 
+// CHECK: LoopHintAttr {{.*}} 
+#pragma unroll(2)
+// CHECK: LoopHintAttr {{.*}} 
+#pragma clang loop vectorize(enable)
+for (int i = 0; i < 10; ++i);
+
+// CHECK: AttributedStmt {{.*}} 
+_Pragma("unroll(2)")
+for (int j = 0; j < 10; ++j);
+
+// CHECK: AttributedStmt {{.*}} 
+DO_PRAGMA (unroll(2))
+for (int k = 0; k < 10; ++k);
+  }
+}
+
 #if __cplusplus >= 201703L
 // CHECK-1Z: FunctionDecl {{.*}} construct_with_init_list
 std::map construct_with_init_list() {
Index: clang/lib/Parse/ParseStmt.cpp
===
--- clang/lib/Parse/ParseStmt.cpp
+++ clang/lib/Parse/ParseStmt.cpp
@@ -2163,6 +2163,9 @@
   // Create temporary attribute list.
   ParsedAttributesWithRange TempAttrs(AttrFactory);
 
+  SourceLocation StartLoc =
+  PP.getSourceManager().getExpansionLoc(Tok.getLocation());
+
   // Get loop hints and consume annotated token.
   while (Tok.is(tok::annot_pragma_loop_hint)) {
 LoopHint Hint;
@@ -2183,6 +2186,9 @@
   Stmts, StmtCtx, TrailingElseLoc, Attrs);
 
   Attrs.takeAllFrom(TempAttrs);
+
+  assert(!Attrs.Range.getBegin().isValid());
+  Attrs.Range.setBegin(StartLoc);
   return S;
 }
 
Index: clang/lib/Parse/ParsePragma.cpp
===
--- clang/lib/Parse/ParsePragma.cpp
+++ clang/lib/Parse/ParsePragma.cpp
@@ -2938,7 +2938,7 @@
 Token LoopHintTok;
 LoopHintTok.startToken();
 LoopHintTok.setKind(tok::annot_pragma_l

[PATCH] D83519: [NewPM] Support optnone under new pass manager

2020-07-17 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added a comment.

In D83519#2144616 , @aeubanks wrote:

> In D83519#2144463 , @aeubanks wrote:
>
> > In D83519#2144403 , @ychen wrote:
> >
> > > High-level request: how about split this patch into two, the first for 
> > > the `require` pass part; the second for the PassInstrument callback. Then 
> > > we could discuss the choices of first patch and D82344 
> > > .
> >
> >
> > Good idea, will split the patch and take a closer look at your patch.
>
>
> I split the required passes part into https://reviews.llvm.org/D83575.


Could you remove the `Required` part of this patch?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83519



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


[PATCH] D83519: [NewPM] Support optnone under new pass manager

2020-07-18 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added inline comments.



Comment at: llvm/include/llvm/Passes/StandardInstrumentations.h:57
 
+class OptNoneInstrumentation {
+public:

I may probably name this `SkipPassInstrumentation`. But it is up to you.



Comment at: llvm/include/llvm/Passes/StandardInstrumentations.h:65
+
+  bool DebugPM;
+};

How about calling this `DebugLogging`?



Comment at: llvm/lib/Passes/StandardInstrumentations.cpp:27
 #include "llvm/Support/Debug.h"
+#include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/FormatVariadic.h"

Why need this?



Comment at: llvm/lib/Passes/StandardInstrumentations.cpp:270
+  }
+  if (F) {
+bool HasOptNone = F->hasOptNone();

```
  if (F && F->hasOptNone()) {
 ...
  }
  return true;
```




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83519



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


[PATCH] D83519: [NewPM] Support optnone under new pass manager

2020-07-20 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen accepted this revision.
ychen added a comment.
This revision is now accepted and ready to land.

LGTM with one nit.




Comment at: llvm/include/llvm/Passes/StandardInstrumentations.h:57
 
+class OptNoneInstrumentation {
+public:

ychen wrote:
> I may probably name this `SkipPassInstrumentation`. But it is up to you.
Errr, let's go with `OptNoneInstrumentation ` if it's your preference. This is 
a bit too verbose IMHO.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83519



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


[PATCH] D84707: [DFSan][NewPM] Port DataFlowSanitizer to NewPM

2020-07-27 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen accepted this revision.
ychen added a comment.
This revision is now accepted and ready to land.

LGTM with two nits. Please wait one day or two in case other reviewers want to 
have a look.




Comment at: llvm/include/llvm/Transforms/Instrumentation/DataFlowSanitizer.h:8
+//===--===//
+#ifndef LLVM_TRANSFORMS_INSTRUMENTATION_DATAFLOWSANITIZERPASS_H
+#define LLVM_TRANSFORMS_INSTRUMENTATION_DATAFLOWSANITIZERPASS_H

LLVM_TRANSFORMS_INSTRUMENTATION_DATAFLOWSANITIZER_H



Comment at: llvm/include/llvm/Transforms/Instrumentation/DataFlowSanitizer.h:11
+
+#include "llvm/IR/Function.h"
+#include "llvm/IR/Module.h"

Is Function.h needed?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84707



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


[PATCH] D84774: [NewPM][PassInstrument] Add PrintPass callback to StandardInstrumentations

2020-07-28 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen created this revision.
ychen added reviewers: asbirlea, aeubanks, hans.
Herald added subscribers: llvm-commits, cfe-commits, dexonsmith, steven_wu, 
zzheng, hiraditya.
Herald added projects: clang, LLVM.
ychen requested review of this revision.

Problem:
Right now, our "Running pass" is not accurate when passes are wrapped in 
adaptor because adaptor is never skipped and a pass could be skipped. The other 
problem is that "Running pass" for a adaptor is before any "Running pass" of 
passes/analyses it depends on. (for example, FunctionToLoopPassAdaptor). So the 
order of printing the not the actual order.

Solution:
Doing things like PassManager::Debuglogging is very intrusive because we need 
to specify Debuglogging whenever adaptor is created. (Actually, right now we're 
not specifying Debuglogging for some sub-PassManagers. Check PassBuilder)

This patch move debug logging for pass as a PassInstrument callback. We could 
be sure that all running passes are logged and in the correct order.

This could also be used to implement hierarchy pass logging in legacy PM. We 
could also move logging of pass manager to this if we want.

The test fixes looks messy. It includes changes:

- Remove PassInstrumentationAnalysis
- Remove PassAdaptor
- If a PassAdaptor is for a real pass, the pass is added
- Pass reorder (to the correct order), related to PassAdaptor
- Add missing passes (due to Debuglogging not passed down)


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D84774

Files:
  clang/test/CodeGen/thinlto-distributed-newpm.ll
  llvm/include/llvm/IR/PassInstrumentation.h
  llvm/include/llvm/IR/PassManager.h
  llvm/include/llvm/IR/PassManagerImpl.h
  llvm/include/llvm/Passes/StandardInstrumentations.h
  llvm/lib/Analysis/CGSCCPassManager.cpp
  llvm/lib/IR/PassInstrumentation.cpp
  llvm/lib/IR/PassTimingInfo.cpp
  llvm/lib/Passes/StandardInstrumentations.cpp
  llvm/lib/Transforms/Scalar/LoopPassManager.cpp
  llvm/test/Other/loop-pm-invalidation.ll
  llvm/test/Other/new-pass-manager.ll
  llvm/test/Other/new-pm-defaults.ll
  llvm/test/Other/new-pm-lto-defaults.ll
  llvm/test/Other/new-pm-pgo.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/Other/new-pm-thinlto-prelink-pgo-defaults.ll
  llvm/test/Other/new-pm-thinlto-prelink-samplepgo-defaults.ll
  llvm/test/Other/pass-pipeline-parsing.ll
  llvm/test/Transforms/LoopRotate/pr35210.ll
  llvm/test/Transforms/LoopUnroll/revisit.ll
  llvm/test/Transforms/LoopUnroll/unroll-loop-invalidation.ll
  llvm/test/Transforms/SCCP/ipsccp-preserve-analysis.ll

Index: llvm/test/Transforms/SCCP/ipsccp-preserve-analysis.ll
===
--- llvm/test/Transforms/SCCP/ipsccp-preserve-analysis.ll
+++ llvm/test/Transforms/SCCP/ipsccp-preserve-analysis.ll
@@ -19,7 +19,6 @@
 ; NEW-PM-NEXT: Invalidating all non-preserved analyses for:
 ; NEW-PM-NEXT: Invalidating all non-preserved analyses for: f1
 ; NEW-PM-NEXT: Invalidating all non-preserved analyses for: f2
-; NEW-PM-NEXT: Running pass: ModuleToFunctionPassAdaptor
 ; NEW-PM-NOT: Running analysis:
 
 ; IR-LABEL: @f1
Index: llvm/test/Transforms/LoopUnroll/unroll-loop-invalidation.ll
===
--- llvm/test/Transforms/LoopUnroll/unroll-loop-invalidation.ll
+++ llvm/test/Transforms/LoopUnroll/unroll-loop-invalidation.ll
@@ -6,20 +6,19 @@
 ; RUN: opt -S -passes='loop(require),loop-unroll,loop(print-access-info)' -debug-pass-manager < %s 2>&1 | FileCheck %s
 ;
 ; CHECK: Starting llvm::Function pass manager run.
-; CHECK: Running pass: FunctionToLoopPassAdaptor
 ; CHECK: Running analysis: LoopAnalysis
 ; CHECK: Running analysis: InnerAnalysisManagerProxy<
 ; CHECK: Starting Loop pass manager run.
 ; CHECK: Running pass: RequireAnalysisPass<{{.*}}LoopAccessAnalysis
-; CHECK: Running analysis: LoopAccessAnalysis on inner1.header
+; CHECK: Running analysis: LoopAccessAnalysis on Loop at depth 2 containing: %inner1.header
 ; CHECK: Finished Loop pass manager run.
 ; CHECK: Starting Loop pass manager run.
 ; CHECK: Running pass: RequireAnalysisPass<{{.*}}LoopAccessAnalysis
-; CHECK: Running analysis: LoopAccessAnalysis on inner2.header
+; CHECK: Running analysis: LoopAccessAnalysis on Loop at depth 2 containing: %inner2.header
 ; CHECK: Finished Loop pass manager run.
 ; CHECK: Starting Loop pass manager run.
 ; CHECK: Running pass: RequireAnalysisPass<{{.*}}LoopAccessAnalysis
-; CHECK: Running analysis: LoopAccessAnalysis on outer.header
+; CHECK: Running analysis: LoopAccessAnalysis on Loop at depth 1 containing: %outer.header
 ; CHECK: Finished Loop pass manager run.
 ; CHECK: Running pass: LoopUnrollPass
 ; CHECK: Clearing all analysis results for: inner2.header
@@ -29,16 +28,15 @@
 ; CHECK: Invalidating analysis: LoopAccessAnalysis on inner1.header
 ; CHECK: Invalidating all non-prese

[PATCH] D84774: [NewPM][PassInstrument] Add PrintPass callback to StandardInstrumentations

2020-07-28 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added a comment.

In D84774#2179410 , @asbirlea wrote:

> Does it make sense to have the option to enable seeing where the adaptors are 
> run?

Adding a static:cl at the top of StandardInstrumentation.cpp should do it. Do 
you want me to add it now or add it when we have use cases?

> Otherwise this looks good, it's nice to have the "Starting" and "Finished" 
> match now.




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84774

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


[PATCH] D84774: [NewPM][PassInstrument] Add PrintPass callback to StandardInstrumentations

2020-07-28 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen updated this revision to Diff 281395.
ychen added a comment.

- Add `-debug-pass-manager-verbose` to print adaptor passes. (test case in 
pass-pipeline-parsing.ll where we could ask for adaptor pass from `-passes`)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84774

Files:
  clang/test/CodeGen/thinlto-distributed-newpm.ll
  llvm/include/llvm/IR/PassInstrumentation.h
  llvm/include/llvm/IR/PassManager.h
  llvm/include/llvm/IR/PassManagerImpl.h
  llvm/include/llvm/Passes/StandardInstrumentations.h
  llvm/lib/Analysis/CGSCCPassManager.cpp
  llvm/lib/IR/PassInstrumentation.cpp
  llvm/lib/IR/PassTimingInfo.cpp
  llvm/lib/Passes/StandardInstrumentations.cpp
  llvm/lib/Transforms/Scalar/LoopPassManager.cpp
  llvm/test/Other/loop-pm-invalidation.ll
  llvm/test/Other/new-pass-manager.ll
  llvm/test/Other/new-pm-defaults.ll
  llvm/test/Other/new-pm-lto-defaults.ll
  llvm/test/Other/new-pm-pgo.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/Other/new-pm-thinlto-prelink-pgo-defaults.ll
  llvm/test/Other/new-pm-thinlto-prelink-samplepgo-defaults.ll
  llvm/test/Other/pass-pipeline-parsing.ll
  llvm/test/Transforms/LoopRotate/pr35210.ll
  llvm/test/Transforms/LoopUnroll/revisit.ll
  llvm/test/Transforms/LoopUnroll/unroll-loop-invalidation.ll
  llvm/test/Transforms/SCCP/ipsccp-preserve-analysis.ll

Index: llvm/test/Transforms/SCCP/ipsccp-preserve-analysis.ll
===
--- llvm/test/Transforms/SCCP/ipsccp-preserve-analysis.ll
+++ llvm/test/Transforms/SCCP/ipsccp-preserve-analysis.ll
@@ -19,7 +19,6 @@
 ; NEW-PM-NEXT: Invalidating all non-preserved analyses for:
 ; NEW-PM-NEXT: Invalidating all non-preserved analyses for: f1
 ; NEW-PM-NEXT: Invalidating all non-preserved analyses for: f2
-; NEW-PM-NEXT: Running pass: ModuleToFunctionPassAdaptor
 ; NEW-PM-NOT: Running analysis:
 
 ; IR-LABEL: @f1
Index: llvm/test/Transforms/LoopUnroll/unroll-loop-invalidation.ll
===
--- llvm/test/Transforms/LoopUnroll/unroll-loop-invalidation.ll
+++ llvm/test/Transforms/LoopUnroll/unroll-loop-invalidation.ll
@@ -6,20 +6,19 @@
 ; RUN: opt -S -passes='loop(require),loop-unroll,loop(print-access-info)' -debug-pass-manager < %s 2>&1 | FileCheck %s
 ;
 ; CHECK: Starting llvm::Function pass manager run.
-; CHECK: Running pass: FunctionToLoopPassAdaptor
 ; CHECK: Running analysis: LoopAnalysis
 ; CHECK: Running analysis: InnerAnalysisManagerProxy<
 ; CHECK: Starting Loop pass manager run.
 ; CHECK: Running pass: RequireAnalysisPass<{{.*}}LoopAccessAnalysis
-; CHECK: Running analysis: LoopAccessAnalysis on inner1.header
+; CHECK: Running analysis: LoopAccessAnalysis on Loop at depth 2 containing: %inner1.header
 ; CHECK: Finished Loop pass manager run.
 ; CHECK: Starting Loop pass manager run.
 ; CHECK: Running pass: RequireAnalysisPass<{{.*}}LoopAccessAnalysis
-; CHECK: Running analysis: LoopAccessAnalysis on inner2.header
+; CHECK: Running analysis: LoopAccessAnalysis on Loop at depth 2 containing: %inner2.header
 ; CHECK: Finished Loop pass manager run.
 ; CHECK: Starting Loop pass manager run.
 ; CHECK: Running pass: RequireAnalysisPass<{{.*}}LoopAccessAnalysis
-; CHECK: Running analysis: LoopAccessAnalysis on outer.header
+; CHECK: Running analysis: LoopAccessAnalysis on Loop at depth 1 containing: %outer.header
 ; CHECK: Finished Loop pass manager run.
 ; CHECK: Running pass: LoopUnrollPass
 ; CHECK: Clearing all analysis results for: inner2.header
@@ -29,16 +28,15 @@
 ; CHECK: Invalidating analysis: LoopAccessAnalysis on inner1.header
 ; CHECK: Invalidating all non-preserved analyses for: inner1.header.1
 ; CHECK-NOT: Invalidating analysis: LoopAccessAnalysis on inner1.header.1
-; CHECK: Running pass: FunctionToLoopPassAdaptor
 ; CHECK: Starting Loop pass manager run.
 ; CHECK: Running pass: LoopAccessInfoPrinterPass
-; CHECK: Running analysis: LoopAccessAnalysis on inner1.header
+; CHECK: Running analysis: LoopAccessAnalysis on Loop at depth 1 containing: %inner1.header
 ; CHECK: Loop access info in function 'test':
 ; CHECK:   inner1.header:
 ; CHECK: Finished Loop pass manager run.
 ; CHECK: Starting Loop pass manager run.
 ; CHECK: Running pass: LoopAccessInfoPrinterPass
-; CHECK: Running analysis: LoopAccessAnalysis on inner1.header.1
+; CHECK: Running analysis: LoopAccessAnalysis on Loop at depth 1 containing: %inner1.header.1
 ; CHECK: Loop access info in function 'test':
 ; CHECK:   inner1.header.1:
 ; CHECK: Finished Loop pass manager run.
Index: llvm/test/Transforms/LoopUnroll/revisit.ll
===
--- llvm/test/Transforms/LoopUnroll/revisit.ll
+++ llvm/test/Transforms/LoopUnroll/revisit.ll
@@ -15,7 +15,7 @@
 ; Basic test is fully unr

[PATCH] D84774: [NewPM][PassInstrument] Add PrintPass callback to StandardInstrumentations

2020-07-28 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen updated this revision to Diff 281399.
ychen added a comment.

- Update `-debug-pass-manager-verbose` test. Some output should be ignored.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84774

Files:
  clang/test/CodeGen/thinlto-distributed-newpm.ll
  llvm/include/llvm/IR/PassInstrumentation.h
  llvm/include/llvm/IR/PassManager.h
  llvm/include/llvm/IR/PassManagerImpl.h
  llvm/include/llvm/Passes/StandardInstrumentations.h
  llvm/lib/Analysis/CGSCCPassManager.cpp
  llvm/lib/IR/PassInstrumentation.cpp
  llvm/lib/IR/PassTimingInfo.cpp
  llvm/lib/Passes/StandardInstrumentations.cpp
  llvm/lib/Transforms/Scalar/LoopPassManager.cpp
  llvm/test/Other/loop-pm-invalidation.ll
  llvm/test/Other/new-pass-manager.ll
  llvm/test/Other/new-pm-defaults.ll
  llvm/test/Other/new-pm-lto-defaults.ll
  llvm/test/Other/new-pm-pgo.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/Other/new-pm-thinlto-prelink-pgo-defaults.ll
  llvm/test/Other/new-pm-thinlto-prelink-samplepgo-defaults.ll
  llvm/test/Other/pass-pipeline-parsing.ll
  llvm/test/Transforms/LoopRotate/pr35210.ll
  llvm/test/Transforms/LoopUnroll/revisit.ll
  llvm/test/Transforms/LoopUnroll/unroll-loop-invalidation.ll
  llvm/test/Transforms/SCCP/ipsccp-preserve-analysis.ll

Index: llvm/test/Transforms/SCCP/ipsccp-preserve-analysis.ll
===
--- llvm/test/Transforms/SCCP/ipsccp-preserve-analysis.ll
+++ llvm/test/Transforms/SCCP/ipsccp-preserve-analysis.ll
@@ -19,7 +19,6 @@
 ; NEW-PM-NEXT: Invalidating all non-preserved analyses for:
 ; NEW-PM-NEXT: Invalidating all non-preserved analyses for: f1
 ; NEW-PM-NEXT: Invalidating all non-preserved analyses for: f2
-; NEW-PM-NEXT: Running pass: ModuleToFunctionPassAdaptor
 ; NEW-PM-NOT: Running analysis:
 
 ; IR-LABEL: @f1
Index: llvm/test/Transforms/LoopUnroll/unroll-loop-invalidation.ll
===
--- llvm/test/Transforms/LoopUnroll/unroll-loop-invalidation.ll
+++ llvm/test/Transforms/LoopUnroll/unroll-loop-invalidation.ll
@@ -6,20 +6,19 @@
 ; RUN: opt -S -passes='loop(require),loop-unroll,loop(print-access-info)' -debug-pass-manager < %s 2>&1 | FileCheck %s
 ;
 ; CHECK: Starting llvm::Function pass manager run.
-; CHECK: Running pass: FunctionToLoopPassAdaptor
 ; CHECK: Running analysis: LoopAnalysis
 ; CHECK: Running analysis: InnerAnalysisManagerProxy<
 ; CHECK: Starting Loop pass manager run.
 ; CHECK: Running pass: RequireAnalysisPass<{{.*}}LoopAccessAnalysis
-; CHECK: Running analysis: LoopAccessAnalysis on inner1.header
+; CHECK: Running analysis: LoopAccessAnalysis on Loop at depth 2 containing: %inner1.header
 ; CHECK: Finished Loop pass manager run.
 ; CHECK: Starting Loop pass manager run.
 ; CHECK: Running pass: RequireAnalysisPass<{{.*}}LoopAccessAnalysis
-; CHECK: Running analysis: LoopAccessAnalysis on inner2.header
+; CHECK: Running analysis: LoopAccessAnalysis on Loop at depth 2 containing: %inner2.header
 ; CHECK: Finished Loop pass manager run.
 ; CHECK: Starting Loop pass manager run.
 ; CHECK: Running pass: RequireAnalysisPass<{{.*}}LoopAccessAnalysis
-; CHECK: Running analysis: LoopAccessAnalysis on outer.header
+; CHECK: Running analysis: LoopAccessAnalysis on Loop at depth 1 containing: %outer.header
 ; CHECK: Finished Loop pass manager run.
 ; CHECK: Running pass: LoopUnrollPass
 ; CHECK: Clearing all analysis results for: inner2.header
@@ -29,16 +28,15 @@
 ; CHECK: Invalidating analysis: LoopAccessAnalysis on inner1.header
 ; CHECK: Invalidating all non-preserved analyses for: inner1.header.1
 ; CHECK-NOT: Invalidating analysis: LoopAccessAnalysis on inner1.header.1
-; CHECK: Running pass: FunctionToLoopPassAdaptor
 ; CHECK: Starting Loop pass manager run.
 ; CHECK: Running pass: LoopAccessInfoPrinterPass
-; CHECK: Running analysis: LoopAccessAnalysis on inner1.header
+; CHECK: Running analysis: LoopAccessAnalysis on Loop at depth 1 containing: %inner1.header
 ; CHECK: Loop access info in function 'test':
 ; CHECK:   inner1.header:
 ; CHECK: Finished Loop pass manager run.
 ; CHECK: Starting Loop pass manager run.
 ; CHECK: Running pass: LoopAccessInfoPrinterPass
-; CHECK: Running analysis: LoopAccessAnalysis on inner1.header.1
+; CHECK: Running analysis: LoopAccessAnalysis on Loop at depth 1 containing: %inner1.header.1
 ; CHECK: Loop access info in function 'test':
 ; CHECK:   inner1.header.1:
 ; CHECK: Finished Loop pass manager run.
Index: llvm/test/Transforms/LoopUnroll/revisit.ll
===
--- llvm/test/Transforms/LoopUnroll/revisit.ll
+++ llvm/test/Transforms/LoopUnroll/revisit.ll
@@ -15,7 +15,7 @@
 ; Basic test is fully unrolled and we revisit the post-unroll new sibling
 ; loops, including the ones

[PATCH] D80944: Add begin source location for the attributed statement created from PragmaLoopHint decorated loop

2020-06-05 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen updated this revision to Diff 268958.
ychen added a comment.

- Address feedback


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80944

Files:
  clang/lib/Parse/ParsePragma.cpp
  clang/lib/Parse/ParseStmt.cpp
  clang/test/AST/sourceranges.cpp


Index: clang/test/AST/sourceranges.cpp
===
--- clang/test/AST/sourceranges.cpp
+++ clang/test/AST/sourceranges.cpp
@@ -108,6 +108,33 @@
   }
 }
 
+// CHECK: NamespaceDecl {{.*}} attributed_stmt
+namespace attributed_stmt {
+  #define DO_PRAGMA(x) _Pragma (#x)
+
+  void f() {
+// CHECK: AttributedStmt {{.*}} 
+DO_PRAGMA (unroll(2))
+for (int i = 0; i < 10; ++i);
+
+// CHECK: AttributedStmt {{.*}} 
+// CHECK: LoopHintAttr {{.*}} 
+#pragma unroll(2)
+for (int i = 0; i < 10; ++i);
+
+// CHECK: AttributedStmt {{.*}} 
+// CHECK: LoopHintAttr {{.*}} 
+#pragma clang loop vectorize(enable)
+// CHECK: LoopHintAttr {{.*}} 
+#pragma clang loop interleave(enable)
+for (int i = 0; i < 10; ++i);
+
+// CHECK: AttributedStmt {{.*}} 
+_Pragma("unroll(2)")
+for (int i = 0; i < 10; ++i);
+  }
+}
+
 #if __cplusplus >= 201703L
 // CHECK-1Z: FunctionDecl {{.*}} construct_with_init_list
 std::map construct_with_init_list() {
Index: clang/lib/Parse/ParseStmt.cpp
===
--- clang/lib/Parse/ParseStmt.cpp
+++ clang/lib/Parse/ParseStmt.cpp
@@ -2163,6 +2163,8 @@
   // Create temporary attribute list.
   ParsedAttributesWithRange TempAttrs(AttrFactory);
 
+  SourceLocation StartLoc = Tok.getLocation();
+
   // Get loop hints and consume annotated token.
   while (Tok.is(tok::annot_pragma_loop_hint)) {
 LoopHint Hint;
@@ -2183,6 +2185,9 @@
   Stmts, StmtCtx, TrailingElseLoc, Attrs);
 
   Attrs.takeAllFrom(TempAttrs);
+
+  assert(!Attrs.Range.getBegin().isValid());
+  Attrs.Range.setBegin(StartLoc);
   return S;
 }
 
Index: clang/lib/Parse/ParsePragma.cpp
===
--- clang/lib/Parse/ParsePragma.cpp
+++ clang/lib/Parse/ParsePragma.cpp
@@ -2938,7 +2938,7 @@
 Token LoopHintTok;
 LoopHintTok.startToken();
 LoopHintTok.setKind(tok::annot_pragma_loop_hint);
-LoopHintTok.setLocation(PragmaName.getLocation());
+LoopHintTok.setLocation(Introducer.Loc);
 LoopHintTok.setAnnotationEndLoc(PragmaName.getLocation());
 LoopHintTok.setAnnotationValue(static_cast(Info));
 TokenList.push_back(LoopHintTok);
@@ -3025,7 +3025,7 @@
   auto TokenArray = std::make_unique(1);
   TokenArray[0].startToken();
   TokenArray[0].setKind(tok::annot_pragma_loop_hint);
-  TokenArray[0].setLocation(PragmaName.getLocation());
+  TokenArray[0].setLocation(Introducer.Loc);
   TokenArray[0].setAnnotationEndLoc(PragmaName.getLocation());
   TokenArray[0].setAnnotationValue(static_cast(Info));
   PP.EnterTokenStream(std::move(TokenArray), 1,


Index: clang/test/AST/sourceranges.cpp
===
--- clang/test/AST/sourceranges.cpp
+++ clang/test/AST/sourceranges.cpp
@@ -108,6 +108,33 @@
   }
 }
 
+// CHECK: NamespaceDecl {{.*}} attributed_stmt
+namespace attributed_stmt {
+  #define DO_PRAGMA(x) _Pragma (#x)
+
+  void f() {
+// CHECK: AttributedStmt {{.*}} 
+DO_PRAGMA (unroll(2))
+for (int i = 0; i < 10; ++i);
+
+// CHECK: AttributedStmt {{.*}} 
+// CHECK: LoopHintAttr {{.*}} 
+#pragma unroll(2)
+for (int i = 0; i < 10; ++i);
+
+// CHECK: AttributedStmt {{.*}} 
+// CHECK: LoopHintAttr {{.*}} 
+#pragma clang loop vectorize(enable)
+// CHECK: LoopHintAttr {{.*}} 
+#pragma clang loop interleave(enable)
+for (int i = 0; i < 10; ++i);
+
+// CHECK: AttributedStmt {{.*}} 
+_Pragma("unroll(2)")
+for (int i = 0; i < 10; ++i);
+  }
+}
+
 #if __cplusplus >= 201703L
 // CHECK-1Z: FunctionDecl {{.*}} construct_with_init_list
 std::map construct_with_init_list() {
Index: clang/lib/Parse/ParseStmt.cpp
===
--- clang/lib/Parse/ParseStmt.cpp
+++ clang/lib/Parse/ParseStmt.cpp
@@ -2163,6 +2163,8 @@
   // Create temporary attribute list.
   ParsedAttributesWithRange TempAttrs(AttrFactory);
 
+  SourceLocation StartLoc = Tok.getLocation();
+
   // Get loop hints and consume annotated token.
   while (Tok.is(tok::annot_pragma_loop_hint)) {
 LoopHint Hint;
@@ -2183,6 +2185,9 @@
   Stmts, StmtCtx, TrailingElseLoc, Attrs);
 
   Attrs.takeAllFrom(TempAttrs);
+
+  assert(!Attrs.Range.getBegin().isValid());
+  Attrs.Range.setBegin(StartLoc);
   return S;
 }
 
Index: clang/lib/Parse/ParsePragma.cpp
===
--- clang/lib/Parse/ParsePragma.cpp
+++ clang/lib/Parse/ParsePragma.cpp
@@ -2938,7 +2938,7 @@
 Token LoopHintTok;
 LoopHintTok.startToken()

[PATCH] D80944: Add begin source location for the attributed statement created from PragmaLoopHint decorated loop

2020-06-05 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen marked 4 inline comments as done.
ychen added inline comments.



Comment at: clang/lib/Parse/ParsePragma.cpp:2941
 LoopHintTok.setKind(tok::annot_pragma_loop_hint);
-LoopHintTok.setLocation(PragmaName.getLocation());
+LoopHintTok.setLocation(Introducer.Loc);
 LoopHintTok.setAnnotationEndLoc(PragmaName.getLocation());

jdenny wrote:
> When I remove this change, the new test still passes.  Please make sure this 
> case is covered.
Added a test case for this.



Comment at: clang/lib/Parse/ParseStmt.cpp:2167
+  SourceLocation StartLoc =
+  PP.getSourceManager().getExpansionLoc(Tok.getLocation());
+

jdenny wrote:
> I think the call to getExpansionLoc shouldn't be here.  If the ast dumper or 
> other clients want to convert to that form, they can do so.
Indeed. Removing this helps code coverage shows the coverage for the macro 
spelling location. Thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80944



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


[PATCH] D80944: Add begin source location for the attributed statement created from PragmaLoopHint decorated loop

2020-06-08 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen updated this revision to Diff 269282.
ychen marked 3 inline comments as done.
ychen added a comment.

- add comment


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80944

Files:
  clang/lib/Parse/ParsePragma.cpp
  clang/lib/Parse/ParseStmt.cpp
  clang/test/AST/sourceranges.cpp


Index: clang/test/AST/sourceranges.cpp
===
--- clang/test/AST/sourceranges.cpp
+++ clang/test/AST/sourceranges.cpp
@@ -108,6 +108,36 @@
   }
 }
 
+// CHECK: NamespaceDecl {{.*}} attributed_stmt
+namespace attributed_stmt {
+  #define DO_PRAGMA(x) _Pragma (#x)
+
+  // In DO_PRAGMA and _Pragma cases, `LoopHintAttr` comes from 
+  // file.
+
+  void f() {
+// CHECK: AttributedStmt {{.*}} 
+DO_PRAGMA (unroll(2))
+for (int i = 0; i < 10; ++i);
+
+// CHECK: AttributedStmt {{.*}} 
+// CHECK: LoopHintAttr {{.*}} 
+#pragma unroll(2)
+for (int i = 0; i < 10; ++i);
+
+// CHECK: AttributedStmt {{.*}} 
+// CHECK: LoopHintAttr {{.*}} 
+#pragma clang loop vectorize(enable)
+// CHECK: LoopHintAttr {{.*}} 
+#pragma clang loop interleave(enable)
+for (int i = 0; i < 10; ++i);
+
+// CHECK: AttributedStmt {{.*}} 
+_Pragma("unroll(2)")
+for (int i = 0; i < 10; ++i);
+  }
+}
+
 #if __cplusplus >= 201703L
 // CHECK-1Z: FunctionDecl {{.*}} construct_with_init_list
 std::map construct_with_init_list() {
Index: clang/lib/Parse/ParseStmt.cpp
===
--- clang/lib/Parse/ParseStmt.cpp
+++ clang/lib/Parse/ParseStmt.cpp
@@ -2163,6 +2163,8 @@
   // Create temporary attribute list.
   ParsedAttributesWithRange TempAttrs(AttrFactory);
 
+  SourceLocation StartLoc = Tok.getLocation();
+
   // Get loop hints and consume annotated token.
   while (Tok.is(tok::annot_pragma_loop_hint)) {
 LoopHint Hint;
@@ -2183,6 +2185,9 @@
   Stmts, StmtCtx, TrailingElseLoc, Attrs);
 
   Attrs.takeAllFrom(TempAttrs);
+
+  assert(!Attrs.Range.getBegin().isValid());
+  Attrs.Range.setBegin(StartLoc);
   return S;
 }
 
Index: clang/lib/Parse/ParsePragma.cpp
===
--- clang/lib/Parse/ParsePragma.cpp
+++ clang/lib/Parse/ParsePragma.cpp
@@ -2938,7 +2938,7 @@
 Token LoopHintTok;
 LoopHintTok.startToken();
 LoopHintTok.setKind(tok::annot_pragma_loop_hint);
-LoopHintTok.setLocation(PragmaName.getLocation());
+LoopHintTok.setLocation(Introducer.Loc);
 LoopHintTok.setAnnotationEndLoc(PragmaName.getLocation());
 LoopHintTok.setAnnotationValue(static_cast(Info));
 TokenList.push_back(LoopHintTok);
@@ -3025,7 +3025,7 @@
   auto TokenArray = std::make_unique(1);
   TokenArray[0].startToken();
   TokenArray[0].setKind(tok::annot_pragma_loop_hint);
-  TokenArray[0].setLocation(PragmaName.getLocation());
+  TokenArray[0].setLocation(Introducer.Loc);
   TokenArray[0].setAnnotationEndLoc(PragmaName.getLocation());
   TokenArray[0].setAnnotationValue(static_cast(Info));
   PP.EnterTokenStream(std::move(TokenArray), 1,


Index: clang/test/AST/sourceranges.cpp
===
--- clang/test/AST/sourceranges.cpp
+++ clang/test/AST/sourceranges.cpp
@@ -108,6 +108,36 @@
   }
 }
 
+// CHECK: NamespaceDecl {{.*}} attributed_stmt
+namespace attributed_stmt {
+  #define DO_PRAGMA(x) _Pragma (#x)
+
+  // In DO_PRAGMA and _Pragma cases, `LoopHintAttr` comes from 
+  // file.
+
+  void f() {
+// CHECK: AttributedStmt {{.*}} 
+DO_PRAGMA (unroll(2))
+for (int i = 0; i < 10; ++i);
+
+// CHECK: AttributedStmt {{.*}} 
+// CHECK: LoopHintAttr {{.*}} 
+#pragma unroll(2)
+for (int i = 0; i < 10; ++i);
+
+// CHECK: AttributedStmt {{.*}} 
+// CHECK: LoopHintAttr {{.*}} 
+#pragma clang loop vectorize(enable)
+// CHECK: LoopHintAttr {{.*}} 
+#pragma clang loop interleave(enable)
+for (int i = 0; i < 10; ++i);
+
+// CHECK: AttributedStmt {{.*}} 
+_Pragma("unroll(2)")
+for (int i = 0; i < 10; ++i);
+  }
+}
+
 #if __cplusplus >= 201703L
 // CHECK-1Z: FunctionDecl {{.*}} construct_with_init_list
 std::map construct_with_init_list() {
Index: clang/lib/Parse/ParseStmt.cpp
===
--- clang/lib/Parse/ParseStmt.cpp
+++ clang/lib/Parse/ParseStmt.cpp
@@ -2163,6 +2163,8 @@
   // Create temporary attribute list.
   ParsedAttributesWithRange TempAttrs(AttrFactory);
 
+  SourceLocation StartLoc = Tok.getLocation();
+
   // Get loop hints and consume annotated token.
   while (Tok.is(tok::annot_pragma_loop_hint)) {
 LoopHint Hint;
@@ -2183,6 +2185,9 @@
   Stmts, StmtCtx, TrailingElseLoc, Attrs);
 
   Attrs.takeAllFrom(TempAttrs);
+
+  assert(!Attrs.Range.getBegin().isValid());
+  Attrs.Range.setBegin(StartLoc);
   return S;
 }
 
Index: clang/lib/Parse/ParsePragma.cpp
==

[PATCH] D80944: Add begin source location for the attributed statement created from PragmaLoopHint decorated loop

2020-06-08 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added inline comments.



Comment at: clang/test/AST/sourceranges.cpp:116
+  void f() {
+// CHECK: AttributedStmt {{.*}} 
+DO_PRAGMA (unroll(2))

jdenny wrote:
> Is there any reason not to check for `LoopHintAttr` here and on the `_Pragma` 
> case below?  If so, I suggest a comment to explain why these cases are 
> different.
Comment added.

The existing checking of `LoopHintAttr` already covered the code changes in  
`ParsePragma.cpp`. In the other two cases `LoopHintAttr` have its location in 
`` which I felt unrelated to this change so I skipped them to 
avoid confusion.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80944



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


[PATCH] D80944: Add begin source location for the attributed statement created from PragmaLoopHint decorated loop

2020-06-08 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen updated this revision to Diff 269380.
ychen added a comment.

- update


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80944

Files:
  clang/lib/Parse/ParsePragma.cpp
  clang/lib/Parse/ParseStmt.cpp
  clang/test/AST/sourceranges.cpp


Index: clang/test/AST/sourceranges.cpp
===
--- clang/test/AST/sourceranges.cpp
+++ clang/test/AST/sourceranges.cpp
@@ -108,6 +108,36 @@
   }
 }
 
+// CHECK: NamespaceDecl {{.*}} attributed_stmt
+namespace attributed_stmt {
+  // In DO_PRAGMA and _Pragma cases, `LoopHintAttr` comes from 
+  // file.
+
+  #define DO_PRAGMA(x) _Pragma (#x)
+
+  void f() {
+// CHECK: AttributedStmt {{.*}} 
+DO_PRAGMA (unroll(2))
+for (int i = 0; i < 10; ++i);
+
+// CHECK: AttributedStmt {{.*}} 
+// CHECK: LoopHintAttr {{.*}} 
+#pragma unroll(2)
+for (int i = 0; i < 10; ++i);
+
+// CHECK: AttributedStmt {{.*}} 
+// CHECK: LoopHintAttr {{.*}} 
+#pragma clang loop vectorize(enable)
+// CHECK: LoopHintAttr {{.*}} 
+#pragma clang loop interleave(enable)
+for (int i = 0; i < 10; ++i);
+
+// CHECK: AttributedStmt {{.*}} 
+_Pragma("unroll(2)")
+for (int i = 0; i < 10; ++i);
+  }
+}
+
 #if __cplusplus >= 201703L
 // CHECK-1Z: FunctionDecl {{.*}} construct_with_init_list
 std::map construct_with_init_list() {
Index: clang/lib/Parse/ParseStmt.cpp
===
--- clang/lib/Parse/ParseStmt.cpp
+++ clang/lib/Parse/ParseStmt.cpp
@@ -2163,6 +2163,8 @@
   // Create temporary attribute list.
   ParsedAttributesWithRange TempAttrs(AttrFactory);
 
+  SourceLocation StartLoc = Tok.getLocation();
+
   // Get loop hints and consume annotated token.
   while (Tok.is(tok::annot_pragma_loop_hint)) {
 LoopHint Hint;
@@ -2183,6 +2185,9 @@
   Stmts, StmtCtx, TrailingElseLoc, Attrs);
 
   Attrs.takeAllFrom(TempAttrs);
+
+  assert(!Attrs.Range.getBegin().isValid());
+  Attrs.Range.setBegin(StartLoc);
   return S;
 }
 
Index: clang/lib/Parse/ParsePragma.cpp
===
--- clang/lib/Parse/ParsePragma.cpp
+++ clang/lib/Parse/ParsePragma.cpp
@@ -2938,7 +2938,7 @@
 Token LoopHintTok;
 LoopHintTok.startToken();
 LoopHintTok.setKind(tok::annot_pragma_loop_hint);
-LoopHintTok.setLocation(PragmaName.getLocation());
+LoopHintTok.setLocation(Introducer.Loc);
 LoopHintTok.setAnnotationEndLoc(PragmaName.getLocation());
 LoopHintTok.setAnnotationValue(static_cast(Info));
 TokenList.push_back(LoopHintTok);
@@ -3025,7 +3025,7 @@
   auto TokenArray = std::make_unique(1);
   TokenArray[0].startToken();
   TokenArray[0].setKind(tok::annot_pragma_loop_hint);
-  TokenArray[0].setLocation(PragmaName.getLocation());
+  TokenArray[0].setLocation(Introducer.Loc);
   TokenArray[0].setAnnotationEndLoc(PragmaName.getLocation());
   TokenArray[0].setAnnotationValue(static_cast(Info));
   PP.EnterTokenStream(std::move(TokenArray), 1,


Index: clang/test/AST/sourceranges.cpp
===
--- clang/test/AST/sourceranges.cpp
+++ clang/test/AST/sourceranges.cpp
@@ -108,6 +108,36 @@
   }
 }
 
+// CHECK: NamespaceDecl {{.*}} attributed_stmt
+namespace attributed_stmt {
+  // In DO_PRAGMA and _Pragma cases, `LoopHintAttr` comes from 
+  // file.
+
+  #define DO_PRAGMA(x) _Pragma (#x)
+
+  void f() {
+// CHECK: AttributedStmt {{.*}} 
+DO_PRAGMA (unroll(2))
+for (int i = 0; i < 10; ++i);
+
+// CHECK: AttributedStmt {{.*}} 
+// CHECK: LoopHintAttr {{.*}} 
+#pragma unroll(2)
+for (int i = 0; i < 10; ++i);
+
+// CHECK: AttributedStmt {{.*}} 
+// CHECK: LoopHintAttr {{.*}} 
+#pragma clang loop vectorize(enable)
+// CHECK: LoopHintAttr {{.*}} 
+#pragma clang loop interleave(enable)
+for (int i = 0; i < 10; ++i);
+
+// CHECK: AttributedStmt {{.*}} 
+_Pragma("unroll(2)")
+for (int i = 0; i < 10; ++i);
+  }
+}
+
 #if __cplusplus >= 201703L
 // CHECK-1Z: FunctionDecl {{.*}} construct_with_init_list
 std::map construct_with_init_list() {
Index: clang/lib/Parse/ParseStmt.cpp
===
--- clang/lib/Parse/ParseStmt.cpp
+++ clang/lib/Parse/ParseStmt.cpp
@@ -2163,6 +2163,8 @@
   // Create temporary attribute list.
   ParsedAttributesWithRange TempAttrs(AttrFactory);
 
+  SourceLocation StartLoc = Tok.getLocation();
+
   // Get loop hints and consume annotated token.
   while (Tok.is(tok::annot_pragma_loop_hint)) {
 LoopHint Hint;
@@ -2183,6 +2185,9 @@
   Stmts, StmtCtx, TrailingElseLoc, Attrs);
 
   Attrs.takeAllFrom(TempAttrs);
+
+  assert(!Attrs.Range.getBegin().isValid());
+  Attrs.Range.setBegin(StartLoc);
   return S;
 }
 
Index: clang/lib/Parse/ParsePragma.cpp
===

[PATCH] D80944: Add begin source location for the attributed statement created from PragmaLoopHint decorated loop

2020-06-09 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen updated this revision to Diff 269586.
ychen added a comment.

- address comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80944

Files:
  clang/lib/Parse/ParsePragma.cpp
  clang/lib/Parse/ParseStmt.cpp
  clang/test/AST/sourceranges.cpp


Index: clang/test/AST/sourceranges.cpp
===
--- clang/test/AST/sourceranges.cpp
+++ clang/test/AST/sourceranges.cpp
@@ -108,6 +108,36 @@
   }
 }
 
+// CHECK: NamespaceDecl {{.*}} attributed_stmt
+namespace attributed_stmt {
+  // In DO_PRAGMA and _Pragma cases, `LoopHintAttr` comes from 
+  // file.
+
+  #define DO_PRAGMA(x) _Pragma (#x)
+
+  void f() {
+// CHECK: AttributedStmt {{.*}} 
+DO_PRAGMA (unroll(2))
+for (int i = 0; i < 10; ++i);
+
+// CHECK: AttributedStmt {{.*}} 
+// CHECK: LoopHintAttr {{.*}} 
+#pragma unroll(2)
+for (int i = 0; i < 10; ++i);
+
+// CHECK: AttributedStmt {{.*}} 
+// CHECK: LoopHintAttr {{.*}} 
+#pragma clang loop vectorize(enable)
+// CHECK: LoopHintAttr {{.*}} 
+#pragma clang loop interleave(enable)
+for (int i = 0; i < 10; ++i);
+
+// CHECK: AttributedStmt {{.*}} 
+_Pragma("unroll(2)")
+for (int i = 0; i < 10; ++i);
+  }
+}
+
 #if __cplusplus >= 201703L
 // CHECK-1Z: FunctionDecl {{.*}} construct_with_init_list
 std::map construct_with_init_list() {
Index: clang/lib/Parse/ParseStmt.cpp
===
--- clang/lib/Parse/ParseStmt.cpp
+++ clang/lib/Parse/ParseStmt.cpp
@@ -2163,6 +2163,8 @@
   // Create temporary attribute list.
   ParsedAttributesWithRange TempAttrs(AttrFactory);
 
+  SourceLocation StartLoc = Tok.getLocation();
+
   // Get loop hints and consume annotated token.
   while (Tok.is(tok::annot_pragma_loop_hint)) {
 LoopHint Hint;
@@ -2183,6 +2185,10 @@
   Stmts, StmtCtx, TrailingElseLoc, Attrs);
 
   Attrs.takeAllFrom(TempAttrs);
+
+  assert(Attrs.Range.getBegin().isInvalid() &&
+ "start of attribute range already set");
+  Attrs.Range.setBegin(StartLoc);
   return S;
 }
 
Index: clang/lib/Parse/ParsePragma.cpp
===
--- clang/lib/Parse/ParsePragma.cpp
+++ clang/lib/Parse/ParsePragma.cpp
@@ -2938,7 +2938,7 @@
 Token LoopHintTok;
 LoopHintTok.startToken();
 LoopHintTok.setKind(tok::annot_pragma_loop_hint);
-LoopHintTok.setLocation(PragmaName.getLocation());
+LoopHintTok.setLocation(Introducer.Loc);
 LoopHintTok.setAnnotationEndLoc(PragmaName.getLocation());
 LoopHintTok.setAnnotationValue(static_cast(Info));
 TokenList.push_back(LoopHintTok);
@@ -3025,7 +3025,7 @@
   auto TokenArray = std::make_unique(1);
   TokenArray[0].startToken();
   TokenArray[0].setKind(tok::annot_pragma_loop_hint);
-  TokenArray[0].setLocation(PragmaName.getLocation());
+  TokenArray[0].setLocation(Introducer.Loc);
   TokenArray[0].setAnnotationEndLoc(PragmaName.getLocation());
   TokenArray[0].setAnnotationValue(static_cast(Info));
   PP.EnterTokenStream(std::move(TokenArray), 1,


Index: clang/test/AST/sourceranges.cpp
===
--- clang/test/AST/sourceranges.cpp
+++ clang/test/AST/sourceranges.cpp
@@ -108,6 +108,36 @@
   }
 }
 
+// CHECK: NamespaceDecl {{.*}} attributed_stmt
+namespace attributed_stmt {
+  // In DO_PRAGMA and _Pragma cases, `LoopHintAttr` comes from 
+  // file.
+
+  #define DO_PRAGMA(x) _Pragma (#x)
+
+  void f() {
+// CHECK: AttributedStmt {{.*}} 
+DO_PRAGMA (unroll(2))
+for (int i = 0; i < 10; ++i);
+
+// CHECK: AttributedStmt {{.*}} 
+// CHECK: LoopHintAttr {{.*}} 
+#pragma unroll(2)
+for (int i = 0; i < 10; ++i);
+
+// CHECK: AttributedStmt {{.*}} 
+// CHECK: LoopHintAttr {{.*}} 
+#pragma clang loop vectorize(enable)
+// CHECK: LoopHintAttr {{.*}} 
+#pragma clang loop interleave(enable)
+for (int i = 0; i < 10; ++i);
+
+// CHECK: AttributedStmt {{.*}} 
+_Pragma("unroll(2)")
+for (int i = 0; i < 10; ++i);
+  }
+}
+
 #if __cplusplus >= 201703L
 // CHECK-1Z: FunctionDecl {{.*}} construct_with_init_list
 std::map construct_with_init_list() {
Index: clang/lib/Parse/ParseStmt.cpp
===
--- clang/lib/Parse/ParseStmt.cpp
+++ clang/lib/Parse/ParseStmt.cpp
@@ -2163,6 +2163,8 @@
   // Create temporary attribute list.
   ParsedAttributesWithRange TempAttrs(AttrFactory);
 
+  SourceLocation StartLoc = Tok.getLocation();
+
   // Get loop hints and consume annotated token.
   while (Tok.is(tok::annot_pragma_loop_hint)) {
 LoopHint Hint;
@@ -2183,6 +2185,10 @@
   Stmts, StmtCtx, TrailingElseLoc, Attrs);
 
   Attrs.takeAllFrom(TempAttrs);
+
+  assert(Attrs.Range.getBegin().isInvalid() &&
+ "start of attribute range already set");
+  Attrs.Range.setBegin(StartLoc);
   ret

[PATCH] D80944: Add begin source location for the attributed statement created from PragmaLoopHint decorated loop

2020-06-09 Thread Yuanfang Chen via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9c2e770034d0: Add begin source location for the attributed 
statement created from… (authored by ychen).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80944

Files:
  clang/lib/Parse/ParsePragma.cpp
  clang/lib/Parse/ParseStmt.cpp
  clang/test/AST/sourceranges.cpp


Index: clang/test/AST/sourceranges.cpp
===
--- clang/test/AST/sourceranges.cpp
+++ clang/test/AST/sourceranges.cpp
@@ -108,6 +108,36 @@
   }
 }
 
+// CHECK: NamespaceDecl {{.*}} attributed_stmt
+namespace attributed_stmt {
+  // In DO_PRAGMA and _Pragma cases, `LoopHintAttr` comes from 
+  // file.
+
+  #define DO_PRAGMA(x) _Pragma (#x)
+
+  void f() {
+// CHECK: AttributedStmt {{.*}} 
+DO_PRAGMA (unroll(2))
+for (int i = 0; i < 10; ++i);
+
+// CHECK: AttributedStmt {{.*}} 
+// CHECK: LoopHintAttr {{.*}} 
+#pragma unroll(2)
+for (int i = 0; i < 10; ++i);
+
+// CHECK: AttributedStmt {{.*}} 
+// CHECK: LoopHintAttr {{.*}} 
+#pragma clang loop vectorize(enable)
+// CHECK: LoopHintAttr {{.*}} 
+#pragma clang loop interleave(enable)
+for (int i = 0; i < 10; ++i);
+
+// CHECK: AttributedStmt {{.*}} 
+_Pragma("unroll(2)")
+for (int i = 0; i < 10; ++i);
+  }
+}
+
 #if __cplusplus >= 201703L
 // CHECK-1Z: FunctionDecl {{.*}} construct_with_init_list
 std::map construct_with_init_list() {
Index: clang/lib/Parse/ParseStmt.cpp
===
--- clang/lib/Parse/ParseStmt.cpp
+++ clang/lib/Parse/ParseStmt.cpp
@@ -2172,6 +2172,8 @@
   // Create temporary attribute list.
   ParsedAttributesWithRange TempAttrs(AttrFactory);
 
+  SourceLocation StartLoc = Tok.getLocation();
+
   // Get loop hints and consume annotated token.
   while (Tok.is(tok::annot_pragma_loop_hint)) {
 LoopHint Hint;
@@ -2192,6 +2194,10 @@
   Stmts, StmtCtx, TrailingElseLoc, Attrs);
 
   Attrs.takeAllFrom(TempAttrs);
+
+  assert(Attrs.Range.getBegin().isInvalid() &&
+ "start of attribute range already set");
+  Attrs.Range.setBegin(StartLoc);
   return S;
 }
 
Index: clang/lib/Parse/ParsePragma.cpp
===
--- clang/lib/Parse/ParsePragma.cpp
+++ clang/lib/Parse/ParsePragma.cpp
@@ -3099,7 +3099,7 @@
 Token LoopHintTok;
 LoopHintTok.startToken();
 LoopHintTok.setKind(tok::annot_pragma_loop_hint);
-LoopHintTok.setLocation(PragmaName.getLocation());
+LoopHintTok.setLocation(Introducer.Loc);
 LoopHintTok.setAnnotationEndLoc(PragmaName.getLocation());
 LoopHintTok.setAnnotationValue(static_cast(Info));
 TokenList.push_back(LoopHintTok);
@@ -3186,7 +3186,7 @@
   auto TokenArray = std::make_unique(1);
   TokenArray[0].startToken();
   TokenArray[0].setKind(tok::annot_pragma_loop_hint);
-  TokenArray[0].setLocation(PragmaName.getLocation());
+  TokenArray[0].setLocation(Introducer.Loc);
   TokenArray[0].setAnnotationEndLoc(PragmaName.getLocation());
   TokenArray[0].setAnnotationValue(static_cast(Info));
   PP.EnterTokenStream(std::move(TokenArray), 1,


Index: clang/test/AST/sourceranges.cpp
===
--- clang/test/AST/sourceranges.cpp
+++ clang/test/AST/sourceranges.cpp
@@ -108,6 +108,36 @@
   }
 }
 
+// CHECK: NamespaceDecl {{.*}} attributed_stmt
+namespace attributed_stmt {
+  // In DO_PRAGMA and _Pragma cases, `LoopHintAttr` comes from 
+  // file.
+
+  #define DO_PRAGMA(x) _Pragma (#x)
+
+  void f() {
+// CHECK: AttributedStmt {{.*}} 
+DO_PRAGMA (unroll(2))
+for (int i = 0; i < 10; ++i);
+
+// CHECK: AttributedStmt {{.*}} 
+// CHECK: LoopHintAttr {{.*}} 
+#pragma unroll(2)
+for (int i = 0; i < 10; ++i);
+
+// CHECK: AttributedStmt {{.*}} 
+// CHECK: LoopHintAttr {{.*}} 
+#pragma clang loop vectorize(enable)
+// CHECK: LoopHintAttr {{.*}} 
+#pragma clang loop interleave(enable)
+for (int i = 0; i < 10; ++i);
+
+// CHECK: AttributedStmt {{.*}} 
+_Pragma("unroll(2)")
+for (int i = 0; i < 10; ++i);
+  }
+}
+
 #if __cplusplus >= 201703L
 // CHECK-1Z: FunctionDecl {{.*}} construct_with_init_list
 std::map construct_with_init_list() {
Index: clang/lib/Parse/ParseStmt.cpp
===
--- clang/lib/Parse/ParseStmt.cpp
+++ clang/lib/Parse/ParseStmt.cpp
@@ -2172,6 +2172,8 @@
   // Create temporary attribute list.
   ParsedAttributesWithRange TempAttrs(AttrFactory);
 
+  SourceLocation StartLoc = Tok.getLocation();
+
   // Get loop hints and consume annotated token.
   while (Tok.is(tok::annot_pragma_loop_hint)) {
 LoopHint Hint;
@@ -2192,6 +2194,10 @@
   Stmts, StmtCtx, TrailingElseLoc, Attrs);
 
   Attrs.takeAllFrom(TempAttrs);
+
+  assert(Attrs.Range.getBegin

[PATCH] D81970: [Clang][Driver] Remove gold linker support for PS4 toolchain

2020-06-16 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen created this revision.
ychen added a reviewer: probinson.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D81970

Files:
  clang/lib/Driver/ToolChains/PS4CPU.cpp
  clang/test/Driver/ps4-linker-non-win.c
  clang/test/Driver/ps4-linker-win.c

Index: clang/test/Driver/ps4-linker-win.c
===
--- clang/test/Driver/ps4-linker-win.c
+++ clang/test/Driver/ps4-linker-win.c
@@ -1,27 +1,32 @@
-// The full path to the gold linker was not found on Windows because the
-// driver fails to add an .exe extension to the name.
-// We check that gold linker's full name (with an extension) is specified
-// on the command line if -fuse-ld=gold, or -shared with no -fuse-ld option
-// are passed. Otherwise, we check that the PS4's linker's full name is
-// specified.
+// This test check that orbis-ld is used for linker all the time. Specifying
+// linker using -fuse-ld causes a error message emitted and compilation fail.
 
 // REQUIRES: system-windows, x86-registered-target
 
 // RUN: mkdir -p %t
 // RUN: touch %t/orbis-ld.exe
-// RUN: touch %t/orbis-ld.gold.exe
-
-// RUN: env "PATH=%t;%PATH%;" %clang -target x86_64-scei-ps4  %s -fuse-ld=gold -### 2>&1 \
-// RUN:   | FileCheck --check-prefix=CHECK-PS4-GOLD %s
-// RUN: env "PATH=%t;%PATH%;" %clang -target x86_64-scei-ps4  %s -shared -### 2>&1 \
-// RUN:   | FileCheck --check-prefix=CHECK-PS4-GOLD %s
 
 // RUN: env "PATH=%t;%PATH%;" %clang -target x86_64-scei-ps4  %s -### 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-PS4-LINKER %s
-// RUN: env "PATH=%t;%PATH%;" %clang -target x86_64-scei-ps4  %s -fuse-ld=ps4 -### 2>&1 \
+// RUN: env "PATH=%t;%PATH%;" %clang -target x86_64-scei-ps4  %s -shared -### 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-PS4-LINKER %s
-// RUN: env "PATH=%t;%PATH%;" %clang -target x86_64-scei-ps4  %s -shared \
-// RUN: -fuse-ld=ps4 -### 2>&1 | FileCheck --check-prefix=CHECK-PS4-LINKER %s
 
-// CHECK-PS4-GOLD: \\orbis-ld.gold
 // CHECK-PS4-LINKER: \\orbis-ld
+
+// RUN: env "PATH=%t;%PATH%;" %clang -### -target x86_64-scei-ps4 -flto=thin %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-PS4-LTO-THIN %s
+// RUN: env "PATH=%t;%PATH%;" %clang -### -target x86_64-scei-ps4 -flto=full %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-PS4-LTO-FULL %s
+// RUN: env "PATH=%t;%PATH%;" %clang -### -target x86_64-scei-ps4  %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-PS4-NO-LTO-THIN --check-prefix=CHECK-PS4-NO-LTO-FULL %s
+
+// CHECK-PS4-LTO-THIN: --lto=thin
+// CHECK-PS4-LTO-FULL: --lto=full
+// CHECK-PS4-NO-LTO-THIN-NOT: --lto=thin
+// CHECK-PS4-NO-LTO-FULL-NOT: --lto=full
+
+// RUN: env "PATH=%t;%PATH%;" %clang -target x86_64-scei-ps4 %s -fuse-ld=gold -### 2>&1 \
+// RUN:   | FileCheck --check-prefix=ERROR %s
+
+// ERROR: error: unsupported option '-fuse-ld' for target 'x86_64-scei-ps4'
+
Index: clang/test/Driver/ps4-linker-non-win.c
===
--- clang/test/Driver/ps4-linker-non-win.c
+++ clang/test/Driver/ps4-linker-non-win.c
@@ -6,16 +6,15 @@
 // RUN: touch %t/orbis-ld
 // RUN: chmod +x %t/orbis-ld
 
-// RUN: env "PATH=%t:%PATH%" %clang -### -target x86_64-scei-ps4  %s -fuse-ld=gold 2>&1 \
-// RUN:   | FileCheck --check-prefix=CHECK-PS4-LINKER %s
-// RUN: env "PATH=%t:%PATH%" %clang -### -target x86_64-scei-ps4  %s -shared 2>&1 \
-// RUN:   | FileCheck --check-prefix=CHECK-PS4-LINKER %s
-
 // RUN: env "PATH=%t:%PATH%" %clang -### -target x86_64-scei-ps4  %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-PS4-LINKER %s
-// RUN: env "PATH=%t:%PATH%" %clang -### -target x86_64-scei-ps4  %s -fuse-ld=ps4 2>&1 \
+// RUN: env "PATH=%t:%PATH%" %clang -### -target x86_64-scei-ps4  %s -shared 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-PS4-LINKER %s
-// RUN: env "PATH=%t:%PATH%" %clang -### -target x86_64-scei-ps4  %s -shared \
-// RUN: -fuse-ld=ps4 2>&1 | FileCheck --check-prefix=CHECK-PS4-LINKER %s
 
 // CHECK-PS4-LINKER: /orbis-ld
+
+// RUN: env "PATH=%t:%PATH%" %clang -### -target x86_64-scei-ps4 %s -fuse-ld=gold 2>&1 \
+// RUN:   | FileCheck --check-prefix=ERROR %s
+
+// ERROR: error: unsupported option '-fuse-ld' for target 'x86_64-scei-ps4'
+
Index: clang/lib/Driver/ToolChains/PS4CPU.cpp
===
--- clang/lib/Driver/ToolChains/PS4CPU.cpp
+++ clang/lib/Driver/ToolChains/PS4CPU.cpp
@@ -88,13 +88,13 @@
 CmdArgs.push_back("--dependent-lib=libSceDbgAddressSanitizer_stub_weak.a");
 }
 
-static void ConstructPS4LinkJob(const Tool &T, Compilation &C,
-const JobAction &JA, const InputInfo &Output,
-const InputInfoList &Inputs,
-const ArgList &Args,
-const char *LinkingOutput) {
+void tools::PS4cpu::Link::ConstructJob(Compilation &C, const 

[PATCH] D81970: [Clang][Driver] Remove gold linker support for PS4 toolchain

2020-06-16 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen updated this revision to Diff 271218.
ychen added a comment.

- update test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81970

Files:
  clang/lib/Driver/ToolChains/PS4CPU.cpp
  clang/test/Driver/ps4-linker-non-win.c
  clang/test/Driver/ps4-linker-win.c

Index: clang/test/Driver/ps4-linker-win.c
===
--- clang/test/Driver/ps4-linker-win.c
+++ clang/test/Driver/ps4-linker-win.c
@@ -1,27 +1,20 @@
-// The full path to the gold linker was not found on Windows because the
-// driver fails to add an .exe extension to the name.
-// We check that gold linker's full name (with an extension) is specified
-// on the command line if -fuse-ld=gold, or -shared with no -fuse-ld option
-// are passed. Otherwise, we check that the PS4's linker's full name is
-// specified.
+// This test check that orbis-ld is used for linker all the time. Specifying
+// linker using -fuse-ld causes a error message emitted and compilation fail.
 
 // REQUIRES: system-windows, x86-registered-target
 
 // RUN: mkdir -p %t
 // RUN: touch %t/orbis-ld.exe
-// RUN: touch %t/orbis-ld.gold.exe
-
-// RUN: env "PATH=%t;%PATH%;" %clang -target x86_64-scei-ps4  %s -fuse-ld=gold -### 2>&1 \
-// RUN:   | FileCheck --check-prefix=CHECK-PS4-GOLD %s
-// RUN: env "PATH=%t;%PATH%;" %clang -target x86_64-scei-ps4  %s -shared -### 2>&1 \
-// RUN:   | FileCheck --check-prefix=CHECK-PS4-GOLD %s
 
 // RUN: env "PATH=%t;%PATH%;" %clang -target x86_64-scei-ps4  %s -### 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-PS4-LINKER %s
-// RUN: env "PATH=%t;%PATH%;" %clang -target x86_64-scei-ps4  %s -fuse-ld=ps4 -### 2>&1 \
+// RUN: env "PATH=%t;%PATH%;" %clang -target x86_64-scei-ps4  %s -shared -### 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-PS4-LINKER %s
-// RUN: env "PATH=%t;%PATH%;" %clang -target x86_64-scei-ps4  %s -shared \
-// RUN: -fuse-ld=ps4 -### 2>&1 | FileCheck --check-prefix=CHECK-PS4-LINKER %s
 
-// CHECK-PS4-GOLD: \\orbis-ld.gold
 // CHECK-PS4-LINKER: \\orbis-ld
+
+// RUN: env "PATH=%t;%PATH%;" %clang -target x86_64-scei-ps4 %s -fuse-ld=gold -### 2>&1 \
+// RUN:   | FileCheck --check-prefix=ERROR %s
+
+// ERROR: error: unsupported option '-fuse-ld' for target 'x86_64-scei-ps4'
+
Index: clang/test/Driver/ps4-linker-non-win.c
===
--- clang/test/Driver/ps4-linker-non-win.c
+++ clang/test/Driver/ps4-linker-non-win.c
@@ -6,16 +6,15 @@
 // RUN: touch %t/orbis-ld
 // RUN: chmod +x %t/orbis-ld
 
-// RUN: env "PATH=%t:%PATH%" %clang -### -target x86_64-scei-ps4  %s -fuse-ld=gold 2>&1 \
-// RUN:   | FileCheck --check-prefix=CHECK-PS4-LINKER %s
-// RUN: env "PATH=%t:%PATH%" %clang -### -target x86_64-scei-ps4  %s -shared 2>&1 \
-// RUN:   | FileCheck --check-prefix=CHECK-PS4-LINKER %s
-
 // RUN: env "PATH=%t:%PATH%" %clang -### -target x86_64-scei-ps4  %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-PS4-LINKER %s
-// RUN: env "PATH=%t:%PATH%" %clang -### -target x86_64-scei-ps4  %s -fuse-ld=ps4 2>&1 \
+// RUN: env "PATH=%t:%PATH%" %clang -### -target x86_64-scei-ps4  %s -shared 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-PS4-LINKER %s
-// RUN: env "PATH=%t:%PATH%" %clang -### -target x86_64-scei-ps4  %s -shared \
-// RUN: -fuse-ld=ps4 2>&1 | FileCheck --check-prefix=CHECK-PS4-LINKER %s
 
 // CHECK-PS4-LINKER: /orbis-ld
+
+// RUN: env "PATH=%t:%PATH%" %clang -### -target x86_64-scei-ps4 %s -fuse-ld=gold 2>&1 \
+// RUN:   | FileCheck --check-prefix=ERROR %s
+
+// ERROR: error: unsupported option '-fuse-ld' for target 'x86_64-scei-ps4'
+
Index: clang/lib/Driver/ToolChains/PS4CPU.cpp
===
--- clang/lib/Driver/ToolChains/PS4CPU.cpp
+++ clang/lib/Driver/ToolChains/PS4CPU.cpp
@@ -88,13 +88,13 @@
 CmdArgs.push_back("--dependent-lib=libSceDbgAddressSanitizer_stub_weak.a");
 }
 
-static void ConstructPS4LinkJob(const Tool &T, Compilation &C,
-const JobAction &JA, const InputInfo &Output,
-const InputInfoList &Inputs,
-const ArgList &Args,
-const char *LinkingOutput) {
+void tools::PS4cpu::Link::ConstructJob(Compilation &C, const JobAction &JA,
+   const InputInfo &Output,
+   const InputInfoList &Inputs,
+   const ArgList &Args,
+   const char *LinkingOutput) const {
   const toolchains::FreeBSD &ToolChain =
-  static_cast(T.getToolChain());
+  static_cast(getToolChain());
   const Driver &D = ToolChain.getDriver();
   ArgStringList CmdArgs;
 
@@ -143,216 +143,17 @@
 CmdArgs.push_back("-lpthread");
   }
 
-  const char *Exec = Args.MakeArgString(ToolChain.GetProgramPath("orbis-ld"))

[PATCH] D80944: Add begin source location for the attributed statement created from PragmaLoopHint decorated loop

2020-06-16 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added a comment.

In D80944#2095564 , @erichkeane wrote:

> Note that this causes a regression (reported here) 
> https://bugs.llvm.org/show_bug.cgi?id=46336
>
> The assert added here breaks in the case where a pragma loop attribute is 
> combined with a C++ attribute.


Resolved with
4676cf444ea2678660ee48279be99efde4bf60e9 

8c6c606cdc72c3ddd55f382d91ef1afc3cb9f2a8 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80944



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


[PATCH] D81970: [Clang][Driver] Remove gold linker support for PS4 toolchain

2020-06-16 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen updated this revision to Diff 271237.
ychen added a comment.

- clang-format


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81970

Files:
  clang/lib/Driver/ToolChains/PS4CPU.cpp
  clang/test/Driver/ps4-linker-non-win.c
  clang/test/Driver/ps4-linker-win.c

Index: clang/test/Driver/ps4-linker-win.c
===
--- clang/test/Driver/ps4-linker-win.c
+++ clang/test/Driver/ps4-linker-win.c
@@ -1,27 +1,19 @@
-// The full path to the gold linker was not found on Windows because the
-// driver fails to add an .exe extension to the name.
-// We check that gold linker's full name (with an extension) is specified
-// on the command line if -fuse-ld=gold, or -shared with no -fuse-ld option
-// are passed. Otherwise, we check that the PS4's linker's full name is
-// specified.
+// This test check that orbis-ld is used for linker all the time. Specifying
+// linker using -fuse-ld causes a error message emitted and compilation fail.
 
 // REQUIRES: system-windows, x86-registered-target
 
 // RUN: mkdir -p %t
 // RUN: touch %t/orbis-ld.exe
-// RUN: touch %t/orbis-ld.gold.exe
-
-// RUN: env "PATH=%t;%PATH%;" %clang -target x86_64-scei-ps4  %s -fuse-ld=gold -### 2>&1 \
-// RUN:   | FileCheck --check-prefix=CHECK-PS4-GOLD %s
-// RUN: env "PATH=%t;%PATH%;" %clang -target x86_64-scei-ps4  %s -shared -### 2>&1 \
-// RUN:   | FileCheck --check-prefix=CHECK-PS4-GOLD %s
 
 // RUN: env "PATH=%t;%PATH%;" %clang -target x86_64-scei-ps4  %s -### 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-PS4-LINKER %s
-// RUN: env "PATH=%t;%PATH%;" %clang -target x86_64-scei-ps4  %s -fuse-ld=ps4 -### 2>&1 \
+// RUN: env "PATH=%t;%PATH%;" %clang -target x86_64-scei-ps4  %s -shared -### 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-PS4-LINKER %s
-// RUN: env "PATH=%t;%PATH%;" %clang -target x86_64-scei-ps4  %s -shared \
-// RUN: -fuse-ld=ps4 -### 2>&1 | FileCheck --check-prefix=CHECK-PS4-LINKER %s
 
-// CHECK-PS4-GOLD: \\orbis-ld.gold
 // CHECK-PS4-LINKER: \\orbis-ld
+
+// RUN: env "PATH=%t;%PATH%;" %clang -target x86_64-scei-ps4 %s -fuse-ld=gold -### 2>&1 \
+// RUN:   | FileCheck --check-prefix=ERROR %s
+
+// ERROR: error: unsupported option '-fuse-ld' for target 'x86_64-scei-ps4'
Index: clang/test/Driver/ps4-linker-non-win.c
===
--- clang/test/Driver/ps4-linker-non-win.c
+++ clang/test/Driver/ps4-linker-non-win.c
@@ -6,16 +6,14 @@
 // RUN: touch %t/orbis-ld
 // RUN: chmod +x %t/orbis-ld
 
-// RUN: env "PATH=%t:%PATH%" %clang -### -target x86_64-scei-ps4  %s -fuse-ld=gold 2>&1 \
-// RUN:   | FileCheck --check-prefix=CHECK-PS4-LINKER %s
-// RUN: env "PATH=%t:%PATH%" %clang -### -target x86_64-scei-ps4  %s -shared 2>&1 \
-// RUN:   | FileCheck --check-prefix=CHECK-PS4-LINKER %s
-
 // RUN: env "PATH=%t:%PATH%" %clang -### -target x86_64-scei-ps4  %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-PS4-LINKER %s
-// RUN: env "PATH=%t:%PATH%" %clang -### -target x86_64-scei-ps4  %s -fuse-ld=ps4 2>&1 \
+// RUN: env "PATH=%t:%PATH%" %clang -### -target x86_64-scei-ps4  %s -shared 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-PS4-LINKER %s
-// RUN: env "PATH=%t:%PATH%" %clang -### -target x86_64-scei-ps4  %s -shared \
-// RUN: -fuse-ld=ps4 2>&1 | FileCheck --check-prefix=CHECK-PS4-LINKER %s
 
 // CHECK-PS4-LINKER: /orbis-ld
+
+// RUN: env "PATH=%t:%PATH%" %clang -### -target x86_64-scei-ps4 %s -fuse-ld=gold 2>&1 \
+// RUN:   | FileCheck --check-prefix=ERROR %s
+
+// ERROR: error: unsupported option '-fuse-ld' for target 'x86_64-scei-ps4'
Index: clang/lib/Driver/ToolChains/PS4CPU.cpp
===
--- clang/lib/Driver/ToolChains/PS4CPU.cpp
+++ clang/lib/Driver/ToolChains/PS4CPU.cpp
@@ -88,13 +88,13 @@
 CmdArgs.push_back("--dependent-lib=libSceDbgAddressSanitizer_stub_weak.a");
 }
 
-static void ConstructPS4LinkJob(const Tool &T, Compilation &C,
-const JobAction &JA, const InputInfo &Output,
-const InputInfoList &Inputs,
-const ArgList &Args,
-const char *LinkingOutput) {
+void tools::PS4cpu::Link::ConstructJob(Compilation &C, const JobAction &JA,
+   const InputInfo &Output,
+   const InputInfoList &Inputs,
+   const ArgList &Args,
+   const char *LinkingOutput) const {
   const toolchains::FreeBSD &ToolChain =
-  static_cast(T.getToolChain());
+  static_cast(getToolChain());
   const Driver &D = ToolChain.getDriver();
   ArgStringList CmdArgs;
 
@@ -143,216 +143,17 @@
 CmdArgs.push_back("-lpthread");
   }
 
-  const char *Exec = Args.MakeArgString(ToolChain.GetProgramPath("orbis-ld"));
-

[PATCH] D81970: [Clang][Driver] Remove gold linker support for PS4 toolchain

2020-06-17 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen updated this revision to Diff 271394.
ychen added a comment.

- address comment


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81970

Files:
  clang/lib/Driver/ToolChains/PS4CPU.cpp
  clang/test/Driver/ps4-linker-non-win.c
  clang/test/Driver/ps4-linker-win.c

Index: clang/test/Driver/ps4-linker-win.c
===
--- clang/test/Driver/ps4-linker-win.c
+++ clang/test/Driver/ps4-linker-win.c
@@ -1,27 +1,19 @@
-// The full path to the gold linker was not found on Windows because the
-// driver fails to add an .exe extension to the name.
-// We check that gold linker's full name (with an extension) is specified
-// on the command line if -fuse-ld=gold, or -shared with no -fuse-ld option
-// are passed. Otherwise, we check that the PS4's linker's full name is
-// specified.
+// This test check that orbis-ld is used for linker all the time. Specifying
+// linker using -fuse-ld causes a error message emitted and compilation fail.
 
 // REQUIRES: system-windows, x86-registered-target
 
 // RUN: mkdir -p %t
 // RUN: touch %t/orbis-ld.exe
-// RUN: touch %t/orbis-ld.gold.exe
-
-// RUN: env "PATH=%t;%PATH%;" %clang -target x86_64-scei-ps4  %s -fuse-ld=gold -### 2>&1 \
-// RUN:   | FileCheck --check-prefix=CHECK-PS4-GOLD %s
-// RUN: env "PATH=%t;%PATH%;" %clang -target x86_64-scei-ps4  %s -shared -### 2>&1 \
-// RUN:   | FileCheck --check-prefix=CHECK-PS4-GOLD %s
 
 // RUN: env "PATH=%t;%PATH%;" %clang -target x86_64-scei-ps4  %s -### 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-PS4-LINKER %s
-// RUN: env "PATH=%t;%PATH%;" %clang -target x86_64-scei-ps4  %s -fuse-ld=ps4 -### 2>&1 \
+// RUN: env "PATH=%t;%PATH%;" %clang -target x86_64-scei-ps4  %s -shared -### 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-PS4-LINKER %s
-// RUN: env "PATH=%t;%PATH%;" %clang -target x86_64-scei-ps4  %s -shared \
-// RUN: -fuse-ld=ps4 -### 2>&1 | FileCheck --check-prefix=CHECK-PS4-LINKER %s
 
-// CHECK-PS4-GOLD: \\orbis-ld.gold
 // CHECK-PS4-LINKER: \\orbis-ld
+
+// RUN: env "PATH=%t;%PATH%;" %clang -target x86_64-scei-ps4 %s -fuse-ld=gold -### 2>&1 \
+// RUN:   | FileCheck --check-prefix=ERROR %s
+
+// ERROR: error: unsupported option '-fuse-ld' for target 'x86_64-scei-ps4'
Index: clang/test/Driver/ps4-linker-non-win.c
===
--- clang/test/Driver/ps4-linker-non-win.c
+++ clang/test/Driver/ps4-linker-non-win.c
@@ -6,16 +6,14 @@
 // RUN: touch %t/orbis-ld
 // RUN: chmod +x %t/orbis-ld
 
-// RUN: env "PATH=%t:%PATH%" %clang -### -target x86_64-scei-ps4  %s -fuse-ld=gold 2>&1 \
-// RUN:   | FileCheck --check-prefix=CHECK-PS4-LINKER %s
-// RUN: env "PATH=%t:%PATH%" %clang -### -target x86_64-scei-ps4  %s -shared 2>&1 \
-// RUN:   | FileCheck --check-prefix=CHECK-PS4-LINKER %s
-
 // RUN: env "PATH=%t:%PATH%" %clang -### -target x86_64-scei-ps4  %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-PS4-LINKER %s
-// RUN: env "PATH=%t:%PATH%" %clang -### -target x86_64-scei-ps4  %s -fuse-ld=ps4 2>&1 \
+// RUN: env "PATH=%t:%PATH%" %clang -### -target x86_64-scei-ps4  %s -shared 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-PS4-LINKER %s
-// RUN: env "PATH=%t:%PATH%" %clang -### -target x86_64-scei-ps4  %s -shared \
-// RUN: -fuse-ld=ps4 2>&1 | FileCheck --check-prefix=CHECK-PS4-LINKER %s
 
 // CHECK-PS4-LINKER: /orbis-ld
+
+// RUN: env "PATH=%t:%PATH%" %clang -### -target x86_64-scei-ps4 %s -fuse-ld=gold 2>&1 \
+// RUN:   | FileCheck --check-prefix=ERROR %s
+
+// ERROR: error: unsupported option '-fuse-ld' for target 'x86_64-scei-ps4'
Index: clang/lib/Driver/ToolChains/PS4CPU.cpp
===
--- clang/lib/Driver/ToolChains/PS4CPU.cpp
+++ clang/lib/Driver/ToolChains/PS4CPU.cpp
@@ -88,13 +88,13 @@
 CmdArgs.push_back("--dependent-lib=libSceDbgAddressSanitizer_stub_weak.a");
 }
 
-static void ConstructPS4LinkJob(const Tool &T, Compilation &C,
-const JobAction &JA, const InputInfo &Output,
-const InputInfoList &Inputs,
-const ArgList &Args,
-const char *LinkingOutput) {
+void tools::PS4cpu::Link::ConstructJob(Compilation &C, const JobAction &JA,
+   const InputInfo &Output,
+   const InputInfoList &Inputs,
+   const ArgList &Args,
+   const char *LinkingOutput) const {
   const toolchains::FreeBSD &ToolChain =
-  static_cast(T.getToolChain());
+  static_cast(getToolChain());
   const Driver &D = ToolChain.getDriver();
   ArgStringList CmdArgs;
 
@@ -143,216 +143,15 @@
 CmdArgs.push_back("-lpthread");
   }
 
-  const char *Exec = Args.MakeArgString(ToolChain.GetProgramPath("orbis-ld"))

[PATCH] D81970: [Clang][Driver] Remove gold linker support for PS4 toolchain

2020-06-17 Thread Yuanfang Chen via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG2956cc50f340: [Clang][Driver] Remove gold linker support for 
PS4 toolchain (authored by ychen).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81970

Files:
  clang/lib/Driver/ToolChains/PS4CPU.cpp
  clang/test/Driver/ps4-linker-non-win.c
  clang/test/Driver/ps4-linker-win.c

Index: clang/test/Driver/ps4-linker-win.c
===
--- clang/test/Driver/ps4-linker-win.c
+++ clang/test/Driver/ps4-linker-win.c
@@ -1,27 +1,19 @@
-// The full path to the gold linker was not found on Windows because the
-// driver fails to add an .exe extension to the name.
-// We check that gold linker's full name (with an extension) is specified
-// on the command line if -fuse-ld=gold, or -shared with no -fuse-ld option
-// are passed. Otherwise, we check that the PS4's linker's full name is
-// specified.
+// This test check that orbis-ld is used for linker all the time. Specifying
+// linker using -fuse-ld causes a error message emitted and compilation fail.
 
 // REQUIRES: system-windows, x86-registered-target
 
 // RUN: mkdir -p %t
 // RUN: touch %t/orbis-ld.exe
-// RUN: touch %t/orbis-ld.gold.exe
-
-// RUN: env "PATH=%t;%PATH%;" %clang -target x86_64-scei-ps4  %s -fuse-ld=gold -### 2>&1 \
-// RUN:   | FileCheck --check-prefix=CHECK-PS4-GOLD %s
-// RUN: env "PATH=%t;%PATH%;" %clang -target x86_64-scei-ps4  %s -shared -### 2>&1 \
-// RUN:   | FileCheck --check-prefix=CHECK-PS4-GOLD %s
 
 // RUN: env "PATH=%t;%PATH%;" %clang -target x86_64-scei-ps4  %s -### 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-PS4-LINKER %s
-// RUN: env "PATH=%t;%PATH%;" %clang -target x86_64-scei-ps4  %s -fuse-ld=ps4 -### 2>&1 \
+// RUN: env "PATH=%t;%PATH%;" %clang -target x86_64-scei-ps4  %s -shared -### 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-PS4-LINKER %s
-// RUN: env "PATH=%t;%PATH%;" %clang -target x86_64-scei-ps4  %s -shared \
-// RUN: -fuse-ld=ps4 -### 2>&1 | FileCheck --check-prefix=CHECK-PS4-LINKER %s
 
-// CHECK-PS4-GOLD: \\orbis-ld.gold
 // CHECK-PS4-LINKER: \\orbis-ld
+
+// RUN: env "PATH=%t;%PATH%;" %clang -target x86_64-scei-ps4 %s -fuse-ld=gold -### 2>&1 \
+// RUN:   | FileCheck --check-prefix=ERROR %s
+
+// ERROR: error: unsupported option '-fuse-ld' for target 'x86_64-scei-ps4'
Index: clang/test/Driver/ps4-linker-non-win.c
===
--- clang/test/Driver/ps4-linker-non-win.c
+++ clang/test/Driver/ps4-linker-non-win.c
@@ -6,16 +6,14 @@
 // RUN: touch %t/orbis-ld
 // RUN: chmod +x %t/orbis-ld
 
-// RUN: env "PATH=%t:%PATH%" %clang -### -target x86_64-scei-ps4  %s -fuse-ld=gold 2>&1 \
-// RUN:   | FileCheck --check-prefix=CHECK-PS4-LINKER %s
-// RUN: env "PATH=%t:%PATH%" %clang -### -target x86_64-scei-ps4  %s -shared 2>&1 \
-// RUN:   | FileCheck --check-prefix=CHECK-PS4-LINKER %s
-
 // RUN: env "PATH=%t:%PATH%" %clang -### -target x86_64-scei-ps4  %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-PS4-LINKER %s
-// RUN: env "PATH=%t:%PATH%" %clang -### -target x86_64-scei-ps4  %s -fuse-ld=ps4 2>&1 \
+// RUN: env "PATH=%t:%PATH%" %clang -### -target x86_64-scei-ps4  %s -shared 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-PS4-LINKER %s
-// RUN: env "PATH=%t:%PATH%" %clang -### -target x86_64-scei-ps4  %s -shared \
-// RUN: -fuse-ld=ps4 2>&1 | FileCheck --check-prefix=CHECK-PS4-LINKER %s
 
 // CHECK-PS4-LINKER: /orbis-ld
+
+// RUN: env "PATH=%t:%PATH%" %clang -### -target x86_64-scei-ps4 %s -fuse-ld=gold 2>&1 \
+// RUN:   | FileCheck --check-prefix=ERROR %s
+
+// ERROR: error: unsupported option '-fuse-ld' for target 'x86_64-scei-ps4'
Index: clang/lib/Driver/ToolChains/PS4CPU.cpp
===
--- clang/lib/Driver/ToolChains/PS4CPU.cpp
+++ clang/lib/Driver/ToolChains/PS4CPU.cpp
@@ -88,13 +88,13 @@
 CmdArgs.push_back("--dependent-lib=libSceDbgAddressSanitizer_stub_weak.a");
 }
 
-static void ConstructPS4LinkJob(const Tool &T, Compilation &C,
-const JobAction &JA, const InputInfo &Output,
-const InputInfoList &Inputs,
-const ArgList &Args,
-const char *LinkingOutput) {
+void tools::PS4cpu::Link::ConstructJob(Compilation &C, const JobAction &JA,
+   const InputInfo &Output,
+   const InputInfoList &Inputs,
+   const ArgList &Args,
+   const char *LinkingOutput) const {
   const toolchains::FreeBSD &ToolChain =
-  static_cast(T.getToolChain());
+  static_cast(getToolChain());
   const Driver &D = ToolChain.getDriver();
   ArgStringList CmdArgs;
 
@@ -143,216 +143,15 @@
 CmdArgs.push_b

[PATCH] D83519: [NewPM] Support optnone under new pass manager

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



Comment at: llvm/include/llvm/IR/PassInstrumentation.h:150
 for (auto &C : Callbacks->BeforePassCallbacks)
-  ShouldRun &= C(Pass.name(), llvm::Any(&IR));
+  ShouldRun &= C(Pass.name(), Pass.isRequired(), llvm::Any(&IR));
 return ShouldRun;

Could we do this to not changing the callback API?
`ShouldRun &= C(Pass.name(), llvm::Any(&IR)) || Pass.isRequired();`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83519



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


[PATCH] D83519: [NewPM] Support optnone under new pass manager

2020-07-10 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added a comment.

High-level request: how about split this patch into two, the first for the 
`require` pass part; the second for the PassInstrument callback. Then we could 
discuss the choices of first patch and D82344 .




Comment at: llvm/include/llvm/IR/PassInstrumentation.h:150
 for (auto &C : Callbacks->BeforePassCallbacks)
-  ShouldRun &= C(Pass.name(), llvm::Any(&IR));
+  ShouldRun &= C(Pass.name(), Pass.isRequired(), llvm::Any(&IR));
 return ShouldRun;

aeubanks wrote:
> aeubanks wrote:
> > ychen wrote:
> > > Could we do this to not changing the callback API?
> > > `ShouldRun &= C(Pass.name(), llvm::Any(&IR)) || Pass.isRequired();`
> > Each pass instrumentation should decide whether or not to run the pass 
> > based on whether or not the pass is required or optional. An optional pass 
> > may still be run, (which should be the case for the vast majority of 
> > instances).
> > 
> > For example, the optnone would only care if a pass is required or not if it 
> > sees that a function is marked optnone.
> > Similarly, opt-bisect would only care if a pass is required if it's hit the 
> > bisect limit.
> Sorry, now I understand what you mean, the ands and ors confused me.
> 
> I don't want to rule out the possibility of some future pass instrumentation 
> wanting to skip even a required pass. But I am open to discussion on this 
> point.
> I don't want to rule out the possibility of some future pass instrumentation 
> wanting to skip even a required pass. But I am open to discussion on this 
> point.

That makes sense. However, since this requires changing the callback API(return 
value or parameter), and there is no real use of it for the moment. IMHO we 
should defer it to the use case comes up. If there was no change to the 
callback API, I wouldn't mind doing this for now.

The immediate motivation for the `require` is the same as D82344 (the approach 
is a little bit different). That's we don't want to consider infrastructure 
passes (pass managers, adaptor passes that have a nested pass manager)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83519



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


[PATCH] D84774: [NewPM][PassInstrument] Add PrintPass callback to StandardInstrumentations

2020-07-30 Thread Yuanfang Chen via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG555cf42f380d: [NewPM][PassInstrument] Add PrintPass callback 
to StandardInstrumentations (authored by ychen).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84774

Files:
  clang/test/CodeGen/thinlto-distributed-newpm.ll
  llvm/include/llvm/IR/PassInstrumentation.h
  llvm/include/llvm/IR/PassManager.h
  llvm/include/llvm/IR/PassManagerImpl.h
  llvm/include/llvm/Passes/StandardInstrumentations.h
  llvm/lib/Analysis/CGSCCPassManager.cpp
  llvm/lib/IR/PassInstrumentation.cpp
  llvm/lib/IR/PassTimingInfo.cpp
  llvm/lib/Passes/StandardInstrumentations.cpp
  llvm/lib/Transforms/Scalar/LoopPassManager.cpp
  llvm/test/Other/loop-pm-invalidation.ll
  llvm/test/Other/new-pass-manager.ll
  llvm/test/Other/new-pm-defaults.ll
  llvm/test/Other/new-pm-lto-defaults.ll
  llvm/test/Other/new-pm-pgo.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/Other/new-pm-thinlto-prelink-pgo-defaults.ll
  llvm/test/Other/new-pm-thinlto-prelink-samplepgo-defaults.ll
  llvm/test/Other/pass-pipeline-parsing.ll
  llvm/test/Transforms/LoopRotate/pr35210.ll
  llvm/test/Transforms/LoopUnroll/revisit.ll
  llvm/test/Transforms/LoopUnroll/unroll-loop-invalidation.ll
  llvm/test/Transforms/SCCP/ipsccp-preserve-analysis.ll

Index: llvm/test/Transforms/SCCP/ipsccp-preserve-analysis.ll
===
--- llvm/test/Transforms/SCCP/ipsccp-preserve-analysis.ll
+++ llvm/test/Transforms/SCCP/ipsccp-preserve-analysis.ll
@@ -19,7 +19,6 @@
 ; NEW-PM-NEXT: Invalidating all non-preserved analyses for:
 ; NEW-PM-NEXT: Invalidating all non-preserved analyses for: f1
 ; NEW-PM-NEXT: Invalidating all non-preserved analyses for: f2
-; NEW-PM-NEXT: Running pass: ModuleToFunctionPassAdaptor
 ; NEW-PM-NOT: Running analysis:
 
 ; IR-LABEL: @f1
Index: llvm/test/Transforms/LoopUnroll/unroll-loop-invalidation.ll
===
--- llvm/test/Transforms/LoopUnroll/unroll-loop-invalidation.ll
+++ llvm/test/Transforms/LoopUnroll/unroll-loop-invalidation.ll
@@ -6,20 +6,19 @@
 ; RUN: opt -S -passes='loop(require),loop-unroll,loop(print-access-info)' -debug-pass-manager < %s 2>&1 | FileCheck %s
 ;
 ; CHECK: Starting llvm::Function pass manager run.
-; CHECK: Running pass: FunctionToLoopPassAdaptor
 ; CHECK: Running analysis: LoopAnalysis
 ; CHECK: Running analysis: InnerAnalysisManagerProxy<
 ; CHECK: Starting Loop pass manager run.
 ; CHECK: Running pass: RequireAnalysisPass<{{.*}}LoopAccessAnalysis
-; CHECK: Running analysis: LoopAccessAnalysis on inner1.header
+; CHECK: Running analysis: LoopAccessAnalysis on Loop at depth 2 containing: %inner1.header
 ; CHECK: Finished Loop pass manager run.
 ; CHECK: Starting Loop pass manager run.
 ; CHECK: Running pass: RequireAnalysisPass<{{.*}}LoopAccessAnalysis
-; CHECK: Running analysis: LoopAccessAnalysis on inner2.header
+; CHECK: Running analysis: LoopAccessAnalysis on Loop at depth 2 containing: %inner2.header
 ; CHECK: Finished Loop pass manager run.
 ; CHECK: Starting Loop pass manager run.
 ; CHECK: Running pass: RequireAnalysisPass<{{.*}}LoopAccessAnalysis
-; CHECK: Running analysis: LoopAccessAnalysis on outer.header
+; CHECK: Running analysis: LoopAccessAnalysis on Loop at depth 1 containing: %outer.header
 ; CHECK: Finished Loop pass manager run.
 ; CHECK: Running pass: LoopUnrollPass
 ; CHECK: Clearing all analysis results for: inner2.header
@@ -29,16 +28,15 @@
 ; CHECK: Invalidating analysis: LoopAccessAnalysis on inner1.header
 ; CHECK: Invalidating all non-preserved analyses for: inner1.header.1
 ; CHECK-NOT: Invalidating analysis: LoopAccessAnalysis on inner1.header.1
-; CHECK: Running pass: FunctionToLoopPassAdaptor
 ; CHECK: Starting Loop pass manager run.
 ; CHECK: Running pass: LoopAccessInfoPrinterPass
-; CHECK: Running analysis: LoopAccessAnalysis on inner1.header
+; CHECK: Running analysis: LoopAccessAnalysis on Loop at depth 1 containing: %inner1.header
 ; CHECK: Loop access info in function 'test':
 ; CHECK:   inner1.header:
 ; CHECK: Finished Loop pass manager run.
 ; CHECK: Starting Loop pass manager run.
 ; CHECK: Running pass: LoopAccessInfoPrinterPass
-; CHECK: Running analysis: LoopAccessAnalysis on inner1.header.1
+; CHECK: Running analysis: LoopAccessAnalysis on Loop at depth 1 containing: %inner1.header.1
 ; CHECK: Loop access info in function 'test':
 ; CHECK:   inner1.header.1:
 ; CHECK: Finished Loop pass manager run.
Index: llvm/test/Transforms/LoopUnroll/revisit.ll
===
--- llvm/test/Transforms/LoopUnroll/revisit.ll
+++ llvm/test/Transforms/LoopUnroll/revisit.ll
@@ -15

[PATCH] D84886: Create LoopNestPass

2020-08-02 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added a comment.

I think this needs unit tests like LoopPassManagerTest.cpp (in that file or a 
similarly named file) to demonstrate the expected behavior: the expected usage 
comparing with LoopPass/LoopAnalysisPass, how the adaptor is used and the 
invalidation interaction within its pass manager and other pass managers.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84886

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


[PATCH] D85457: [NewPM][optnone] Mark various passes as required

2020-08-07 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added a comment.

Looks reasonable to me. Please let @asbirlea double-check.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85457

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


[PATCH] D85676: [NewPM] collapsing nested pass mangers of the same type

2020-08-10 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen created this revision.
ychen added reviewers: asbirlea, chandlerc.
Herald added subscribers: llvm-commits, cfe-commits, dexonsmith, steven_wu, 
hiraditya.
Herald added projects: clang, LLVM.
ychen requested review of this revision.

This is one of the reason for extra invalidations in D84959 
. In
practice, I don't think we have use cases needing this. This simplifies
the pipeline a bit and prune corner cases when considering
invalidations.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D85676

Files:
  clang/test/CodeGen/thinlto-distributed-newpm.ll
  llvm/include/llvm/IR/PassManager.h
  llvm/test/Other/new-pass-manager.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/Other/new-pm-thinlto-prelink-pgo-defaults.ll
  llvm/test/Other/new-pm-thinlto-prelink-samplepgo-defaults.ll
  llvm/test/Other/pass-pipeline-parsing.ll

Index: llvm/test/Other/pass-pipeline-parsing.ll
===
--- llvm/test/Other/pass-pipeline-parsing.ll
+++ llvm/test/Other/pass-pipeline-parsing.ll
@@ -10,11 +10,9 @@
 ; RUN: -passes='module(no-op-module,no-op-module)' %s 2>&1 \
 ; RUN: | FileCheck %s --check-prefix=CHECK-NESTED-TWO-NOOP-MP
 ; CHECK-NESTED-TWO-NOOP-MP: Starting llvm::Module pass manager run
-; CHECK-NESTED-TWO-NOOP-MP: Starting llvm::Module pass manager run
 ; CHECK-NESTED-TWO-NOOP-MP: Running pass: NoOpModulePass
 ; CHECK-NESTED-TWO-NOOP-MP: Running pass: NoOpModulePass
 ; CHECK-NESTED-TWO-NOOP-MP: Finished llvm::Module pass manager run
-; CHECK-NESTED-TWO-NOOP-MP: Finished llvm::Module pass manager run
 
 ; RUN: opt -disable-output -debug-pass-manager \
 ; RUN: -passes=no-op-function,no-op-function %s 2>&1 \
@@ -112,7 +110,6 @@
 ; RUN: -passes='module(function(no-op-function),cgscc(no-op-cgscc,function(no-op-function),no-op-cgscc),function(no-op-function))' %s 2>&1 \
 ; RUN: | FileCheck %s --check-prefix=CHECK-NESTED-MP-CG-FP
 ; CHECK-NESTED-MP-CG-FP: Starting llvm::Module pass manager run
-; CHECK-NESTED-MP-CG-FP: Starting llvm::Module pass manager run
 ; CHECK-NESTED-MP-CG-FP: Starting llvm::Function pass manager run
 ; CHECK-NESTED-MP-CG-FP: Running pass: NoOpFunctionPass
 ; CHECK-NESTED-MP-CG-FP: Finished llvm::Function pass manager run
@@ -127,7 +124,6 @@
 ; CHECK-NESTED-MP-CG-FP: Running pass: NoOpFunctionPass
 ; CHECK-NESTED-MP-CG-FP: Finished llvm::Function pass manager run
 ; CHECK-NESTED-MP-CG-FP: Finished llvm::Module pass manager run
-; CHECK-NESTED-MP-CG-FP: Finished llvm::Module pass manager run
 
 ; RUN: opt -disable-output -debug-pass-manager \
 ; RUN: -passes='no-op-loop,no-op-loop' %s 2>&1 \
@@ -165,7 +161,6 @@
 ; RUN: -passes='module(no-op-function,no-op-loop,no-op-cgscc,cgscc(no-op-function,no-op-loop),function(no-op-loop))' %s 2>&1 \
 ; RUN: | FileCheck %s --check-prefix=CHECK-ADAPTORS
 ; CHECK-ADAPTORS: Starting llvm::Module pass manager run
-; CHECK-ADAPTORS: Starting llvm::Module pass manager run
 ; CHECK-ADAPTORS: Running pass: ModuleToFunctionPassAdaptor<{{.*}}NoOpFunctionPass>
 ; CHECK-ADAPTORS: Running pass: NoOpFunctionPass
 ; CHECK-ADAPTORS: Running pass: ModuleToFunctionPassAdaptor<{{.*}}FunctionToLoopPassAdaptor<{{.*}}NoOpLoopPass>{{.*}}>
@@ -187,7 +182,6 @@
 ; CHECK-ADAPTORS: Running pass: NoOpLoopPass on Loop at depth 1 containing: %loop
 ; CHECK-ADAPTORS: Finished llvm::Function pass manager run
 ; CHECK-ADAPTORS: Finished llvm::Module pass manager run
-; CHECK-ADAPTORS: Finished llvm::Module pass manager run
 
 ; RUN: opt -disable-output -debug-pass-manager \
 ; RUN: -passes='cgscc(print)' %s 2>&1 \
Index: llvm/test/Other/new-pm-thinlto-prelink-samplepgo-defaults.ll
===
--- llvm/test/Other/new-pm-thinlto-prelink-samplepgo-defaults.ll
+++ llvm/test/Other/new-pm-thinlto-prelink-samplepgo-defaults.ll
@@ -26,12 +26,10 @@
 ; RUN: | FileCheck %s --check-prefixes=CHECK-DIS,CHECK-O,CHECK-O2,CHECK-O23SZ,CHECK-O123 --dump-input=fail
 ;
 ; CHECK-O: Starting {{.*}}Module pass manager run.
-; CHECK-O-NEXT: Starting {{.*}}Module pass manager run.
 ; CHECK-O-NEXT: Running pass: ForceFunctionAttrsPass
 ; CHECK-O-NEXT: Running analysis: InnerAnalysisManagerProxy
 ; CHECK-O-NEXT: Running pass: AddDiscriminatorsPass
 ; CHECK-EP-PIPELINE-START-NEXT: Running pass: NoOpModulePass
-; CHECK-O-NEXT: Starting {{.*}}Module pass manager run.
 ; CHECK-O-NEXT: Running pass: InferFunctionAttrsPass
 ; CHECK-O-NEXT: Running analysis: TargetLibraryAnalysis
 ; CHECK-O-NEXT: Starting {{.*}}Function pass manager run.
@@ -171,9 +169,7 @@
 ; CHECK-O-NEXT: Finished {{.*}}Function pass manager run.
 ; CHECK-O-NEXT: Finished CGSCC pass manager run.
 ; CHECK-O-NEXT: Finished {{.*}}Module pass manager run.
-;

[PATCH] D84886: Create LoopNestPass

2020-08-11 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added a comment.

Hello, sorry for the late reply. I have some high-level questions

- What are existing and future loop passes/analyses that could benefit from 
using LoopNestPass?
- I'd feel more comfortable if existing loop pass/analysis managers could be 
extended to handle LoopNestPass, rather than have separate full-fledged 
managers. Implementation aside, this models the idea that loopnest is just a 
special kind of loop, not a fundamental different IR unit. Have you thought 
about the alternative design of adding new adaptors or extending existing loop 
managers to run/query/invalidate loopnest passes?
- I'm not sure how common loopnest analyses are or will be? What's your opinion?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84886

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


[PATCH] D86008: [test] Fix aggregate-assign-call.c in preparation for -enable-npm-optnone

2020-08-14 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen accepted this revision.
ychen 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/D86008/new/

https://reviews.llvm.org/D86008

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


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

2022-08-29 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added a comment.

ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131820

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


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

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

- add a release note.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132592

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


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


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

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

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

- update


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131820

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


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


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

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

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

- use `--target`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131820

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


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


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

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

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

- update


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131820

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


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


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

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

2022-08-29 Thread Yuanfang Chen via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG70248bfdea6c: [Clang] Implement function attribute nouwtable 
(authored by ychen).

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

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132592

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


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


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

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

2022-08-29 Thread Yuanfang Chen via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG288576f474f2: [PS4][driver] make -fjmc work with LTO driver 
linking stage (authored by ychen).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131820

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


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


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

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

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

- handle constrained placeholder [pack] types


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128750

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

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

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

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

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


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128750

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


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

2022-08-30 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen updated this revision to Diff 456743.
ychen marked an inline comment as done.
ychen added a comment.

- For function templates, compare canonical types of funtion parameters 
directly.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128750

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

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

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

2022-08-30 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added a comment.

In D128750#3758750 , @mizvekov wrote:

> Just a first glance at the patch, will try to do a more comprehensive review 
> later.

Thanks!




Comment at: clang/lib/Sema/SemaTemplateInstantiate.cpp:1838
 
-QualType Replacement = Arg.getAsType();
 

mizvekov wrote:
> I think this change could be masking a bug.
> 
> The arguments to an instantiation should always be canonical.
> 
> We could implement one day instantiation with non-canonical args, but this 
> would not be the only change required to get this to work.
> 
> And regardless it should be done in separate patch with proper test cases :)
Agreed.

It turns out this is because I was using injected template arguments to 
instantiate a function declaration (to compare function parameter types between 
two function templates). The injected template type arguments seem to be not 
canonical. 

Now I realized that I don't need this instantiation. Comparing the function 
parameter canonical types directly should be fine since the template parameters 
are uniqued by their kind/index/level etc. which is comparable between two 
function templates.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128750

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


[PATCH] D133052: [clang] Avoid crash when expanding conversion templates in concepts.

2022-08-31 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added a comment.

Like mentioned in 
https://stackoverflow.com/questions/68853472/is-this-a-bug-in-clangs-c20-concepts-implementation-unnecessary-checking-of,
 could we not go down the path of considering conversion candidates? It seems 
that's blessed by the standard.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133052

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


[PATCH] D133052: [clang] Avoid crash when expanding conversion templates in concepts.

2022-08-31 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added a comment.

In D133052#3763041 , @luken-google 
wrote:

> In D133052#3762596 , @ychen wrote:
>
>> Like mentioned in 
>> https://stackoverflow.com/questions/68853472/is-this-a-bug-in-clangs-c20-concepts-implementation-unnecessary-checking-of,
>>  could we not go down the path of considering conversion candidates? It 
>> seems that's blessed by the standard.
>
> If I'm understanding the code correctly, the intent of this patch is to 
> definitely consider conversion candidates, only to exclude those conversion 
> candidates that are templated methods where the From type is the same as the 
> To type, which to me mean they are possibly redundant?

Excluding them is basically saying "because it may be a redundant conversion, 
we should not consider it as the best via function." which doesn't seem correct 
to me.

I think the straightforward approach would be to check if we're in the 
`ConstraintCheck` instantiation context, and if so check if any template 
parameter is constrained by the same concept. However, I'm worried about the 
overhead. So I'd prefer to skip this add-conv-candicates-for-copy-elision path 
(https://github.com/llvm/llvm-project/blob/main/clang/lib/Sema/SemaInit.cpp#L4012-L4053)
 during the concept check. The compiler guarantees copy elision under certain 
conditions (C++17) but I could not think of any situation that users want to or 
could check copy elision inside the concept. So I think we're safe.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133052

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


[PATCH] D133052: [clang] Avoid crash when expanding conversion templates in concepts.

2022-09-01 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen accepted this revision.
ychen added a comment.
This revision is now accepted and ready to land.

In D133052#3763983 , @luken-google 
wrote:

> In D133052#3763201 , @ychen wrote:
>
>> In D133052#3763041 , @luken-google 
>> wrote:
>>
>>> In D133052#3762596 , @ychen wrote:
>>>
 Like mentioned in 
 https://stackoverflow.com/questions/68853472/is-this-a-bug-in-clangs-c20-concepts-implementation-unnecessary-checking-of,
  could we not go down the path of considering conversion candidates? It 
 seems that's blessed by the standard.
>>>
>>> If I'm understanding the code correctly, the intent of this patch is to 
>>> definitely consider conversion candidates, only to exclude those conversion 
>>> candidates that are templated methods where the From type is the same as 
>>> the To type, which to me mean they are possibly redundant?
>>
>> Excluding them is basically saying "because it may be a redundant 
>> conversion, we should not consider it as the best via function." which 
>> doesn't seem correct to me.
>>
>> I think the straightforward approach would be to check if we're in the 
>> `ConstraintCheck` instantiation context, and if so check if any template 
>> parameter is constrained by the same concept. However, I'm worried about the 
>> overhead. So I'd prefer to skip this add-conv-candicates-for-copy-elision 
>> path 
>> (https://github.com/llvm/llvm-project/blob/main/clang/lib/Sema/SemaInit.cpp#L4012-L4053)
>>  during the concept check. The compiler guarantees copy elision under 
>> certain conditions (C++17) but I could not think of any situation that users 
>> want to or could check copy elision inside the concept. So I think we're 
>> safe.
>
> Thanks for your suggestion, I didn't know about the context member in Sema. I 
> agree I think this is a much better approach than my original. While looping 
> the code is in the `RequirementInstantiation` context, so that's the one I've 
> keyed off here. Please let me know if this is what you had in mind.

LGTM. Thanks. That's what I have in mind. The patch needs a rebase though.

For future reference, I want to mention that the infinite recursion could 
happen in many other ways inside require expression. I'm not sure it is 
possible or worthwhile to check them all. I think we should do this check for 
the copy elision path because making conv-functions candidates are merely 
Clang's implementation detail about copy elision, the standard does not dictate 
*how* to perform copy elision. So avoiding infinite recursion in this path is 
better for user experiences.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133052

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


[PATCH] D133052: [clang] Avoid crash when expanding conversion templates in concepts.

2022-09-01 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added inline comments.



Comment at: clang/lib/Sema/SemaInit.cpp:4012
 
+  // Avoid an infinite template expansion loop in requirements checking by
+  // skipping the conversion functions check.

Would be better to check this lazily (inside the if statement below).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133052

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


[PATCH] D133052: [clang] Avoid crash when expanding conversion templates in concepts.

2022-09-01 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen requested changes to this revision.
ychen added a comment.
This revision now requires changes to proceed.

Oh, one more thing, we probably need to handle nested levels too, for example, 
`foo(a);` might be triggered by a template which may be in turn triggered by 
the concept check. So only checking `S.CodeSynthesisContexts.back()` seems not 
enough. We need to check if we're in concept check context regardless of 
instantiation levels.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133052

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


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

2022-09-06 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen marked 4 inline comments as done.
ychen added a comment.

@mizvekov thanks for the detailed review. It helped me a lot in reconsidering 
the auto type handling.




Comment at: clang/include/clang/Sema/SemaConcept.h:48-52
+  if (ArgA.getKind() == TemplateArgument::Expression &&
+  ArgB.getKind() == TemplateArgument::Expression &&
+  ArgA.getAsExpr()->getType()->isUndeducedAutoType() &&
+  ArgB.getAsExpr()->getType()->isUndeducedAutoType())
+continue;

mizvekov wrote:
> Why are looking at only the type of the expression?
> The expression can be arbitrarily different, but as long as they are both 
> undeduced auto, that is okay?
In the partial ordering context, the expression is the same explicit template 
argument. So we could treat two undeduced autos as equal. 

This code is to deal with the fact that, `AuoType` is currently being uniqued 
on type constrained, which goes against the spirit of P2113R0 which considers 
type constraints only when the two types are equivalent.

I think the more neat way is to unique auto template parameter with the kind of 
placeholder type (`auto`, `auto*`, `auto&`, `decltype(auto)`, ...), and its 
template parameter depth/index. Then we don't need the workaround here and I 
could simplify the code in `SemaTemplateDeduction.cpp` too. WDYT?



Comment at: clang/include/clang/Sema/SemaConcept.h:54-68
+  if (ArgA.getKind() == TemplateArgument::Type &&
+  ArgB.getKind() == TemplateArgument::Type)
+if (const auto *SubstA =
+ArgA.getAsType()->getAs())
+  if (const auto *SubstB =
+  ArgB.getAsType()->getAs()) {
+QualType ReplacementA = SubstA->getReplacementType();

mizvekov wrote:
> It's a bit odd to find `SubstTemplateTypeParmType` necessary to implement the 
> semantics of this change.
> 
> This is just type sugar we leave behind in the template instantiator to mark 
> where type replacement happened.
> 
> There are several potential issues here:
> 1) This could be marking a substitution that happened at any template depth. 
> Ie this could be marking a substitution from an outer template. Does the 
> level not matter here at all? 
> 2) If the level does matter, you won't be able to reconstitute that easily 
> without further improvements. See 
> https://github.com/llvm/llvm-project/issues/55886 for example.
> 3) A substitution can replace a dependent type for another one, and when that 
> other gets replaced, we lose track of that because 
> `SubstTemplateTypeParmType` only holds a canonical underlying type.
> 
> 
> 
> Leaving that aside, I get the impression you are trying to work around the 
> fact that when an expression appears in a canonical type, presumably because 
> that expression is dependent on an NTTP, we can't rely on uniquing anymore to 
> compare if they are the same type, as we lack in Clang the equivalent concept 
> of canonicalization for expressions.
> 
> But this however is a bit hard to implement. Are we sure the standard 
> requires this, or can we simply consider these types always different?
> It's a bit odd to find SubstTemplateTypeParmType necessary to implement the 
> semantics of this change.

Odd indeed. 

> Leaving that aside, I get the impression you are trying to work around the 
> fact that when an expression appears in a canonical type, presumably because 
> that expression is dependent on an NTTP, we can't rely on uniquing anymore to 
> compare if they are the same type, as we lack in Clang the equivalent concept 
> of canonicalization for expressions.

Yeah, sort of . This workaround is to deal with the fact that `DecltypeType` is 
not uniqued. However, the injected template argument for `t` of `template` is `decltype(t)` (which on a side note, might be wrong since `auto` means 
using template arg deduct rules; `decltype(auto)` means using `decltype(expr)` 
type, let's keep it this way now since this code path is still needed when 
Clang starts to support `decltype(auto)` as NTTP type) and concepts partial 
ordering rules need to compare these concept template arguments 
(https://eel.is/c++draft/temp.constr#atomic-1). 

Looking at the motivation why `DecltypeType` is not uniqued 
(https://github.com/llvm/llvm-project/blob/main/clang/lib/AST/ASTContext.cpp#L5637-L5640),
 I think maybe we should unique decltype on the expr to deal with concepts 
cleanly. Thoughts?



Comment at: clang/lib/AST/ASTContext.cpp:5154-5156
+  E = new (*this) PackExpansionExpr(
+  NTTPType->isUndeducedAutoType() ? NTTPType : DependentTy, E,
+  NTTP->getLocation(), None);

mizvekov wrote:
> I don't know if this change is necessary for this patch, as this looks part 
> of the workaround in `SemaConcept.h`,
> but I think a better way to preserve the type here might be to always use 
> `NTTPType`, but then add an additional `Dependent` parame

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

2022-09-11 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added a comment.

Hi @mizvekov , I noticed that deduction for partial ordering also inherits this 
new behavior. Do you think partial ordering could opt out of this, or is it 
better for partial ordering to deal with the new sugared types?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111283

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


[PATCH] D133683: [c++] implements tentative DR1432 for partial ordering of function template

2022-09-12 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen created this revision.
ychen added reviewers: aaron.ballman, erichkeane.
Herald added a project: All.
ychen requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

D128745  handled DR1432 for the partial 
ordering of partial specializations, but
missed the handling for the partial ordering of function templates. This patch
implements the latter. While at it, also simplies the previous implementation to
be more close the wording without funtional changes.

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


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D133683

Files:
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/test/CXX/drs/dr6xx.cpp

Index: clang/test/CXX/drs/dr6xx.cpp
===
--- clang/test/CXX/drs/dr6xx.cpp
+++ clang/test/CXX/drs/dr6xx.cpp
@@ -1083,13 +1083,18 @@
   // Also see dr1395.
 
   namespace temp_func_order_example2 {
-template  struct A {};
-template  void f(U, A *p = 0); // expected-note {{candidate}}
+template  struct A {}; // expected-error 0-1{{C++11}}
+template  void e(A) = delete; // expected-error 0-2{{C++11}}
+template  void e(A);
+template  void f(U, A *p = 0) = delete; // expected-note {{candidate}} expected-error 0-1{{C++11}}
 template  int &f(U, A *p = 0); // expected-note {{candidate}}
 template  void g(T, T = T()); // expected-note {{candidate}}
 template  void g(T, U...); // expected-note {{candidate}} expected-error 0-1{{C++11}}
 void h() {
-  int &r = f(42, (A *)0);
+  A a;
+  int &r = f(42, &a);
+  A b;
+  e(b);
   f(42); // expected-error {{ambiguous}}
   g(42); // expected-error {{ambiguous}}
 }
Index: clang/lib/Sema/SemaTemplateDeduction.cpp
===
--- clang/lib/Sema/SemaTemplateDeduction.cpp
+++ clang/lib/Sema/SemaTemplateDeduction.cpp
@@ -5187,6 +5187,32 @@
   return FT1;
   }
 
+  // Consider this a fix for CWG1432. Similar to the fix for CWG1395.
+  bool ClangABICompat15 =
+  Context.getLangOpts().getClangABICompat() <= LangOptions::ClangABI::Ver15;
+  if (!ClangABICompat15) {
+for (int i = 0, e = std::min(NumParams1, NumParams2); i < e; ++i) {
+  QualType T1 = FD1->getParamDecl(i)->getType().getDesugaredType(Context);
+  QualType T2 = FD2->getParamDecl(i)->getType().getDesugaredType(Context);
+  auto *TST1 = dyn_cast(T1);
+  auto *TST2 = dyn_cast(T2);
+  if (TST1 && TST2) {
+unsigned NumArgs1 = TST1->getNumArgs();
+unsigned NumArgs2 = TST2->getNumArgs();
+bool IsPackExpansion1 =
+NumArgs1 && TST1->template_arguments().back().isPackExpansion();
+bool IsPackExpansion2 =
+NumArgs2 && TST2->template_arguments().back().isPackExpansion();
+if (NumArgs1 != NumArgs2 && IsPackExpansion1 != IsPackExpansion2) {
+  if (NumArgs1 > NumArgs2 && IsPackExpansion1)
+return FT2;
+  if (NumArgs1 < NumArgs2 && IsPackExpansion2)
+return FT1;
+}
+  }
+}
+  }
+
   return JudgeByConstraints();
 }
 
@@ -5422,31 +5448,29 @@
 return nullptr;
 
   if (Better1 && Better2) {
+// Consider this a fix for CWG1432. Similar to the fix for CWG1395.
 bool ClangABICompat15 = S.Context.getLangOpts().getClangABICompat() <=
 LangOptions::ClangABI::Ver15;
 if (!ClangABICompat15) {
-  // Consider this a fix for CWG1432. Similar to the fix for CWG1395.
   auto *TST1 = T1->castAs();
   auto *TST2 = T2->castAs();
-  if (TST1->getNumArgs()) {
-const TemplateArgument &TA1 = TST1->template_arguments().back();
-if (TA1.getKind() == TemplateArgument::Pack) {
-  assert(TST1->getNumArgs() == TST2->getNumArgs());
-  const TemplateArgument &TA2 = TST2->template_arguments().back();
-  assert(TA2.getKind() == TemplateArgument::Pack);
-  unsigned PackSize1 = TA1.pack_size();
-  unsigned PackSize2 = TA2.pack_size();
-  bool IsPackExpansion1 =
-  PackSize1 && TA1.pack_elements().back().isPackExpansion();
-  bool IsPackExpansion2 =
-  PackSize2 && TA2.pack_elements().back().isPackExpansion();
-  if (PackSize1 != PackSize2 && IsPackExpansion1 != IsPackExpansion2) {
-if (PackSize1 > PackSize2 && IsPackExpansion1)
-  return GetP2()(P1, P2);
-if (PackSize1 < PackSize2 && IsPackExpansion2)
-  return P1;
-  }
-}
+  const TemplateArgument &TA1 = TST1->template_arguments().back();
+  const TemplateArgument &TA2 = TST2->template_arguments().back();
+  unsigned PackSize1 =
+  TA1.getKind() == TemplateArgument::Pack ? TA1.pack_size() : 0u;
+  unsigned PackSize2 =
+  TA2.getKind() == TemplateArgument::Pack ? TA2.pack_size() : 0u

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

2022-09-12 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added a comment.

In D111283#3783338 , @mizvekov wrote:

> In D111283#3783250 , @ychen wrote:
>
>> Hi @mizvekov , I noticed that deduction for partial ordering also inherits 
>> this new behavior. Do you think partial ordering could opt out of this, or 
>> is it better for partial ordering to deal with the new sugared types?
>
> I would expect partial ordering to be performed only using canonical types, 
> that type sugar should make no difference there.
>
> Note that previous to this patch, we would already produce sugar on 
> deduction, but the behavior with regards to deducing the same template 
> parameter from multiple places was pretty badly behaved: We would just keep 
> the sugar from the first deduction, and ignore any subsequent ones. That 
> meant that the deduction order had an effect on the result. With this patch, 
> deduction becomes order agnostic.

I see. I  think it is definitely a good thing. I'm still learning what the 
expected AST should look like during the partial ordering.

> What kind of difference are you seeing?

For

  template  struct A {};
  
  template 
  bool foo(A);
  
  template 
  bool foo(A);
  
  template  bool bar()
  {
  return foo(Tuple{});
  }

`A` is currently modeled as ElaboratedType. It was 
`TemplateSpecializationType` before. Reading comments for `ElaboratedType`, it 
looks like sugar type might not be needed here?

  ElaboratedType 0xd79c8f0 'A' sugar dependent
  `-TemplateSpecializationType 0xd79c8b0 'A' dependent A
`-TemplateArgument type 'T'
  `-TemplateTypeParmType 0xd79c7f0 'T' dependent depth 0 index 0
`-TemplateTypeParm 0xd79c768 'T'


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111283

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


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

2022-09-12 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added a comment.

In D111283#3784648 , @mizvekov wrote:

> In D111283#3784615 , @ychen wrote:
>
>> `A` is currently modeled as ElaboratedType. It was 
>> `TemplateSpecializationType` before. Reading comments for `ElaboratedType`, 
>> it looks like sugar type might not be needed here?
>
> Ah you might be seeing an ElaboratedTYpe here, where there was none before, 
> perhaps because of https://reviews.llvm.org/D112374, and not because of this 
> patch.
>
> Yeah ElaboratedType is just sugar that should have no effect on partial 
> ordering. But then I think no sugar should have effect on partial ordering. 
> What is stopping you from just looking at the canonical type instead? On a 
> canonical type, you would never see an ElaboratedType node, or a 
> TemplateSpecializationType which is not dependent.

Thanks for the link. I'm not blocked by any of these patches, instead just 
trying to have a mental model of when to expect the sugared type :-). For 
partial ordering, the `TemplateSpecializationType` could be dependent, since 
the injected template arguments are dependent, I guess that's the reason there 
is the `ElaboratedType`?

> Is this related to the AutoType canonicalization issues we were discussing in 
> the other patch of yours?

Nope. I found this AST difference while investigating D133683 
.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111283

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


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

2022-09-12 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added a comment.

In D111283#3784702 , @mizvekov wrote:

> In D111283#3784663 , @ychen wrote:
>
>> Thanks for the link. I'm not blocked by any of these patches, instead just 
>> trying to have a mental model of when to expect the sugared type :-). For 
>> partial ordering, the `TemplateSpecializationType` could be dependent, since 
>> the injected template arguments are dependent, I guess that's the reason 
>> there is the `ElaboratedType`?
>
> The ElaboratedType is a sort of a `companion node` to other nodes that 
> represent things in the language which can have (non-dependent) nested name 
> qualifiers (a NNS for short) and / or an elaborated type specifier (such as 
> the `struct` in `struct A`).
>
> It's only purpose is to carry that extra bit of data, like some external 
> storage really, and it shouldn't affect the semantics of the program once the 
> source code is parsed into an AST.
>
> Here, in your example, the ElaboratedType is there, as a companion to that 
> TemplateSpecializationType, just to say that this template specialization was 
> written without any name qualifiers nor elaboration.

Very helpful explanation :-).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111283

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


[PATCH] D133683: [c++] implements tentative DR1432 for partial ordering of function template

2022-09-13 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added a comment.

@mizvekov Thanks for taking a look.




Comment at: clang/lib/Sema/SemaTemplateDeduction.cpp:5195-5196
+for (int i = 0, e = std::min(NumParams1, NumParams2); i < e; ++i) {
+  QualType T1 = FD1->getParamDecl(i)->getType().getDesugaredType(Context);
+  QualType T2 = FD2->getParamDecl(i)->getType().getDesugaredType(Context);
+  auto *TST1 = dyn_cast(T1);

mizvekov wrote:
> This should work, as all the properties you are testing below are present on 
> the canonical type.
Gotta admit that I was confused by `DesugaredType` and `CanonicalType`.  But 
since you pointed it out, I could see the differences now. The `CanonicalType` 
could be sugared, and desugaring is not necessary here. Thanks.



Comment at: clang/lib/Sema/SemaTemplateDeduction.cpp:5455-5456
 if (!ClangABICompat15) {
-  // Consider this a fix for CWG1432. Similar to the fix for CWG1395.
   auto *TST1 = T1->castAs();
   auto *TST2 = T2->castAs();
+  const TemplateArgument &TA1 = TST1->template_arguments().back();

mizvekov wrote:
> This is a bug, T1 and T2 are not in general canonical types for this 
> function, and this castAs can pick up an alias template, and these should 
> never participate in deduction.
> 
> (Also, can you please add a test for that?)
> 
> You should not need to keep sugar here, everything being tested below is 
> present on the canonical type, so this is simple to solve, as suggested.
I see. I'll add a test.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133683

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


[PATCH] D133341: [C++] [Coroutines] Prefer aligned (de)allocation for coroutines - implement the option2 of P2014R0

2022-09-13 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added a comment.

It surprises me that Option 2 does not change 
https://eel.is/c++draft/dcl.fct.def.coroutine#10. For consistency, I think it 
should. And according to your test case, it deals with alignment as expected. 
Probably we should change the P2014R0 wording accordingly. Before that, let's 
just mention this difference in the Clang release notes.




Comment at: clang/docs/ClangCommandLineReference.rst:1580
+
+Enable support for P2014R0 Option2, which will always pursue the aligned 
allocation function.
+This option is disabled by default.





Comment at: clang/docs/ReleaseNotes.rst:152-154
+- Implemented `-fcoro-aligned-allocation` flag. This option2 implement
+  option2 for P2014R0 aligned allocation of coroutine frames
+  (`P2014R0 
`_).





Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:11283
+def err_conflicting_aligned_options : Error <
+  "conflicting option '-fcoro-aligned-allocation' and 
'-fno-aligned-allocation'"
 >;

Since we're digressing from the usual operator new/delete look-up rules per 
Option 2, I think it might be easier to just *not* respect 
`-fno-aligned-allocation` and `-fno-sized-deallocation`. Using 
'-fcoro-aligned-allocation' explicitly should permit us to assume these 
functions could be found.



Comment at: clang/include/clang/Basic/LangOptions.def:157
 LANGOPT(Coroutines, 1, 0, "C++20 coroutines")
+LANGOPT(CoroAlignedAllocation, 1, 0, "prefer Aligned Allocation according to 
P2014's option2")
 LANGOPT(DllExportInlines  , 1, 1, "dllexported classes dllexport inline 
methods")





Comment at: clang/lib/Sema/SemaCoroutine.cpp:1302-1318
   // According to [dcl.fct.def.coroutine]p9, Lookup allocation functions using 
a
   // parameter list composed of the requested size of the coroutine state being
   // allocated, followed by the coroutine function's arguments. If a matching
   // allocation function exists, use it. Otherwise, use an allocation function
   // that just takes the requested size.
   //
   // [dcl.fct.def.coroutine]p9

Update comment here.



Comment at: clang/lib/Sema/SemaCoroutine.cpp:1400
 
+  // If we found a non-aligned allocation function in the promise_type,
+  // it indicates the user forgot to update the allocation function. Let's emit

Option 2's order of look-up is 
```
void* T::operator new  ( std::size_t count, std::align_val_t al, 
user-defined-args... );
void* T::operator new  ( std::size_t count, std::align_val_t al);
void* T::operator new  ( std::size_t count, user-defined-args... );
void* T::operator new  ( std::size_t count);
void* operator new  ( std::size_t count, std::align_val_t al );
```
Why not allow `void* T::operator new  ( std::size_t count);` here?



Comment at: clang/test/CodeGenCoroutines/coro-aligned-alloc.cpp:94
+void return_value(int) {}
+void operator delete(void *ptr, std::align_val_t);
+  };

Please add test cases for 
```
void operator delete  ( void* ptr, std::size_t, std::align_val_t);
void operator delete  ( void* ptr, std::size_t);
void operator delete  ( void* ptr);
void ::operator delete  ( void* ptr, std::size_t, std::align_val_t);
void ::operator delete  ( void* ptr, std::size_t);
void ::operator delete  ( void* ptr);
```
in that lookup order, and makes sure the look-up order is expected.


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

https://reviews.llvm.org/D133341

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


[PATCH] D133341: [C++] [Coroutines] Prefer aligned (de)allocation for coroutines - implement the option2 of P2014R0

2022-09-13 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added inline comments.



Comment at: clang/test/SemaCXX/coroutine-alloc-4.cpp:49
+void return_value(int) {}
+void *operator new(std::size_t, std::align_val_t) noexcept;
+void *operator new(std::size_t) noexcept;

Like this test case, please add additional test cases to check the expected 
look-up order, one test for each consecutive pair should be good.

```
void* T::operator new  ( std::size_t count, std::align_val_t al, 
user-defined-args... );
void* T::operator new  ( std::size_t count, std::align_val_t al);
void* T::operator new  ( std::size_t count, user-defined-args... );
void* T::operator new  ( std::size_t count);
void* operator new  ( std::size_t count, std::align_val_t al );
```




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

https://reviews.llvm.org/D133341

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


[PATCH] D133341: [C++] [Coroutines] Prefer aligned (de)allocation for coroutines - implement the option2 of P2014R0

2022-09-14 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added a comment.

Looks great. Just a few more nits.




Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:11280
+def warn_non_aligned_allocation_function : Warning <
+  "found non aligned allocation function for coroutine %0">,
+  InGroup;

"under `-fcoro-aligned-allocation`, the non-aligned allocation function for the 
promise type %0 has higher precedence than the global aligned allocation 
function"



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:11283
+def err_conflicting_aligned_options : Error <
+  "conflicting option '-fcoro-aligned-allocation' and 
'-fno-aligned-allocation'"
 >;

ChuanqiXu wrote:
> ychen wrote:
> > Since we're digressing from the usual operator new/delete look-up rules per 
> > Option 2, I think it might be easier to just *not* respect 
> > `-fno-aligned-allocation` and `-fno-sized-deallocation`. Using 
> > '-fcoro-aligned-allocation' explicitly should permit us to assume these 
> > functions could be found.
> I guess it may not be good to enable `-fsized-deallocation` automatically if 
> `-fcoro-aligned-allocation` enabled. Since it looks like there are other 
> reasons why we disabled `-fsized-deallocation` before. And it looks it will 
> block our users to use `-fcoro-aligned-allocation`. For the 
> `-faligned-allocation` flag, this is enabled by default but people could 
> disable it explicitly. So the check here is for that.
You're right. It is better to diagnose the conflicting intent.



Comment at: clang/lib/Sema/SemaCoroutine.cpp:1425
+  if (HavePlacementArgs)
+collectPlacementArgs(S, FD, Loc, PlacementArgs);
+  LookupAllocationFunction(/*NewScope*/ Sema::AFS_Class,

Micro-optimization: instead of recomputing this, add a flag `bool 
WithoutPlacementArgs` to LookupAllocationFunction to switch between an empty 
vector and `PlacementArgs`.



Comment at: clang/test/CodeGenCoroutines/coro-aligned-alloc.cpp:94
+void return_value(int) {}
+void operator delete(void *ptr, std::align_val_t);
+  };

ChuanqiXu wrote:
> ychen wrote:
> > Please add test cases for 
> > ```
> > void operator delete  ( void* ptr, std::size_t, std::align_val_t);
> > void operator delete  ( void* ptr, std::size_t);
> > void operator delete  ( void* ptr);
> > void ::operator delete  ( void* ptr, std::size_t, std::align_val_t);
> > void ::operator delete  ( void* ptr, std::size_t);
> > void ::operator delete  ( void* ptr);
> > ```
> > in that lookup order, and makes sure the look-up order is expected.
> I've tried my best. But it looks hard to test these operator delete under 
> global namespace since they are automatically declared by the compiler.
Thanks for adding these. It looks great! I wouldn't worry about the global ones 
since this patch did not change their look-up order. 



Comment at: clang/test/SemaCXX/coroutine-alloc-4.cpp:49
+void return_value(int) {}
+void *operator new(std::size_t, std::align_val_t) noexcept;
+void *operator new(std::size_t) noexcept;

ChuanqiXu wrote:
> ychen wrote:
> > Like this test case, please add additional test cases to check the expected 
> > look-up order, one test for each consecutive pair should be good.
> > 
> > ```
> > void* T::operator new  ( std::size_t count, std::align_val_t al, 
> > user-defined-args... );
> > void* T::operator new  ( std::size_t count, std::align_val_t al);
> > void* T::operator new  ( std::size_t count, user-defined-args... );
> > void* T::operator new  ( std::size_t count);
> > void* operator new  ( std::size_t count, std::align_val_t al );
> > ```
> > 
> > 
> Yeah, I'm testing this in CodeGenCoroutines. (It is hard to test the 
> selection in Sema Test)
Thanks for adding the overload. I think the `noexcept` on operator new is not 
necessary. Strictly speaking, it is not a conforming API.


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

https://reviews.llvm.org/D133341

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


[PATCH] D115844: [ubsan] Using metadata instead of prologue data for function sanitizer

2022-06-27 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen updated this revision to Diff 440329.
ychen marked an inline comment as done.
ychen added a comment.

Update LangRef.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115844

Files:
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/CodeGenModule.h
  clang/lib/Driver/SanitizerArgs.cpp
  clang/test/CodeGen/ubsan-function.cpp
  clang/test/CodeGenCXX/catch-undef-behavior.cpp
  clang/test/CodeGenCXX/ubsan-function-noexcept.cpp
  clang/test/Driver/fsanitize.c
  llvm/docs/LangRef.rst
  llvm/include/llvm/IR/FixedMetadataKinds.def
  llvm/include/llvm/IR/MDBuilder.h
  llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
  llvm/lib/IR/MDBuilder.cpp
  llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
  llvm/test/CodeGen/X86/func-sanitizer.ll

Index: llvm/test/CodeGen/X86/func-sanitizer.ll
===
--- /dev/null
+++ llvm/test/CodeGen/X86/func-sanitizer.ll
@@ -0,0 +1,18 @@
+; RUN: llc -mtriple=x86_64-unknown-linux-gnu < %s | FileCheck %s
+
+; CHECK: _Z3funv:
+; CHECK: .cfi_startproc
+; CHECK: .long   846595819
+; CHECK: .long   .L__llvm_rtti_proxy-_Z3funv
+; CHECK: .L__llvm_rtti_proxy:
+; CHECK: .quad   i
+; CHECK: .size   .L__llvm_rtti_proxy, 8
+
+@i = linkonce_odr constant i32 1
+@__llvm_rtti_proxy = private unnamed_addr constant i32* @i
+
+define dso_local void @_Z3funv() !func_sanitize !0 {
+  ret void
+}
+
+!0 = !{i32 846595819, i32** @__llvm_rtti_proxy}
Index: llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
===
--- llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
+++ llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
@@ -1217,7 +1217,11 @@
 /// Check if \p G has been created by a trusted compiler pass.
 static bool GlobalWasGeneratedByCompiler(GlobalVariable *G) {
   // Do not instrument @llvm.global_ctors, @llvm.used, etc.
-  if (G->getName().startswith("llvm."))
+  if (G->getName().startswith("llvm.") ||
+  // Do not instrument gcov counter arrays.
+  G->getName().startswith("__llvm_gcov_ctr") ||
+  // Do not instrument rtti proxy symbols for function sanitizer.
+  G->getName().startswith("__llvm_rtti_proxy"))
 return true;
 
   // Do not instrument asan globals.
@@ -1226,10 +1230,6 @@
   G->getName().startswith(kODRGenPrefix))
 return true;
 
-  // Do not instrument gcov counter arrays.
-  if (G->getName() == "__llvm_gcov_ctr")
-return true;
-
   return false;
 }
 
Index: llvm/lib/IR/MDBuilder.cpp
===
--- llvm/lib/IR/MDBuilder.cpp
+++ llvm/lib/IR/MDBuilder.cpp
@@ -150,6 +150,14 @@
   return MDNode::get(Context, Ops);
 }
 
+MDNode *MDBuilder::createRTTIPointerPrologue(Constant *PrologueSig,
+ Constant *RTTI) {
+  SmallVector Ops;
+  Ops.push_back(createConstant(PrologueSig));
+  Ops.push_back(createConstant(RTTI));
+  return MDNode::get(Context, Ops);
+}
+
 MDNode *MDBuilder::createAnonymousAARoot(StringRef Name, MDNode *Extra) {
   SmallVector Args(1, nullptr);
   if (Extra)
Index: llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
===
--- llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
+++ llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
@@ -1004,6 +1004,24 @@
   // Emit the prologue data.
   if (F.hasPrologueData())
 emitGlobalConstant(F.getParent()->getDataLayout(), F.getPrologueData());
+
+  // Emit the function prologue data for the indirect call sanitizer.
+  if (const MDNode *MD = F.getMetadata(LLVMContext::MD_func_sanitize)) {
+assert(TM.getTargetTriple().getArch() == Triple::x86 ||
+   TM.getTargetTriple().getArch() == Triple::x86_64);
+assert(MD->getNumOperands() == 2);
+
+auto *PrologueSig = mdconst::extract(MD->getOperand(0));
+auto *FTRTTIProxy = mdconst::extract(MD->getOperand(1));
+assert(PrologueSig && FTRTTIProxy);
+emitGlobalConstant(F.getParent()->getDataLayout(), PrologueSig);
+
+const MCExpr *Proxy = lowerConstant(FTRTTIProxy);
+const MCExpr *FnExp = MCSymbolRefExpr::create(CurrentFnSym, OutContext);
+const MCExpr *PCRel = MCBinaryExpr::createSub(Proxy, FnExp, OutContext);
+// Use 32 bit since only small code model is supported.
+OutStreamer->emitValue(PCRel, 4u);
+  }
 }
 
 /// EmitFunctionEntryLabel - Emit the label that is the entrypoint for the
Index: llvm/include/llvm/IR/MDBuilder.h
===
--- llvm/include/llvm/IR/MDBuilder.h
+++ llvm/include/llvm/IR/MDBuilder.h
@@ -108,6 +108,10 @@
   /// Merge the new callback encoding \p NewCB into \p ExistingCallbacks.
   MDNode *mergeCallbackEncodings(MDNode *ExistingCallbacks, MDNode *NewCB);
 
+ 

[PATCH] D115844: [ubsan] Using metadata instead of prologue data for function sanitizer

2022-06-27 Thread Yuanfang Chen via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG6678f8e505b1: [ubsan] Using metadata instead of prologue 
data for function sanitizer (authored by ychen).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115844

Files:
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/CodeGenModule.h
  clang/lib/Driver/SanitizerArgs.cpp
  clang/test/CodeGen/ubsan-function.cpp
  clang/test/CodeGenCXX/catch-undef-behavior.cpp
  clang/test/CodeGenCXX/ubsan-function-noexcept.cpp
  clang/test/Driver/fsanitize.c
  llvm/docs/LangRef.rst
  llvm/include/llvm/IR/FixedMetadataKinds.def
  llvm/include/llvm/IR/MDBuilder.h
  llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
  llvm/lib/IR/MDBuilder.cpp
  llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
  llvm/test/CodeGen/X86/func-sanitizer.ll

Index: llvm/test/CodeGen/X86/func-sanitizer.ll
===
--- /dev/null
+++ llvm/test/CodeGen/X86/func-sanitizer.ll
@@ -0,0 +1,18 @@
+; RUN: llc -mtriple=x86_64-unknown-linux-gnu < %s | FileCheck %s
+
+; CHECK: _Z3funv:
+; CHECK: .cfi_startproc
+; CHECK: .long   846595819
+; CHECK: .long   .L__llvm_rtti_proxy-_Z3funv
+; CHECK: .L__llvm_rtti_proxy:
+; CHECK: .quad   i
+; CHECK: .size   .L__llvm_rtti_proxy, 8
+
+@i = linkonce_odr constant i32 1
+@__llvm_rtti_proxy = private unnamed_addr constant i32* @i
+
+define dso_local void @_Z3funv() !func_sanitize !0 {
+  ret void
+}
+
+!0 = !{i32 846595819, i32** @__llvm_rtti_proxy}
Index: llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
===
--- llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
+++ llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
@@ -1217,7 +1217,11 @@
 /// Check if \p G has been created by a trusted compiler pass.
 static bool GlobalWasGeneratedByCompiler(GlobalVariable *G) {
   // Do not instrument @llvm.global_ctors, @llvm.used, etc.
-  if (G->getName().startswith("llvm."))
+  if (G->getName().startswith("llvm.") ||
+  // Do not instrument gcov counter arrays.
+  G->getName().startswith("__llvm_gcov_ctr") ||
+  // Do not instrument rtti proxy symbols for function sanitizer.
+  G->getName().startswith("__llvm_rtti_proxy"))
 return true;
 
   // Do not instrument asan globals.
@@ -1226,10 +1230,6 @@
   G->getName().startswith(kODRGenPrefix))
 return true;
 
-  // Do not instrument gcov counter arrays.
-  if (G->getName() == "__llvm_gcov_ctr")
-return true;
-
   return false;
 }
 
Index: llvm/lib/IR/MDBuilder.cpp
===
--- llvm/lib/IR/MDBuilder.cpp
+++ llvm/lib/IR/MDBuilder.cpp
@@ -150,6 +150,14 @@
   return MDNode::get(Context, Ops);
 }
 
+MDNode *MDBuilder::createRTTIPointerPrologue(Constant *PrologueSig,
+ Constant *RTTI) {
+  SmallVector Ops;
+  Ops.push_back(createConstant(PrologueSig));
+  Ops.push_back(createConstant(RTTI));
+  return MDNode::get(Context, Ops);
+}
+
 MDNode *MDBuilder::createAnonymousAARoot(StringRef Name, MDNode *Extra) {
   SmallVector Args(1, nullptr);
   if (Extra)
Index: llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
===
--- llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
+++ llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
@@ -1004,6 +1004,24 @@
   // Emit the prologue data.
   if (F.hasPrologueData())
 emitGlobalConstant(F.getParent()->getDataLayout(), F.getPrologueData());
+
+  // Emit the function prologue data for the indirect call sanitizer.
+  if (const MDNode *MD = F.getMetadata(LLVMContext::MD_func_sanitize)) {
+assert(TM.getTargetTriple().getArch() == Triple::x86 ||
+   TM.getTargetTriple().getArch() == Triple::x86_64);
+assert(MD->getNumOperands() == 2);
+
+auto *PrologueSig = mdconst::extract(MD->getOperand(0));
+auto *FTRTTIProxy = mdconst::extract(MD->getOperand(1));
+assert(PrologueSig && FTRTTIProxy);
+emitGlobalConstant(F.getParent()->getDataLayout(), PrologueSig);
+
+const MCExpr *Proxy = lowerConstant(FTRTTIProxy);
+const MCExpr *FnExp = MCSymbolRefExpr::create(CurrentFnSym, OutContext);
+const MCExpr *PCRel = MCBinaryExpr::createSub(Proxy, FnExp, OutContext);
+// Use 32 bit since only small code model is supported.
+OutStreamer->emitValue(PCRel, 4u);
+  }
 }
 
 /// EmitFunctionEntryLabel - Emit the label that is the entrypoint for the
Index: llvm/include/llvm/IR/MDBuilder.h
===
--- llvm/include/llvm/IR/MDBuilder.h
+++ llvm/include/llvm/IR/MDBuilder.h
@@ -108,6 +108,10 @@
   /// Merge the new call

  1   2   3   4   5   6   7   >