[PATCH] D149867: [M68k] Add Clang support for the new M68k_RTD CC

2023-05-31 Thread Jessica Clarke via Phabricator via cfe-commits
jrtc27 requested changes to this revision.
jrtc27 added a comment.
This revision now requires changes to proceed.

I disagree. Being experimental doesn't mean you should do the wrong thing. 
Reusing std call in the frontend is ugly, pollutes non-m68k code paths (doing 
your own thing _avoids_ that and makes the experimental backend get out of the 
way, even) and introduces a bug where you can write garbage code and have it 
compile rather than be rejected like it should be.

Add your own calling convention like everyone else.


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

https://reviews.llvm.org/D149867

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


[PATCH] D149867: [M68k] Add Clang support for the new M68k_RTD CC

2023-05-31 Thread Sheng via Phabricator via cfe-commits
0x59616e accepted this revision.
0x59616e added a comment.
This revision is now accepted and ready to land.

Though creating our own calling convention is better, I think Min's path is 
correct at this moment given that m68k is still an experimental target. We can 
reignite this discussion once we're approaching to becoming a offiical target.

@myhsu could you open an issue to cite this problem ?


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

https://reviews.llvm.org/D149867

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


[PATCH] D148490: [AIX] use system assembler for assembly files

2023-05-31 Thread ChenZheng via Phabricator via cfe-commits
shchenz added inline comments.



Comment at: clang/test/Driver/target-as.s:1
 // Make sure the -march is passed down to cc1as.
 // RUN: %clang -target i386-unknown-freebsd -### -c -integrated-as %s \

MaskRay wrote:
> aix-as.c will be more appropriate.
Do you mean we change this file to `aix-as.s` or we change back to previous 
version? The file `target-as.s` can not be renamed to `aix-as.s`, it also 
contains tests for i386, see the first run line.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148490

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


[PATCH] D128059: [Clang] Add a warning on invalid UTF-8 in comments.

2023-05-31 Thread Wanda Golden via Phabricator via cfe-commits
marginstrawberries added a comment.
Herald added a subscriber: pcwang-thead.

In D128059#3640424 , @cor3ntin wrote:

> @aaron.ballman Thanks for the review. I landed the changes and got a bunch of 
> bots screaming at me for changes that are completely unrelated
>
> https://lab.llvm.org/buildbot/#/builders/21/builds/45146
> https://lab.llvm.org/buildbot/#/builders/36/builds/22838
> https://lab.llvm.org/buildbot/#/builders/121/builds/21183 free games 
> 

Good point. The error was confusing, but it's probably a segfault while running.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128059

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


[PATCH] D151761: clang-format: Add AlignConsecutiveShortCaseLabels

2023-05-31 Thread Galen Elias via Phabricator via cfe-commits
galenelias added inline comments.



Comment at: clang/docs/ClangFormatStyleOptions.rst:790
+
+**AlignConsecutiveShortCaseLabels** (``AlignConsecutiveStyle``) 
:versionbadge:`clang-format 17` :ref:`¶ `
+  Style of aligning consecutive short case labels.

MyDeveloperDay wrote:
> Did you generate this by hand or run the dump_format_style.py function? 
> Format.h and the rst look out of sync
This was generated from dump_format_style.py.  What looks out of sync?  My 
guess is the confusing thing is all the styles which use 
`AlignConsecutiveStyle` get the same documentation pasted for them which 
specifically references `AlignConsecutiveMacros` and makes it look like it's 
for the wrong option.



Comment at: clang/unittests/Format/FormatTest.cpp:19255
+   Alignment);
+}
+

HazardyKnusperkeks wrote:
> Add a test with `AcrossEmptyLines` and `AcrossComments`.
There is a test for both `AcrossEmptyLines` and `AcrossComments`.  Maybe I'm 
not understanding your comment?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151761

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


[PATCH] D144634: [Clang][OpenMP] Support for Code Generation of loop bind clause

2023-05-31 Thread Sunil K via Phabricator via cfe-commits
koops added a comment.

Can someone please let me know the following changes that I did in my latest 
patch?

1. clang/test/OpenMP/generic_loop_ast_print.cpp is failing because of the 
mapped directives. It is because of –ast-print & -ast-dump. This is because 
when the Sema comes across "omp loop bind( )" then it is mapped other 
constructs "omp simd", "omp for" or "omp distribute" . If the user of the 
compiler uses -ast-print then it is possible to be confused on seeing the new 
constructs.

I have not done the changes for -ast-dump since, it tends to be used mainly by 
the developer of clang. Can someone please let me know if I am correct? Can I 
correct the generic_loop_ast_print.cpp for the -ast-dump usage to reflect the 
mapped constructs instead of "omp loop"?

2. I have also written a testcase for "enclosed in different regions" : 
loop_bind_enclosed.cpp. I want to know if this correct and sufficient? Is there 
anything extra that I need to write or should it be done differently?


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

https://reviews.llvm.org/D144634

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


[PATCH] D150221: Add option -fkeep-static-variables to emit all static variables

2023-05-31 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added inline comments.



Comment at: clang/test/CodeGen/keep-static-variables.cpp:1
+// RUN: %clang_cc1 -fkeep-static-variables -emit-llvm %s -o - 
-triple=x86_64-unknown-linux-gnu | FileCheck %s --check-prefixes=CHECK,CHECK-ELF
+// RUN: %clang_cc1 -fkeep-static-variables -emit-llvm %s -o - 
-triple=powerpc64-ibm-aix-xcoff | FileCheck %s 
--check-prefixes=CHECK,CHECK-NON-ELF

@qianzhen, a driver option was added. IMO, there should be tests (probably in 
another file) for the driver option too.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150221

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


[PATCH] D150221: Add option -fkeep-static-variables to emit all static variables

2023-05-31 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added inline comments.



Comment at: clang/lib/CodeGen/CodeGenModule.cpp:2201-2210
+  if ((CodeGenOpts.KeepStaticConsts || CodeGenOpts.KeepStaticVariables) && D &&
+  isa(D)) {
 const auto *VD = cast(D);
-if (VD->getType().isConstQualified() &&
-VD->getStorageDuration() == SD_Static)
-  addUsedOrCompilerUsedGlobal(GV);
+if (VD->getStorageDuration() == SD_Static) {
+  if (CodeGenOpts.KeepStaticVariables)
+addUsedOrCompilerUsedGlobal(GV);
+  else if (CodeGenOpts.KeepStaticConsts && 
VD->getType().isConstQualified())

aaron.ballman wrote:
> Reformatted with whatever clang-format does for that, as I doubt I have the 
> formatting correct.
@qianzhen, I don't think the suggestion was applied/applied correctly.

There should not be an `isa` followed by `dyn_cast`. That said, I think 
`dyn_cast_or_null` is perhaps appropriate instead of plain `dyn_cast`. 
Additionally, `VD` being non-null should be part of the condition.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150221

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


[PATCH] D151833: Respect "-fdiagnostics-absolute-paths" on emit include location

2023-05-31 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder added a comment.

Can you add a test case for the change? Looks like there's something similar 
already in `clang/test/Frontend/absolute-paths.c`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151833

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


[PATCH] D151720: [clang][ExprConstant] Fix display of syntactically-invalid note for member function calls

2023-05-31 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder added inline comments.



Comment at: clang/lib/AST/ExprConstant.cpp:1925
   if (This && IsMemberCall) {
-APValue Val;
-This->moveInto(Val);
-Val.printPretty(Out, Info.Ctx,
-This->Designator.MostDerivedType);
-// FIXME: Add parens around Val if needed.
-Out << "->" << *Callee << '(';
+if (const auto *MCE = dyn_cast_or_null(CallExpr)) {
+  const Expr *Object = MCE->getImplicitObjectArgument();





Comment at: clang/lib/AST/ExprConstant.cpp:1933
+} else if (const auto *OCE =
+   dyn_cast_or_null(CallExpr)) {
+  OCE->getArg(0)->printPretty(Out, nullptr, Info.Ctx.getPrintingPolicy(),




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

https://reviews.llvm.org/D151720

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


[PATCH] D151837: [Clang][Parser] Accept GNU attributes preceding C++ style attributes on templates

2023-05-31 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd accepted this revision.
compnerd added a comment.
This revision is now accepted and ready to land.

Could you add a test case for the inverted order of attributes on a template as 
well?  I don't think that there is a test case for that.


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

https://reviews.llvm.org/D151837

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


[PATCH] D146664: Apply the same fallbacks as runtimes search for stdlib search

2023-05-31 Thread Mike Hommey via Phabricator via cfe-commits
glandium added a comment.

In D146664#4352695 , @thakis wrote:

> Is it possible to test this?

I don't know how.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146664

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


[PATCH] D150988: [clang][Darwin] Error out when missing requested libarclite library

2023-05-31 Thread Keith Smiley via Phabricator via cfe-commits
keith updated this revision to Diff 527261.
keith added a comment.

Improve error message


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150988

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/lib/Driver/ToolChains/Darwin.cpp
  clang/test/Driver/arclite-link-external-toolchain.c
  clang/test/Driver/arclite-link.c


Index: clang/test/Driver/arclite-link.c
===
--- clang/test/Driver/arclite-link.c
+++ clang/test/Driver/arclite-link.c
@@ -1,9 +1,13 @@
 // RUN: touch %t.o
-// RUN: %clang -### -target x86_64-apple-darwin10 -fobjc-link-runtime -lfoo 
-mmacosx-version-min=10.10 %t.o 2>&1 | FileCheck 
-check-prefix=CHECK-ARCLITE-OSX %s
+// RUN: mkdir -p 
%t.tmpdir/Xcode.app/Contents/Developers/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk
+// RUN: %clang -### -target x86_64-apple-darwin10 -fobjc-link-runtime -lfoo 
-mmacosx-version-min=10.10 %t.o \
+// RUN: -isysroot 
%t.tmpdir/Xcode.app/Contents/Developers/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk
 2>&1 | FileCheck -check-prefix=CHECK-ARCLITE-OSX %s
 // RUN: %clang -### -target x86_64-apple-darwin10 -fobjc-link-runtime 
-mmacosx-version-min=10.11 %t.o 2>&1 | FileCheck -check-prefix=CHECK-NOARCLITE 
%s
 // RUN: %clang -### -target i386-apple-darwin10 -fobjc-link-runtime 
-mmacosx-version-min=10.7 %t.o 2>&1 | FileCheck -check-prefix=CHECK-NOARCLITE %s
 // RUN: %clang -### -target x86_64-apple-darwin10 -fobjc-link-runtime 
-nostdlib %t.o 2>&1 | FileCheck -check-prefix=CHECK-NOSTDLIB %s
 
+// CHECK-ARCLITE-OSX: .tmpdir/Xcode.app/{{.*}}libarclite_macosx.a';
+// CHECK-ARCLITE-OSX: try increasing the minimum deployment target
 // CHECK-ARCLITE-OSX: -lfoo
 // CHECK-ARCLITE-OSX: libarclite_macosx.a
 // CHECK-ARCLITE-OSX: -framework
Index: clang/test/Driver/arclite-link-external-toolchain.c
===
--- clang/test/Driver/arclite-link-external-toolchain.c
+++ clang/test/Driver/arclite-link-external-toolchain.c
@@ -4,5 +4,8 @@
 // RUN:   -isysroot 
%t.tmpdir/Xcode.app/Contents/Developers/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk
 \
 // RUN:   %s 2>&1 | FileCheck %s
 
+// CHECK: error: SDK does not contain 'libarclite' at the path '
+// CHECK: .tmpdir/Xcode.app/{{.*}}libarclite_macosx.a';
+// CHECK: try increasing the minimum deployment target
 // CHECK: -lfoo
 // CHECK: .tmpdir/Xcode.app/{{.*}}libarclite_macosx.a
Index: clang/lib/Driver/ToolChains/Darwin.cpp
===
--- clang/lib/Driver/ToolChains/Darwin.cpp
+++ clang/lib/Driver/ToolChains/Darwin.cpp
@@ -1204,6 +1204,9 @@
 P += "macosx";
   P += ".a";
 
+  if (!getVFS().exists(P))
+getDriver().Diag(clang::diag::err_drv_darwin_sdk_missing_arclite) << P;
+
   CmdArgs.push_back(Args.MakeArgString(P));
 }
 
Index: clang/include/clang/Basic/DiagnosticDriverKinds.td
===
--- clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -619,6 +619,9 @@
   "SDK settings were ignored as 'SDKSettings.json' could not be parsed">,
   InGroup>;
 
+def err_drv_darwin_sdk_missing_arclite : Error<
+  "SDK does not contain 'libarclite' at the path '%0'; try increasing the 
minimum deployment target">;
+
 def err_drv_trivial_auto_var_init_stop_after_missing_dependency : Error<
   "'-ftrivial-auto-var-init-stop-after=*' is used without "
   "'-ftrivial-auto-var-init=zero' or '-ftrivial-auto-var-init=pattern'">;


Index: clang/test/Driver/arclite-link.c
===
--- clang/test/Driver/arclite-link.c
+++ clang/test/Driver/arclite-link.c
@@ -1,9 +1,13 @@
 // RUN: touch %t.o
-// RUN: %clang -### -target x86_64-apple-darwin10 -fobjc-link-runtime -lfoo -mmacosx-version-min=10.10 %t.o 2>&1 | FileCheck -check-prefix=CHECK-ARCLITE-OSX %s
+// RUN: mkdir -p %t.tmpdir/Xcode.app/Contents/Developers/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk
+// RUN: %clang -### -target x86_64-apple-darwin10 -fobjc-link-runtime -lfoo -mmacosx-version-min=10.10 %t.o \
+// RUN: -isysroot %t.tmpdir/Xcode.app/Contents/Developers/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk 2>&1 | FileCheck -check-prefix=CHECK-ARCLITE-OSX %s
 // RUN: %clang -### -target x86_64-apple-darwin10 -fobjc-link-runtime -mmacosx-version-min=10.11 %t.o 2>&1 | FileCheck -check-prefix=CHECK-NOARCLITE %s
 // RUN: %clang -### -target i386-apple-darwin10 -fobjc-link-runtime -mmacosx-version-min=10.7 %t.o 2>&1 | FileCheck -check-prefix=CHECK-NOARCLITE %s
 // RUN: %clang -### -target x86_64-apple-darwin10 -fobjc-link-runtime -nostdlib %t.o 2>&1 | FileCheck -check-prefix=CHECK-NOSTDLIB %s
 
+// CHECK-ARCLITE-OSX: .tmpdir/Xcode.app/{{.*}}libarclite_macosx.a';
+// CHECK-ARCLITE-OSX: try 

[PATCH] D151595: [BOLT][CMake] Redo the build and install targets

2023-05-31 Thread Amir Ayupov via Phabricator via cfe-commits
Amir accepted this revision.
Amir added a comment.

Thanks. Will update the dependencies, removing always-installed symlinks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151595

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


[PATCH] D150988: [clang][Darwin] Error out when missing requested libarclite library

2023-05-31 Thread Ravi via Phabricator via cfe-commits
ravikandhadai added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticDriverKinds.td:623
+def err_drv_darwin_sdk_missing_arclite : Error<
+  "SDK does not contain 'libarclite' at the path '%0'. This likely means you 
need to increase your minimum deployment target">;
+

To be consistent with other error messages, it would better to rephrase as
"SDK does not contain 'libarclite' at the path '%0'; try increasing the minimum 
deployment target"




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150988

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


[clang] bf8fe1c - Fix clang driver tests for cspgo in lld

2023-05-31 Thread Ellis Hoag via cfe-commits

Author: Ellis Hoag
Date: 2023-05-31T18:21:41-07:00
New Revision: bf8fe1c38f1031c88c80e0e86ffea4375e7693ff

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

LOG: Fix clang driver tests for cspgo in lld

The tests introduced by https://reviews.llvm.org/D151589 were failing
because I guess some test platforms don't have `lld`. Similar tests add
`-B%S/Inputs/lld` to the clang commands so lets try this here to fix the
tests.

```
clang: error: invalid linker name in argument '-fuse-ld=lld'
```

Added: 


Modified: 
clang/test/Driver/cspgo-lto.c

Removed: 




diff  --git a/clang/test/Driver/cspgo-lto.c b/clang/test/Driver/cspgo-lto.c
index a22b2f83c4aa..232d21bbf948 100644
--- a/clang/test/Driver/cspgo-lto.c
+++ b/clang/test/Driver/cspgo-lto.c
@@ -5,14 +5,14 @@
 
 // CHECK: -plugin-opt=cs-profile-path=default.profdata
 
-// RUN: %clang --target=apple-arm64-ios -### %t.o -flto=thin -fuse-ld=lld 
-fprofile-use 2>&1 | FileCheck %s --check-prefix=DARWIN-USE1
-// RUN: %clang --target=apple-arm64-ios -### %t.o -flto=thin -fuse-ld=lld 
-fprofile-use=a.profdata 2>&1 | FileCheck %s --check-prefix=DARWIN-USE2
+// RUN: %clang --target=apple-arm64-ios -### %t.o -flto=thin -fuse-ld=lld 
-B%S/Inputs/lld -fprofile-use 2>&1 | FileCheck %s --check-prefix=DARWIN-USE1
+// RUN: %clang --target=apple-arm64-ios -### %t.o -flto=thin -fuse-ld=lld 
-B%S/Inputs/lld -fprofile-use=a.profdata 2>&1 | FileCheck %s 
--check-prefix=DARWIN-USE2
 
 // DARWIN-USE1: "--cs-profile-path=default.profdata"
 // DARWIN-USE2: "--cs-profile-path=a.profdata"
 
-// RUN: %clang --target=apple-arm64-ios -### %t.o -flto=thin -fuse-ld=lld 
-fcs-profile-generate 2>&1 | FileCheck %s --check-prefix=DARWIN-GEN1
-// RUN: %clang --target=apple-arm64-ios -### %t.o -flto=thin -fuse-ld=lld 
-fcs-profile-generate=directory 2>&1 | FileCheck %s --check-prefix=DARWIN-GEN2
+// RUN: %clang --target=apple-arm64-ios -### %t.o -flto=thin -fuse-ld=lld 
-B%S/Inputs/lld -fcs-profile-generate 2>&1 | FileCheck %s 
--check-prefix=DARWIN-GEN1
+// RUN: %clang --target=apple-arm64-ios -### %t.o -flto=thin -fuse-ld=lld 
-B%S/Inputs/lld -fcs-profile-generate=directory 2>&1 | FileCheck %s 
--check-prefix=DARWIN-GEN2
 
 // DARWIN-GEN1: "--cs-profile-generate"
 // DARWIN-GEN1-SAME: "--cs-profile-path=default_%m.profraw"



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


[clang] 85af42d - [lld] add context-sensitive PGO options for MachO

2023-05-31 Thread Ellis Hoag via cfe-commits

Author: Ellis Hoag
Date: 2023-05-31T17:53:46-07:00
New Revision: 85af42df5dbb964d767feb16a5551dddb36fd4f1

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

LOG: [lld] add context-sensitive PGO options for MachO

Enable support for CSPGO for lld MachO targets.

Since lld MachO does not support `-plugin-opt=`, we need to create the 
`--cs-profile-generate` and `--cs-profile-path=` options and propagate them in 
`Darwin.cpp`. These flags are not supported by ld64.

Also outline code into `getLastCSProfileGenerateArg()` to share between 
`CommonArgs.cpp` and `Darwin.cpp`.

CSPGO is already implemented for ELF (https://reviews.llvm.org/D56675) and COFF 
(https://reviews.llvm.org/D98763).

Reviewed By: MaskRay

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

Added: 
lld/test/MachO/cspgo-gen.ll
lld/test/MachO/cspgo-use.ll

Modified: 
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Driver/ToolChains/CommonArgs.cpp
clang/lib/Driver/ToolChains/CommonArgs.h
clang/lib/Driver/ToolChains/Darwin.cpp
clang/test/Driver/cspgo-lto.c
lld/MachO/Config.h
lld/MachO/Driver.cpp
lld/MachO/LTO.cpp
lld/MachO/Options.td
lld/test/lit.cfg.py

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index e22c2ce7f2ede..02eec4d59b620 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -716,12 +716,7 @@ static void addPGOAndCoverageFlags(const ToolChain , 
Compilation ,
   PGOGenerateArg->getOption().matches(options::OPT_fno_profile_generate))
 PGOGenerateArg = nullptr;
 
-  auto *CSPGOGenerateArg = Args.getLastArg(options::OPT_fcs_profile_generate,
-   
options::OPT_fcs_profile_generate_EQ,
-   options::OPT_fno_profile_generate);
-  if (CSPGOGenerateArg &&
-  CSPGOGenerateArg->getOption().matches(options::OPT_fno_profile_generate))
-CSPGOGenerateArg = nullptr;
+  auto *CSPGOGenerateArg = getLastCSProfileGenerateArg(Args);
 
   auto *ProfileGenerateArg = Args.getLastArg(
   options::OPT_fprofile_instr_generate,

diff  --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp 
b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index 57bf345f1708e..a952fdbacb386 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -772,16 +772,7 @@ void tools::addLTOOptions(const ToolChain , 
const ArgList ,
"sample-profile=" + FName));
   }
 
-  auto *CSPGOGenerateArg = Args.getLastArg(options::OPT_fcs_profile_generate,
-   
options::OPT_fcs_profile_generate_EQ,
-   options::OPT_fno_profile_generate);
-  if (CSPGOGenerateArg &&
-  CSPGOGenerateArg->getOption().matches(options::OPT_fno_profile_generate))
-CSPGOGenerateArg = nullptr;
-
-  auto *ProfileUseArg = getLastProfileUseArg(Args);
-
-  if (CSPGOGenerateArg) {
+  if (auto *CSPGOGenerateArg = getLastCSProfileGenerateArg(Args)) {
 CmdArgs.push_back(Args.MakeArgString(Twine(PluginOptPrefix) + ExtraDash +
  "cs-profile-generate"));
 if (CSPGOGenerateArg->getOption().matches(
@@ -794,7 +785,7 @@ void tools::addLTOOptions(const ToolChain , const 
ArgList ,
   CmdArgs.push_back(
   Args.MakeArgString(Twine(PluginOptPrefix) + ExtraDash +
  "cs-profile-path=default_%m.profraw"));
-  } else if (ProfileUseArg) {
+  } else if (auto *ProfileUseArg = getLastProfileUseArg(Args)) {
 SmallString<128> Path(
 ProfileUseArg->getNumValues() == 0 ? "" : ProfileUseArg->getValue());
 if (Path.empty() || llvm::sys::fs::is_directory(Path))
@@ -1348,6 +1339,17 @@ void tools::claimNoWarnArgs(const ArgList ) {
   Args.ClaimAllArgs(options::OPT_fno_lto);
 }
 
+Arg *tools::getLastCSProfileGenerateArg(const ArgList ) {
+  auto *CSPGOGenerateArg = Args.getLastArg(options::OPT_fcs_profile_generate,
+   
options::OPT_fcs_profile_generate_EQ,
+   options::OPT_fno_profile_generate);
+  if (CSPGOGenerateArg &&
+  CSPGOGenerateArg->getOption().matches(options::OPT_fno_profile_generate))
+CSPGOGenerateArg = nullptr;
+
+  return CSPGOGenerateArg;
+}
+
 Arg *tools::getLastProfileUseArg(const ArgList ) {
   auto *ProfileUseArg = Args.getLastArg(
   options::OPT_fprofile_instr_use, options::OPT_fprofile_instr_use_EQ,

diff  --git a/clang/lib/Driver/ToolChains/CommonArgs.h 
b/clang/lib/Driver/ToolChains/CommonArgs.h
index c196cbc28e218..66948f3f586ba 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.h
+++ 

[PATCH] D151589: [lld] add context-sensitive PGO options for MachO

2023-05-31 Thread Ellis Hoag 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 rG85af42df5dbb: [lld] add context-sensitive PGO options for 
MachO (authored by ellis).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151589

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/lib/Driver/ToolChains/CommonArgs.h
  clang/lib/Driver/ToolChains/Darwin.cpp
  clang/test/Driver/cspgo-lto.c
  lld/MachO/Config.h
  lld/MachO/Driver.cpp
  lld/MachO/LTO.cpp
  lld/MachO/Options.td
  lld/test/MachO/cspgo-gen.ll
  lld/test/MachO/cspgo-use.ll
  lld/test/lit.cfg.py

Index: lld/test/lit.cfg.py
===
--- lld/test/lit.cfg.py
+++ lld/test/lit.cfg.py
@@ -45,6 +45,7 @@
 "llvm-objdump",
 "llvm-otool",
 "llvm-pdbutil",
+"llvm-profdata",
 "llvm-dwarfdump",
 "llvm-readelf",
 "llvm-readobj",
Index: lld/test/MachO/cspgo-use.ll
===
--- /dev/null
+++ lld/test/MachO/cspgo-use.ll
@@ -0,0 +1,18 @@
+; REQUIRES: x86
+
+; Create an empty profile
+; RUN: echo > %t.proftext
+; RUN: llvm-profdata merge %t.proftext -o %t.profdata
+
+; RUN: llvm-as %s -o %t.o
+; RUN: %lld -dylib --cs-profile-path=%t.profdata %t.o -o %t --lto-debug-pass-manager 2>&1 | FileCheck %s --implicit-check-not=PGOInstrumentation
+
+; CHECK: Running pass: PGOInstrumentationUse
+
+target triple = "x86_64-apple-darwin"
+target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
+
+define void @foo() {
+entry:
+  ret void
+}
Index: lld/test/MachO/cspgo-gen.ll
===
--- /dev/null
+++ lld/test/MachO/cspgo-gen.ll
@@ -0,0 +1,16 @@
+; REQUIRES: x86
+
+; RUN: llvm-as %s -o %t.o
+; RUN: %lld -dylib --cs-profile-generate --cs-profile-path=default_%m.profraw %t.o -o %t --lto-debug-pass-manager 2>&1 | FileCheck %s --implicit-check-not=PGOInstrumentation
+
+; CHECK: PGOInstrumentationGen
+
+target triple = "x86_64-apple-darwin"
+target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
+
+@__llvm_profile_runtime = global i32 0, align 4
+
+define void @foo() {
+entry:
+  ret void
+}
Index: lld/MachO/Options.td
===
--- lld/MachO/Options.td
+++ lld/MachO/Options.td
@@ -126,6 +126,10 @@
 Group;
 def lto_debug_pass_manager: Flag<["--"], "lto-debug-pass-manager">,
 HelpText<"Debug new pass manager">, Group;
+def cs_profile_generate: Flag<["--"], "cs-profile-generate">,
+HelpText<"Perform context senstive PGO instrumentation">, Group;
+def cs_profile_path: Joined<["--"], "cs-profile-path=">,
+HelpText<"Context sensitive profile file path">, Group;
 
 // This is a complete Options.td compiled from Apple's ld(1) manpage
 // dated 2018-03-07 and cross checked with ld64 source code in repo
Index: lld/MachO/LTO.cpp
===
--- lld/MachO/LTO.cpp
+++ lld/MachO/LTO.cpp
@@ -69,6 +69,8 @@
   c.TimeTraceEnabled = config->timeTraceEnabled;
   c.TimeTraceGranularity = config->timeTraceGranularity;
   c.DebugPassManager = config->ltoDebugPassManager;
+  c.CSIRProfile = std::string(config->csProfilePath);
+  c.RunCSIRInstr = config->csProfileGenerate;
   c.OptLevel = config->ltoo;
   c.CGOptLevel = config->ltoCgo;
   if (config->saveTemps)
Index: lld/MachO/Driver.cpp
===
--- lld/MachO/Driver.cpp
+++ lld/MachO/Driver.cpp
@@ -1637,6 +1637,8 @@
 config->ignoreAutoLinkOptions.insert(arg->getValue());
   config->strictAutoLink = args.hasArg(OPT_strict_auto_link);
   config->ltoDebugPassManager = args.hasArg(OPT_lto_debug_pass_manager);
+  config->csProfileGenerate = args.hasArg(OPT_cs_profile_generate);
+  config->csProfilePath = args.getLastArgValue(OPT_cs_profile_path);
 
   for (const Arg *arg : args.filtered(OPT_alias)) {
 config->aliasedSymbols.push_back(
Index: lld/MachO/Config.h
===
--- lld/MachO/Config.h
+++ lld/MachO/Config.h
@@ -206,6 +206,8 @@
   std::vector sectionAlignments;
   std::vector segmentProtections;
   bool ltoDebugPassManager = false;
+  bool csProfileGenerate = false;
+  llvm::StringRef csProfilePath;
 
   bool callGraphProfileSort = false;
   llvm::StringRef printSymbolOrder;
Index: clang/test/Driver/cspgo-lto.c
===
--- clang/test/Driver/cspgo-lto.c
+++ clang/test/Driver/cspgo-lto.c
@@ -4,3 +4,17 @@
 // RUN:   -fprofile-use 2>&1 | FileCheck %s
 
 // CHECK: -plugin-opt=cs-profile-path=default.profdata
+
+// RUN: %clang --target=apple-arm64-ios -### %t.o -flto=thin -fuse-ld=lld 

[PATCH] D151595: [BOLT][CMake] Redo the build and install targets

2023-05-31 Thread Petr Hosek via Phabricator via cfe-commits
phosek marked 2 inline comments as done.
phosek added inline comments.



Comment at: bolt/test/CMakeLists.txt:40
   llvm-bolt
-  llvm-boltdiff
   llvm-bolt-heatmap

Amir wrote:
> We have a number of dependencies on llvm-boltdiff and perf2bolt, e.g. in 
> internal and upstream binary tests: 
> https://github.com/rafaelauler/bolt-tests/blob/main/CMakeLists.txt#L22. Can 
> we keep these targets somehow?
These symlinks are now always generated, see the `ALWAYS_GENERATED` option in 
`add_bolt_tool_symlink` so there's no need to specify those as targets here 
separately.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151595

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


[PATCH] D151595: [BOLT][CMake] Redo the build and install targets

2023-05-31 Thread Petr Hosek via Phabricator via cfe-commits
phosek updated this revision to Diff 527243.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151595

Files:
  bolt/CMakeLists.txt
  bolt/cmake/modules/AddBOLT.cmake
  bolt/test/CMakeLists.txt
  bolt/tools/CMakeLists.txt
  bolt/tools/bat-dump/CMakeLists.txt
  bolt/tools/driver/CMakeLists.txt
  bolt/tools/heatmap/CMakeLists.txt
  bolt/tools/merge-fdata/CMakeLists.txt
  clang/cmake/caches/Fuchsia-stage2.cmake
  llvm/cmake/modules/AddLLVM.cmake

Index: llvm/cmake/modules/AddLLVM.cmake
===
--- llvm/cmake/modules/AddLLVM.cmake
+++ llvm/cmake/modules/AddLLVM.cmake
@@ -2121,7 +2121,7 @@
   if (NOT LLVM_ENABLE_IDE AND NOT ARG_ALWAYS_GENERATE)
 add_llvm_install_targets(install-${name}
  DEPENDS ${name} ${dest}
- COMPONENT ${name}
+ COMPONENT ${component}
  SYMLINK ${dest})
   endif()
 endfunction()
Index: clang/cmake/caches/Fuchsia-stage2.cmake
===
--- clang/cmake/caches/Fuchsia-stage2.cmake
+++ clang/cmake/caches/Fuchsia-stage2.cmake
@@ -6,7 +6,7 @@
 
 set(PACKAGE_VENDOR Fuchsia CACHE STRING "")
 
-set(_FUCHSIA_ENABLE_PROJECTS "clang;clang-tools-extra;lld;llvm;polly")
+set(_FUCHSIA_ENABLE_PROJECTS "bolt;clang;clang-tools-extra;lld;llvm;polly")
 set(LLVM_ENABLE_RUNTIMES "compiler-rt;libcxx;libcxxabi;libunwind" CACHE STRING "")
 
 set(LLVM_ENABLE_BACKTRACES OFF CACHE BOOL "")
@@ -328,6 +328,7 @@
   CACHE STRING "")
 
 set(LLVM_Toolchain_DISTRIBUTION_COMPONENTS
+  bolt
   clang
   lld
   clang-apply-replacements
Index: bolt/tools/merge-fdata/CMakeLists.txt
===
--- bolt/tools/merge-fdata/CMakeLists.txt
+++ bolt/tools/merge-fdata/CMakeLists.txt
@@ -8,14 +8,8 @@
   DEPENDS
   intrinsics_gen
 )
-set_target_properties(merge-fdata PROPERTIES FOLDER "BOLT")
 
 add_dependencies(bolt merge-fdata)
-install(PROGRAMS
-  ${CMAKE_BINARY_DIR}/bin/merge-fdata
-  DESTINATION ${CMAKE_INSTALL_BINDIR}
-  COMPONENT bolt
-  )
 
 # Emit relocations for BOLT meta test (bolt/test/runtime/meta-merge-fdata.test)
 if (BOLT_INCLUDE_TESTS AND UNIX AND NOT APPLE)
Index: bolt/tools/heatmap/CMakeLists.txt
===
--- bolt/tools/heatmap/CMakeLists.txt
+++ bolt/tools/heatmap/CMakeLists.txt
@@ -17,4 +17,4 @@
   LLVMBOLTUtils
   )
 
-set_target_properties(llvm-bolt-heatmap PROPERTIES FOLDER "BOLT")
+add_dependencies(bolt llvm-bolt-heatmap)
Index: bolt/tools/driver/CMakeLists.txt
===
--- bolt/tools/driver/CMakeLists.txt
+++ bolt/tools/driver/CMakeLists.txt
@@ -30,22 +30,6 @@
 add_bolt_tool_symlink(perf2bolt llvm-bolt)
 add_bolt_tool_symlink(llvm-boltdiff llvm-bolt)
 
-set(BOLT_DEPENDS
-  llvm-bolt
-  perf2bolt
-  llvm-boltdiff
-  )
-
-add_custom_target(bolt DEPENDS ${BOLT_DEPENDS})
-install(PROGRAMS
-  ${CMAKE_BINARY_DIR}/bin/llvm-bolt
-  ${CMAKE_BINARY_DIR}/bin/perf2bolt
-  ${CMAKE_BINARY_DIR}/bin/llvm-boltdiff
-  DESTINATION ${CMAKE_INSTALL_BINDIR}
-  COMPONENT bolt
-  )
-add_llvm_install_targets(install-bolt DEPENDS bolt COMPONENT bolt)
-set_target_properties(bolt PROPERTIES FOLDER "BOLT")
-set_target_properties(install-bolt PROPERTIES FOLDER "BOLT")
+add_dependencies(bolt llvm-bolt)
 
-include_directories( ${BOLT_SOURCE_DIR}/lib )
+include_directories(${BOLT_SOURCE_DIR}/lib)
Index: bolt/tools/bat-dump/CMakeLists.txt
===
--- bolt/tools/bat-dump/CMakeLists.txt
+++ bolt/tools/bat-dump/CMakeLists.txt
@@ -3,7 +3,7 @@
   Support
   )
 
-add_llvm_tool(llvm-bat-dump
+add_bolt_executable(llvm-bat-dump
   bat-dump.cpp
 
   DISABLE_LLVM_LINK_LLVM_DYLIB
@@ -13,5 +13,3 @@
   PRIVATE
   LLVMBOLTProfile
   )
-
-set_target_properties(llvm-bat-dump PROPERTIES FOLDER "BOLT")
Index: bolt/tools/CMakeLists.txt
===
--- bolt/tools/CMakeLists.txt
+++ bolt/tools/CMakeLists.txt
@@ -2,16 +2,6 @@
 "Path for binary subdirectory (defaults to '${CMAKE_INSTALL_BINDIR}')")
 mark_as_advanced(BOLT_TOOLS_INSTALL_DIR)
 
-# Move these macros to AddBolt if such a CMake module is ever created.
-
-macro(add_bolt_tool name)
-  llvm_add_tool(BOLT ${ARGV})
-endmacro()
-
-macro(add_bolt_tool_symlink name)
-  llvm_add_tool_symlink(BOLT ${ARGV})
-endmacro()
-
 add_subdirectory(driver)
 add_subdirectory(llvm-bolt-fuzzer)
 add_subdirectory(bat-dump)
Index: bolt/test/CMakeLists.txt
===
--- bolt/test/CMakeLists.txt
+++ bolt/test/CMakeLists.txt
@@ -37,7 +37,6 @@
   lld
   llvm-config
   llvm-bolt
-  llvm-boltdiff
   llvm-bolt-heatmap
   llvm-bat-dump
   llvm-dwarfdump
@@ -52,7 +51,6 @@
   llvm-objcopy
 

[PATCH] D148266: [clang][driver] Linking to just-built libc++.dylib when bootstrapping libc++ with clang

2023-05-31 Thread Fahad Nayyar via Phabricator via cfe-commits
fahadnayyar updated this revision to Diff 527241.
fahadnayyar added a comment.

Passing -L /bin/../lib/ unconditionally to the linker.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148266

Files:
  clang/lib/Driver/ToolChains/Darwin.cpp
  clang/test/Driver/darwin-header-search-libcxx.cpp
  clang/test/Driver/darwin-link-libcxx-from-toolchain.cpp

Index: clang/test/Driver/darwin-link-libcxx-from-toolchain.cpp
===
--- clang/test/Driver/darwin-link-libcxx-from-toolchain.cpp
+++ clang/test/Driver/darwin-link-libcxx-from-toolchain.cpp
@@ -1,63 +1,48 @@
 // UNSUPPORTED: system-windows
 
-// General tests that the header search paths for libc++ detected by the driver
-// and passed to CC1 are correct on Darwin platforms.
+// Tests to check that we pass -L /bin/../lib/ to the linker to prioritize the toolchain's libc++.dylib over system's libc++.tbd in all cases.
 
 // Check without a sysroot and without headers alongside the installation
-// (no include path should be added, and no warning or error).
 //
-// RUN: %clang -### %s -fsyntax-only 2>&1 \
+// RUN: %clang -### %s 2>&1 \
 // RUN: --target=x86_64-apple-darwin \
 // RUN: -stdlib=libc++ \
 // RUN: -ccc-install-dir %S/Inputs/basic_darwin_toolchain_no_libcxx/usr/bin \
-// RUN:   | FileCheck --check-prefix=CHECK-LIBCXX-NONE %s
-// CHECK-LIBCXX-NONE: "-cc1"
+// RUN:   | FileCheck -DTOOLCHAIN=%S/Inputs/basic_darwin_toolchain_no_libcxx --check-prefix=CHECK-TOOLCHAIN-LIBCXX-LINKING-2 %s
 
 // Check with only headers alongside the installation (those should be used).
 //
-// RUN: %clang -### %s -fsyntax-only 2>&1 \
+// RUN: %clang -### %s 2>&1 \
 // RUN: --target=x86_64-apple-darwin \
 // RUN: -stdlib=libc++ \
 // RUN: -ccc-install-dir %S/Inputs/basic_darwin_toolchain/usr/bin \
 // RUN: --sysroot="" \
 // RUN:   | FileCheck -DTOOLCHAIN=%S/Inputs/basic_darwin_toolchain \
-// RUN:   --check-prefix=CHECK-LIBCXX-TOOLCHAIN-1 %s
-// CHECK-LIBCXX-TOOLCHAIN-1: "-cc1"
-// CHECK-LIBCXX-TOOLCHAIN-1: "-internal-isystem" "[[TOOLCHAIN]]/usr/bin/../include/c++/v1"
-// CHECK-LIBCXX-TOOLCHAIN-1-NOT: "-internal-isystem" "/usr/include/c++/v1"
+// RUN:   --check-prefix=CHECK-TOOLCHAIN-LIBCXX-LINKING-1 %s
 //
-// RUN: %clang -### %s -fsyntax-only 2>&1 \
+// RUN: %clang -### %s 2>&1 \
 // RUN: --target=x86_64-apple-darwin \
 // RUN: -stdlib=libc++ \
 // RUN: -ccc-install-dir %S/Inputs/basic_darwin_toolchain/usr/bin \
 // RUN: -isysroot %S/Inputs/basic_darwin_sdk_no_libcxx \
 // RUN:   | FileCheck -DTOOLCHAIN=%S/Inputs/basic_darwin_toolchain \
 // RUN:   -DSYSROOT=%S/Inputs/basic_darwin_sdk_no_libcxx \
-// RUN:   --check-prefix=CHECK-LIBCXX-TOOLCHAIN-2 %s
-// CHECK-LIBCXX-TOOLCHAIN-2: "-cc1"
-// CHECK-LIBCXX-TOOLCHAIN-2: "-internal-isystem" "[[TOOLCHAIN]]/usr/bin/../include/c++/v1"
-// CHECK-LIBCXX-TOOLCHAIN-2-NOT: "-internal-isystem" "[[SYSROOT]]/usr/include/c++/v1"
+// RUN:   --check-prefix=CHECK-TOOLCHAIN-LIBCXX-LINKING-1 %s
 
 // Check with only headers in the sysroot (those should be used).
 //
-// RUN: %clang -### %s -fsyntax-only 2>&1 \
+// RUN: %clang -### %s 2>&1 \
 // RUN: --target=x86_64-apple-darwin \
 // RUN: -stdlib=libc++ \
 // RUN: -ccc-install-dir %S/Inputs/basic_darwin_toolchain_no_libcxx/usr/bin \
 // RUN: -isysroot %S/Inputs/basic_darwin_sdk_usr_cxx_v1 \
 // RUN:   | FileCheck -DSYSROOT=%S/Inputs/basic_darwin_sdk_usr_cxx_v1 \
 // RUN:   -DTOOLCHAIN=%S/Inputs/basic_darwin_toolchain_no_libcxx \
-// RUN:   --check-prefix=CHECK-LIBCXX-SYSROOT-1 %s
-// CHECK-LIBCXX-SYSROOT-1: "-cc1"
-// CHECK-LIBCXX-SYSROOT-1: "-internal-isystem" "[[SYSROOT]]/usr/include/c++/v1"
-// CHECK-LIBCXX-SYSROOT-1-NOT: "-internal-isystem" "[[TOOLCHAIN]]/usr/bin/../include/c++/v1"
+// RUN:   --check-prefix=CHECK-TOOLCHAIN-LIBCXX-LINKING-1 %s
 
 // Check with both headers in the sysroot and headers alongside the installation
-// (the headers in the toolchain should be preferred over the  headers).
-// Ensure that both -isysroot and --sysroot work, and that isysroot has precedence
-// over --sysroot.
 //
-// RUN: %clang -### %s -fsyntax-only 2>&1 \
+// RUN: %clang -### %s 2>&1 \
 // RUN: --target=x86_64-apple-darwin \
 // RUN: -stdlib=libc++ \
 // RUN: -ccc-install-dir %S/Inputs/basic_darwin_toolchain/usr/bin \
@@ -65,9 +50,9 @@
 // RUN: -isysroot %S/Inputs/basic_darwin_sdk_usr_cxx_v1 \
 // RUN:   | FileCheck -DSYSROOT=%S/Inputs/basic_darwin_sdk_usr_cxx_v1 \
 // RUN:   -DTOOLCHAIN=%S/Inputs/basic_darwin_toolchain \
-// RUN:   --check-prefix=CHECK-LIBCXX-SYSROOT_AND_TOOLCHAIN-1 %s
+// RUN:   --check-prefix=CHECK-TOOLCHAIN-LIBCXX-LINKING-1 %s
 //
-// RUN: %clang -### %s -fsyntax-only 2>&1 \
+// RUN: %clang -### %s 2>&1 \
 // RUN: 

[PATCH] D151839: [LinkerWrapper] Fix static library symbol resolution

2023-05-31 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 added inline comments.



Comment at: clang/test/Driver/linker-wrapper-libs.c:27
 //
 // Check that we extract a static library defining an undefined symbol.
 //

tra wrote:
> jhuber6 wrote:
> > tra wrote:
> > > How does this test test the functionality of the undefined symbol? E.g. 
> > > how does it fail now, before the patch?
> > > 
> > > Is there an explicit check we could to do to make sure things work as 
> > > intended as opposed to "there's no obvious error" which may also mean "we 
> > > forgot to process *undefined.bc".
> > Yeah, I wasn't sure how to define a good test for this. The problem I 
> > encountered before making this patch was that having another file that used 
> > an undefined symbol would override the `NewSymbol` check and then would 
> > prevent it from being extracted. So this checks that case.
> AFAICT, with -DUNDEFINED, the file would have only `extern int sym;`. CE says 
> suggests that it produces an embty bitcode file: 
> https://godbolt.org/z/EY9a8Pfeb
> 
> What exactly is supposed to be in the `*.undefined.bc` ?  If it's intended to 
> have an undefined reference to `sym` you need to add some sort of a reference 
> to it. 
> 
Good catch, forgot about that. It's why the other use of `extern sym` returns 
it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151839

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


[PATCH] D151839: [LinkerWrapper] Fix static library symbol resolution

2023-05-31 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 updated this revision to Diff 527240.
jhuber6 added a comment.

Fix test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151839

Files:
  clang/test/Driver/linker-wrapper-libs.c
  clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp

Index: clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
===
--- clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
+++ clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
@@ -1163,20 +1163,21 @@
 /// Scan the symbols from a BitcodeFile \p Buffer and record if we need to
 /// extract any symbols from it.
 Expected getSymbolsFromBitcode(MemoryBufferRef Buffer, OffloadKind Kind,
- StringSaver ,
+ bool IsArchive, StringSaver ,
  DenseMap ) {
   Expected IRSymtabOrErr = readIRSymtab(Buffer);
   if (!IRSymtabOrErr)
 return IRSymtabOrErr.takeError();
 
-  bool ShouldExtract = false;
+  bool ShouldExtract = !IsArchive;
+  DenseMap TmpSyms;
   for (unsigned I = 0; I != IRSymtabOrErr->Mods.size(); ++I) {
 for (const auto  : IRSymtabOrErr->TheReader.module_symbols(I)) {
   if (Sym.isFormatSpecific() || !Sym.isGlobal())
 continue;
 
   bool NewSymbol = Syms.count(Sym.getName()) == 0;
-  auto  = Syms[Saver.save(Sym.getName())];
+  auto OldSym = NewSymbol ? Sym_None : Syms[Sym.getName()];
 
   // We will extract if it defines a currenlty undefined non-weak symbol.
   bool ResolvesStrongReference =
@@ -1192,23 +1193,31 @@
 
   // Update this symbol in the "table" with the new information.
   if (OldSym & Sym_Undefined && !Sym.isUndefined())
-OldSym = static_cast(OldSym & ~Sym_Undefined);
+TmpSyms[Saver.save(Sym.getName())] =
+static_cast(OldSym & ~Sym_Undefined);
   if (Sym.isUndefined() && NewSymbol)
-OldSym = static_cast(OldSym | Sym_Undefined);
+TmpSyms[Saver.save(Sym.getName())] =
+static_cast(OldSym | Sym_Undefined);
   if (Sym.isWeak())
-OldSym = static_cast(OldSym | Sym_Weak);
+TmpSyms[Saver.save(Sym.getName())] =
+static_cast(OldSym | Sym_Weak);
 }
   }
 
+  // If the file gets extracted we update the table with the new symbols.
+  if (ShouldExtract)
+Syms.insert(std::begin(TmpSyms), std::end(TmpSyms));
+
   return ShouldExtract;
 }
 
 /// Scan the symbols from an ObjectFile \p Obj and record if we need to extract
 /// any symbols from it.
 Expected getSymbolsFromObject(const ObjectFile , OffloadKind Kind,
-StringSaver ,
+bool IsArchive, StringSaver ,
 DenseMap ) {
-  bool ShouldExtract = false;
+  bool ShouldExtract = !IsArchive;
+  DenseMap TmpSyms;
   for (SymbolRef Sym : Obj.symbols()) {
 auto FlagsOrErr = Sym.getFlags();
 if (!FlagsOrErr)
@@ -1223,7 +1232,7 @@
   return NameOrErr.takeError();
 
 bool NewSymbol = Syms.count(*NameOrErr) == 0;
-auto  = Syms[Saver.save(*NameOrErr)];
+auto OldSym = NewSymbol ? Sym_None : Syms[*NameOrErr];
 
 // We will extract if it defines a currenlty undefined non-weak symbol.
 bool ResolvesStrongReference = (OldSym & Sym_Undefined) &&
@@ -1240,12 +1249,19 @@
 
 // Update this symbol in the "table" with the new information.
 if (OldSym & Sym_Undefined && !(*FlagsOrErr & SymbolRef::SF_Undefined))
-  OldSym = static_cast(OldSym & ~Sym_Undefined);
+  TmpSyms[Saver.save(*NameOrErr)] =
+  static_cast(OldSym & ~Sym_Undefined);
 if (*FlagsOrErr & SymbolRef::SF_Undefined && NewSymbol)
-  OldSym = static_cast(OldSym | Sym_Undefined);
+  TmpSyms[Saver.save(*NameOrErr)] =
+  static_cast(OldSym | Sym_Undefined);
 if (*FlagsOrErr & SymbolRef::SF_Weak)
-  OldSym = static_cast(OldSym | Sym_Weak);
+  TmpSyms[Saver.save(*NameOrErr)] = static_cast(OldSym | Sym_Weak);
   }
+
+  // If the file gets extracted we update the table with the new symbols.
+  if (ShouldExtract)
+Syms.insert(std::begin(TmpSyms), std::end(TmpSyms));
+
   return ShouldExtract;
 }
 
@@ -1255,18 +1271,19 @@
 ///   1) It defines an undefined symbol in a regular object filie.
 ///   2) It defines a global symbol without hidden visibility that has not
 ///  yet been defined.
-Expected getSymbols(StringRef Image, OffloadKind Kind, StringSaver ,
+Expected getSymbols(StringRef Image, OffloadKind Kind, bool IsArchive,
+  StringSaver ,
   DenseMap ) {
   MemoryBufferRef Buffer = MemoryBufferRef(Image, "");
   switch (identify_magic(Image)) {
   case file_magic::bitcode:
-return getSymbolsFromBitcode(Buffer, Kind, Saver, Syms);
+return getSymbolsFromBitcode(Buffer, Kind, IsArchive, Saver, Syms);
   case 

[PATCH] D151587: [clang][ConstantEmitter] have tryEmitPrivateForVarInit try ConstExprEmitter fast-path first

2023-05-31 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added inline comments.



Comment at: clang/lib/CodeGen/CGExprConstant.cpp:1324
 // This is a string literal initializing an array in an initializer.
-return CGM.GetConstantArrayFromStringLiteral(E);
+return E->isLValue() ?
+  CGM.GetAddrOfConstantStringFromLiteral(E).getPointer() :

nickdesaulniers wrote:
> efriedma wrote:
> > Maybe we should have a separate ConstExprEmitterLValue... trying to handle 
> > both LValues and RValues on the same codepath has been problematic in the 
> > past.  It's very easy for code to get confused what it's actually trying to 
> > emit.
> So we'd have a `ConstExprEmitterLValue` class with some visitor methods, and 
> a `ConstExprEmitterRValue` with other methods implemented?
Something like that.

Actually thinking about it a bit more, not sure you need to actually implement 
ConstExprEmitterLValue for now.  You might just be able to ensure we don't ever 
call ConstExprEmitter with an lvalue.  The current ConstExprEmitter doesn't 
expect lvalues, and shouldn't call itself with lvalues.  (We bail on explicit 
LValueToRValue conversions.)  And Evaluate() shouldn't actually evaluate the 
contents of an lvalue if it isn't dereferenced, so there hopefully aren't any 
performance issues using that codepath.

In terms of implementation, I guess that's basically restoring the 
destType->isReferenceType() that got removed?  (I know I suggested it, but I 
wasn't really thinking about it...)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151587

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


[PATCH] D150746: [CodeGen]Translating pointer arguments can require an address space cast

2023-05-31 Thread Alex Voicu via Phabricator via cfe-commits
AlexVlx added a comment.

In D150746#4381758 , @rjmccall wrote:

> The process is pretty lightweight; I'd recommend just doing it if you expect 
> to make more than one patch.  But we don't have a policy against committing 
> patches for other people as long as there's clear attribution in the commit.
>
> I do think you could successfully test the basic code patterns with passing 
> VTT arguments.  Your test is solely testing that these constructors and 
> destructors are being declared with the right signature, but it doesn't test 
> any calls to them.

Thanks, I've sorted the commit access since this (and some associated work) 
will entail multiple patches. I would like to clarify the second point to make 
sure that I'm incorporating that suggestion - the checks on lines 25, 26 & 27 
are for actual calls - since now the signature matches the VTT type there's no 
arg setup prior to the call, it's a direct passing of the global. Were you 
thinking about something else here / am I missing somethign obvious?


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

https://reviews.llvm.org/D150746

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


[PATCH] D151855: [clang] Use `{File,Directory}EntryRef` in modular header search (part 2/2)

2023-05-31 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 created this revision.
jansvoboda11 added reviewers: benlangmuir, bnbarham.
Herald added a subscriber: ributzka.
Herald added a project: All.
jansvoboda11 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This patch removes some deprecated uses of `{File,Directory}Entry::getName()`. 
No functional change indended.

Depends on D151854 .


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D151855

Files:
  clang/include/clang/Lex/HeaderSearch.h
  clang/include/clang/Lex/ModuleMap.h
  clang/lib/Lex/HeaderSearch.cpp
  clang/lib/Lex/ModuleMap.cpp
  clang/lib/Lex/PPDirectives.cpp

Index: clang/lib/Lex/PPDirectives.cpp
===
--- clang/lib/Lex/PPDirectives.cpp
+++ clang/lib/Lex/PPDirectives.cpp
@@ -867,7 +867,7 @@
 
 // We want to find all possible modules that might contain this header, so
 // search all enclosing directories for module maps and load them.
-HeaderInfo.hasModuleMap(FE->getName(), /*Root*/ nullptr,
+HeaderInfo.hasModuleMap(FE->getNameAsRequested(), /*Root*/ nullptr,
 SourceMgr.isInSystemHeader(Loc));
 
 bool InPrivateHeader = false;
Index: clang/lib/Lex/ModuleMap.cpp
===
--- clang/lib/Lex/ModuleMap.cpp
+++ clang/lib/Lex/ModuleMap.cpp
@@ -700,12 +700,12 @@
   return It->second;
 }
 
-bool ModuleMap::isHeaderInUnavailableModule(const FileEntry *Header) const {
+bool ModuleMap::isHeaderInUnavailableModule(FileEntryRef Header) const {
   return isHeaderUnavailableInModule(Header, nullptr);
 }
 
 bool
-ModuleMap::isHeaderUnavailableInModule(const FileEntry *Header,
+ModuleMap::isHeaderUnavailableInModule(FileEntryRef Header,
const Module *RequestingModule) const {
   resolveHeaderDirectives(Header);
   HeadersMap::const_iterator Known = Headers.find(Header);
@@ -734,8 +734,8 @@
 return true;
   }
 
-  const DirectoryEntry *Dir = Header->getDir();
-  SmallVector SkippedDirs;
+  OptionalDirectoryEntryRef Dir = Header.getDir();
+  SmallVector SkippedDirs;
   StringRef DirName = Dir->getName();
 
   auto IsUnavailable = [&](const Module *M) {
@@ -746,8 +746,7 @@
   // Keep walking up the directory hierarchy, looking for a directory with
   // an umbrella header.
   do {
-llvm::DenseMap::const_iterator KnownDir
-  = UmbrellaDirs.find(Dir);
+auto KnownDir = UmbrellaDirs.find(*Dir);
 if (KnownDir != UmbrellaDirs.end()) {
   Module *Found = KnownDir->second;
   if (IsUnavailable(Found))
@@ -761,11 +760,11 @@
 UmbrellaModule = UmbrellaModule->Parent;
 
   if (UmbrellaModule->InferSubmodules) {
-for (const DirectoryEntry *SkippedDir : llvm::reverse(SkippedDirs)) {
+for (DirectoryEntryRef SkippedDir : llvm::reverse(SkippedDirs)) {
   // Find or create the module that corresponds to this directory name.
   SmallString<32> NameBuf;
   StringRef Name = sanitizeFilenameAsIdentifier(
-  llvm::sys::path::stem(SkippedDir->getName()), NameBuf);
+  llvm::sys::path::stem(SkippedDir.getName()), NameBuf);
   Found = lookupModuleQualified(Name, Found);
   if (!Found)
 return false;
@@ -776,7 +775,7 @@
 // Infer a submodule with the same name as this header file.
 SmallString<32> NameBuf;
 StringRef Name = sanitizeFilenameAsIdentifier(
-   llvm::sys::path::stem(Header->getName()),
+   llvm::sys::path::stem(Header.getName()),
NameBuf);
 Found = lookupModuleQualified(Name, Found);
 if (!Found)
@@ -786,7 +785,7 @@
   return IsUnavailable(Found);
 }
 
-SkippedDirs.push_back(Dir);
+SkippedDirs.push_back(*Dir);
 
 // Retrieve our parent path.
 DirName = llvm::sys::path::parent_path(DirName);
@@ -794,10 +793,7 @@
   break;
 
 // Resolve the parent path to a directory entry.
-if (auto DirEntry = SourceMgr.getFileManager().getDirectory(DirName))
-  Dir = *DirEntry;
-else
-  Dir = nullptr;
+Dir = SourceMgr.getFileManager().getOptionalDirectoryRef(DirName);
   } while (Dir);
 
   return false;
Index: clang/lib/Lex/HeaderSearch.cpp
===
--- clang/lib/Lex/HeaderSearch.cpp
+++ clang/lib/Lex/HeaderSearch.cpp
@@ -1278,8 +1278,8 @@
   getFileInfo(>getFileEntry()).DirInfo = DirInfo;
 
   FrameworkName.pop_back(); // remove the trailing '/'
-  if (!findUsableModuleForFrameworkHeader(*File, FrameworkName,
-  RequestingModule, SuggestedModule,
+  if (!findUsableModuleForFrameworkHeader(*File, FrameworkName, RequestingModule,
+  SuggestedModule,
   

[PATCH] D151854: [clang] Use `FileEntryRef` in modular header search (part 1/2)

2023-05-31 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 created this revision.
jansvoboda11 added reviewers: benlangmuir, bnbarham.
Herald added subscribers: ributzka, arphaman.
Herald added a project: All.
jansvoboda11 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This patch removes some deprecated uses of `{File,Directory}Entry::getName()`. 
No functional change indended.

Depends on D151853 .


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D151854

Files:
  clang/include/clang/Lex/HeaderSearch.h
  clang/include/clang/Lex/ModuleMap.h
  clang/lib/Lex/HeaderSearch.cpp
  clang/lib/Lex/ModuleMap.cpp
  clang/tools/libclang/CIndex.cpp

Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -8799,7 +8799,8 @@
 
   ASTUnit  = *cxtu::getASTUnit(TU);
   HeaderSearch  = Unit.getPreprocessor().getHeaderSearchInfo();
-  ModuleMap::KnownHeader Header = HS.findModuleForHeader(FE);
+  // TODO: Make CXFile a FileEntryRef.
+  ModuleMap::KnownHeader Header = HS.findModuleForHeader(FE->getLastRef());
 
   return Header.getModule();
 }
Index: clang/lib/Lex/ModuleMap.cpp
===
--- clang/lib/Lex/ModuleMap.cpp
+++ clang/lib/Lex/ModuleMap.cpp
@@ -409,29 +409,27 @@
   return Known;
 }
 
-ModuleMap::KnownHeader
-ModuleMap::findHeaderInUmbrellaDirs(const FileEntry *File,
-SmallVectorImpl ) {
+ModuleMap::KnownHeader ModuleMap::findHeaderInUmbrellaDirs(
+FileEntryRef File, SmallVectorImpl ) {
   if (UmbrellaDirs.empty())
 return {};
 
-  const DirectoryEntry *Dir = File->getDir();
-  assert(Dir && "file in no directory");
+  OptionalDirectoryEntryRef Dir = File.getDir();
 
   // Note: as an egregious but useful hack we use the real path here, because
   // frameworks moving from top-level frameworks to embedded frameworks tend
   // to be symlinked from the top-level location to the embedded location,
   // and we need to resolve lookups as if we had found the embedded location.
-  StringRef DirName = SourceMgr.getFileManager().getCanonicalName(Dir);
+  StringRef DirName = SourceMgr.getFileManager().getCanonicalName(*Dir);
 
   // Keep walking up the directory hierarchy, looking for a directory with
   // an umbrella header.
   do {
-auto KnownDir = UmbrellaDirs.find(Dir);
+auto KnownDir = UmbrellaDirs.find(*Dir);
 if (KnownDir != UmbrellaDirs.end())
   return KnownHeader(KnownDir->second, NormalHeader);
 
-IntermediateDirs.push_back(Dir);
+IntermediateDirs.push_back(*Dir);
 
 // Retrieve our parent path.
 DirName = llvm::sys::path::parent_path(DirName);
@@ -439,10 +437,7 @@
   break;
 
 // Resolve the parent path to a directory entry.
-if (auto DirEntry = SourceMgr.getFileManager().getDirectory(DirName))
-  Dir = *DirEntry;
-else
-  Dir = nullptr;
+Dir = SourceMgr.getFileManager().getOptionalDirectoryRef(DirName);
   } while (Dir);
   return {};
 }
@@ -582,7 +577,7 @@
   return false;
 }
 
-ModuleMap::KnownHeader ModuleMap::findModuleForHeader(const FileEntry *File,
+ModuleMap::KnownHeader ModuleMap::findModuleForHeader(FileEntryRef File,
   bool AllowTextual,
   bool AllowExcluded) {
   auto MakeResult = [&](ModuleMap::KnownHeader R) -> ModuleMap::KnownHeader {
@@ -612,10 +607,10 @@
 }
 
 ModuleMap::KnownHeader
-ModuleMap::findOrCreateModuleForHeaderInUmbrellaDir(const FileEntry *File) {
+ModuleMap::findOrCreateModuleForHeaderInUmbrellaDir(FileEntryRef File) {
   assert(!Headers.count(File) && "already have a module for this header");
 
-  SmallVector SkippedDirs;
+  SmallVector SkippedDirs;
   KnownHeader H = findHeaderInUmbrellaDirs(File, SkippedDirs);
   if (H) {
 Module *Result = H.getModule();
@@ -635,11 +630,11 @@
   // the actual header is located.
   bool Explicit = UmbrellaModule->InferExplicitSubmodules;
 
-  for (const DirectoryEntry *SkippedDir : llvm::reverse(SkippedDirs)) {
+  for (DirectoryEntryRef SkippedDir : llvm::reverse(SkippedDirs)) {
 // Find or create the module that corresponds to this directory name.
 SmallString<32> NameBuf;
 StringRef Name = sanitizeFilenameAsIdentifier(
-llvm::sys::path::stem(SkippedDir->getName()), NameBuf);
+llvm::sys::path::stem(SkippedDir.getName()), NameBuf);
 Result = findOrCreateModule(Name, Result, /*IsFramework=*/false,
 Explicit).first;
 InferredModuleAllowedBy[Result] = UmbrellaModuleMap;
@@ -657,7 +652,7 @@
   // Infer a submodule with the same name as this header file.
   SmallString<32> NameBuf;
   StringRef Name = sanitizeFilenameAsIdentifier(
- 

[PATCH] D151853: [clang] NFCI: Split `HeaderSearch::findAllModulesForHeader()`

2023-05-31 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 created this revision.
jansvoboda11 added reviewers: benlangmuir, bnbarham.
Herald added a subscriber: ributzka.
Herald added a project: All.
jansvoboda11 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This mimics the `ModuleMap` API and enables Dxx, where the `AllowCreation = 
true` function needs `FileEntryRef` but `AllowCreation = false` functions is 
happy with plain `FileEntry`. No functional change intended.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D151853

Files:
  clang/include/clang/Lex/HeaderSearch.h
  clang/include/clang/Lex/ModuleMap.h
  clang/lib/Lex/HeaderSearch.cpp
  clang/lib/Lex/ModuleMap.cpp
  clang/lib/Serialization/ASTWriter.cpp

Index: clang/lib/Serialization/ASTWriter.cpp
===
--- clang/lib/Serialization/ASTWriter.cpp
+++ clang/lib/Serialization/ASTWriter.cpp
@@ -185,8 +185,7 @@
 if (!HFI || (HFI->isModuleHeader && !HFI->isCompilingModuleHeader))
   continue;
 
-for (const auto  :
- HS.findAllModulesForHeader(File, /*AllowCreation=*/false)) {
+for (const auto  : HS.findResolvedModulesForHeader(File)) {
   if (!KH.getModule())
 continue;
   ModulesToProcess.push_back(KH.getModule());
Index: clang/lib/Lex/ModuleMap.cpp
===
--- clang/lib/Lex/ModuleMap.cpp
+++ clang/lib/Lex/ModuleMap.cpp
@@ -684,12 +684,12 @@
 }
 
 ArrayRef
-ModuleMap::findAllModulesForHeader(const FileEntry *File, bool AllowCreation) {
+ModuleMap::findAllModulesForHeader(const FileEntry *File) {
   HeadersMap::iterator Known = findKnownHeader(File);
   if (Known != Headers.end())
 return Known->second;
 
-  if (AllowCreation && findOrCreateModuleForHeaderInUmbrellaDir(File))
+  if (findOrCreateModuleForHeaderInUmbrellaDir(File))
 return Headers.find(File)->second;
 
   return std::nullopt;
Index: clang/lib/Lex/HeaderSearch.cpp
===
--- clang/lib/Lex/HeaderSearch.cpp
+++ clang/lib/Lex/HeaderSearch.cpp
@@ -1570,14 +1570,23 @@
 }
 
 ArrayRef
-HeaderSearch::findAllModulesForHeader(const FileEntry *File,
-  bool AllowCreation) const {
+HeaderSearch::findAllModulesForHeader(const FileEntry *File) const {
   if (ExternalSource) {
 // Make sure the external source has handled header info about this file,
 // which includes whether the file is part of a module.
 (void)getExistingFileInfo(File);
   }
-  return ModMap.findAllModulesForHeader(File, AllowCreation);
+  return ModMap.findAllModulesForHeader(File);
+}
+
+ArrayRef
+HeaderSearch::findResolvedModulesForHeader(const FileEntry *File) const {
+  if (ExternalSource) {
+// Make sure the external source has handled header info about this file,
+// which includes whether the file is part of a module.
+(void)getExistingFileInfo(File);
+  }
+  return ModMap.findResolvedModulesForHeader(File);
 }
 
 static bool suggestModule(HeaderSearch , const FileEntry *File,
Index: clang/include/clang/Lex/ModuleMap.h
===
--- clang/include/clang/Lex/ModuleMap.h
+++ clang/include/clang/Lex/ModuleMap.h
@@ -448,13 +448,9 @@
   /// and does not consult the external source. (Those checks are the
   /// responsibility of \ref HeaderSearch.)
   ///
-  /// \param AllowCreation Whether to allow inference of a new submodule, or to
-  ///only return existing known modules.
-  ///
   /// Typically, \ref findModuleForHeader should be used instead, as it picks
   /// the preferred module for the header.
-  ArrayRef findAllModulesForHeader(const FileEntry *File,
-bool AllowCreation = true);
+  ArrayRef findAllModulesForHeader(const FileEntry *File);
 
   /// Like \ref findAllModulesForHeader, but do not attempt to infer module
   /// ownership from umbrella headers if we've not already done so.
Index: clang/include/clang/Lex/HeaderSearch.h
===
--- clang/include/clang/Lex/HeaderSearch.h
+++ clang/include/clang/Lex/HeaderSearch.h
@@ -670,8 +670,12 @@
   ///
   /// \ref findModuleForHeader should typically be used instead of this.
   ArrayRef
-  findAllModulesForHeader(const FileEntry *File,
-  bool AllowCreation = true) const;
+  findAllModulesForHeader(const FileEntry *File) const;
+
+  /// Like \ref findAllModulesForHeader, but do not attempt to infer module
+  /// ownership from umbrella headers if we've not already done so.
+  ArrayRef
+  findResolvedModulesForHeader(const FileEntry *File) const;
 
   /// Read the contents of the given module map file.
   ///
___
cfe-commits mailing list
cfe-commits@lists.llvm.org

[PATCH] D151852: [clang] NFCI: Use `FileEntryRef` in `ModuleMapCallbacks`

2023-05-31 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 created this revision.
jansvoboda11 added reviewers: benlangmuir, bnbarham.
Herald added a subscriber: ributzka.
Herald added a project: All.
jansvoboda11 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This patch removes path hackery from `ModuleMapCallbacks` by adopting 
`FileEntryRef`. No functional change intended.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D151852

Files:
  clang/include/clang/Lex/ModuleMap.h
  clang/lib/Frontend/ModuleDependencyCollector.cpp
  clang/lib/Lex/ModuleMap.cpp


Index: clang/lib/Lex/ModuleMap.cpp
===
--- clang/lib/Lex/ModuleMap.cpp
+++ clang/lib/Lex/ModuleMap.cpp
@@ -1180,7 +1180,7 @@
 
   // Notify callbacks that we just added a new header.
   for (const auto  : Callbacks)
-Cb->moduleMapAddUmbrellaHeader((), 
UmbrellaHeader);
+Cb->moduleMapAddUmbrellaHeader(UmbrellaHeader);
 }
 
 void ModuleMap::setUmbrellaDirAsWritten(
Index: clang/lib/Frontend/ModuleDependencyCollector.cpp
===
--- clang/lib/Frontend/ModuleDependencyCollector.cpp
+++ clang/lib/Frontend/ModuleDependencyCollector.cpp
@@ -72,37 +72,12 @@
 if (llvm::sys::path::is_absolute(HeaderPath))
   Collector.addFile(HeaderPath);
   }
-  void moduleMapAddUmbrellaHeader(FileManager *FileMgr,
-  const FileEntry *Header) override {
-StringRef HeaderFilename = Header->getName();
-moduleMapAddHeader(HeaderFilename);
-// The FileManager can find and cache the symbolic link for a framework
-// header before its real path, this means a module can have some of its
-// headers to use other paths. Although this is usually not a problem, it's
-// inconsistent, and not collecting the original path header leads to
-// umbrella clashes while rebuilding modules in the crash reproducer. For
-// example:
-//ApplicationServices.framework/Frameworks/ImageIO.framework/ImageIO.h
-// instead of:
-//ImageIO.framework/ImageIO.h
-//
-// FIXME: this shouldn't be necessary once we have FileName instances
-// around instead of FileEntry ones. For now, make sure we collect all
-// that we need for the reproducer to work correctly.
-StringRef UmbreallDirFromHeader =
-llvm::sys::path::parent_path(HeaderFilename);
-StringRef UmbrellaDir = Header->getDir()->getName();
-if (!UmbrellaDir.equals(UmbreallDirFromHeader)) {
-  SmallString<128> AltHeaderFilename;
-  llvm::sys::path::append(AltHeaderFilename, UmbrellaDir,
-  llvm::sys::path::filename(HeaderFilename));
-  if (FileMgr->getFile(AltHeaderFilename))
-moduleMapAddHeader(AltHeaderFilename);
-}
+  void moduleMapAddUmbrellaHeader(FileEntryRef Header) override {
+moduleMapAddHeader(Header.getNameAsRequested());
   }
 };
 
-}
+} // namespace
 
 void ModuleDependencyCollector::attachToASTReader(ASTReader ) {
   R.addListener(
Index: clang/include/clang/Lex/ModuleMap.h
===
--- clang/include/clang/Lex/ModuleMap.h
+++ clang/include/clang/Lex/ModuleMap.h
@@ -69,8 +69,7 @@
   ///
   /// \param FileMgr FileManager instance
   /// \param Header The umbrella header to collect.
-  virtual void moduleMapAddUmbrellaHeader(FileManager *FileMgr,
-  const FileEntry *Header) {}
+  virtual void moduleMapAddUmbrellaHeader(FileEntryRef Header) {}
 };
 
 class ModuleMap {


Index: clang/lib/Lex/ModuleMap.cpp
===
--- clang/lib/Lex/ModuleMap.cpp
+++ clang/lib/Lex/ModuleMap.cpp
@@ -1180,7 +1180,7 @@
 
   // Notify callbacks that we just added a new header.
   for (const auto  : Callbacks)
-Cb->moduleMapAddUmbrellaHeader((), UmbrellaHeader);
+Cb->moduleMapAddUmbrellaHeader(UmbrellaHeader);
 }
 
 void ModuleMap::setUmbrellaDirAsWritten(
Index: clang/lib/Frontend/ModuleDependencyCollector.cpp
===
--- clang/lib/Frontend/ModuleDependencyCollector.cpp
+++ clang/lib/Frontend/ModuleDependencyCollector.cpp
@@ -72,37 +72,12 @@
 if (llvm::sys::path::is_absolute(HeaderPath))
   Collector.addFile(HeaderPath);
   }
-  void moduleMapAddUmbrellaHeader(FileManager *FileMgr,
-  const FileEntry *Header) override {
-StringRef HeaderFilename = Header->getName();
-moduleMapAddHeader(HeaderFilename);
-// The FileManager can find and cache the symbolic link for a framework
-// header before its real path, this means a module can have some of its
-// headers to use other paths. Although this is usually not a problem, it's
-// inconsistent, and not collecting the original path header leads to
-// umbrella clashes while rebuilding modules in 

[PATCH] D151839: [LinkerWrapper] Fix static library symbol resolution

2023-05-31 Thread Artem Belevich via Phabricator via cfe-commits
tra added inline comments.



Comment at: clang/test/Driver/linker-wrapper-libs.c:27
 //
 // Check that we extract a static library defining an undefined symbol.
 //

jhuber6 wrote:
> tra wrote:
> > How does this test test the functionality of the undefined symbol? E.g. how 
> > does it fail now, before the patch?
> > 
> > Is there an explicit check we could to do to make sure things work as 
> > intended as opposed to "there's no obvious error" which may also mean "we 
> > forgot to process *undefined.bc".
> Yeah, I wasn't sure how to define a good test for this. The problem I 
> encountered before making this patch was that having another file that used 
> an undefined symbol would override the `NewSymbol` check and then would 
> prevent it from being extracted. So this checks that case.
AFAICT, with -DUNDEFINED, the file would have only `extern int sym;`. CE says 
suggests that it produces an embty bitcode file: https://godbolt.org/z/EY9a8Pfeb

What exactly is supposed to be in the `*.undefined.bc` ?  If it's intended to 
have an undefined reference to `sym` you need to add some sort of a reference 
to it. 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151839

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


[PATCH] D151595: [BOLT][CMake] Redo the build and install targets

2023-05-31 Thread Amir Ayupov via Phabricator via cfe-commits
Amir added inline comments.



Comment at: bolt/test/CMakeLists.txt:40
   llvm-bolt
-  llvm-boltdiff
   llvm-bolt-heatmap

We have a number of dependencies on llvm-boltdiff and perf2bolt, e.g. in 
internal and upstream binary tests: 
https://github.com/rafaelauler/bolt-tests/blob/main/CMakeLists.txt#L22. Can we 
keep these targets somehow?



Comment at: bolt/tools/heatmap/CMakeLists.txt:8
 
-add_bolt_tool(llvm-bolt-heatmap
+add_bolt_executable(llvm-bolt-heatmap
   heatmap.cpp

phosek wrote:
> smeenai wrote:
> > Why this change?
> This tool wasn't previously included in the `bolt` umbrella target so I 
> assume that it doesn't need an install target, but I'd be helpful for @Amir 
> to confirm.
It wasn't included by omission. Let's include it into the umbrella target.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151595

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


[PATCH] D151839: [LinkerWrapper] Fix static library symbol resolution

2023-05-31 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 added inline comments.



Comment at: clang/test/Driver/linker-wrapper-libs.c:27
 //
 // Check that we extract a static library defining an undefined symbol.
 //

tra wrote:
> How does this test test the functionality of the undefined symbol? E.g. how 
> does it fail now, before the patch?
> 
> Is there an explicit check we could to do to make sure things work as 
> intended as opposed to "there's no obvious error" which may also mean "we 
> forgot to process *undefined.bc".
Yeah, I wasn't sure how to define a good test for this. The problem I 
encountered before making this patch was that having another file that used an 
undefined symbol would override the `NewSymbol` check and then would prevent it 
from being extracted. So this checks that case.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151839

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


[PATCH] D151839: [LinkerWrapper] Fix static library symbol resolution

2023-05-31 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment.

LGTM in general.




Comment at: clang/test/Driver/linker-wrapper-libs.c:27
 //
 // Check that we extract a static library defining an undefined symbol.
 //

How does this test test the functionality of the undefined symbol? E.g. how 
does it fail now, before the patch?

Is there an explicit check we could to do to make sure things work as intended 
as opposed to "there's no obvious error" which may also mean "we forgot to 
process *undefined.bc".


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151839

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


[clang] 0038d6c - [clang] NFCI: Use `DirectoryEntryRef` in framework lookup

2023-05-31 Thread Jan Svoboda via cfe-commits

Author: Jan Svoboda
Date: 2023-05-31T16:04:46-07:00
New Revision: 0038d6c7fe75a9f45076a347e4fd9b1f59051899

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

LOG: [clang] NFCI: Use `DirectoryEntryRef` in framework lookup

This removes one use of the deprecated `DirectoryEntry::getName()`.

Added: 


Modified: 
clang/lib/Lex/HeaderSearch.cpp

Removed: 




diff  --git a/clang/lib/Lex/HeaderSearch.cpp b/clang/lib/Lex/HeaderSearch.cpp
index 7e8f93ab172a..db7e531ed313 100644
--- a/clang/lib/Lex/HeaderSearch.cpp
+++ b/clang/lib/Lex/HeaderSearch.cpp
@@ -690,7 +690,7 @@ OptionalFileEntryRef DirectoryLookup::DoFrameworkLookup(
   // If we found the header and are allowed to suggest a module, do so now.
   if (File && needModuleLookup(RequestingModule, SuggestedModule)) {
 // Find the framework in which this header occurs.
-StringRef FrameworkPath = File->getFileEntry().getDir()->getName();
+StringRef FrameworkPath = File->getDir().getName();
 bool FoundFramework = false;
 do {
   // Determine whether this directory exists.



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


[clang] 2d817d0 - [clang] NFCI: Use the `*Ref()` variant on search paths

2023-05-31 Thread Jan Svoboda via cfe-commits

Author: Jan Svoboda
Date: 2023-05-31T16:04:45-07:00
New Revision: 2d817d0368ee72e2bd97bad88434cba2df30be8a

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

LOG: [clang] NFCI: Use the `*Ref()` variant on search paths

This removes some uses of the deprecated `DirectoryEntry::getName()`.

Added: 


Modified: 
clang-tools-extra/clangd/index/StdLib.cpp
clang/lib/Lex/HeaderSearch.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/index/StdLib.cpp 
b/clang-tools-extra/clangd/index/StdLib.cpp
index 381d599e3d2aa..d9aa46d6b75b1 100644
--- a/clang-tools-extra/clangd/index/StdLib.cpp
+++ b/clang-tools-extra/clangd/index/StdLib.cpp
@@ -314,7 +314,7 @@ std::optional StdLibSet::add(const 
LangOptions ,
llvm::make_range(HS.search_dir_begin(), HS.search_dir_end())) {
 switch (DL.getLookupType()) {
 case DirectoryLookup::LT_NormalDir: {
-  Path = DL.getDir()->getName();
+  Path = DL.getDirRef()->getName();
   llvm::sys::path::append(Path, ProbeHeader);
   llvm::vfs::Status Stat;
   if (!HS.getFileMgr().getNoncachedStatValue(Path, Stat) &&

diff  --git a/clang/lib/Lex/HeaderSearch.cpp b/clang/lib/Lex/HeaderSearch.cpp
index 3366f158fd4f7..7e8f93ab172ad 100644
--- a/clang/lib/Lex/HeaderSearch.cpp
+++ b/clang/lib/Lex/HeaderSearch.cpp
@@ -311,7 +311,7 @@ Module *HeaderSearch::lookupModule(StringRef ModuleName, 
StringRef SearchName,
   // SearchName rather than ModuleName, to permit finding private modules
   // named FooPrivate in buggy frameworks named Foo.
   SmallString<128> FrameworkDirName;
-  FrameworkDirName += Dir.getFrameworkDir()->getName();
+  FrameworkDirName += Dir.getFrameworkDirRef()->getName();
   llvm::sys::path::append(FrameworkDirName, SearchName + ".framework");
   if (auto FrameworkDir =
   FileMgr.getOptionalDirectoryRef(FrameworkDirName)) {
@@ -345,7 +345,7 @@ Module *HeaderSearch::lookupModule(StringRef ModuleName, 
StringRef SearchName,
 // Search for a module map in a subdirectory with the same name as the
 // module.
 SmallString<128> NestedModuleMapDirName;
-NestedModuleMapDirName = Dir.getDir()->getName();
+NestedModuleMapDirName = Dir.getDirRef()->getName();
 llvm::sys::path::append(NestedModuleMapDirName, ModuleName);
 if (loadModuleMapFile(NestedModuleMapDirName, IsSystem,
   /*IsFramework*/false) == LMM_NewlyLoaded){
@@ -405,11 +405,10 @@ void HeaderSearch::indexInitialHeaderMaps() {
 /// getName - Return the directory or filename corresponding to this lookup
 /// object.
 StringRef DirectoryLookup::getName() const {
-  // FIXME: Use the name from \c DirectoryEntryRef.
   if (isNormalDir())
-return getDir()->getName();
+return getDirRef()->getName();
   if (isFramework())
-return getFrameworkDir()->getName();
+return getFrameworkDirRef()->getName();
   assert(isHeaderMap() && "Unknown DirectoryLookup");
   return getHeaderMap()->getFileName();
 }
@@ -1840,7 +1839,7 @@ void 
HeaderSearch::collectAllModules(SmallVectorImpl ) {
   if (DL.isFramework()) {
 std::error_code EC;
 SmallString<128> DirNative;
-llvm::sys::path::native(DL.getFrameworkDir()->getName(), DirNative);
+llvm::sys::path::native(DL.getFrameworkDirRef()->getName(), DirNative);
 
 // Search each of the ".framework" directories to load them as modules.
 llvm::vfs::FileSystem  = FileMgr.getVirtualFileSystem();
@@ -1903,7 +1902,7 @@ void 
HeaderSearch::loadSubdirectoryModuleMaps(DirectoryLookup ) {
 return;
 
   std::error_code EC;
-  SmallString<128> Dir = SearchDir.getDir()->getName();
+  SmallString<128> Dir = SearchDir.getDirRef()->getName();
   FileMgr.makeAbsolutePath(Dir);
   SmallString<128> DirNative;
   llvm::sys::path::native(Dir, DirNative);
@@ -1986,14 +1985,14 @@ std::string 
HeaderSearch::suggestPathToFileForDiagnostics(
   bool BestPrefixIsFramework = false;
   for (const DirectoryLookup  : search_dir_range()) {
 if (DL.isNormalDir()) {
-  StringRef Dir = DL.getDir()->getName();
+  StringRef Dir = DL.getDirRef()->getName();
   if (CheckDir(Dir)) {
 if (IsSystem)
   *IsSystem = BestPrefixLength && isSystem(DL.getDirCharacteristic());
 BestPrefixIsFramework = false;
   }
 } else if (DL.isFramework()) {
-  StringRef Dir = DL.getFrameworkDir()->getName();
+  StringRef Dir = DL.getFrameworkDirRef()->getName();
   if (CheckDir(Dir)) {
 if (IsSystem)
   *IsSystem = BestPrefixLength && isSystem(DL.getDirCharacteristic());



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


[clang] 5be0e83 - [clang] NFCI: Use `FileEntryRef` in `PPLexerChange`

2023-05-31 Thread Jan Svoboda via cfe-commits

Author: Jan Svoboda
Date: 2023-05-31T16:04:45-07:00
New Revision: 5be0e83635a22da0a42aeeeca8d42193ff2f9db6

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

LOG: [clang] NFCI: Use `FileEntryRef` in `PPLexerChange`

This removes some uses of the deprecated `FileEntry::getName()`.

Added: 


Modified: 
clang/lib/Lex/PPLexerChange.cpp

Removed: 




diff  --git a/clang/lib/Lex/PPLexerChange.cpp b/clang/lib/Lex/PPLexerChange.cpp
index e2dc532e6b70..ab005381adfa 100644
--- a/clang/lib/Lex/PPLexerChange.cpp
+++ b/clang/lib/Lex/PPLexerChange.cpp
@@ -223,18 +223,17 @@ void Preprocessor::EnterTokenStream(const Token *Toks, 
unsigned NumToks,
 /// Compute the relative path that names the given file relative to
 /// the given directory.
 static void computeRelativePath(FileManager , const DirectoryEntry *Dir,
-const FileEntry *File,
-SmallString<128> ) {
+FileEntryRef File, SmallString<128> ) {
   Result.clear();
 
-  StringRef FilePath = File->getDir()->getName();
+  StringRef FilePath = File.getDir().getName();
   StringRef Path = FilePath;
   while (!Path.empty()) {
 if (auto CurDir = FM.getDirectory(Path)) {
   if (*CurDir == Dir) {
 Result = FilePath.substr(Path.size());
 llvm::sys::path::append(Result,
-llvm::sys::path::filename(File->getName()));
+llvm::sys::path::filename(File.getName()));
 return;
   }
 }
@@ -242,7 +241,7 @@ static void computeRelativePath(FileManager , const 
DirectoryEntry *Dir,
 Path = llvm::sys::path::parent_path(Path);
   }
 
-  Result = File->getName();
+  Result = File.getName();
 }
 
 void Preprocessor::PropagateLineStartLeadingSpaceInfo(Token ) {
@@ -314,7 +313,7 @@ void Preprocessor::diagnoseMissingHeaderInUmbrellaDir(const 
Module ) {
  .Default(false))
   continue;
 
-if (auto Header = getFileManager().getFile(Entry->path()))
+if (auto Header = getFileManager().getOptionalFileRef(Entry->path()))
   if (!getSourceManager().hasFileInfo(*Header)) {
 if (!ModMap.isHeaderInUnavailableModule(*Header)) {
   // Find the relative path that would access this header.



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


[clang] 80614e1 - [Fuchsia] Pass through LLVM_ENABLE_HTTPLIB to stage 2

2023-05-31 Thread Daniel Thornburgh via cfe-commits

Author: Daniel Thornburgh
Date: 2023-05-31T15:56:20-07:00
New Revision: 80614e16e857d8767174284701aec69381c4

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

LOG: [Fuchsia] Pass through LLVM_ENABLE_HTTPLIB to stage 2

Added: 


Modified: 
clang/cmake/caches/Fuchsia.cmake

Removed: 




diff  --git a/clang/cmake/caches/Fuchsia.cmake 
b/clang/cmake/caches/Fuchsia.cmake
index 5596cc61359c..e3acd6f29a74 100644
--- a/clang/cmake/caches/Fuchsia.cmake
+++ b/clang/cmake/caches/Fuchsia.cmake
@@ -32,6 +32,7 @@ set(_FUCHSIA_BOOTSTRAP_PASSTHROUGH
   LLVM_ENABLE_LIBXML2
   LibXml2_ROOT
   LLVM_ENABLE_CURL
+  LLVM_ENABLE_HTTPLIB
   CURL_ROOT
   OpenSSL_ROOT
   FUCHSIA_ENABLE_LLDB



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


[PATCH] D150803: [WebAssembly] Add a new `wasm_async` clang attribute for marking async functions.

2023-05-31 Thread Brendan Dahl via Phabricator via cfe-commits
brendandahl updated this revision to Diff 527218.
brendandahl marked an inline comment as done.
brendandahl added a comment.

Address comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150803

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/lib/CodeGen/TargetInfo.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/CodeGen/WebAssembly/wasm-async.c
  clang/test/Misc/pragma-attribute-supported-attributes-list.test
  clang/test/Sema/attr-wasm-async.c
  clang/test/Sema/wasm-async-support.c
  lld/test/wasm/async.s
  lld/test/wasm/merge-async-section.ll
  lld/wasm/InputChunks.cpp
  lld/wasm/InputFiles.cpp
  llvm/include/llvm/BinaryFormat/WasmRelocs.def
  llvm/include/llvm/MC/MCExpr.h
  llvm/lib/MC/MCExpr.cpp
  llvm/lib/MC/WasmObjectWriter.cpp
  llvm/lib/Object/WasmObjectFile.cpp
  llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyWasmObjectWriter.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.h
  llvm/test/CodeGen/WebAssembly/async.ll
  llvm/test/MC/WebAssembly/async.s

Index: llvm/test/MC/WebAssembly/async.s
===
--- /dev/null
+++ llvm/test/MC/WebAssembly/async.s
@@ -0,0 +1,21 @@
+# RUN: llvm-mc -triple=wasm32-unknown-unknown < %s | FileCheck %s
+# Check that it also comiled to object for format.
+# RUN: llvm-mc -triple=wasm32-unknown-unknown -filetype=obj -o - < %s | obj2yaml | FileCheck -check-prefix=CHECK-OBJ %s
+
+foo:
+.globl foo
+.functype foo () -> ()
+end_function
+
+.section.custom_section.async,"",@
+.int32  foo@FUNCINDEX
+
+# CHECK:   .section .custom_section.async,"",@
+# CHECK-NEXT: .int32  foo@FUNCINDEX
+
+# CHECK-OBJ:- Type:CUSTOM
+# CHECK-OBJ-NEXT: Relocations:
+# CHECK-OBJ-NEXT:- Type:R_WASM_FUNCTION_INDEX_I32
+# CHECK-OBJ-NEXT:  Index:   0
+# CHECK-OBJ-NEXT:  Offset:  0x0
+# CHECK-OBJ-NEXT: Name:async
Index: llvm/test/CodeGen/WebAssembly/async.ll
===
--- /dev/null
+++ llvm/test/CodeGen/WebAssembly/async.ll
@@ -0,0 +1,17 @@
+; RUN: llc < %s -asm-verbose=false -wasm-keep-registers | FileCheck %s
+
+target triple = "wasm32-unknown-unknown"
+
+define void @test0() #0 {
+  ret void
+}
+
+define void @test1() #0 {
+  ret void
+}
+
+attributes #0 = { "wasm-async" }
+
+; CHECK:  .section.custom_section.async,"",@
+; CHECK-NEXT: .int32  test0@FUNCINDEX
+; CHECK-NEXT: .int32  test1@FUNCINDEX
Index: llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.h
===
--- llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.h
+++ llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.h
@@ -66,6 +66,7 @@
   void emitEndOfAsmFile(Module ) override;
   void EmitProducerInfo(Module );
   void EmitTargetFeatures(Module );
+  void EmitAsync(Module );
   void emitSymbolType(const MCSymbolWasm *Sym);
   void emitGlobalVariable(const GlobalVariable *GV) override;
   void emitJumpTableInfo() override;
Index: llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp
===
--- llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp
+++ llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp
@@ -438,6 +438,7 @@
 
   EmitProducerInfo(M);
   EmitTargetFeatures(M);
+  EmitAsync(M);
 }
 
 void WebAssemblyAsmPrinter::EmitProducerInfo(Module ) {
@@ -556,6 +557,32 @@
   OutStreamer->popSection();
 }
 
+void WebAssemblyAsmPrinter::EmitAsync(Module ) {
+  SmallVector AsyncFuncs;
+
+  for (const auto  : M) {
+auto *Sym = cast(getSymbol());
+if (F.hasFnAttribute("wasm-async"))
+  AsyncFuncs.push_back(Sym);
+  }
+  if (AsyncFuncs.size() == 0)
+return;
+
+  MCSectionWasm *AsyncSection = OutContext.getWasmSection(
+  ".custom_section.async", SectionKind::getMetadata());
+  OutStreamer->pushSection();
+  OutStreamer->switchSection(AsyncSection);
+
+  for (auto  : AsyncFuncs) {
+OutStreamer->emitValue(
+MCSymbolRefExpr::create(Sym, MCSymbolRefExpr::VK_WASM_FUNCINDEX,
+OutContext),
+4);
+  }
+
+  OutStreamer->popSection();
+}
+
 void WebAssemblyAsmPrinter::emitConstantPool() {
   emitDecls(*MMI->getModule());
   assert(MF->getConstantPool()->getConstants().empty() &&
Index: llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyWasmObjectWriter.cpp
===
--- llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyWasmObjectWriter.cpp
+++ llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyWasmObjectWriter.cpp
@@ -91,6 +91,8 @@
   return wasm::R_WASM_TYPE_INDEX_LEB;
 case MCSymbolRefExpr::VK_None:
   break;
+case 

[PATCH] D150803: [WebAssembly] Add a new `wasm_async` clang attribute for marking async functions.

2023-05-31 Thread Brendan Dahl via Phabricator via cfe-commits
brendandahl marked 12 inline comments as done.
brendandahl added inline comments.



Comment at: clang/lib/Sema/SemaDeclAttr.cpp:7645
+  if (FD->isThisDeclarationADefinition()) {
+S.Diag(D->getLocation(), diag::err_alias_is_definition) << FD << 0;
+return;

aaron.ballman wrote:
> This diagnostic doesn't make sense to me -- how does this attribute relate to 
> ifuncs or aliases? Why should users be prohibited from writing the attribute 
> on a definition?
This was from a previous version, it's not needed anymore. I'll remove.



Comment at: llvm/test/MC/WebAssembly/async.s:10-11
+
+.section.custom_section.async,"",@
+.int32  foo@FUNCINDEX
+

brendandahl wrote:
> aheejin wrote:
> > The intention looks little weird.. Is that what `llc` emits? 
> Yeah, I wasn't really sure how to format, but that's what llc was doing. Open 
> to changing it.
Actually, it does look like something got messed up. I'll fix.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150803

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


[PATCH] D151587: [clang][ConstantEmitter] have tryEmitPrivateForVarInit try ConstExprEmitter fast-path first

2023-05-31 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added inline comments.



Comment at: clang/lib/CodeGen/CGExprConstant.cpp:1324
 // This is a string literal initializing an array in an initializer.
-return CGM.GetConstantArrayFromStringLiteral(E);
+return E->isLValue() ?
+  CGM.GetAddrOfConstantStringFromLiteral(E).getPointer() :

efriedma wrote:
> Maybe we should have a separate ConstExprEmitterLValue... trying to handle 
> both LValues and RValues on the same codepath has been problematic in the 
> past.  It's very easy for code to get confused what it's actually trying to 
> emit.
So we'd have a `ConstExprEmitterLValue` class with some visitor methods, and a 
`ConstExprEmitterRValue` with other methods implemented?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151587

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


[PATCH] D151761: clang-format: Add AlignConsecutiveShortCaseLabels

2023-05-31 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added inline comments.



Comment at: clang/docs/ClangFormatStyleOptions.rst:790
+
+**AlignConsecutiveShortCaseLabels** (``AlignConsecutiveStyle``) 
:versionbadge:`clang-format 17` :ref:`¶ `
+  Style of aligning consecutive short case labels.

Did you generate this by hand or run the dump_format_style.py function? 
Format.h and the rst look out of sync


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151761

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


[PATCH] D151761: clang-format: Add AlignConsecutiveShortCaseLabels

2023-05-31 Thread Galen Elias via Phabricator via cfe-commits
galenelias added a comment.

In D151761#4385163 , 
@HazardyKnusperkeks wrote:

> When I read the title I thought "Yay, some one is doing what I want and don't 
> find the time.", but (for me) sadly you're not.
> I'd like to align the colon (and thus the statement behind that). Do you 
> think you can add that option too?

Hmm, it had not occurred to me that there are folks who would want to insert 
the spaces after the 'case'.  I can think about how that might be accomplished, 
but it doesn't seem straightforward given the current alignment infrastructure 
since the token you want to align (the colon) isn't the token which should be 
padded (the token after the case keyword).  I think I'd have to write custom 
alignment code to allow for the separation of these two.




Comment at: clang/include/clang/Format/Format.h:308
+  /// \version 17
+  AlignConsecutiveStyle AlignConsecutiveShortCaseLabels;
 

HazardyKnusperkeks wrote:
> We need another name, you're not aligning the label, but the statement.
I was taking the name from the GitHub issue, which while I agree is a slight 
misnomer seemed to yield what I assumed most people would expect.  I guess 
`AlignConsecutiveStatementsAfterShortCaseLabels` is more correct, but is also 
getting pretty verbose.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151761

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


[PATCH] D151820: [clang][WebAssembly] Fix __BIGGEST_ALIGNMENT__ under emscripten

2023-05-31 Thread Sam Clegg via Phabricator via cfe-commits
sbc100 added a subscriber: ngzhian.
sbc100 added a comment.

In D151820#4385568 , @sbc100 wrote:

> In D151820#4385536 , @dschuff wrote:
>
>>> I don't think it will since `__BIGGEST_ALIGNMENT__ >= 
>>> XNN_ALLOCATION_ALIGNMENT` will remain true after this change.. so this 
>>> change should have no effect on that code.
>>
>> I meant that when `__BIGGEST_ALIGNMENT__ >= XNN_ALLOCATION_ALIGNMENT` (which 
>> was true before and will remain true), then XNNPack uses 
>> `__builtin_alloca()` as the implementation of `XNN_SIMD_ALLOCA` (which 
>> presumably is for allocating SIMD values). This change will reduce the 
>> alignment used by `__builtin_alloca()` from 16 to 8, such that (I think) it 
>> is no longer suitable for SIMD values.
>>
>> Maybe this is a bug in XNNPack (they should maybe be using 
>> XNN_ALLOCATION_ALIGNMENT with a value suitable for SIMD?) but given that 
>> BIGGEST_ALIGNMENT and alloca seem to be intended for any base type 
>> (including SIMD) it wouldn't be surprising if someone else were depending on 
>> this too.
>
> XNN_ALLOCATION_ALIGNMENT is 8 under webassembly, which apparently the 
> alignment than xnnpack wants for webassemebly.  Using alloca for this is find 
> both before and after this change since both 8 and 18 as fit this requirement.
>
>> which... maybe this is just re-litigating the previous discussion, I don't 
>> know. I wonder at what point our ABI should be treating SIMD values as 
>> "normal" rather than rare.

If xnnpack wanted more than 8 byte alignment it should surely set 
XNN_ALLOCATION_ALIGNMENT to greater than 8?

Adding @tlively and @ngzhian in case that have some more background on this..


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151820

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


[PATCH] D151820: [clang][WebAssembly] Fix __BIGGEST_ALIGNMENT__ under emscripten

2023-05-31 Thread Sam Clegg via Phabricator via cfe-commits
sbc100 added a comment.

In D151820#4385536 , @dschuff wrote:

>> I don't think it will since `__BIGGEST_ALIGNMENT__ >= 
>> XNN_ALLOCATION_ALIGNMENT` will remain true after this change.. so this 
>> change should have no effect on that code.
>
> I meant that when `__BIGGEST_ALIGNMENT__ >= XNN_ALLOCATION_ALIGNMENT` (which 
> was true before and will remain true), then XNNPack uses `__builtin_alloca()` 
> as the implementation of `XNN_SIMD_ALLOCA` (which presumably is for 
> allocating SIMD values). This change will reduce the alignment used by 
> `__builtin_alloca()` from 16 to 8, such that (I think) it is no longer 
> suitable for SIMD values.
>
> Maybe this is a bug in XNNPack (they should maybe be using 
> XNN_ALLOCATION_ALIGNMENT with a value suitable for SIMD?) but given that 
> BIGGEST_ALIGNMENT and alloca seem to be intended for any base type (including 
> SIMD) it wouldn't be surprising if someone else were depending on this too.

XNN_ALLOCATION_ALIGNMENT is 8 under webassembly, which apparently the alignment 
than xnnpack wants for webassemebly.  Using alloca for this is find both before 
and after this change since both 8 and 18 as fit this requirement.

> which... maybe this is just re-litigating the previous discussion, I don't 
> know. I wonder at what point our ABI should be treating SIMD values as 
> "normal" rather than rare.




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151820

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


[clang] 54e4772 - [clang] NFCI: Use `DirectoryEntryRef` in `PrecompiledPreamble`

2023-05-31 Thread Jan Svoboda via cfe-commits

Author: Jan Svoboda
Date: 2023-05-31T14:54:42-07:00
New Revision: 54e47724cfbf12dce05412c5b127ae311066afb3

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

LOG: [clang] NFCI: Use `DirectoryEntryRef` in `PrecompiledPreamble`

This removes some uses of the deprecated `DirectoryEntry::getName()`.

Added: 


Modified: 
clang/lib/Frontend/PrecompiledPreamble.cpp

Removed: 




diff  --git a/clang/lib/Frontend/PrecompiledPreamble.cpp 
b/clang/lib/Frontend/PrecompiledPreamble.cpp
index a47d2b0be004c..5ffb54e2fdf65 100644
--- a/clang/lib/Frontend/PrecompiledPreamble.cpp
+++ b/clang/lib/Frontend/PrecompiledPreamble.cpp
@@ -113,16 +113,16 @@ class MissingFileCollector : public PPCallbacks {
 
 // Reconstruct the filenames that would satisfy this directive...
 llvm::SmallString<256> Buf;
-auto NotFoundRelativeTo = [&](const DirectoryEntry *DE) {
-  Buf = DE->getName();
+auto NotFoundRelativeTo = [&](DirectoryEntryRef DE) {
+  Buf = DE.getName();
   llvm::sys::path::append(Buf, FileName);
   llvm::sys::path::remove_dots(Buf, /*remove_dot_dot=*/true);
   Out.insert(Buf);
 };
 // ...relative to the including file.
 if (!IsAngled) {
-  if (const FileEntry *IncludingFile =
-  SM.getFileEntryForID(SM.getFileID(IncludeTok.getLocation(
+  if (OptionalFileEntryRef IncludingFile =
+  SM.getFileEntryRefForID(SM.getFileID(IncludeTok.getLocation(
 if (IncludingFile->getDir())
   NotFoundRelativeTo(IncludingFile->getDir());
 }
@@ -132,7 +132,7 @@ class MissingFileCollector : public PPCallbacks {
  Search.search_dir_end())) {
   // No support for frameworks or header maps yet.
   if (Dir.isNormalDir())
-NotFoundRelativeTo(Dir.getDir());
+NotFoundRelativeTo(*Dir.getDirRef());
 }
   }
 };



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


[clang] 6587d9d - [clang] NFCI: Use `DirectoryEntryRef` for `ModuleMap::BuiltinIncludeDir`

2023-05-31 Thread Jan Svoboda via cfe-commits

Author: Jan Svoboda
Date: 2023-05-31T14:54:42-07:00
New Revision: 6587d9d87a58b08e86484ab25a121c3bfeb68949

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

LOG: [clang] NFCI: Use `DirectoryEntryRef` for `ModuleMap::BuiltinIncludeDir`

This removes some uses of the deprecated `DirectoryEntry::getName()`.

Added: 


Modified: 
clang/include/clang/Lex/ModuleMap.h
clang/lib/Lex/InitHeaderSearch.cpp

Removed: 




diff  --git a/clang/include/clang/Lex/ModuleMap.h 
b/clang/include/clang/Lex/ModuleMap.h
index 79cf0afc46271..e28147c7be080 100644
--- a/clang/include/clang/Lex/ModuleMap.h
+++ b/clang/include/clang/Lex/ModuleMap.h
@@ -84,7 +84,7 @@ class ModuleMap {
 
   /// The directory used for Clang-supplied, builtin include headers,
   /// such as "stdint.h".
-  const DirectoryEntry *BuiltinIncludeDir = nullptr;
+  OptionalDirectoryEntryRefDegradesToDirectoryEntryPtr BuiltinIncludeDir;
 
   /// Language options used to parse the module map itself.
   ///
@@ -407,7 +407,7 @@ class ModuleMap {
 
   /// Set the directory that contains Clang-supplied include
   /// files, such as our stdarg.h or tgmath.h.
-  void setBuiltinIncludeDir(const DirectoryEntry *Dir) {
+  void setBuiltinIncludeDir(DirectoryEntryRef Dir) {
 BuiltinIncludeDir = Dir;
   }
 

diff  --git a/clang/lib/Lex/InitHeaderSearch.cpp 
b/clang/lib/Lex/InitHeaderSearch.cpp
index 313efb36bcc93..41382d7cb3fc6 100644
--- a/clang/lib/Lex/InitHeaderSearch.cpp
+++ b/clang/lib/Lex/InitHeaderSearch.cpp
@@ -652,7 +652,7 @@ void clang::ApplyHeaderSearchOptions(HeaderSearch ,
 // Set up the builtin include directory in the module map.
 SmallString<128> P = StringRef(HSOpts.ResourceDir);
 llvm::sys::path::append(P, "include");
-if (auto Dir = HS.getFileMgr().getDirectory(P))
+if (auto Dir = HS.getFileMgr().getOptionalDirectoryRef(P))
   HS.getModuleMap().setBuiltinIncludeDir(*Dir);
   }
 



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


[clang] 20edfae - [clang] NFCI: Use `DirectoryEntryRef` in `ASTWriter`

2023-05-31 Thread Jan Svoboda via cfe-commits

Author: Jan Svoboda
Date: 2023-05-31T14:54:42-07:00
New Revision: 20edfaeef7c55bc6ef320ffe1dcb82b88583c92c

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

LOG: [clang] NFCI: Use `DirectoryEntryRef` in `ASTWriter`

This removes the call to deprecated `DirectoryEntry::getName()`.

Added: 


Modified: 
clang/lib/Serialization/ASTWriter.cpp

Removed: 




diff  --git a/clang/lib/Serialization/ASTWriter.cpp 
b/clang/lib/Serialization/ASTWriter.cpp
index 63d91708aeb02..6fa2cd681b191 100644
--- a/clang/lib/Serialization/ASTWriter.cpp
+++ b/clang/lib/Serialization/ASTWriter.cpp
@@ -1280,8 +1280,9 @@ void ASTWriter::WriteControlBlock(Preprocessor , 
ASTContext ,
 SmallString<128> BaseDir;
 if (PP.getHeaderSearchInfo().getHeaderSearchOpts().ModuleFileHomeIsCwd) {
   // Use the current working directory as the base path for all inputs.
-  auto *CWD =
-  Context.getSourceManager().getFileManager().getDirectory(".").get();
+  auto CWD =
+  Context.getSourceManager().getFileManager().getOptionalDirectoryRef(
+  ".");
   BaseDir.assign(CWD->getName());
 } else {
   BaseDir.assign(WritingModule->Directory->getName());



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


[PATCH] D151589: [lld] add context-sensitive PGO options for MachO

2023-05-31 Thread Ellis Hoag via Phabricator via cfe-commits
ellis updated this revision to Diff 527205.
ellis added a comment.

Fix paths in clang test to support windows


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151589

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/lib/Driver/ToolChains/CommonArgs.h
  clang/lib/Driver/ToolChains/Darwin.cpp
  clang/test/Driver/cspgo-lto.c
  lld/MachO/Config.h
  lld/MachO/Driver.cpp
  lld/MachO/LTO.cpp
  lld/MachO/Options.td
  lld/test/MachO/cspgo-gen.ll
  lld/test/MachO/cspgo-use.ll
  lld/test/lit.cfg.py

Index: lld/test/lit.cfg.py
===
--- lld/test/lit.cfg.py
+++ lld/test/lit.cfg.py
@@ -45,6 +45,7 @@
 "llvm-objdump",
 "llvm-otool",
 "llvm-pdbutil",
+"llvm-profdata",
 "llvm-dwarfdump",
 "llvm-readelf",
 "llvm-readobj",
Index: lld/test/MachO/cspgo-use.ll
===
--- /dev/null
+++ lld/test/MachO/cspgo-use.ll
@@ -0,0 +1,18 @@
+; REQUIRES: x86
+
+; Create an empty profile
+; RUN: echo > %t.proftext
+; RUN: llvm-profdata merge %t.proftext -o %t.profdata
+
+; RUN: llvm-as %s -o %t.o
+; RUN: %lld -dylib --cs-profile-path=%t.profdata %t.o -o %t --lto-debug-pass-manager 2>&1 | FileCheck %s --implicit-check-not=PGOInstrumentation
+
+; CHECK: Running pass: PGOInstrumentationUse
+
+target triple = "x86_64-apple-darwin"
+target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
+
+define void @foo() {
+entry:
+  ret void
+}
Index: lld/test/MachO/cspgo-gen.ll
===
--- /dev/null
+++ lld/test/MachO/cspgo-gen.ll
@@ -0,0 +1,16 @@
+; REQUIRES: x86
+
+; RUN: llvm-as %s -o %t.o
+; RUN: %lld -dylib --cs-profile-generate --cs-profile-path=default_%m.profraw %t.o -o %t --lto-debug-pass-manager 2>&1 | FileCheck %s --implicit-check-not=PGOInstrumentation
+
+; CHECK: PGOInstrumentationGen
+
+target triple = "x86_64-apple-darwin"
+target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
+
+@__llvm_profile_runtime = global i32 0, align 4
+
+define void @foo() {
+entry:
+  ret void
+}
Index: lld/MachO/Options.td
===
--- lld/MachO/Options.td
+++ lld/MachO/Options.td
@@ -126,6 +126,10 @@
 Group;
 def lto_debug_pass_manager: Flag<["--"], "lto-debug-pass-manager">,
 HelpText<"Debug new pass manager">, Group;
+def cs_profile_generate: Flag<["--"], "cs-profile-generate">,
+HelpText<"Perform context senstive PGO instrumentation">, Group;
+def cs_profile_path: Joined<["--"], "cs-profile-path=">,
+HelpText<"Context sensitive profile file path">, Group;
 
 // This is a complete Options.td compiled from Apple's ld(1) manpage
 // dated 2018-03-07 and cross checked with ld64 source code in repo
Index: lld/MachO/LTO.cpp
===
--- lld/MachO/LTO.cpp
+++ lld/MachO/LTO.cpp
@@ -69,6 +69,8 @@
   c.TimeTraceEnabled = config->timeTraceEnabled;
   c.TimeTraceGranularity = config->timeTraceGranularity;
   c.DebugPassManager = config->ltoDebugPassManager;
+  c.CSIRProfile = std::string(config->csProfilePath);
+  c.RunCSIRInstr = config->csProfileGenerate;
   c.OptLevel = config->ltoo;
   c.CGOptLevel = config->ltoCgo;
   if (config->saveTemps)
Index: lld/MachO/Driver.cpp
===
--- lld/MachO/Driver.cpp
+++ lld/MachO/Driver.cpp
@@ -1637,6 +1637,8 @@
 config->ignoreAutoLinkOptions.insert(arg->getValue());
   config->strictAutoLink = args.hasArg(OPT_strict_auto_link);
   config->ltoDebugPassManager = args.hasArg(OPT_lto_debug_pass_manager);
+  config->csProfileGenerate = args.hasArg(OPT_cs_profile_generate);
+  config->csProfilePath = args.getLastArgValue(OPT_cs_profile_path);
 
   for (const Arg *arg : args.filtered(OPT_alias)) {
 config->aliasedSymbols.push_back(
Index: lld/MachO/Config.h
===
--- lld/MachO/Config.h
+++ lld/MachO/Config.h
@@ -206,6 +206,8 @@
   std::vector sectionAlignments;
   std::vector segmentProtections;
   bool ltoDebugPassManager = false;
+  bool csProfileGenerate = false;
+  llvm::StringRef csProfilePath;
 
   bool callGraphProfileSort = false;
   llvm::StringRef printSymbolOrder;
Index: clang/test/Driver/cspgo-lto.c
===
--- clang/test/Driver/cspgo-lto.c
+++ clang/test/Driver/cspgo-lto.c
@@ -4,3 +4,17 @@
 // RUN:   -fprofile-use 2>&1 | FileCheck %s
 
 // CHECK: -plugin-opt=cs-profile-path=default.profdata
+
+// RUN: %clang --target=apple-arm64-ios -### %t.o -flto=thin -fuse-ld=lld -fprofile-use 2>&1 | FileCheck %s --check-prefix=DARWIN-USE1
+// RUN: %clang --target=apple-arm64-ios -### %t.o -flto=thin 

[PATCH] D151820: [clang][WebAssembly] Fix __BIGGEST_ALIGNMENT__ under emscripten

2023-05-31 Thread Derek Schuff via Phabricator via cfe-commits
dschuff added a comment.

> I don't think it will since `__BIGGEST_ALIGNMENT__ >= 
> XNN_ALLOCATION_ALIGNMENT` will remain true after this change.. so this change 
> should have no effect on that code.

I meant that when `__BIGGEST_ALIGNMENT__ >= XNN_ALLOCATION_ALIGNMENT` (which 
was true before and will remain true), then XNNPack uses `__builtin_alloca()` 
as the implementation of `XNN_SIMD_ALLOCA` (which presumably is for allocating 
SIMD values). This change will reduce the alignment used by 
`__builtin_alloca()` from 16 to 8, such that (I think) it is no longer suitable 
for SIMD values.

Maybe this is a bug in XNNPack (they should maybe be using 
XNN_ALLOCATION_ALIGNMENT with a value suitable for SIMD?) but given that 
BIGGEST_ALIGNMENT and alloca seem to be intended for any base type (including 
SIMD) it wouldn't be surprising if someone else were depending on this too.

which... maybe this is just re-litigating the previous discussion, I don't 
know. I wonder at what point our ABI should be treating SIMD values as "normal" 
rather than rare.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151820

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


[PATCH] D151595: [BOLT][CMake] Redo the build and install targets

2023-05-31 Thread Amir Ayupov via Phabricator via cfe-commits
Amir added a comment.

In D151595#4385506 , @phosek wrote:

> @Amir does this change look good to you?

Looks good overall. Thanks for adding AddBolt cmake module. Testing the build 
internally, will reply shortly.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151595

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


[PATCH] D151820: [clang][WebAssembly] Fix __BIGGEST_ALIGNMENT__ under emscripten

2023-05-31 Thread Sam Clegg via Phabricator via cfe-commits
sbc100 added a comment.

In D151820#4385512 , @dschuff wrote:

>> I don't think it will change anything in that code since 
>> `__BIGGEST_ALIGNMENT__ >= XNN_ALLOCATION_ALIGNMENT` will still hold true 
>> both before and after this change (XNN_ALLOCATION_ALIGNMENT == 4 on wasm)
>
> Right, that check causes XNN_ALLOCATION_ALIGNMENT to be ignored in favor of 
> using clang's `_builtin_alloca()` which will be changed by this CL.

I don't think it will since `__BIGGEST_ALIGNMENT__ >= XNN_ALLOCATION_ALIGNMENT` 
will remain true after this change.. so this change should have no effect on 
that code.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151820

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


[PATCH] D151820: [clang][WebAssembly] Fix __BIGGEST_ALIGNMENT__ under emscripten

2023-05-31 Thread Derek Schuff via Phabricator via cfe-commits
dschuff added a subscriber: tlively.
dschuff added a comment.

> I don't think it will change anything in that code since 
> `__BIGGEST_ALIGNMENT__ >= XNN_ALLOCATION_ALIGNMENT` will still hold true both 
> before and after this change (XNN_ALLOCATION_ALIGNMENT == 4 on wasm)

Right, that check causes XNN_ALLOCATION_ALIGNMENT to be ignored in favor of 
using clang's `_builtin_alloca()` which will be changed by this CL.
I seem to recall that @tlively and I spent a bunch of time with XNNpack chasing 
down some kind of subtle error that I suspect had to do with alignment, but 
maybe he remembers that better than I do.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151820

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


[PATCH] D151595: [BOLT][CMake] Redo the build and install targets

2023-05-31 Thread Petr Hosek via Phabricator via cfe-commits
phosek added a comment.

@Amir does this change look good to you?




Comment at: bolt/tools/heatmap/CMakeLists.txt:8
 
-add_bolt_tool(llvm-bolt-heatmap
+add_bolt_executable(llvm-bolt-heatmap
   heatmap.cpp

smeenai wrote:
> Why this change?
This tool wasn't previously included in the `bolt` umbrella target so I assume 
that it doesn't need an install target, but I'd be helpful for @Amir to confirm.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151595

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


[PATCH] D151763: [clang] Fix crash when passing a braced-init list to a parentehsized aggregate init expression

2023-05-31 Thread Alan Zhao via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG1cf5188c7290: [clang] Fix crash when passing a braced-init 
list to a parentehsized aggregate… (authored by ayzhao).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151763

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Sema/SemaInit.cpp
  clang/test/SemaCXX/paren-list-agg-init.cpp


Index: clang/test/SemaCXX/paren-list-agg-init.cpp
===
--- clang/test/SemaCXX/paren-list-agg-init.cpp
+++ clang/test/SemaCXX/paren-list-agg-init.cpp
@@ -266,3 +266,9 @@
 O o3(0);
 // expected-error@-1 {{reference member of type 'int &&' uninitialized}}
 }
+
+namespace gh63008 {
+auto a = new A('a', {1.1});
+// expected-warning@-1 {{braces around scalar init}}
+// beforecxx20-warning@-2 {{aggregate initialization of type 'A' from a 
parenthesized list of values is a C++20 extension}}
+}
Index: clang/lib/Sema/SemaInit.cpp
===
--- clang/lib/Sema/SemaInit.cpp
+++ clang/lib/Sema/SemaInit.cpp
@@ -1158,6 +1158,7 @@
   case InitializedEntity::EK_Parameter_CF_Audited:
   case InitializedEntity::EK_TemplateParameter:
   case InitializedEntity::EK_Result:
+  case InitializedEntity::EK_ParenAggInitMember:
 // Extra braces here are suspicious.
 DiagID = diag::warn_braces_around_init;
 break;
@@ -1192,7 +1193,6 @@
   case InitializedEntity::EK_LambdaToBlockConversionBlockElement:
   case InitializedEntity::EK_Binding:
   case InitializedEntity::EK_StmtExprResult:
-  case InitializedEntity::EK_ParenAggInitMember:
 llvm_unreachable("unexpected braced scalar init");
   }
 
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -460,6 +460,9 @@
 - Fix crash when diagnosing default comparison method.
   (`#62791 `_) and
   (`#62102 `_).
+- Fix crash when passing a braced initializer list to a parentehsized aggregate
+  initialization expression.
+  (`#63008 `_).
 
 Bug Fixes to Compiler Builtins
 ^^


Index: clang/test/SemaCXX/paren-list-agg-init.cpp
===
--- clang/test/SemaCXX/paren-list-agg-init.cpp
+++ clang/test/SemaCXX/paren-list-agg-init.cpp
@@ -266,3 +266,9 @@
 O o3(0);
 // expected-error@-1 {{reference member of type 'int &&' uninitialized}}
 }
+
+namespace gh63008 {
+auto a = new A('a', {1.1});
+// expected-warning@-1 {{braces around scalar init}}
+// beforecxx20-warning@-2 {{aggregate initialization of type 'A' from a parenthesized list of values is a C++20 extension}}
+}
Index: clang/lib/Sema/SemaInit.cpp
===
--- clang/lib/Sema/SemaInit.cpp
+++ clang/lib/Sema/SemaInit.cpp
@@ -1158,6 +1158,7 @@
   case InitializedEntity::EK_Parameter_CF_Audited:
   case InitializedEntity::EK_TemplateParameter:
   case InitializedEntity::EK_Result:
+  case InitializedEntity::EK_ParenAggInitMember:
 // Extra braces here are suspicious.
 DiagID = diag::warn_braces_around_init;
 break;
@@ -1192,7 +1193,6 @@
   case InitializedEntity::EK_LambdaToBlockConversionBlockElement:
   case InitializedEntity::EK_Binding:
   case InitializedEntity::EK_StmtExprResult:
-  case InitializedEntity::EK_ParenAggInitMember:
 llvm_unreachable("unexpected braced scalar init");
   }
 
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -460,6 +460,9 @@
 - Fix crash when diagnosing default comparison method.
   (`#62791 `_) and
   (`#62102 `_).
+- Fix crash when passing a braced initializer list to a parentehsized aggregate
+  initialization expression.
+  (`#63008 `_).
 
 Bug Fixes to Compiler Builtins
 ^^
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 1cf5188 - [clang] Fix crash when passing a braced-init list to a parentehsized aggregate init expression

2023-05-31 Thread Alan Zhao via cfe-commits

Author: Alan Zhao
Date: 2023-05-31T13:52:45-07:00
New Revision: 1cf5188c72902e85e85095d788f5dfa138c320f8

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

LOG: [clang] Fix crash when passing a braced-init list to a parentehsized 
aggregate init expression

The previous code incorrectly assumed that we would never call
warnBracedScalarInit(...) with a EK_ParenAggInitMember. This patch fixes
the bug by warning when a scalar member is initialized via a braced-init
list when performing a parentehsized aggregate initialization. This
behavior is consistent with parentehsized list aggregate initialization.

Fixes #63008

Reviewed By: shafik

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

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/lib/Sema/SemaInit.cpp
clang/test/SemaCXX/paren-list-agg-init.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index b5814350a5f11..02736f2ee67fc 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -460,6 +460,9 @@ Bug Fixes in This Version
 - Fix crash when diagnosing default comparison method.
   (`#62791 `_) and
   (`#62102 `_).
+- Fix crash when passing a braced initializer list to a parentehsized aggregate
+  initialization expression.
+  (`#63008 `_).
 
 Bug Fixes to Compiler Builtins
 ^^

diff  --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp
index eaddba3e7c75d..f617cd021e594 100644
--- a/clang/lib/Sema/SemaInit.cpp
+++ b/clang/lib/Sema/SemaInit.cpp
@@ -1158,6 +1158,7 @@ static void warnBracedScalarInit(Sema , const 
InitializedEntity ,
   case InitializedEntity::EK_Parameter_CF_Audited:
   case InitializedEntity::EK_TemplateParameter:
   case InitializedEntity::EK_Result:
+  case InitializedEntity::EK_ParenAggInitMember:
 // Extra braces here are suspicious.
 DiagID = diag::warn_braces_around_init;
 break;
@@ -1192,7 +1193,6 @@ static void warnBracedScalarInit(Sema , const 
InitializedEntity ,
   case InitializedEntity::EK_LambdaToBlockConversionBlockElement:
   case InitializedEntity::EK_Binding:
   case InitializedEntity::EK_StmtExprResult:
-  case InitializedEntity::EK_ParenAggInitMember:
 llvm_unreachable("unexpected braced scalar init");
   }
 

diff  --git a/clang/test/SemaCXX/paren-list-agg-init.cpp 
b/clang/test/SemaCXX/paren-list-agg-init.cpp
index 7bdf49b8fd0c1..042ce3b3ddce2 100644
--- a/clang/test/SemaCXX/paren-list-agg-init.cpp
+++ b/clang/test/SemaCXX/paren-list-agg-init.cpp
@@ -266,3 +266,9 @@ O o2(0, 0); // no-error
 O o3(0);
 // expected-error@-1 {{reference member of type 'int &&' uninitialized}}
 }
+
+namespace gh63008 {
+auto a = new A('a', {1.1});
+// expected-warning@-1 {{braces around scalar init}}
+// beforecxx20-warning@-2 {{aggregate initialization of type 'A' from a 
parenthesized list of values is a C++20 extension}}
+}



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


[PATCH] D151820: [clang][WebAssembly] Fix __BIGGEST_ALIGNMENT__ under emscripten

2023-05-31 Thread Sam Clegg via Phabricator via cfe-commits
sbc100 added a comment.

In D151820#4385393 , @dschuff wrote:

> I guess this is basically the C version of max_align_t so it should match.

Yes, it should match.   Having `__BIGGEST_ALIGNMENT__` be 16 for emscripten 
doesn't make any sense right now.

> but... this still has the potential to break things.
> e.g. it will change the allocation in 
> https://github.com/google/XNNPACK/blob/master/src/xnnpack/allocator.h#L66
> ISTR that was one of the projects that had an issue with this the first time 
> around?




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151820

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


[PATCH] D151820: [clang][WebAssembly] Fix __BIGGEST_ALIGNMENT__ under emscripten

2023-05-31 Thread Sam Clegg via Phabricator via cfe-commits
sbc100 added a comment.

In D151820#4385393 , @dschuff wrote:

> I guess this is basically the C version of max_align_t so it should match.
> but... this still has the potential to break things.

True, but I think it's not as likely the break things as that change the 
max_align_t.. which is more commonly used.

> e.g. it will change the allocation in 
> https://github.com/google/XNNPACK/blob/master/src/xnnpack/allocator.h#L66

I don't think it will change anything in that code since `__BIGGEST_ALIGNMENT__ 
>= XNN_ALLOCATION_ALIGNMENT` will still hold true both before and after this 
change (XNN_ALLOCATION_ALIGNMENT == 4 on wasm)

> ISTR that was one of the projects that had an issue with this the first time 
> around?




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151820

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


[PATCH] D151839: [LinkerWrapper] Fix static library symbol resolution

2023-05-31 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 created this revision.
jhuber6 added reviewers: jdoerfert, tianshilei1992, JonChesterfield, tra, 
yaxunl.
Herald added a project: All.
jhuber6 requested review of this revision.
Herald added subscribers: cfe-commits, jplehr, sstefan1.
Herald added a project: clang.

The linker wrapper performs its own very basic symbol resolution for the
purpose of supporting standard static library semantics. We do this here
because the Nvidia `nvlink` wrapper does not support static linking and
we have some offloading specific extensions.

Currently, we always place symbols in the "table" even if they aren't
extracted. This caused the logic to fail when many files were used that
referenced the same undefined variable. This patch changes the pass to
only add the symbols to the global "table" if the file is actually
extracted.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D151839

Files:
  clang/test/Driver/linker-wrapper-libs.c
  clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp

Index: clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
===
--- clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
+++ clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
@@ -1163,20 +1163,21 @@
 /// Scan the symbols from a BitcodeFile \p Buffer and record if we need to
 /// extract any symbols from it.
 Expected getSymbolsFromBitcode(MemoryBufferRef Buffer, OffloadKind Kind,
- StringSaver ,
+ bool IsArchive, StringSaver ,
  DenseMap ) {
   Expected IRSymtabOrErr = readIRSymtab(Buffer);
   if (!IRSymtabOrErr)
 return IRSymtabOrErr.takeError();
 
-  bool ShouldExtract = false;
+  bool ShouldExtract = !IsArchive;
+  DenseMap TmpSyms;
   for (unsigned I = 0; I != IRSymtabOrErr->Mods.size(); ++I) {
 for (const auto  : IRSymtabOrErr->TheReader.module_symbols(I)) {
   if (Sym.isFormatSpecific() || !Sym.isGlobal())
 continue;
 
   bool NewSymbol = Syms.count(Sym.getName()) == 0;
-  auto  = Syms[Saver.save(Sym.getName())];
+  auto OldSym = NewSymbol ? Sym_None : Syms[Sym.getName()];
 
   // We will extract if it defines a currenlty undefined non-weak symbol.
   bool ResolvesStrongReference =
@@ -1192,23 +1193,31 @@
 
   // Update this symbol in the "table" with the new information.
   if (OldSym & Sym_Undefined && !Sym.isUndefined())
-OldSym = static_cast(OldSym & ~Sym_Undefined);
+TmpSyms[Saver.save(Sym.getName())] =
+static_cast(OldSym & ~Sym_Undefined);
   if (Sym.isUndefined() && NewSymbol)
-OldSym = static_cast(OldSym | Sym_Undefined);
+TmpSyms[Saver.save(Sym.getName())] =
+static_cast(OldSym | Sym_Undefined);
   if (Sym.isWeak())
-OldSym = static_cast(OldSym | Sym_Weak);
+TmpSyms[Saver.save(Sym.getName())] =
+static_cast(OldSym | Sym_Weak);
 }
   }
 
+  // If the file gets extracted we update the table with the new symbols.
+  if (ShouldExtract)
+Syms.insert(std::begin(TmpSyms), std::end(TmpSyms));
+
   return ShouldExtract;
 }
 
 /// Scan the symbols from an ObjectFile \p Obj and record if we need to extract
 /// any symbols from it.
 Expected getSymbolsFromObject(const ObjectFile , OffloadKind Kind,
-StringSaver ,
+bool IsArchive, StringSaver ,
 DenseMap ) {
-  bool ShouldExtract = false;
+  bool ShouldExtract = !IsArchive;
+  DenseMap TmpSyms;
   for (SymbolRef Sym : Obj.symbols()) {
 auto FlagsOrErr = Sym.getFlags();
 if (!FlagsOrErr)
@@ -1223,7 +1232,7 @@
   return NameOrErr.takeError();
 
 bool NewSymbol = Syms.count(*NameOrErr) == 0;
-auto  = Syms[Saver.save(*NameOrErr)];
+auto OldSym = NewSymbol ? Sym_None : Syms[*NameOrErr];
 
 // We will extract if it defines a currenlty undefined non-weak symbol.
 bool ResolvesStrongReference = (OldSym & Sym_Undefined) &&
@@ -1240,12 +1249,19 @@
 
 // Update this symbol in the "table" with the new information.
 if (OldSym & Sym_Undefined && !(*FlagsOrErr & SymbolRef::SF_Undefined))
-  OldSym = static_cast(OldSym & ~Sym_Undefined);
+  TmpSyms[Saver.save(*NameOrErr)] =
+  static_cast(OldSym & ~Sym_Undefined);
 if (*FlagsOrErr & SymbolRef::SF_Undefined && NewSymbol)
-  OldSym = static_cast(OldSym | Sym_Undefined);
+  TmpSyms[Saver.save(*NameOrErr)] =
+  static_cast(OldSym | Sym_Undefined);
 if (*FlagsOrErr & SymbolRef::SF_Weak)
-  OldSym = static_cast(OldSym | Sym_Weak);
+  TmpSyms[Saver.save(*NameOrErr)] = static_cast(OldSym | Sym_Weak);
   }
+
+  // If the file gets extracted we update the table with the new symbols.
+  if (ShouldExtract)
+Syms.insert(std::begin(TmpSyms), std::end(TmpSyms));
+
   return ShouldExtract;
 }
 
@@ -1255,18 +1271,19 

[PATCH] D151828: [z/OS] Disable pr59765-modules-global-ctor-dtor.cppm on z/OS to make it unsupported.

2023-05-31 Thread Sean via Phabricator via cfe-commits
SeanP accepted this revision.
SeanP 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/D151828/new/

https://reviews.llvm.org/D151828

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


[PATCH] D151837: [Clang][Parser] Accept GNU attributes preceding C++ style attributes on templates

2023-05-31 Thread Elizabeth Andrews via Phabricator via cfe-commits
eandrews created this revision.
eandrews added reviewers: aaron.ballman, erichkeane, compnerd.
Herald added a project: All.
eandrews requested review of this revision.

Clang was rejecting valid code where GNU style attributes preceded C++ style 
attributes in template declarations as follows:

template
__attribute__((deprecated("oh no!"))) [[deprecated("oh no!")]] void foo();

This PR fixes the bug.


https://reviews.llvm.org/D151837

Files:
  clang/lib/Parse/ParseTemplate.cpp
  clang/test/Parser/attr-order.cpp


Index: clang/test/Parser/attr-order.cpp
===
--- clang/test/Parser/attr-order.cpp
+++ clang/test/Parser/attr-order.cpp
@@ -13,12 +13,15 @@
 [[noreturn]] __declspec(dllexport) __attribute__((cdecl)) void b(); // ok
 [[]] [[noreturn]] __attribute__((cdecl)) __declspec(dllexport) void c(); // ok
 
-// [[]] attributes before a declaration must be at the start of the line.
 __declspec(dllexport) [[noreturn]] __attribute__((cdecl)) void d(); // 
expected-error {{an attribute list cannot appear here}}
 __declspec(dllexport) __attribute__((cdecl)) [[noreturn]] void e(); // 
expected-error {{an attribute list cannot appear here}}
 __attribute__((cdecl)) __declspec(dllexport) [[noreturn]] void f(); // 
expected-error {{an attribute list cannot appear here}}
-__attribute__((cdecl)) [[noreturn]] __declspec(dllexport) void g();
+
+__attribute__((cdecl)) [[noreturn]] __declspec(dllexport) void g(); // ok
 
 [[noreturn]] __attribute__((cdecl))
 [[]]
 __declspec(dllexport) void h();
+
+template 
+__attribute__((cdecl)) [[noreturn]] __declspec(dllexport) void i(); // ok
Index: clang/lib/Parse/ParseTemplate.cpp
===
--- clang/lib/Parse/ParseTemplate.cpp
+++ clang/lib/Parse/ParseTemplate.cpp
@@ -210,7 +210,15 @@
   }
 
   ParsedAttributes prefixAttrs(AttrFactory);
-  MaybeParseCXX11Attributes(prefixAttrs);
+  ParsedAttributes DeclSpecAttrs(AttrFactory);
+
+  // GNU attributes are applied to the declaration specification while the
+  // standard attributes are applied to the declaration.  We parse the two
+  // attribute sets into different containters so we can apply them during
+  // the regular parsing process.
+  while (MaybeParseCXX11Attributes(prefixAttrs) ||
+ MaybeParseGNUAttributes(DeclSpecAttrs))
+;
 
   if (Tok.is(tok::kw_using)) {
 auto usingDeclPtr = ParseUsingDirectiveOrDeclaration(Context, 
TemplateInfo, DeclEnd,
@@ -223,6 +231,9 @@
   // Parse the declaration specifiers, stealing any diagnostics from
   // the template parameters.
   ParsingDeclSpec DS(*this, );
+  DS.SetRangeStart(DeclSpecAttrs.Range.getBegin());
+  DS.SetRangeEnd(DeclSpecAttrs.Range.getEnd());
+  DS.takeAttributesFrom(DeclSpecAttrs);
 
   ParseDeclarationSpecifiers(DS, TemplateInfo, AS,
  getDeclSpecContextFromDeclaratorContext(Context));


Index: clang/test/Parser/attr-order.cpp
===
--- clang/test/Parser/attr-order.cpp
+++ clang/test/Parser/attr-order.cpp
@@ -13,12 +13,15 @@
 [[noreturn]] __declspec(dllexport) __attribute__((cdecl)) void b(); // ok
 [[]] [[noreturn]] __attribute__((cdecl)) __declspec(dllexport) void c(); // ok
 
-// [[]] attributes before a declaration must be at the start of the line.
 __declspec(dllexport) [[noreturn]] __attribute__((cdecl)) void d(); // expected-error {{an attribute list cannot appear here}}
 __declspec(dllexport) __attribute__((cdecl)) [[noreturn]] void e(); // expected-error {{an attribute list cannot appear here}}
 __attribute__((cdecl)) __declspec(dllexport) [[noreturn]] void f(); // expected-error {{an attribute list cannot appear here}}
-__attribute__((cdecl)) [[noreturn]] __declspec(dllexport) void g();
+
+__attribute__((cdecl)) [[noreturn]] __declspec(dllexport) void g(); // ok
 
 [[noreturn]] __attribute__((cdecl))
 [[]]
 __declspec(dllexport) void h();
+
+template 
+__attribute__((cdecl)) [[noreturn]] __declspec(dllexport) void i(); // ok
Index: clang/lib/Parse/ParseTemplate.cpp
===
--- clang/lib/Parse/ParseTemplate.cpp
+++ clang/lib/Parse/ParseTemplate.cpp
@@ -210,7 +210,15 @@
   }
 
   ParsedAttributes prefixAttrs(AttrFactory);
-  MaybeParseCXX11Attributes(prefixAttrs);
+  ParsedAttributes DeclSpecAttrs(AttrFactory);
+
+  // GNU attributes are applied to the declaration specification while the
+  // standard attributes are applied to the declaration.  We parse the two
+  // attribute sets into different containters so we can apply them during
+  // the regular parsing process.
+  while (MaybeParseCXX11Attributes(prefixAttrs) ||
+ MaybeParseGNUAttributes(DeclSpecAttrs))
+;
 
   if (Tok.is(tok::kw_using)) {
 auto usingDeclPtr = ParseUsingDirectiveOrDeclaration(Context, TemplateInfo, DeclEnd,
@@ -223,6 +231,9 @@
   // Parse the declaration specifiers, stealing any diagnostics 

[PATCH] D151820: [clang][WebAssembly] Fix __BIGGEST_ALIGNMENT__ under emscripten

2023-05-31 Thread Derek Schuff via Phabricator via cfe-commits
dschuff added a comment.

I guess this is basically the C version of max_align_t so it should match.
but... this still has the potential to break things.
e.g. it will change the allocation in 
https://github.com/google/XNNPACK/blob/master/src/xnnpack/allocator.h#L66
ISTR that was one of the projects that had an issue with this the first time 
around?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151820

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


[PATCH] D149280: [clang-tidy] Add modernize-printf-to-std-print check

2023-05-31 Thread Mike Crowe via Phabricator via cfe-commits
mikecrowe added inline comments.



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/modernize/use-std-print.rst:79
+
+.. option:: StrictMode
+

mikecrowe wrote:
> It turns out that absl::PrintF and absl::FPrintF work like std::format, 
> fmt::printf, etc. and use the signedness of the argument rather than the 
> signedness indicated in the format string to determine how to format the 
> number. In other words:
> `unsigned int ui = 0x; absl::PrintF("%d\n", ui);` yields `4294967295` 
> (see https://godbolt.org/z/dYcbehxP9 ), so the casts that StrictMode adds 
> would change the behaviour of the converted code.
> 
> I can think of several ways around this:
> 
> 1. Update the documentation to explain this, recommending not to use 
> StrictMode when converting Abseil functions.
> 
> 2. Remove built-in support for Abseil functions from this check. Anyone 
> wishing to convert them can do so via the customisation features, and can 
> choose not to use StrictMode. (This could be documented here.)
> 
> 3. Teach the code to recognise whether the arguments is being passed as a 
> C-style variable argument list or as fully-typed arguments to a templated 
> function and make StrictMode only add the casts for the former. (I've not 
> investigated how feasible this is.)
> 
> 4. Treat the known Abseil functions in this check differently by name and 
> disable the casting behaviour. This means that conversion from fmt::printf 
> via the customisation mechanism wouldn't automatically get that behaviour.
> 
> As someone who doesn't use Abseil I'm inclined towards option 2, with the 
> possibility of implementing option 3 in a separate commit later. I'm not 
> particularly keen on the other two options.
It turns out that option 3 was easier to implement than I expected, so I've 
implemented it in the latest version.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149280

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


[PATCH] D151741: [Lex] Only warn on defining or undefining language-defined builtins

2023-05-31 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added inline comments.



Comment at: clang/test/Preprocessor/init-x86.c:1728-1741
+// RUN: %clang_cc1 -triple=i386-none-none -fsyntax-only -verify -DUNDEF %s
+// RUN: %clang_cc1 -triple=i686-none-none -fsyntax-only -verify -DUNDEF %s
+// RUN: %clang_cc1 -triple=x86_64-none-none -fsyntax-only -verify -DUNDEF %s
+#ifdef UNDEF
+// Check that we can undefine triple-specific defines without warning
+// expected-no-diagnostics
+#undef __i386

Hmm...I guess if this is going to require adding run lines, then let's move 
these to a new test file in the same dir. Maybe `undef-x86.c` or whatever? 
Sorry for back and forth.


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

https://reviews.llvm.org/D151741

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


[PATCH] D151834: Include math-errno with fast-math

2023-05-31 Thread Zahira Ammarguellat via Phabricator via cfe-commits
zahiraam created this revision.
zahiraam added reviewers: andrew.w.kaylor, jcranmer-intel.
Herald added a project: All.
zahiraam requested review of this revision.
Herald added a project: clang.

MSVC includes math-errno with #pragma float_control(precise,on) at O2 
. 
At fast-math math-errno should also be included with optnone and the pragma.

https://github.com/llvm/llvm-project/issues/62098


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D151834

Files:
  clang/include/clang/Basic/FPOptions.def
  clang/include/clang/Basic/LangOptions.h
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CodeGenModule.h
  clang/test/CodeGen/math-errno.c

Index: clang/test/CodeGen/math-errno.c
===
--- /dev/null
+++ clang/test/CodeGen/math-errno.c
@@ -0,0 +1,52 @@
+// Tests that at -O2 math-errno is taken into account. Same than MSVC.
+// RUN: %clang_cc1 -Wno-implicit-function-declaration -fmath-errno \
+// RUN: -O2 -emit-llvm -o - %s \
+// RUN: | FileCheck %s
+
+// Tests that with -ffast-math math-errno is taken into account with
+// float_control(precise,on) and optnone.
+// RUN: %clang_cc1 -Wno-implicit-function-declaration  \
+// RUN: -ffast-math -emit-llvm -o - %s \
+// RUN: | FileCheck %s -check-prefix=FAST
+
+float f1(float x) { 
+#pragma float_control(precise,on)
+return sqrtf(x);
+}
+
+float f2(float x) { 
+#pragma float_control(precise,on)
+  {
+float y = sqrtf(x);
+return y;
+  }
+}
+
+float f3(float x) { 
+#pragma float_control(precise,off)
+  {
+float y = sqrtf(x);
+  return y;
+  }
+}
+
+__attribute__((optnone))
+float f4(float x) { 
+  x = sqrtf(x); 
+  return x;
+}
+
+// CHECK-LABEL: define dso_local float @f2(float noundef {{.*}})
+// CHECK:  tail call float @sqrtf(float noundef {{.*}})
+
+// CHECK-LABEL: define dso_local float @f3(float noundef {{.*}})
+// CHECK: call float @llvm.sqrt.f32(float {{.*}})
+
+// FAST-LABEL: define dso_local nofpclass(nan inf) float @f1(float noundef nofpclass(nan inf) {{.*}})
+// FAST: call reassoc nnan ninf nsz arcp afn nofpclass(nan inf) float @sqrtf(float noundef nofpclass(nan inf) {{.*}}) #[[ATTR0:[0-9]+]]
+
+// FAST-LABEL: define dso_local nofpclass(nan inf) float @f4(float noundef nofpclass(nan inf) {{.*}})
+// FAST: call reassoc nnan ninf nsz arcp afn nofpclass(nan inf) float @sqrtf(float noundef nofpclass(nan inf) %0) #[[ATTR0:[0-9]+]]
+
+// FAST: attributes #[[ATTR0]] = { {{.*}} memory(none) }
+
Index: clang/lib/CodeGen/CodeGenModule.h
===
--- clang/lib/CodeGen/CodeGenModule.h
+++ clang/lib/CodeGen/CodeGenModule.h
@@ -608,6 +608,7 @@
   ~CodeGenModule();
 
   void clear();
+  bool OptNone = true;
 
   /// Finalize LLVM code generation.
   void Release();
Index: clang/lib/CodeGen/CGCall.cpp
===
--- clang/lib/CodeGen/CGCall.cpp
+++ clang/lib/CodeGen/CGCall.cpp
@@ -2381,6 +2381,9 @@
   // Collect function IR attributes based on global settiings.
   getDefaultFunctionAttributes(Name, HasOptnone, AttrOnCallSite, FuncAttrs);
 
+  if (HasOptnone && !getLangOpts().MathErrno)
+OptNone = false;
+
   // Override some default IR attributes based on declaration-specific
   // information.
   if (TargetDecl) {
Index: clang/lib/CodeGen/CGBuiltin.cpp
===
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ clang/lib/CodeGen/CGBuiltin.cpp
@@ -2229,6 +2229,13 @@
   // likely to get lowered to the renamed library functions.
   const unsigned BuiltinIDIfNoAsmLabel =
   FD->hasAttr() ? 0 : BuiltinID;
+  bool MathErrnoOverrride = false;
+  if (E->hasStoredFPFeatures()) {
+FPOptionsOverride OP = E->getFPFeatures();
+if (OP.hasMathErrnoOverride())
+  MathErrnoOverrride = OP.getMathErrnoOverride();
+  }
+  bool EmitIntrinsic = !MathErrnoOverrride && CGM.OptNone;
 
   // There are LLVM math intrinsics/instructions corresponding to math library
   // functions except the LLVM op will never set errno while the math library
@@ -2241,9 +2248,12 @@
   getContext().BuiltinInfo.isConstWithoutErrnoAndExceptions(BuiltinID);
   bool ConstWithoutExceptions =
   getContext().BuiltinInfo.isConstWithoutExceptions(BuiltinID);
-  if (FD->hasAttr() ||
-  ((ConstWithoutErrnoAndExceptions || ConstWithoutExceptions) &&
-   (!ConstWithoutErrnoAndExceptions || (!getLangOpts().MathErrno {
+
+  if ((FD->hasAttr() && EmitIntrinsic) ||
+  (EmitIntrinsic ||
+   ((ConstWithoutErrnoAndExceptions || ConstWithoutExceptions) &&
+ (!ConstWithoutErrnoAndExceptions ||
+ (!getLangOpts().MathErrno && EmitIntrinsic) {
 switch (BuiltinIDIfNoAsmLabel) {
 case Builtin::BIceil:
 case Builtin::BIceilf:
Index: clang/include/clang/Basic/LangOptions.h

[PATCH] D151397: [3/N][RISCV] Model vxrm in C intrinsics for RVV fixed-point instruction vaadd

2023-05-31 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: clang/include/clang/Basic/riscv_vector.td:2079
+[{
+enum RVV_VXRM {
+  VXRM_RNU = 0,

enum name needs `__` prefix



Comment at: clang/include/clang/Basic/riscv_vector.td:2080
+enum RVV_VXRM {
+  VXRM_RNU = 0,
+  VXRM_RNE = 1,

These need `__` prefix


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151397

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


[PATCH] D151833: Respect "-fdiagnostics-absolute-paths" on emit include location

2023-05-31 Thread Charalampos Mitrodimas via Phabricator via cfe-commits
charmitro created this revision.
Herald added a subscriber: kristof.beyls.
Herald added a project: All.
charmitro requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Signed-off-by: Charalampos Mitrodimas 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D151833

Files:
  clang/lib/Frontend/TextDiagnostic.cpp


Index: clang/lib/Frontend/TextDiagnostic.cpp
===
--- clang/lib/Frontend/TextDiagnostic.cpp
+++ clang/lib/Frontend/TextDiagnostic.cpp
@@ -896,10 +896,11 @@
 }
 
 void TextDiagnostic::emitIncludeLocation(FullSourceLoc Loc, PresumedLoc PLoc) {
-  if (DiagOpts->ShowLocation && PLoc.isValid())
-OS << "In file included from " << PLoc.getFilename() << ':'
-   << PLoc.getLine() << ":\n";
-  else
+  if (DiagOpts->ShowLocation && PLoc.isValid()) {
+OS << "In file included from ";
+emitFilename(PLoc.getFilename(), Loc.getManager());
+OS << ':' << PLoc.getLine() << ":\n";
+  } else
 OS << "In included file:\n";
 }
 


Index: clang/lib/Frontend/TextDiagnostic.cpp
===
--- clang/lib/Frontend/TextDiagnostic.cpp
+++ clang/lib/Frontend/TextDiagnostic.cpp
@@ -896,10 +896,11 @@
 }
 
 void TextDiagnostic::emitIncludeLocation(FullSourceLoc Loc, PresumedLoc PLoc) {
-  if (DiagOpts->ShowLocation && PLoc.isValid())
-OS << "In file included from " << PLoc.getFilename() << ':'
-   << PLoc.getLine() << ":\n";
-  else
+  if (DiagOpts->ShowLocation && PLoc.isValid()) {
+OS << "In file included from ";
+emitFilename(PLoc.getFilename(), Loc.getManager());
+OS << ':' << PLoc.getLine() << ":\n";
+  } else
 OS << "In included file:\n";
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 5a0d53c - [Tooling] Remove unused function setRestoreWorkingDir

2023-05-31 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2023-05-31T12:43:37-07:00
New Revision: 5a0d53ce41486225fd8be6b1d13f338d19c29f62

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

LOG: [Tooling] Remove unused function setRestoreWorkingDir

The last use was removed by:

  commit 146ec74a8382dc820809d0a2bf4b918d0b5e6603
  Author: Jan Svoboda 
  Date:   Fri Sep 10 10:24:16 2021 +0200

Once I remove the function, RestoreCWD is always true, so this patch
removes the variable and propagates the constant.

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

Added: 


Modified: 
clang/include/clang/Tooling/Tooling.h
clang/lib/Tooling/Tooling.cpp

Removed: 




diff  --git a/clang/include/clang/Tooling/Tooling.h 
b/clang/include/clang/Tooling/Tooling.h
index 7a1c62e3a3d57..13c1b51bf85fb 100644
--- a/clang/include/clang/Tooling/Tooling.h
+++ b/clang/include/clang/Tooling/Tooling.h
@@ -361,11 +361,6 @@ class ClangTool {
   /// append them to ASTs.
   int buildASTs(std::vector> );
 
-  /// Sets whether working directory should be restored after calling run(). By
-  /// default, working directory is restored. However, it could be useful to
-  /// turn this off when running on multiple threads to avoid the raciness.
-  void setRestoreWorkingDir(bool RestoreCWD);
-
   /// Sets whether an error message should be printed out if an action fails. 
By
   /// default, if an action fails, a message is printed out to stderr.
   void setPrintErrorMessage(bool PrintErrorMessage);
@@ -395,7 +390,6 @@ class ClangTool {
 
   DiagnosticConsumer *DiagConsumer = nullptr;
 
-  bool RestoreCWD = true;
   bool PrintErrorMessage = true;
 };
 

diff  --git a/clang/lib/Tooling/Tooling.cpp b/clang/lib/Tooling/Tooling.cpp
index dd22cfedd0ffe..46a784e44b931 100644
--- a/clang/lib/Tooling/Tooling.cpp
+++ b/clang/lib/Tooling/Tooling.cpp
@@ -542,13 +542,11 @@ int ClangTool::run(ToolAction *Action) {
 
   // Remember the working directory in case we need to restore it.
   std::string InitialWorkingDir;
-  if (RestoreCWD) {
-if (auto CWD = OverlayFileSystem->getCurrentWorkingDirectory()) {
-  InitialWorkingDir = std::move(*CWD);
-} else {
-  llvm::errs() << "Could not get working directory: "
-   << CWD.getError().message() << "\n";
-}
+  if (auto CWD = OverlayFileSystem->getCurrentWorkingDirectory()) {
+InitialWorkingDir = std::move(*CWD);
+  } else {
+llvm::errs() << "Could not get working directory: "
+ << CWD.getError().message() << "\n";
   }
 
   for (llvm::StringRef File : AbsolutePaths) {
@@ -662,10 +660,6 @@ int 
ClangTool::buildASTs(std::vector> ) {
   return run();
 }
 
-void ClangTool::setRestoreWorkingDir(bool RestoreCWD) {
-  this->RestoreCWD = RestoreCWD;
-}
-
 void ClangTool::setPrintErrorMessage(bool PrintErrorMessage) {
   this->PrintErrorMessage = PrintErrorMessage;
 }



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


[PATCH] D151786: [Tooling] Remove unused function setRestoreWorkingDir

2023-05-31 Thread Kazu Hirata via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG5a0d53ce4148: [Tooling] Remove unused function 
setRestoreWorkingDir (authored by kazu).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151786

Files:
  clang/include/clang/Tooling/Tooling.h
  clang/lib/Tooling/Tooling.cpp


Index: clang/lib/Tooling/Tooling.cpp
===
--- clang/lib/Tooling/Tooling.cpp
+++ clang/lib/Tooling/Tooling.cpp
@@ -542,13 +542,11 @@
 
   // Remember the working directory in case we need to restore it.
   std::string InitialWorkingDir;
-  if (RestoreCWD) {
-if (auto CWD = OverlayFileSystem->getCurrentWorkingDirectory()) {
-  InitialWorkingDir = std::move(*CWD);
-} else {
-  llvm::errs() << "Could not get working directory: "
-   << CWD.getError().message() << "\n";
-}
+  if (auto CWD = OverlayFileSystem->getCurrentWorkingDirectory()) {
+InitialWorkingDir = std::move(*CWD);
+  } else {
+llvm::errs() << "Could not get working directory: "
+ << CWD.getError().message() << "\n";
   }
 
   for (llvm::StringRef File : AbsolutePaths) {
@@ -662,10 +660,6 @@
   return run();
 }
 
-void ClangTool::setRestoreWorkingDir(bool RestoreCWD) {
-  this->RestoreCWD = RestoreCWD;
-}
-
 void ClangTool::setPrintErrorMessage(bool PrintErrorMessage) {
   this->PrintErrorMessage = PrintErrorMessage;
 }
Index: clang/include/clang/Tooling/Tooling.h
===
--- clang/include/clang/Tooling/Tooling.h
+++ clang/include/clang/Tooling/Tooling.h
@@ -361,11 +361,6 @@
   /// append them to ASTs.
   int buildASTs(std::vector> );
 
-  /// Sets whether working directory should be restored after calling run(). By
-  /// default, working directory is restored. However, it could be useful to
-  /// turn this off when running on multiple threads to avoid the raciness.
-  void setRestoreWorkingDir(bool RestoreCWD);
-
   /// Sets whether an error message should be printed out if an action fails. 
By
   /// default, if an action fails, a message is printed out to stderr.
   void setPrintErrorMessage(bool PrintErrorMessage);
@@ -395,7 +390,6 @@
 
   DiagnosticConsumer *DiagConsumer = nullptr;
 
-  bool RestoreCWD = true;
   bool PrintErrorMessage = true;
 };
 


Index: clang/lib/Tooling/Tooling.cpp
===
--- clang/lib/Tooling/Tooling.cpp
+++ clang/lib/Tooling/Tooling.cpp
@@ -542,13 +542,11 @@
 
   // Remember the working directory in case we need to restore it.
   std::string InitialWorkingDir;
-  if (RestoreCWD) {
-if (auto CWD = OverlayFileSystem->getCurrentWorkingDirectory()) {
-  InitialWorkingDir = std::move(*CWD);
-} else {
-  llvm::errs() << "Could not get working directory: "
-   << CWD.getError().message() << "\n";
-}
+  if (auto CWD = OverlayFileSystem->getCurrentWorkingDirectory()) {
+InitialWorkingDir = std::move(*CWD);
+  } else {
+llvm::errs() << "Could not get working directory: "
+ << CWD.getError().message() << "\n";
   }
 
   for (llvm::StringRef File : AbsolutePaths) {
@@ -662,10 +660,6 @@
   return run();
 }
 
-void ClangTool::setRestoreWorkingDir(bool RestoreCWD) {
-  this->RestoreCWD = RestoreCWD;
-}
-
 void ClangTool::setPrintErrorMessage(bool PrintErrorMessage) {
   this->PrintErrorMessage = PrintErrorMessage;
 }
Index: clang/include/clang/Tooling/Tooling.h
===
--- clang/include/clang/Tooling/Tooling.h
+++ clang/include/clang/Tooling/Tooling.h
@@ -361,11 +361,6 @@
   /// append them to ASTs.
   int buildASTs(std::vector> );
 
-  /// Sets whether working directory should be restored after calling run(). By
-  /// default, working directory is restored. However, it could be useful to
-  /// turn this off when running on multiple threads to avoid the raciness.
-  void setRestoreWorkingDir(bool RestoreCWD);
-
   /// Sets whether an error message should be printed out if an action fails. By
   /// default, if an action fails, a message is printed out to stderr.
   void setPrintErrorMessage(bool PrintErrorMessage);
@@ -395,7 +390,6 @@
 
   DiagnosticConsumer *DiagConsumer = nullptr;
 
-  bool RestoreCWD = true;
   bool PrintErrorMessage = true;
 };
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D151741: [Lex] Only warn on defining or undefining language-defined builtins

2023-05-31 Thread John Brawn via Phabricator via cfe-commits
john.brawn updated this revision to Diff 527164.
john.brawn added a comment.

Move some of the testing to init-x86.c


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

https://reviews.llvm.org/D151741

Files:
  clang/lib/Lex/PPDirectives.cpp
  clang/test/Preprocessor/init-x86.c
  clang/test/Preprocessor/macro-reserved.c

Index: clang/test/Preprocessor/macro-reserved.c
===
--- clang/test/Preprocessor/macro-reserved.c
+++ clang/test/Preprocessor/macro-reserved.c
@@ -7,6 +7,7 @@
 #define _HAVE_X 0
 #define X__Y
 #define __STDC__ 1 // expected-warning {{redefining builtin macro}}
+#define __clang__ 1
 
 #undef for
 #undef final
@@ -15,6 +16,11 @@
 #undef _HAVE_X
 #undef X__Y
 #undef __STDC_HOSTED__ // expected-warning {{undefining builtin macro}}
+#undef __INT32_TYPE__
+#undef __UINT32_TYPE__
+#undef __UINTPTR_TYPE__
+#undef __UINT64_TYPE__
+#undef __INT64_TYPE__
 
 // allowlisted definitions
 #define while while
Index: clang/test/Preprocessor/init-x86.c
===
--- clang/test/Preprocessor/init-x86.c
+++ clang/test/Preprocessor/init-x86.c
@@ -1724,3 +1724,18 @@
 
 // RUN: %clang_cc1 -E -dM -triple=i386-unknown-openbsd -x c++ < /dev/null | FileCheck -match-full-lines -check-prefix I386-OPENBSD-CXX %s
 // I386-OPENBSD-CXX: #define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 16UL
+
+// RUN: %clang_cc1 -triple=i386-none-none -fsyntax-only -verify -DUNDEF %s
+// RUN: %clang_cc1 -triple=i686-none-none -fsyntax-only -verify -DUNDEF %s
+// RUN: %clang_cc1 -triple=x86_64-none-none -fsyntax-only -verify -DUNDEF %s
+#ifdef UNDEF
+// Check that we can undefine triple-specific defines without warning
+// expected-no-diagnostics
+#undef __i386
+#undef __i386__
+#undef i386
+#undef __amd64
+#undef __amd64__
+#undef __x86_64
+#undef __x86_64__
+#endif
Index: clang/lib/Lex/PPDirectives.cpp
===
--- clang/lib/Lex/PPDirectives.cpp
+++ clang/lib/Lex/PPDirectives.cpp
@@ -150,6 +150,30 @@
 MacroName);
 }
 
+static bool isLanguageDefinedBuiltin(const SourceManager ,
+ const MacroInfo *MI,
+ const StringRef MacroName) {
+  // If this is a macro with special handling (like __LINE__) then it's language
+  // defined.
+  if (MI->isBuiltinMacro())
+return true;
+  // Builtin macros are defined in the builtin file
+  if (!SourceMgr.isWrittenInBuiltinFile(MI->getDefinitionLoc()))
+return false;
+  // C defines macros starting with __STDC, and C++ defines macros starting with
+  // __STDCPP
+  if (MacroName.startswith("__STDC"))
+return true;
+  // C++ defines the __cplusplus macro
+  if (MacroName == "__cplusplus")
+return true;
+  // C++ defines various feature-test macros starting with __cpp
+  if (MacroName.startswith("__cpp"))
+return true;
+  // Anything else isn't language-defined
+  return false;
+}
+
 static MacroDiag shouldWarnOnMacroDef(Preprocessor , IdentifierInfo *II) {
   const LangOptions  = PP.getLangOpts();
   StringRef Text = II->getName();
@@ -3107,9 +3131,7 @@
 
   // Warn if defining "__LINE__" and other builtins, per C99 6.10.8/4 and
   // C++ [cpp.predefined]p4, but allow it as an extension.
-  if (OtherMI->isBuiltinMacro() ||
-  (SourceMgr.isWrittenInBuiltinFile(OtherMI->getDefinitionLoc()) &&
-   !isFeatureTestMacro(MacroNameTok.getIdentifierInfo()->getName(
+  if (isLanguageDefinedBuiltin(SourceMgr, OtherMI, II->getName()))
 Diag(MacroNameTok, diag::ext_pp_redef_builtin_macro);
   // Macros must be identical.  This means all tokens and whitespace
   // separation must be the same.  C99 6.10.3p2.
@@ -3190,11 +3212,8 @@
   Diag(MI->getDefinitionLoc(), diag::pp_macro_not_used);
 
 // Warn if undefining "__LINE__" and other builtins, per C99 6.10.8/4 and
-// C++ [cpp.predefined]p4, but allow it as an extension. Don't warn if this
-// is an Objective-C builtin macro though.
-if ((MI->isBuiltinMacro() ||
- SourceMgr.isWrittenInBuiltinFile(MI->getDefinitionLoc())) &&
-!(getLangOpts().ObjC && isObjCProtectedMacro(II)))
+// C++ [cpp.predefined]p4, but allow it as an extension.
+if (isLanguageDefinedBuiltin(SourceMgr, MI, II->getName()))
   Diag(MacroNameTok, diag::ext_pp_undef_builtin_macro);
 
 if (MI->isWarnIfUnused())
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D150926: [RISCV] Support LMUL!=1 for __attribute__((riscv_rvv_vector_bits(N)))

2023-05-31 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment.

Ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150926

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


[PATCH] D151761: clang-format: Add AlignConsecutiveShortCaseLabels

2023-05-31 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks added a comment.

When I read the title I thought "Yay, some one is doing what I want and don't 
find the time.", but (for me) sadly you're not.
I'd like to align the colon (and thus the statement behind that). Do you think 
you can add that option too?




Comment at: clang/include/clang/Format/Format.h:308
+  /// \version 17
+  AlignConsecutiveStyle AlignConsecutiveShortCaseLabels;
 

We need another name, you're not aligning the label, but the statement.



Comment at: clang/unittests/Format/FormatTest.cpp:19206
+
+  // Make sure we don't incorrectly align correctly across nested switch cases
+  EXPECT_EQ("switch (level) {\n"





Comment at: clang/unittests/Format/FormatTest.cpp:19207
+  // Make sure we don't incorrectly align correctly across nested switch cases
+  EXPECT_EQ("switch (level) {\n"
+"case log::info:return \"info\";\n"

There is a `verifyFormat` overload which takes 2 strings, please use that.



Comment at: clang/unittests/Format/FormatTest.cpp:19255
+   Alignment);
+}
+

Add a test with `AcrossEmptyLines` and `AcrossComments`.



Comment at: clang/unittests/Format/FormatTest.cpp:19256
+}
+
 TEST_F(FormatTest, AlignWithLineBreaks) {

Also add tests with `SpaceBeforeCaseColon`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151761

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


[PATCH] D151553: [clang] Fix consteval operators in template contexts

2023-05-31 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: clang/lib/Sema/TreeTransform.h:11940-11943
-  ExprResult Callee = getDerived().TransformExpr(E->getCallee());
-  if (Callee.isInvalid())
-return ExprError();
-

Fznamznon wrote:
> cor3ntin wrote:
> > I don't understand why we would not need to transform the callee. do we do 
> > that elsewhere?
> For example, the code above for call and subscript operators never transforms 
> the callee.
> This `TransFormExpr` call  seems to be a no-op for overloaded operator call 
> case, and the result never ends up in the resulting ast.
> 
To me it looks like we need to transform the callee in order to transform the 
declarations in the `UnresolvedLookupExpr`, if the operator has such functions. 
For example, in:

```
namespace A {
  template T f(T t) {
T operator+(T, T);
return t + t;
  }
}
namespace B {
  struct X {};
}
void g(B::X x) { A::f(x); }
```

... we need to transform the `UnresolvedLookupExpr` for the `t + t` to map from 
the `operator+` declaration in the `A::f` template to the instantiated 
`operator+` declaration in `A::f`.

But I think this patch is going in the right direction. We don't *actually* 
want to transform the callee; all we want to do is to transform the function or 
list of functions contained in the callee to form an `UnresolvedSet` of 
candidates found during the template parse. Building and then throwing away a 
`DeclRefExpr` or `UnresolvedLookupExpr` denoting that function or set of 
functions is both a waste of time and (as demonstrated by the bug being 
addressed here) problematic.

Instead of calling `TransformExpr` on the callee, we should be calling 
`TransformOverloadExprDecls` if the callee is an `UnresolvedLookupExpr` or 
`TransformDecl` if it's a `DeclRefExpr`, and I think 
`RebuildCXXOperatorCallExpr` should be changed to take an `UnresolvedSet` and a 
`RequiresADL` flag, and it looks like we can then remove the `OrigCallee` 
parameter, if we pass in some extra source locations.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151553

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


[PATCH] D151786: [Tooling] Remove unused function setRestoreWorkingDir

2023-05-31 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 accepted this revision.
jansvoboda11 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/D151786/new/

https://reviews.llvm.org/D151786

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


[PATCH] D150985: [clang] Allow fp in atomic fetch max/min builtins

2023-05-31 Thread Yaxun Liu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
yaxunl marked 4 inline comments as done.
Closed by commit rG00448a548c4e: [clang] Allow fp in atomic fetch max/min 
builtins (authored by yaxunl).
Herald added a project: clang.

Changed prior to commit:
  https://reviews.llvm.org/D150985?vs=527034=527159#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150985

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/CodeGen/CGAtomic.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGenCUDA/amdgpu-atomic-ops.cu
  clang/test/Sema/atomic-ops.c
  clang/test/SemaOpenCL/atomic-ops.cl

Index: clang/test/SemaOpenCL/atomic-ops.cl
===
--- clang/test/SemaOpenCL/atomic-ops.cl
+++ clang/test/SemaOpenCL/atomic-ops.cl
@@ -61,8 +61,10 @@
 
   __opencl_atomic_fetch_min(i, 1, memory_order_seq_cst, memory_scope_work_group);
   __opencl_atomic_fetch_max(i, 1, memory_order_seq_cst, memory_scope_work_group);
-  __opencl_atomic_fetch_min(f, 1, memory_order_seq_cst, memory_scope_work_group); // expected-error {{address argument to atomic operation must be a pointer to atomic integer ('__generic atomic_float *' (aka '__generic _Atomic(float) *') invalid)}}
-  __opencl_atomic_fetch_max(f, 1, memory_order_seq_cst, memory_scope_work_group); // expected-error {{address argument to atomic operation must be a pointer to atomic integer ('__generic atomic_float *' (aka '__generic _Atomic(float) *') invalid)}}
+  __opencl_atomic_fetch_min(f, 1, memory_order_seq_cst, memory_scope_work_group);
+  __opencl_atomic_fetch_max(f, 1, memory_order_seq_cst, memory_scope_work_group);
+  __opencl_atomic_fetch_min(d, 1, memory_order_seq_cst, memory_scope_work_group);
+  __opencl_atomic_fetch_max(d, 1, memory_order_seq_cst, memory_scope_work_group);
 
   bool cmpexch_1 = __opencl_atomic_compare_exchange_strong(i, I, 1, memory_order_seq_cst, memory_order_seq_cst, memory_scope_work_group);
   bool cmpexch_2 = __opencl_atomic_compare_exchange_strong(p, P, 1, memory_order_seq_cst, memory_order_seq_cst, memory_scope_work_group);
Index: clang/test/Sema/atomic-ops.c
===
--- clang/test/Sema/atomic-ops.c
+++ clang/test/Sema/atomic-ops.c
@@ -131,7 +131,7 @@
_Atomic(int*) *p, _Atomic(float) *f, _Atomic(double) *d,
_Atomic(long double) *ld,
int *I, const int *CI,
-   int **P, float *D, struct S *s1, struct S *s2) {
+   int **P, float *F, double *D, struct S *s1, struct S *s2) {
   __c11_atomic_init(I, 5); // expected-error {{pointer to _Atomic}}
   __c11_atomic_init(ci, 5); // expected-error {{address argument to atomic operation must be a pointer to non-const _Atomic type ('const _Atomic(int) *' invalid)}}
 
@@ -199,14 +199,27 @@
   __c11_atomic_fetch_add(f, 1.0f, memory_order_seq_cst);
   __c11_atomic_fetch_add(d, 1.0, memory_order_seq_cst);
   __c11_atomic_fetch_add(ld, 1.0, memory_order_seq_cst); // fp80-error {{must be a pointer to atomic integer, pointer or supported floating point type}}
+  __c11_atomic_fetch_min(i, 1, memory_order_seq_cst);
+  __c11_atomic_fetch_min(p, 1, memory_order_seq_cst); // expected-error {{must be a pointer to atomic integer or supported floating point type}}
+  __c11_atomic_fetch_min(f, 1.0f, memory_order_seq_cst);
+  __c11_atomic_fetch_min(d, 1.0, memory_order_seq_cst);
+  __c11_atomic_fetch_min(ld, 1.0, memory_order_seq_cst); // fp80-error {{must be a pointer to atomic integer or supported floating point type}}
+  __c11_atomic_fetch_max(i, 1, memory_order_seq_cst);
+  __c11_atomic_fetch_max(p, 1, memory_order_seq_cst); // expected-error {{must be a pointer to atomic integer or supported floating point type}}
+  __c11_atomic_fetch_max(f, 1.0f, memory_order_seq_cst);
+  __c11_atomic_fetch_max(d, 1.0, memory_order_seq_cst);
+  __c11_atomic_fetch_max(ld, 1.0, memory_order_seq_cst); // fp80-error {{must be a pointer to atomic integer or supported floating point type}}
 
   __atomic_fetch_add(i, 3, memory_order_seq_cst); // expected-error {{pointer to integer, pointer or supported floating point type}}
   __atomic_fetch_sub(I, 3, memory_order_seq_cst);
   __atomic_fetch_sub(P, 3, memory_order_seq_cst);
-  __atomic_fetch_sub(D, 3, memory_order_seq_cst);
+  __atomic_fetch_sub(F, 3, memory_order_seq_cst);
   __atomic_fetch_sub(s1, 3, memory_order_seq_cst); // expected-error {{must be a pointer to integer, pointer or supported floating point type}}
-  __atomic_fetch_min(D, 3, memory_order_seq_cst); // expected-error {{must be a pointer to integer}}
-  __atomic_fetch_max(P, 3, memory_order_seq_cst); // expected-error {{must be a pointer to integer}}
+  __atomic_fetch_min(F, 3, memory_order_seq_cst);
+  __atomic_fetch_min(D, 3, memory_order_seq_cst);
+  __atomic_fetch_max(F, 3, memory_order_seq_cst);
+  __atomic_fetch_max(D, 3, memory_order_seq_cst);
+  

[clang] 00448a5 - [clang] Allow fp in atomic fetch max/min builtins

2023-05-31 Thread Yaxun Liu via cfe-commits

Author: Yaxun (Sam) Liu
Date: 2023-05-31T15:19:31-04:00
New Revision: 00448a548c4efc4bdcfd6be5f161eacc69b30021

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

LOG: [clang] Allow fp in atomic fetch max/min builtins

LLVM IR already allows floating point type in atomicrmw.
Update clang atomic fetch max/min builtins to accept
floating point type like we did for fetch add/sub.

Reviewed by: Artem Belevich

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

Fixes: SWDEV-401056

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/CodeGen/CGAtomic.cpp
clang/lib/Sema/SemaChecking.cpp
clang/test/CodeGenCUDA/amdgpu-atomic-ops.cu
clang/test/Sema/atomic-ops.c
clang/test/SemaOpenCL/atomic-ops.cl

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 4847509ae1ec3..90ecbd623ceef 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -8529,6 +8529,9 @@ def err_atomic_op_needs_atomic_int_ptr_or_fp : Error<
 def err_atomic_op_needs_atomic_int_or_ptr : Error<
   "address argument to atomic operation must be a pointer to %select{|atomic 
}0"
   "integer or pointer (%1 invalid)">;
+def err_atomic_op_needs_atomic_int_or_fp : Error<
+  "address argument to atomic operation must be a pointer to %select{|atomic 
}0"
+  "integer or supported floating point type (%1 invalid)">;
 def err_atomic_op_needs_atomic_int : Error<
   "address argument to atomic operation must be a pointer to "
   "%select{|atomic }0integer (%1 invalid)">;

diff  --git a/clang/lib/CodeGen/CGAtomic.cpp b/clang/lib/CodeGen/CGAtomic.cpp
index 0e7eb9723b49e..e2d23a7252613 100644
--- a/clang/lib/CodeGen/CGAtomic.cpp
+++ b/clang/lib/CodeGen/CGAtomic.cpp
@@ -637,8 +637,11 @@ static void EmitAtomicOp(CodeGenFunction , AtomicExpr 
*E, Address Dest,
   case AtomicExpr::AO__hip_atomic_fetch_min:
   case AtomicExpr::AO__opencl_atomic_fetch_min:
   case AtomicExpr::AO__atomic_fetch_min:
-Op = E->getValueType()->isSignedIntegerType() ? llvm::AtomicRMWInst::Min
-  : llvm::AtomicRMWInst::UMin;
+Op = E->getValueType()->isFloatingType()
+ ? llvm::AtomicRMWInst::FMin
+ : (E->getValueType()->isSignedIntegerType()
+? llvm::AtomicRMWInst::Min
+: llvm::AtomicRMWInst::UMin);
 break;
 
   case AtomicExpr::AO__atomic_max_fetch:
@@ -648,8 +651,11 @@ static void EmitAtomicOp(CodeGenFunction , AtomicExpr 
*E, Address Dest,
   case AtomicExpr::AO__hip_atomic_fetch_max:
   case AtomicExpr::AO__opencl_atomic_fetch_max:
   case AtomicExpr::AO__atomic_fetch_max:
-Op = E->getValueType()->isSignedIntegerType() ? llvm::AtomicRMWInst::Max
-  : llvm::AtomicRMWInst::UMax;
+Op = E->getValueType()->isFloatingType()
+ ? llvm::AtomicRMWInst::FMax
+ : (E->getValueType()->isSignedIntegerType()
+? llvm::AtomicRMWInst::Max
+: llvm::AtomicRMWInst::UMax);
 break;
 
   case AtomicExpr::AO__atomic_and_fetch:
@@ -918,9 +924,19 @@ RValue CodeGenFunction::EmitAtomicExpr(AtomicExpr *E) {
 }
 [[fallthrough]];
   case AtomicExpr::AO__atomic_fetch_add:
+  case AtomicExpr::AO__atomic_fetch_max:
+  case AtomicExpr::AO__atomic_fetch_min:
   case AtomicExpr::AO__atomic_fetch_sub:
   case AtomicExpr::AO__atomic_add_fetch:
+  case AtomicExpr::AO__atomic_max_fetch:
+  case AtomicExpr::AO__atomic_min_fetch:
   case AtomicExpr::AO__atomic_sub_fetch:
+  case AtomicExpr::AO__c11_atomic_fetch_max:
+  case AtomicExpr::AO__c11_atomic_fetch_min:
+  case AtomicExpr::AO__opencl_atomic_fetch_max:
+  case AtomicExpr::AO__opencl_atomic_fetch_min:
+  case AtomicExpr::AO__hip_atomic_fetch_max:
+  case AtomicExpr::AO__hip_atomic_fetch_min:
 ShouldCastToIntPtrTy = !MemTy->isFloatingType();
 [[fallthrough]];
 
@@ -936,13 +952,9 @@ RValue CodeGenFunction::EmitAtomicExpr(AtomicExpr *E) {
   case AtomicExpr::AO__c11_atomic_fetch_or:
   case AtomicExpr::AO__c11_atomic_fetch_xor:
   case AtomicExpr::AO__c11_atomic_fetch_nand:
-  case AtomicExpr::AO__c11_atomic_fetch_max:
-  case AtomicExpr::AO__c11_atomic_fetch_min:
   case AtomicExpr::AO__opencl_atomic_fetch_and:
   case AtomicExpr::AO__opencl_atomic_fetch_or:
   case AtomicExpr::AO__opencl_atomic_fetch_xor:
-  case AtomicExpr::AO__opencl_atomic_fetch_min:
-  case AtomicExpr::AO__opencl_atomic_fetch_max:
   case AtomicExpr::AO__atomic_fetch_and:
   case AtomicExpr::AO__hip_atomic_fetch_and:
   case AtomicExpr::AO__atomic_fetch_or:
@@ -954,12 +966,6 @@ RValue CodeGenFunction::EmitAtomicExpr(AtomicExpr *E) {
  

[clang] dfce185 - [clang] NFCI: Use `FileEntryRef` in `VerifyDiagnosticConsumer`

2023-05-31 Thread Jan Svoboda via cfe-commits

Author: Jan Svoboda
Date: 2023-05-31T12:17:37-07:00
New Revision: dfce18506b7a9354ddc6706c9ca12644a7be9767

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

LOG: [clang] NFCI: Use `FileEntryRef` in `VerifyDiagnosticConsumer`

This is a prep patch that enables removal of some calls to the deprecated 
`{File,Directory}Entry::getName()`.

Added: 


Modified: 
clang/lib/Frontend/VerifyDiagnosticConsumer.cpp

Removed: 




diff  --git a/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp 
b/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp
index 378f7ddd0159f..d57b27e9e36fc 100644
--- a/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp
+++ b/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp
@@ -737,12 +737,12 @@ void VerifyDiagnosticConsumer::HandleDiagnostic(
   Loc = SrcManager->getExpansionLoc(Loc);
   FileID FID = SrcManager->getFileID(Loc);
 
-  const FileEntry *FE = SrcManager->getFileEntryForID(FID);
+  auto FE = SrcManager->getFileEntryRefForID(FID);
   if (FE && CurrentPreprocessor && SrcManager->isLoadedFileID(FID)) {
 // If the file is a modules header file it shall not be parsed
 // for expected-* directives.
 HeaderSearch  = CurrentPreprocessor->getHeaderSearchInfo();
-if (HS.findModuleForHeader(FE))
+if (HS.findModuleForHeader(*FE))
   PS = IsUnparsedNoDirectives;
   }
 



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


[clang] 53690f8 - [clang] NFCI: Use `FileEntryRef` in `PPDirectives`

2023-05-31 Thread Jan Svoboda via cfe-commits

Author: Jan Svoboda
Date: 2023-05-31T12:17:37-07:00
New Revision: 53690f8f0db78d27a9ab5a7b924faaae627da4c4

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

LOG: [clang] NFCI: Use `FileEntryRef` in `PPDirectives`

This is a prep patch that enables removal of some calls to the deprecated 
`{File,Directory}Entry::getName()`.

Added: 


Modified: 
clang/lib/Lex/PPDirectives.cpp

Removed: 




diff  --git a/clang/lib/Lex/PPDirectives.cpp b/clang/lib/Lex/PPDirectives.cpp
index b3ce92f1699da..e83da5c573871 100644
--- a/clang/lib/Lex/PPDirectives.cpp
+++ b/clang/lib/Lex/PPDirectives.cpp
@@ -833,10 +833,10 @@ Module *Preprocessor::getModuleForLocation(SourceLocation 
Loc,
 // Try to determine the module of the include directive.
 // FIXME: Look into directly passing the FileEntry from LookupFile instead.
 FileID IDOfIncl = SourceMgr.getFileID(SourceMgr.getExpansionLoc(Loc));
-if (const FileEntry *EntryOfIncl = SourceMgr.getFileEntryForID(IDOfIncl)) {
+if (auto EntryOfIncl = SourceMgr.getFileEntryRefForID(IDOfIncl)) {
   // The include comes from an included file.
   return HeaderInfo.getModuleMap()
-  .findModuleForHeader(EntryOfIncl, AllowTextual)
+  .findModuleForHeader(*EntryOfIncl, AllowTextual)
   .getModule();
 }
   }
@@ -861,7 +861,7 @@ 
Preprocessor::getHeaderToIncludeForDiagnostics(SourceLocation IncLoc,
   auto  = getSourceManager();
   while (!Loc.isInvalid() && !SM.isInMainFile(Loc)) {
 auto ID = SM.getFileID(SM.getExpansionLoc(Loc));
-auto *FE = SM.getFileEntryForID(ID);
+auto FE = SM.getFileEntryRefForID(ID);
 if (!FE)
   break;
 
@@ -871,7 +871,7 @@ 
Preprocessor::getHeaderToIncludeForDiagnostics(SourceLocation IncLoc,
 SourceMgr.isInSystemHeader(Loc));
 
 bool InPrivateHeader = false;
-for (auto Header : HeaderInfo.findAllModulesForHeader(FE)) {
+for (auto Header : HeaderInfo.findAllModulesForHeader(*FE)) {
   if (!Header.isAccessibleFrom(IncM)) {
 // It's in a private header; we can't #include it.
 // FIXME: If there's a public header in some module that re-exports it,
@@ -899,7 +899,7 @@ 
Preprocessor::getHeaderToIncludeForDiagnostics(SourceLocation IncLoc,
   // If this is an accessible, non-textual header of M's top-level module
   // that transitively includes the given location and makes the
   // corresponding module visible, this is the thing to #include.
-  return FE;
+  return *FE;
 }
 
 // FIXME: If we're bailing out due to a private header, we shouldn't 
suggest
@@ -910,8 +910,8 @@ 
Preprocessor::getHeaderToIncludeForDiagnostics(SourceLocation IncLoc,
 // If the header is includable and has an include guard, assume the
 // intended way to expose its contents is by #include, not by importing a
 // module that transitively includes it.
-if (getHeaderSearchInfo().isFileMultipleIncludeGuarded(FE))
-  return FE;
+if (getHeaderSearchInfo().isFileMultipleIncludeGuarded(*FE))
+  return *FE;
 
 Loc = SM.getIncludeLoc(ID);
   }



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


[PATCH] D151783: [clang] Use the appropriate definition when checking FunctionDecl::isInlineBuiltinDeclaration

2023-05-31 Thread serge via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG1676b1ff63af: [clang] Use the appropriate definition when 
checking FunctionDecl… (authored by serge-sans-paille).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151783

Files:
  clang/lib/AST/Decl.cpp
  clang/test/CodeGen/memcpy-inline-builtin-mutliple-decl.c


Index: clang/test/CodeGen/memcpy-inline-builtin-mutliple-decl.c
===
--- /dev/null
+++ clang/test/CodeGen/memcpy-inline-builtin-mutliple-decl.c
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -triple i686-w64-mingw32 -S -emit-llvm -disable-llvm-passes 
-o - %s | FileCheck %s
+//
+// Verifies that clang detects memcpy inline version and uses it instead of 
the builtin.
+// Checks that clang correctly walks through multiple forward declaration.
+
+typedef unsigned int size_t;
+
+void *memcpy(void *_Dst, const void *_Src, size_t _Size);
+
+extern __inline__ __attribute__((__always_inline__, __gnu_inline__)) 
__attribute__((__artificial__))
+void *memcpy(void *__dst, const void *__src, size_t __n)
+{
+  return __builtin___memcpy_chk(__dst, __src, __n, 
__builtin_object_size((__dst), ((0) > 0) && (2 > 1)));
+}
+
+void *memcpy(void *_Dst, const void *_Src, size_t _Size);
+
+char *a, *b;
+void func(void) {
+memcpy(a, b, 42);
+}
+
+// CHECK-LABEL: define {{.*}} @func(
+// CHECK: call ptr @memcpy.inline
+
+// CHECK-LABEL: declare {{.*}} @memcpy(
+
+// CHECK-LABEL: define {{.*}} @memcpy.inline(
+// CHECK: call ptr @__memcpy_chk
Index: clang/lib/AST/Decl.cpp
===
--- clang/lib/AST/Decl.cpp
+++ clang/lib/AST/Decl.cpp
@@ -3322,7 +3322,7 @@
 return false;
 
   ASTContext  = getASTContext();
-  switch (Context.GetGVALinkageForFunction(this)) {
+  switch (Context.GetGVALinkageForFunction(Definition)) {
   case GVA_Internal:
   case GVA_DiscardableODR:
   case GVA_StrongODR:


Index: clang/test/CodeGen/memcpy-inline-builtin-mutliple-decl.c
===
--- /dev/null
+++ clang/test/CodeGen/memcpy-inline-builtin-mutliple-decl.c
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -triple i686-w64-mingw32 -S -emit-llvm -disable-llvm-passes -o - %s | FileCheck %s
+//
+// Verifies that clang detects memcpy inline version and uses it instead of the builtin.
+// Checks that clang correctly walks through multiple forward declaration.
+
+typedef unsigned int size_t;
+
+void *memcpy(void *_Dst, const void *_Src, size_t _Size);
+
+extern __inline__ __attribute__((__always_inline__, __gnu_inline__)) __attribute__((__artificial__))
+void *memcpy(void *__dst, const void *__src, size_t __n)
+{
+  return __builtin___memcpy_chk(__dst, __src, __n, __builtin_object_size((__dst), ((0) > 0) && (2 > 1)));
+}
+
+void *memcpy(void *_Dst, const void *_Src, size_t _Size);
+
+char *a, *b;
+void func(void) {
+memcpy(a, b, 42);
+}
+
+// CHECK-LABEL: define {{.*}} @func(
+// CHECK: call ptr @memcpy.inline
+
+// CHECK-LABEL: declare {{.*}} @memcpy(
+
+// CHECK-LABEL: define {{.*}} @memcpy.inline(
+// CHECK: call ptr @__memcpy_chk
Index: clang/lib/AST/Decl.cpp
===
--- clang/lib/AST/Decl.cpp
+++ clang/lib/AST/Decl.cpp
@@ -3322,7 +3322,7 @@
 return false;
 
   ASTContext  = getASTContext();
-  switch (Context.GetGVALinkageForFunction(this)) {
+  switch (Context.GetGVALinkageForFunction(Definition)) {
   case GVA_Internal:
   case GVA_DiscardableODR:
   case GVA_StrongODR:
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 1676b1f - [clang] Use the appropriate definition when checking FunctionDecl::isInlineBuiltinDeclaration

2023-05-31 Thread via cfe-commits

Author: serge-sans-paille
Date: 2023-05-31T21:13:07+02:00
New Revision: 1676b1ff63afb1cadc523d74f1e8f2c75fd49126

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

LOG: [clang] Use the appropriate definition when checking 
FunctionDecl::isInlineBuiltinDeclaration

This is a follow-up to https://reviews.llvm.org/D148723 and fixes the
bug reported by @mstorsjo.

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

Added: 
clang/test/CodeGen/memcpy-inline-builtin-mutliple-decl.c

Modified: 
clang/lib/AST/Decl.cpp

Removed: 




diff  --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp
index 99926b2786ef..85d8f11aafde 100644
--- a/clang/lib/AST/Decl.cpp
+++ b/clang/lib/AST/Decl.cpp
@@ -3322,7 +3322,7 @@ bool FunctionDecl::isInlineBuiltinDeclaration() const {
 return false;
 
   ASTContext  = getASTContext();
-  switch (Context.GetGVALinkageForFunction(this)) {
+  switch (Context.GetGVALinkageForFunction(Definition)) {
   case GVA_Internal:
   case GVA_DiscardableODR:
   case GVA_StrongODR:

diff  --git a/clang/test/CodeGen/memcpy-inline-builtin-mutliple-decl.c 
b/clang/test/CodeGen/memcpy-inline-builtin-mutliple-decl.c
new file mode 100644
index ..39a964c51c7d
--- /dev/null
+++ b/clang/test/CodeGen/memcpy-inline-builtin-mutliple-decl.c
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -triple i686-w64-mingw32 -S -emit-llvm -disable-llvm-passes 
-o - %s | FileCheck %s
+//
+// Verifies that clang detects memcpy inline version and uses it instead of 
the builtin.
+// Checks that clang correctly walks through multiple forward declaration.
+
+typedef unsigned int size_t;
+
+void *memcpy(void *_Dst, const void *_Src, size_t _Size);
+
+extern __inline__ __attribute__((__always_inline__, __gnu_inline__)) 
__attribute__((__artificial__))
+void *memcpy(void *__dst, const void *__src, size_t __n)
+{
+  return __builtin___memcpy_chk(__dst, __src, __n, 
__builtin_object_size((__dst), ((0) > 0) && (2 > 1)));
+}
+
+void *memcpy(void *_Dst, const void *_Src, size_t _Size);
+
+char *a, *b;
+void func(void) {
+memcpy(a, b, 42);
+}
+
+// CHECK-LABEL: define {{.*}} @func(
+// CHECK: call ptr @memcpy.inline
+
+// CHECK-LABEL: declare {{.*}} @memcpy(
+
+// CHECK-LABEL: define {{.*}} @memcpy.inline(
+// CHECK: call ptr @__memcpy_chk



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


[PATCH] D151753: [Clang][Sema] Do not try to analyze dependent alignment during -Wcast-align

2023-05-31 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik added inline comments.



Comment at: clang/lib/Sema/SemaChecking.cpp:16163
+// Dependent alignment cannot be resolved -> bail out.
+if (any_of(VD->specific_attrs(),
+   [](auto *A) { return A->isAlignmentDependent(); }))

Can't we just use `hasDependentAlignment()` which basically does this.

I am curious that we don't have to do this check in every location we use 
`getDeclAlign`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151753

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


[PATCH] D151828: Disable pr59765-modules-global-ctor-dtor.cppm on z/OS to make it unsupported.

2023-05-31 Thread Zibi Sarbino via Phabricator via cfe-commits
zibi created this revision.
Herald added a project: All.
zibi requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

[z/OS] Disable pr59765-modules-global-ctor-dtor.cppm


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D151828

Files:
  clang/test/CodeGenCXX/pr59765-modules-global-ctor-dtor.cppm


Index: clang/test/CodeGenCXX/pr59765-modules-global-ctor-dtor.cppm
===
--- clang/test/CodeGenCXX/pr59765-modules-global-ctor-dtor.cppm
+++ clang/test/CodeGenCXX/pr59765-modules-global-ctor-dtor.cppm
@@ -1,9 +1,9 @@
 // https://github.com/llvm/llvm-project/issues/59765
 // FIXME: Since the signature of the constructors/destructors is
 // different in different targets. The current CHECK can't work
-// well when targeting or running on AIX.
+// well when targeting or running on AIX and z/OS.
 // It would be better to add the corresponding test for other test.
-// UNSUPPORTED: system-aix
+// UNSUPPORTED: system-zos, system-aix
 //
 // RUN: rm -rf %t
 // RUN: mkdir %t


Index: clang/test/CodeGenCXX/pr59765-modules-global-ctor-dtor.cppm
===
--- clang/test/CodeGenCXX/pr59765-modules-global-ctor-dtor.cppm
+++ clang/test/CodeGenCXX/pr59765-modules-global-ctor-dtor.cppm
@@ -1,9 +1,9 @@
 // https://github.com/llvm/llvm-project/issues/59765
 // FIXME: Since the signature of the constructors/destructors is
 // different in different targets. The current CHECK can't work
-// well when targeting or running on AIX.
+// well when targeting or running on AIX and z/OS.
 // It would be better to add the corresponding test for other test.
-// UNSUPPORTED: system-aix
+// UNSUPPORTED: system-zos, system-aix
 //
 // RUN: rm -rf %t
 // RUN: mkdir %t
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D151634: [clang] Add test for CWG253

2023-05-31 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik added a comment.

In D151634#4383428 , @Endill wrote:

> @shafik Thank you for letting me know! Now I wonder if it was possible to 
> realize by myself without prior knowledge of CWG 2536, because I feel like 
> some cross-references are missing.
> Can we proceed if I strip CWG 78 out, leaving only CWG 253?

I don't think there was a way to figure this out w/o knowing or luck.

I think just leave out 78 for now.




Comment at: clang/test/CXX/drs/dr2xx.cpp:686
 
+namespace dr253 { // dr253: 3.9
+struct Z {

Note this was fixed via: 
https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0490r0.html


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151634

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


[PATCH] D150985: [clang] Allow fp in atomic fetch max/min builtins

2023-05-31 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl marked 4 inline comments as done.
yaxunl added inline comments.



Comment at: clang/lib/Sema/SemaChecking.cpp:6576-6578
   if (!ValType->isFloatingType())
 return false;
+  if (!(AllowedType & AOAVT_FP))

tra wrote:
> Collapse into a single if statement: `if (!(ValType->isFloatingType() && 
> (AllowedType & AOAVT_FP)))`
will do



Comment at: clang/lib/Sema/SemaChecking.cpp:6588
+if (!IsAllowedValueType(ValType, ArithAllows)) {
+  assert(ArithAllows & AOAVT_Integer);
+  auto DID = ArithAllows & AOAVT_FP

tra wrote:
> Why do we expect a failed `IsAllowedValueType` check to fail only if we were 
> allowed integers? Is that because we assume that all atomic instructions 
> support integers?
> 
> If that's the case, I'd hoist the assertion and apply it right after we're 
> done setting `ArithAllows`. Alternatively, we could discard `AOAVT_Integer` 
> and call the enum `ArithOpExtraValueType`. Tracking a bit that's always set 
> does not buy us much, though it does make the code a bit more uniform. Up to 
> you.
> 
> 
> 
we assume integer is always allowed. AOAVT_Integer is for uniformity. I will 
change the enum to ArithOpExtraValueType and remove AOAVT_Integer 



Comment at: clang/test/Sema/atomic-ops.c:134
int *I, const int *CI,
int **P, float *D, struct S *s1, struct S *s2) {
   __c11_atomic_init(I, 5); // expected-error {{pointer to _Atomic}}

tra wrote:
> I wonder why we have this inconsistency in the non-atomic arguments.
> We don't actually have any double variants and the argument `D` is actually a 
> `float *`, even though the naming convention used suggests that it should've 
> been either a `double *` or should be called `F`.
> 
will rename it to F and add double *D



Comment at: clang/test/Sema/atomic-ops.c:218
   __atomic_fetch_sub(s1, 3, memory_order_seq_cst); // expected-error {{must be 
a pointer to integer, pointer or supported floating point type}}
-  __atomic_fetch_min(D, 3, memory_order_seq_cst); // expected-error {{must be 
a pointer to integer}}
-  __atomic_fetch_max(P, 3, memory_order_seq_cst); // expected-error {{must be 
a pointer to integer}}
+  __atomic_fetch_min(D, 3, memory_order_seq_cst);
+  __atomic_fetch_max(P, 3, memory_order_seq_cst); // expected-error {{must be 
a pointer to integer or supported floating point type}}

tra wrote:
> We seem to be missing the tests for `double *` here, too.
will add it


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

https://reviews.llvm.org/D150985

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


[PATCH] D144999: [Clang][MC][MachO]Only emits compact-unwind format for "canonical" personality symbols. For the rest, use DWARFs.

2023-05-31 Thread Vy Nguyen via Phabricator via cfe-commits
oontvoo reopened this revision.
oontvoo added a comment.
This revision is now accepted and ready to land.

In D144999#4356218 , @thakis wrote:

> Reverted in 4980eead4d0b4666d53dad07afb091375b3a13a0 
>  for now.
>
> (The assert only happens when targeting x86_64, not arm64. The repro script 
> above has the right `-arch` flag to toggle it.)

Thanks for the revert! This was caused by another bug (should be fixed in 
https://reviews.llvm.org/D151824)
Will reland this once that is landed.




Comment at: llvm/lib/MC/MCAsmBackend.cpp:125
+// Reserving an empty slot for it seems silly.
+return name == "__gxx_personality_v0" || name == "__objc_personality_v0";
+  }

need an additional _


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144999

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


[PATCH] D150689: [clang][DependencyScanner] Remove all warning flags when suppressing warnings

2023-05-31 Thread Juergen Ributzka via Phabricator via cfe-commits
ributzka accepted this revision.
ributzka added a comment.

I see. LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150689

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


[PATCH] D151818: [clang][analyzer][NFC] Use the operator new directly with the `BumpPtrAllocator`

2023-05-31 Thread Dmitri Gribenko 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 rG7ebf64f7e934: [clang][analyzer][NFC] Use the operator new 
directly with the `BumpPtrAllocator` (authored by gribozavr).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151818

Files:
  clang/lib/Analysis/CFG.cpp
  clang/lib/StaticAnalyzer/Core/BasicValueFactory.cpp
  clang/lib/StaticAnalyzer/Core/ExplodedGraph.cpp
  clang/lib/StaticAnalyzer/Core/MemRegion.cpp
  clang/lib/StaticAnalyzer/Core/SymbolManager.cpp

Index: clang/lib/StaticAnalyzer/Core/SymbolManager.cpp
===
--- clang/lib/StaticAnalyzer/Core/SymbolManager.cpp
+++ clang/lib/StaticAnalyzer/Core/SymbolManager.cpp
@@ -170,8 +170,7 @@
   void *InsertPos;
   SymExpr *SD = DataSet.FindNodeOrInsertPos(profile, InsertPos);
   if (!SD) {
-SD = BPAlloc.Allocate();
-new (SD) SymbolRegionValue(SymbolCounter, R);
+SD = new (BPAlloc) SymbolRegionValue(SymbolCounter, R);
 DataSet.InsertNode(SD, InsertPos);
 ++SymbolCounter;
   }
@@ -189,8 +188,7 @@
   void *InsertPos;
   SymExpr *SD = DataSet.FindNodeOrInsertPos(profile, InsertPos);
   if (!SD) {
-SD = BPAlloc.Allocate();
-new (SD) SymbolConjured(SymbolCounter, E, LCtx, T, Count, SymbolTag);
+SD = new (BPAlloc) SymbolConjured(SymbolCounter, E, LCtx, T, Count, SymbolTag);
 DataSet.InsertNode(SD, InsertPos);
 ++SymbolCounter;
   }
@@ -206,8 +204,7 @@
   void *InsertPos;
   SymExpr *SD = DataSet.FindNodeOrInsertPos(profile, InsertPos);
   if (!SD) {
-SD = BPAlloc.Allocate();
-new (SD) SymbolDerived(SymbolCounter, parentSymbol, R);
+SD = new (BPAlloc) SymbolDerived(SymbolCounter, parentSymbol, R);
 DataSet.InsertNode(SD, InsertPos);
 ++SymbolCounter;
   }
@@ -222,8 +219,7 @@
   void *InsertPos;
   SymExpr *SD = DataSet.FindNodeOrInsertPos(profile, InsertPos);
   if (!SD) {
-SD = BPAlloc.Allocate();
-new (SD) SymbolExtent(SymbolCounter, R);
+SD = new (BPAlloc) SymbolExtent(SymbolCounter, R);
 DataSet.InsertNode(SD, InsertPos);
 ++SymbolCounter;
   }
@@ -240,8 +236,7 @@
   void *InsertPos;
   SymExpr *SD = DataSet.FindNodeOrInsertPos(profile, InsertPos);
   if (!SD) {
-SD = BPAlloc.Allocate();
-new (SD) SymbolMetadata(SymbolCounter, R, S, T, LCtx, Count, SymbolTag);
+SD = new (BPAlloc) SymbolMetadata(SymbolCounter, R, S, T, LCtx, Count, SymbolTag);
 DataSet.InsertNode(SD, InsertPos);
 ++SymbolCounter;
   }
@@ -257,8 +252,7 @@
   void *InsertPos;
   SymExpr *data = DataSet.FindNodeOrInsertPos(ID, InsertPos);
   if (!data) {
-data = BPAlloc.Allocate();
-new (data) SymbolCast(Op, From, To);
+data = new (BPAlloc) SymbolCast(Op, From, To);
 DataSet.InsertNode(data, InsertPos);
   }
 
@@ -275,8 +269,7 @@
   SymExpr *data = DataSet.FindNodeOrInsertPos(ID, InsertPos);
 
   if (!data) {
-data = BPAlloc.Allocate();
-new (data) SymIntExpr(lhs, op, v, t);
+data = new (BPAlloc) SymIntExpr(lhs, op, v, t);
 DataSet.InsertNode(data, InsertPos);
   }
 
@@ -293,8 +286,7 @@
   SymExpr *data = DataSet.FindNodeOrInsertPos(ID, InsertPos);
 
   if (!data) {
-data = BPAlloc.Allocate();
-new (data) IntSymExpr(lhs, op, rhs, t);
+data = new (BPAlloc) IntSymExpr(lhs, op, rhs, t);
 DataSet.InsertNode(data, InsertPos);
   }
 
@@ -311,8 +303,7 @@
   SymExpr *data = DataSet.FindNodeOrInsertPos(ID, InsertPos);
 
   if (!data) {
-data = BPAlloc.Allocate();
-new (data) SymSymExpr(lhs, op, rhs, t);
+data = new (BPAlloc) SymSymExpr(lhs, op, rhs, t);
 DataSet.InsertNode(data, InsertPos);
   }
 
@@ -327,8 +318,7 @@
   void *InsertPos;
   SymExpr *data = DataSet.FindNodeOrInsertPos(ID, InsertPos);
   if (!data) {
-data = BPAlloc.Allocate();
-new (data) UnarySymExpr(Operand, Opc, T);
+data = new (BPAlloc) UnarySymExpr(Operand, Opc, T);
 DataSet.InsertNode(data, InsertPos);
   }
 
Index: clang/lib/StaticAnalyzer/Core/MemRegion.cpp
===
--- clang/lib/StaticAnalyzer/Core/MemRegion.cpp
+++ clang/lib/StaticAnalyzer/Core/MemRegion.cpp
@@ -73,8 +73,7 @@
   auto *R = cast_or_null(Regions.FindNodeOrInsertPos(ID, InsertPos));
 
   if (!R) {
-R = A.Allocate();
-new (R) RegionTy(arg1, superRegion);
+R = new (A) RegionTy(arg1, superRegion);
 Regions.InsertNode(R, InsertPos);
   }
 
@@ -90,8 +89,7 @@
   auto *R = cast_or_null(Regions.FindNodeOrInsertPos(ID, InsertPos));
 
   if (!R) {
-R = A.Allocate();
-new (R) RegionTy(arg1, arg2, superRegion);
+R = new (A) RegionTy(arg1, arg2, superRegion);
 Regions.InsertNode(R, InsertPos);
   }
 
@@ -109,8 +107,7 @@
   auto *R = cast_or_null(Regions.FindNodeOrInsertPos(ID, InsertPos));
 
   if (!R) {
-R = A.Allocate();
-new (R) RegionTy(arg1, arg2, arg3, 

[clang] 7ebf64f - [clang][analyzer][NFC] Use the operator new directly with the `BumpPtrAllocator`

2023-05-31 Thread Dmitri Gribenko via cfe-commits

Author: Dmitri Gribenko
Date: 2023-05-31T20:18:30+02:00
New Revision: 7ebf64f7e934a5e42d550194604b613113132bc0

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

LOG: [clang][analyzer][NFC] Use the operator new directly with the 
`BumpPtrAllocator`

Reviewed By: xazax.hun

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

Added: 


Modified: 
clang/lib/Analysis/CFG.cpp
clang/lib/StaticAnalyzer/Core/BasicValueFactory.cpp
clang/lib/StaticAnalyzer/Core/ExplodedGraph.cpp
clang/lib/StaticAnalyzer/Core/MemRegion.cpp
clang/lib/StaticAnalyzer/Core/SymbolManager.cpp

Removed: 




diff  --git a/clang/lib/Analysis/CFG.cpp b/clang/lib/Analysis/CFG.cpp
index 4c8ceb792d2a7..246bace4debcf 100644
--- a/clang/lib/Analysis/CFG.cpp
+++ b/clang/lib/Analysis/CFG.cpp
@@ -1992,8 +1992,7 @@ LocalScope* 
CFGBuilder::createOrReuseLocalScope(LocalScope* Scope) {
   if (Scope)
 return Scope;
   llvm::BumpPtrAllocator  = cfg->getAllocator();
-  return new (alloc.Allocate())
-  LocalScope(BumpVectorContext(alloc), ScopePos);
+  return new (alloc) LocalScope(BumpVectorContext(alloc), ScopePos);
 }
 
 /// addLocalScopeForStmt - Add LocalScope to local scopes tree for statement
@@ -5214,8 +5213,7 @@ CFGBlock *CFG::createBlock() {
   bool first_block = begin() == end();
 
   // Create the block.
-  CFGBlock *Mem = getAllocator().Allocate();
-  new (Mem) CFGBlock(NumBlockIDs++, BlkBVC, this);
+  CFGBlock *Mem = new (getAllocator()) CFGBlock(NumBlockIDs++, BlkBVC, this);
   Blocks.push_back(Mem, BlkBVC);
 
   // If this is the first block, set it as the Entry and Exit.

diff  --git a/clang/lib/StaticAnalyzer/Core/BasicValueFactory.cpp 
b/clang/lib/StaticAnalyzer/Core/BasicValueFactory.cpp
index 5a5851975bb60..5924f6a671c2a 100644
--- a/clang/lib/StaticAnalyzer/Core/BasicValueFactory.cpp
+++ b/clang/lib/StaticAnalyzer/Core/BasicValueFactory.cpp
@@ -97,8 +97,7 @@ const llvm::APSInt& BasicValueFactory::getValue(const 
llvm::APSInt& X) {
   FoldNodeTy* P = APSIntSet.FindNodeOrInsertPos(ID, InsertPos);
 
   if (!P) {
-P = BPAlloc.Allocate();
-new (P) FoldNodeTy(X);
+P = new (BPAlloc) FoldNodeTy(X);
 APSIntSet.InsertNode(P, InsertPos);
   }
 
@@ -132,8 +131,7 @@ BasicValueFactory::getCompoundValData(QualType T,
   CompoundValData* D = CompoundValDataSet.FindNodeOrInsertPos(ID, InsertPos);
 
   if (!D) {
-D = BPAlloc.Allocate();
-new (D) CompoundValData(T, Vals);
+D = new (BPAlloc) CompoundValData(T, Vals);
 CompoundValDataSet.InsertNode(D, InsertPos);
   }
 
@@ -151,8 +149,7 @@ BasicValueFactory::getLazyCompoundValData(const StoreRef 
,
 LazyCompoundValDataSet.FindNodeOrInsertPos(ID, InsertPos);
 
   if (!D) {
-D = BPAlloc.Allocate();
-new (D) LazyCompoundValData(store, region);
+D = new (BPAlloc) LazyCompoundValData(store, region);
 LazyCompoundValDataSet.InsertNode(D, InsertPos);
   }
 
@@ -169,8 +166,7 @@ const PointerToMemberData 
*BasicValueFactory::getPointerToMemberData(
   PointerToMemberDataSet.FindNodeOrInsertPos(ID, InsertPos);
 
   if (!D) {
-D = BPAlloc.Allocate();
-new (D) PointerToMemberData(ND, L);
+D = new (BPAlloc) PointerToMemberData(ND, L);
 PointerToMemberDataSet.InsertNode(D, InsertPos);
   }
 
@@ -358,8 +354,7 @@ BasicValueFactory::getPersistentSValWithData(const SVal& V, 
uintptr_t Data) {
   FoldNodeTy* P = Map.FindNodeOrInsertPos(ID, InsertPos);
 
   if (!P) {
-P = BPAlloc.Allocate();
-new (P) FoldNodeTy(std::make_pair(V, Data));
+P = new (BPAlloc) FoldNodeTy(std::make_pair(V, Data));
 Map.InsertNode(P, InsertPos);
   }
 
@@ -383,8 +378,7 @@ BasicValueFactory::getPersistentSValPair(const SVal& V1, 
const SVal& V2) {
   FoldNodeTy* P = Map.FindNodeOrInsertPos(ID, InsertPos);
 
   if (!P) {
-P = BPAlloc.Allocate();
-new (P) FoldNodeTy(std::make_pair(V1, V2));
+P = new (BPAlloc) FoldNodeTy(std::make_pair(V1, V2));
 Map.InsertNode(P, InsertPos);
   }
 

diff  --git a/clang/lib/StaticAnalyzer/Core/ExplodedGraph.cpp 
b/clang/lib/StaticAnalyzer/Core/ExplodedGraph.cpp
index 314a4feda81b3..e1f26a50cbc5e 100644
--- a/clang/lib/StaticAnalyzer/Core/ExplodedGraph.cpp
+++ b/clang/lib/StaticAnalyzer/Core/ExplodedGraph.cpp
@@ -233,8 +233,7 @@ void ExplodedNode::NodeGroup::addNode(ExplodedNode *N, 
ExplodedGraph ) {
 ExplodedNode *Old = Storage.get();
 
 BumpVectorContext  = G.getNodeAllocator();
-V = G.getAllocator().Allocate();
-new (V) ExplodedNodeVector(Ctx, 4);
+V = new (G.getAllocator()) ExplodedNodeVector(Ctx, 4);
 V->push_back(Old, Ctx);
 
 Storage = V;

diff  --git a/clang/lib/StaticAnalyzer/Core/MemRegion.cpp 
b/clang/lib/StaticAnalyzer/Core/MemRegion.cpp
index d7409ae6aebe8..7cda64d6a028a 100644
--- 

[PATCH] D148387: remove Demangle/StringView.h

2023-05-31 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers updated this revision to Diff 527132.
nickdesaulniers added a comment.

- rebase for presubmit testing


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148387

Files:
  clang/docs/tools/clang-formatted-files.txt
  libcxxabi/src/demangle/StringView.h
  libcxxabi/src/demangle/cp-to-llvm.sh
  llvm/include/llvm/Demangle/StringView.h
  llvm/unittests/Demangle/CMakeLists.txt
  llvm/unittests/Demangle/StringViewTest.cpp

Index: llvm/unittests/Demangle/StringViewTest.cpp
===
--- llvm/unittests/Demangle/StringViewTest.cpp
+++ /dev/null
@@ -1,48 +0,0 @@
-//===- llvm/unittest/StringViewTest.cpp - StringView unit tests ---===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===--===//
-
-#include "llvm/Demangle/StringView.h"
-#include "gtest/gtest.h"
-
-using namespace llvm;
-using llvm::itanium_demangle::StringView;
-
-namespace llvm {
-namespace itanium_demangle {
-
-std::ostream <<(std::ostream , const StringView ) {
-  return OS.write(S.begin(), S.size());
-}
-
-} // namespace itanium_demangle
-} // namespace llvm
-
-TEST(StringViewTest, EmptyInitializerList) {
-  StringView S = {};
-  EXPECT_TRUE(S.empty());
-
-  S = {};
-  EXPECT_TRUE(S.empty());
-}
-
-TEST(StringViewTest, Substr) {
-  StringView S("abcdef");
-
-  EXPECT_EQ("abcdef", S.substr(0));
-  EXPECT_EQ("f", S.substr(5));
-  EXPECT_EQ("", S.substr(6));
-
-  EXPECT_EQ("", S.substr(0, 0));
-  EXPECT_EQ("a", S.substr(0, 1));
-  EXPECT_EQ("abcde", S.substr(0, 5));
-  EXPECT_EQ("abcdef", S.substr(0, 6));
-  EXPECT_EQ("abcdef", S.substr(0, 7));
-
-  EXPECT_EQ("f", S.substr(5, 100));
-  EXPECT_EQ("", S.substr(6, 100));
-}
Index: llvm/unittests/Demangle/CMakeLists.txt
===
--- llvm/unittests/Demangle/CMakeLists.txt
+++ llvm/unittests/Demangle/CMakeLists.txt
@@ -10,5 +10,4 @@
   OutputBufferTest.cpp
   PartialDemangleTest.cpp
   RustDemangleTest.cpp
-  StringViewTest.cpp
 )
Index: llvm/include/llvm/Demangle/StringView.h
===
--- llvm/include/llvm/Demangle/StringView.h
+++ /dev/null
@@ -1,98 +0,0 @@
-//===--- StringView.h *- mode:c++;eval:(read-only-mode) -*-===//
-//   Do not edit! See README.txt.
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===--===//
-//
-// FIXME: Use std::string_view instead when we support C++17.
-// There are two copies of this file in the source tree.  The one under
-// libcxxabi is the original and the one under llvm is the copy.  Use
-// cp-to-llvm.sh to update the copy.  See README.txt for more details.
-//
-//===--===//
-
-#ifndef DEMANGLE_STRINGVIEW_H
-#define DEMANGLE_STRINGVIEW_H
-
-#include "DemangleConfig.h"
-#include 
-#include 
-
-DEMANGLE_NAMESPACE_BEGIN
-
-class StringView {
-  const char *First;
-  const char *Last;
-
-public:
-  static const size_t npos = ~size_t(0);
-
-  template 
-  StringView(const char ()[N]) : First(Str), Last(Str + N - 1) {}
-  StringView(const char *First_, size_t Len)
-  : First(First_), Last(First_ + Len) {}
-  StringView(const char *Str) : First(Str), Last(Str + std::strlen(Str)) {}
-  StringView() : First(nullptr), Last(nullptr) {}
-
-  StringView substr(size_t Pos, size_t Len = npos) const {
-assert(Pos <= size());
-if (Len > size() - Pos)
-  Len = size() - Pos;
-return StringView(begin() + Pos, Len);
-  }
-
-  size_t find(char C, size_t From = 0) const {
-// Avoid calling memchr with nullptr.
-if (From < size()) {
-  // Just forward to memchr, which is faster than a hand-rolled loop.
-  if (const void *P = ::memchr(First + From, C, size() - From))
-return size_t(static_cast(P) - First);
-}
-return npos;
-  }
-
-  void remove_prefix(size_t N) {
-assert(size() >= N);
-First += N;
-  }
-  void remove_suffix(size_t N) {
-assert(size() >= N);
-Last -= N;
-  }
-
-  char front() const {
-assert(!empty());
-return *begin();
-  }
-
-  char back() const {
-assert(!empty());
-return *(end() - 1);
-  }
-
-  bool startsWith(char C) const { return !empty() && *begin() == C; }
-
-  bool startsWith(StringView Str) const {
-if (Str.size() > size())
-  return false;
-return std::strncmp(Str.begin(), begin(), Str.size()) == 0;
-  }
-
-  const char [](size_t Idx) const { return 

[PATCH] D144634: [Clang][OpenMP] Support for Code Generation of loop bind clause

2023-05-31 Thread Sunil K via Phabricator via cfe-commits
koops updated this revision to Diff 527127.
koops added a comment.

1. Addition of extra test case loop_bind_enclosed.cpp.
2. Changing of name from Map1D to MappedDirective
3. Printing "omp loop bind" instead of the mapped Directives (e.g. "omp simd") 
when -ast-print option is used.


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

https://reviews.llvm.org/D144634

Files:
  clang/include/clang/AST/StmtOpenMP.h
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/StmtPrinter.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/OpenMP/loop_bind_codegen.cpp
  clang/test/OpenMP/loop_bind_enclosed.cpp
  clang/test/OpenMP/loop_bind_messages.cpp
  clang/test/OpenMP/nested_loop_codegen.cpp

Index: clang/test/OpenMP/nested_loop_codegen.cpp
===
--- clang/test/OpenMP/nested_loop_codegen.cpp
+++ clang/test/OpenMP/nested_loop_codegen.cpp
@@ -58,6 +58,11 @@
 // CHECK1-NEXT:[[DOTGLOBAL_TID__ADDR:%.*]] = alloca ptr, align 8
 // CHECK1-NEXT:[[DOTBOUND_TID__ADDR:%.*]] = alloca ptr, align 8
 // CHECK1-NEXT:[[I_ADDR:%.*]] = alloca ptr, align 8
+// CHECK1-NEXT:[[DOTOMP_IV:%.*]] = alloca i32, align 4
+// CHECK1-NEXT:[[DOTOMP_LB:%.*]] = alloca i32, align 4
+// CHECK1-NEXT:[[DOTOMP_UB:%.*]] = alloca i32, align 4
+// CHECK1-NEXT:[[DOTOMP_STRIDE:%.*]] = alloca i32, align 4
+// CHECK1-NEXT:[[DOTOMP_IS_LAST:%.*]] = alloca i32, align 4
 // CHECK1-NEXT:[[K:%.*]] = alloca i32, align 4
 // CHECK1-NEXT:store ptr [[DOTGLOBAL_TID_]], ptr [[DOTGLOBAL_TID__ADDR]], align 8
 // CHECK1-NEXT:store ptr [[DOTBOUND_TID_]], ptr [[DOTBOUND_TID__ADDR]], align 8
@@ -71,6 +76,9 @@
 // CHECK1-NEXT:br i1 [[CMP]], label [[FOR_BODY:%.*]], label [[FOR_END7:%.*]]
 // CHECK1:   for.body:
 // CHECK1-NEXT:store i32 0, ptr [[K]], align 4
+// CHECK:  [[TMP2:%.*]] = load ptr, ptr [[DOTGLOBSL_TID__ADDR]], align 8
+// CHECK1-NEXT:[[TMP3:%.*]] = load i32, ptr [[TMP2]], align 4
+// CHECK1-NEXT:call void @__kmpc_for_static_init_4(ptr @1, i32 [[TMP3]], i32 34, ptr %.omp.is_last, ptr %.omp.lb, ptr %.omp.ub, ptr %.omp.stride, i32 1, i32 1)
 // CHECK1-NEXT:br label [[FOR_COND1:%.*]]
 // CHECK1:   for.cond1:
 // CHECK1-NEXT:[[TMP2:%.*]] = load i32, ptr [[K]], align 4
Index: clang/test/OpenMP/loop_bind_messages.cpp
===
--- /dev/null
+++ clang/test/OpenMP/loop_bind_messages.cpp
@@ -0,0 +1,76 @@
+#ifndef HEADER
+#define HEADER
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=50 -verify %s
+
+#define NNN 50
+int aaa[NNN];
+
+void parallel_loop() {
+  #pragma omp parallel
+  {
+ #pragma omp loop
+ for (int j = 0 ; j < NNN ; j++) {
+   aaa[j] = j*NNN;
+ }
+   }
+}
+
+void teams_loop() {
+  int var1, var2;
+
+  #pragma omp teams
+  {
+ #pragma omp loop bind(teams)
+ for (int j = 0 ; j < NNN ; j++) {
+   aaa[j] = j*NNN;
+ }
+
+ #pragma omp loop bind(teams) collapse(2) private(var1)
+ for (int i = 0 ; i < 3 ; i++) {
+   for (int j = 0 ; j < NNN ; j++) {
+ var1 += aaa[j];
+   }
+ }
+   }
+}
+
+void orphan_loop_with_bind() {
+  #pragma omp loop bind(parallel) 
+  for (int j = 0 ; j < NNN ; j++) {
+aaa[j] = j*NNN;
+  }
+}
+
+void orphan_loop_no_bind() {
+  #pragma omp loop  // expected-error{{expected 'bind' clause for loop construct without an enclosing OpenMP construct}}
+  for (int j = 0 ; j < NNN ; j++) {
+aaa[j] = j*NNN;
+  }
+}
+
+void teams_loop_reduction() {
+  int total = 0;
+
+  #pragma omp teams
+  {
+ #pragma omp loop bind(teams)
+ for (int j = 0 ; j < NNN ; j++) {
+   aaa[j] = j*NNN;
+ }
+
+ #pragma omp loop bind(teams) reduction(+:total) // expected-error{{reduction clause not handled with '#pragma omp loop bind(teams)'}}
+ for (int j = 0 ; j < NNN ; j++) {
+   total+=aaa[j];
+ }
+   }
+}
+
+int main(int argc, char *argv[]) {
+  parallel_loop();
+  teams_loop();
+  orphan_loop_with_bind();
+  orphan_loop_no_bind();
+  teams_loop_reduction();
+}
+
+#endif
Index: clang/test/OpenMP/loop_bind_enclosed.cpp
===
--- /dev/null
+++ clang/test/OpenMP/loop_bind_enclosed.cpp
@@ -0,0 +1,140 @@
+// expected-no-diagnostics
+// RUN: %clang_cc1 -DCK1 -verify -fopenmp -x c++ %s -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple x86_64-unknown-unknown -emit-llvm %s -o - | FileCheck %s
+
+#define NNN 50
+int aaa[NNN];
+
+void parallel_taskgroup_loop() {
+  #pragma omp parallel
+  {
+#pragma omp taskgroup
+for (int i = 0 ; i < 2 ; i++) {
+  #pragma omp loop
+  for (int j = 0 ; j < NNN ; j++) {
+aaa[j] = j*NNN;
+  }
+}
+  }
+}
+// CHECK-LABEL: define {{[^@]+}}@_Z23parallel_taskgroup_loopv
+// CHECK-NEXT: entry:
+// CHECK-NEXT: call void (ptr, i32, ptr, ...) @__kmpc_fork_call(ptr @1, i32 0, ptr 

[clang] 731f9ac - [Fuchsia] Add llvm-debuginfod to toolchain

2023-05-31 Thread Daniel Thornburgh via cfe-commits

Author: Daniel Thornburgh
Date: 2023-05-31T11:01:39-07:00
New Revision: 731f9ac6e53611dabb51c52bfc8011c2aab7790b

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

LOG: [Fuchsia] Add llvm-debuginfod to toolchain

Added: 


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

Removed: 




diff  --git a/clang/cmake/caches/Fuchsia-stage2.cmake 
b/clang/cmake/caches/Fuchsia-stage2.cmake
index 2465cc7b8c2f8..6d868abf21202 100644
--- a/clang/cmake/caches/Fuchsia-stage2.cmake
+++ b/clang/cmake/caches/Fuchsia-stage2.cmake
@@ -296,6 +296,7 @@ set(LLVM_TOOLCHAIN_TOOLS
   llvm-ar
   llvm-cov
   llvm-cxxfilt
+  llvm-debuginfod
   llvm-debuginfod-find
   llvm-dlltool
   ${LLVM_DRIVER_TARGET}



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


[PATCH] D151818: [clang][analyzer][NFC] Use the operator new directly with the `BumpPtrAllocator`

2023-05-31 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun accepted this revision.
xazax.hun added a comment.
This revision is now accepted and ready to land.

Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151818

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


[PATCH] D151820: [clang][WebAssembly] Fix __BIGGEST_ALIGNMENT__ under emscripten

2023-05-31 Thread Sam Clegg via Phabricator via cfe-commits
sbc100 created this revision.
Herald added subscribers: pmatos, wingo, sunfish, jgravelle-google, dschuff.
Herald added a project: All.
sbc100 requested review of this revision.
Herald added subscribers: cfe-commits, aheejin.
Herald added a project: clang.

Follow up to https://reviews.llvm.org/D104808 and
https://reviews.llvm.org/D105749.  The only place that seems to be used
is when defining __BIGGEST_ALIGNMENT__ and when choosing the alignment
for the `alloca` builtin.  It seems that both of these should match the
`alignof(max_align_t)` which, for emscripten, is currently 8 bytes.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D151820

Files:
  clang/lib/Basic/Targets/OSTargets.h
  clang/test/Preprocessor/init.c


Index: clang/test/Preprocessor/init.c
===
--- clang/test/Preprocessor/init.c
+++ clang/test/Preprocessor/init.c
@@ -1500,10 +1500,10 @@
 //
 // RUN: %clang_cc1 -E -dM -ffreestanding -fgnuc-version=4.2.1 
-triple=wasm32-unknown-unknown \
 // RUN:   < /dev/null \
-// RUN:   | FileCheck -match-full-lines 
-check-prefixes=WEBASSEMBLY,WEBASSEMBLY32 %s
+// RUN:   | FileCheck -match-full-lines 
-check-prefixes=WEBASSEMBLY,WEBASSEMBLY32,WEBASSEMBLY-DEFAULT %s
 // RUN: %clang_cc1 -E -dM -ffreestanding -fgnuc-version=4.2.1 
-triple=wasm64-unknown-unknown \
 // RUN:   < /dev/null \
-// RUN:   | FileCheck -match-full-lines 
-check-prefixes=WEBASSEMBLY,WEBASSEMBLY64 %s
+// RUN:   | FileCheck -match-full-lines 
-check-prefixes=WEBASSEMBLY,WEBASSEMBLY64,WEBASSEMBLY-DEFAULT %s
 // RUN: %clang_cc1 -E -dM -ffreestanding -fgnuc-version=4.2.1 
-triple=wasm32-emscripten \
 // RUN:   < /dev/null \
 // RUN:   | FileCheck -match-full-lines 
-check-prefixes=WEBASSEMBLY,WEBASSEMBLY32,EMSCRIPTEN %s
@@ -1515,10 +1515,10 @@
 // RUN:   | FileCheck -match-full-lines 
-check-prefixes=WEBASSEMBLY,WEBASSEMBLY64,EMSCRIPTEN %s
 // RUN: %clang_cc1 -E -dM -ffreestanding -fgnuc-version=4.2.1 
-triple=wasm32-wasi \
 // RUN:   < /dev/null \
-// RUN:   | FileCheck -match-full-lines 
-check-prefixes=WEBASSEMBLY,WEBASSEMBLY32,WEBASSEMBLY-WASI %s
+// RUN:   | FileCheck -match-full-lines 
-check-prefixes=WEBASSEMBLY,WEBASSEMBLY32,WEBASSEMBLY-DEFAULT,WEBASSEMBLY-WASI 
%s
 // RUN: %clang_cc1 -E -dM -ffreestanding -fgnuc-version=4.2.1 
-triple=wasm64-wasi \
 // RUN:   < /dev/null \
-// RUN:   | FileCheck -match-full-lines 
-check-prefixes=WEBASSEMBLY,WEBASSEMBLY64,WEBASSEMBLY-WASI %s
+// RUN:   | FileCheck -match-full-lines 
-check-prefixes=WEBASSEMBLY,WEBASSEMBLY64,WEBASSEMBLY-DEFAULT,WEBASSEMBLY-WASI 
%s
 // RUN: %clang_cc1 -E -dM -ffreestanding -fgnuc-version=4.2.1 
-triple=wasm32-unknown-unknown -x c++ \
 // RUN:   < /dev/null \
 // RUN:   | FileCheck -match-full-lines -check-prefixes=WEBASSEMBLY-CXX %s
@@ -1537,7 +1537,8 @@
 // WEBASSEMBLY-NEXT:#define __ATOMIC_RELAXED 0
 // WEBASSEMBLY-NEXT:#define __ATOMIC_RELEASE 3
 // WEBASSEMBLY-NEXT:#define __ATOMIC_SEQ_CST 5
-// WEBASSEMBLY-NEXT:#define __BIGGEST_ALIGNMENT__ 16
+// EMSCRIPTEN-NEXT:#define __BIGGEST_ALIGNMENT__ 8
+// WEBASSEMBLY-DEFAULT-NEXT:#define __BIGGEST_ALIGNMENT__ 16
 // WEBASSEMBLY-NEXT:#define __BITINT_MAXWIDTH__ 128
 // WEBASSEMBLY-NEXT:#define __BOOL_WIDTH__ 8
 // WEBASSEMBLY-NEXT:#define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__
Index: clang/lib/Basic/Targets/OSTargets.h
===
--- clang/lib/Basic/Targets/OSTargets.h
+++ clang/lib/Basic/Targets/OSTargets.h
@@ -984,6 +984,7 @@
 // Emscripten's ABI is unstable and we may change this back to 128 to match
 // the WebAssembly default in the future.
 this->LongDoubleAlign = 64;
+this->SuitableAlign = 64;
   }
 };
 


Index: clang/test/Preprocessor/init.c
===
--- clang/test/Preprocessor/init.c
+++ clang/test/Preprocessor/init.c
@@ -1500,10 +1500,10 @@
 //
 // RUN: %clang_cc1 -E -dM -ffreestanding -fgnuc-version=4.2.1 -triple=wasm32-unknown-unknown \
 // RUN:   < /dev/null \
-// RUN:   | FileCheck -match-full-lines -check-prefixes=WEBASSEMBLY,WEBASSEMBLY32 %s
+// RUN:   | FileCheck -match-full-lines -check-prefixes=WEBASSEMBLY,WEBASSEMBLY32,WEBASSEMBLY-DEFAULT %s
 // RUN: %clang_cc1 -E -dM -ffreestanding -fgnuc-version=4.2.1 -triple=wasm64-unknown-unknown \
 // RUN:   < /dev/null \
-// RUN:   | FileCheck -match-full-lines -check-prefixes=WEBASSEMBLY,WEBASSEMBLY64 %s
+// RUN:   | FileCheck -match-full-lines -check-prefixes=WEBASSEMBLY,WEBASSEMBLY64,WEBASSEMBLY-DEFAULT %s
 // RUN: %clang_cc1 -E -dM -ffreestanding -fgnuc-version=4.2.1 -triple=wasm32-emscripten \
 // RUN:   < /dev/null \
 // RUN:   | FileCheck -match-full-lines -check-prefixes=WEBASSEMBLY,WEBASSEMBLY32,EMSCRIPTEN %s
@@ -1515,10 +1515,10 @@
 // RUN:   | FileCheck -match-full-lines -check-prefixes=WEBASSEMBLY,WEBASSEMBLY64,EMSCRIPTEN %s
 // RUN: %clang_cc1 -E -dM -ffreestanding -fgnuc-version=4.2.1 -triple=wasm32-wasi \
 // RUN:   < /dev/null \
-// 

[PATCH] D151277: [clang][modules] Mark fewer identifiers as out-of-date

2023-05-31 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 added inline comments.



Comment at: clang/lib/Serialization/ASTReader.cpp:4413
+// first/next use via ASTReader::updateOutOfDateIdentifier().
+II = ().get(Key);
+  }

benlangmuir wrote:
> Why did this change from `getOwn` to `get`?
That's a fluke on my part, this should've remained `getOwn()`. These don't 
differ very much for C++ modules, but `getOwn()` is the intended functionality 
here for sure. I'll fix that in next revision.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151277

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


[PATCH] D150985: [clang] Allow fp in atomic fetch max/min builtins

2023-05-31 Thread Artem Belevich via Phabricator via cfe-commits
tra accepted this revision.
tra added a comment.
This revision is now accepted and ready to land.

LGTM with few more test nits.




Comment at: clang/test/Sema/atomic-ops.c:134
int *I, const int *CI,
int **P, float *D, struct S *s1, struct S *s2) {
   __c11_atomic_init(I, 5); // expected-error {{pointer to _Atomic}}

I wonder why we have this inconsistency in the non-atomic arguments.
We don't actually have any double variants and the argument `D` is actually a 
`float *`, even though the naming convention used suggests that it should've 
been either a `double *` or should be called `F`.




Comment at: clang/test/Sema/atomic-ops.c:218
   __atomic_fetch_sub(s1, 3, memory_order_seq_cst); // expected-error {{must be 
a pointer to integer, pointer or supported floating point type}}
-  __atomic_fetch_min(D, 3, memory_order_seq_cst); // expected-error {{must be 
a pointer to integer}}
-  __atomic_fetch_max(P, 3, memory_order_seq_cst); // expected-error {{must be 
a pointer to integer}}
+  __atomic_fetch_min(D, 3, memory_order_seq_cst);
+  __atomic_fetch_max(P, 3, memory_order_seq_cst); // expected-error {{must be 
a pointer to integer or supported floating point type}}

We seem to be missing the tests for `double *` here, too.


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

https://reviews.llvm.org/D150985

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


[PATCH] D151720: [clang][ExprConstant] Fix display of syntactically-invalid note for member function calls

2023-05-31 Thread Takuya Shimizu via Phabricator via cfe-commits
hazohelet updated this revision to Diff 527104.
hazohelet added a comment.

I think the proper message here can be obtained by letting the stack frame keep 
the syntactical structure of the function call, although it introduces 
additional memory footprint.

- Add `const Expr *` new field to `CallStackFrame` in order to save the 
syntactical structure of the member function call
- Generate proper message using that new field
- Fallback to the conventional value-based printing when handling destructors 
because it is not explicitly written by the user


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

https://reviews.llvm.org/D151720

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/AST/ExprConstant.cpp
  clang/test/AST/Interp/constexpr-nqueens.cpp
  clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p9.cpp
  clang/test/CXX/temp/temp.param/p8-cxx20.cpp
  clang/test/SemaCXX/constant-expression-cxx11.cpp
  clang/test/SemaCXX/constexpr-frame-describe.cpp
  clang/test/SemaCXX/cxx2a-consteval.cpp
  clang/test/SemaCXX/deduced-return-type-cxx14.cpp

Index: clang/test/SemaCXX/deduced-return-type-cxx14.cpp
===
--- clang/test/SemaCXX/deduced-return-type-cxx14.cpp
+++ clang/test/SemaCXX/deduced-return-type-cxx14.cpp
@@ -296,7 +296,7 @@
   void f() {
 X().f();
 Y().f();
-constexpr int q = Y().f(); // expected-error {{must be initialized by a constant expression}} expected-note {{in call to '()->f()'}}
+constexpr int q = Y().f(); // expected-error {{must be initialized by a constant expression}} expected-note {{in call to 'Y().f()'}}
   }
   struct NonLiteral { ~NonLiteral(); } nl; // cxx14-note {{user-provided destructor}}
   // cxx20_23-note@-1 {{'NonLiteral' is not literal because its destructor is not constexpr}}
Index: clang/test/SemaCXX/cxx2a-consteval.cpp
===
--- clang/test/SemaCXX/cxx2a-consteval.cpp
+++ clang/test/SemaCXX/cxx2a-consteval.cpp
@@ -840,13 +840,13 @@
   copy fail1{good0}; // expected-error {{call to consteval function 'defaulted_special_member_template::copy::copy' is not a constant expression}} \
  expected-note {{in call to 'copy(good0)'}}
   fail1 = good0;  // expected-error {{call to consteval function 'defaulted_special_member_template::copy::operator=' is not a constant expression}} \
- expected-note {{in call to '>operator=(good0)'}}
+ expected-note {{in call to 'fail1.operator=(good0)'}}
 
   move good1;
   move fail2{static_cast&&>(good1)}; // expected-error {{call to consteval function 'defaulted_special_member_template::move::move' is not a constant expression}} \
expected-note {{in call to 'move(good1)'}}
   fail2 = static_cast&&>(good1);  // expected-error {{call to consteval function 'defaulted_special_member_template::move::operator=' is not a constant expression}} \
-   expected-note {{in call to '>operator=(good1)'}}
+   expected-note {{in call to 'fail2.operator=(good1)'}}
 }
 } // namespace defaulted_special_member_template
 
Index: clang/test/SemaCXX/constexpr-frame-describe.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/constexpr-frame-describe.cpp
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify %s
+
+
+struct Foo {
+constexpr void zomg() const { (void)(1 / 0); } // expected-error {{constant expression}} expected-warning {{division by zero}} expected-note 2{{division by zero}}
+};
+
+struct S {
+constexpr S() {}
+constexpr bool operator==(const S&) const { // expected-error {{never produces a constant expression}}
+  return 1 / 0; // expected-warning {{division by zero}} expected-note 3{{division by zero}}
+}
+
+constexpr bool heh() const {
+auto F = new Foo();
+F->zomg(); // expected-note {{in call to 'F->zomg()'}}
+delete F;
+return false;
+}
+};
+
+constexpr S s;
+
+static_assert(s.heh()); // expected-error {{constant expression}} // expected-note {{in call to 's.heh()'}}
+
+constexpr S s2;
+constexpr const S *sptr = 
+constexpr const S *sptr2 = 
+static_assert(s == s2); // expected-error {{constant expression}} expected-note {{in call to 's.operator==(s2)'}}
+static_assert(*sptr == *sptr2); // expected-error {{constant expression}} expected-note {{in call to '*sptr.operator==(s2)'}}
Index: clang/test/SemaCXX/constant-expression-cxx11.cpp
===
--- clang/test/SemaCXX/constant-expression-cxx11.cpp
+++ clang/test/SemaCXX/constant-expression-cxx11.cpp
@@ -975,7 +975,7 @@
   int n;
 };
 constexpr int S::f() const {
-  return static_cast(this)->n; // expected-note 

[PATCH] D151818: [clang][analyzer][NFC] Use the operator new directly with the `BumpPtrAllocator`

2023-05-31 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr updated this revision to Diff 527115.
gribozavr added a comment.

Format the edits


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151818

Files:
  clang/lib/Analysis/CFG.cpp
  clang/lib/StaticAnalyzer/Core/BasicValueFactory.cpp
  clang/lib/StaticAnalyzer/Core/ExplodedGraph.cpp
  clang/lib/StaticAnalyzer/Core/MemRegion.cpp
  clang/lib/StaticAnalyzer/Core/SymbolManager.cpp

Index: clang/lib/StaticAnalyzer/Core/SymbolManager.cpp
===
--- clang/lib/StaticAnalyzer/Core/SymbolManager.cpp
+++ clang/lib/StaticAnalyzer/Core/SymbolManager.cpp
@@ -170,8 +170,7 @@
   void *InsertPos;
   SymExpr *SD = DataSet.FindNodeOrInsertPos(profile, InsertPos);
   if (!SD) {
-SD = BPAlloc.Allocate();
-new (SD) SymbolRegionValue(SymbolCounter, R);
+SD = new (BPAlloc) SymbolRegionValue(SymbolCounter, R);
 DataSet.InsertNode(SD, InsertPos);
 ++SymbolCounter;
   }
@@ -189,8 +188,7 @@
   void *InsertPos;
   SymExpr *SD = DataSet.FindNodeOrInsertPos(profile, InsertPos);
   if (!SD) {
-SD = BPAlloc.Allocate();
-new (SD) SymbolConjured(SymbolCounter, E, LCtx, T, Count, SymbolTag);
+SD = new (BPAlloc) SymbolConjured(SymbolCounter, E, LCtx, T, Count, SymbolTag);
 DataSet.InsertNode(SD, InsertPos);
 ++SymbolCounter;
   }
@@ -206,8 +204,7 @@
   void *InsertPos;
   SymExpr *SD = DataSet.FindNodeOrInsertPos(profile, InsertPos);
   if (!SD) {
-SD = BPAlloc.Allocate();
-new (SD) SymbolDerived(SymbolCounter, parentSymbol, R);
+SD = new (BPAlloc) SymbolDerived(SymbolCounter, parentSymbol, R);
 DataSet.InsertNode(SD, InsertPos);
 ++SymbolCounter;
   }
@@ -222,8 +219,7 @@
   void *InsertPos;
   SymExpr *SD = DataSet.FindNodeOrInsertPos(profile, InsertPos);
   if (!SD) {
-SD = BPAlloc.Allocate();
-new (SD) SymbolExtent(SymbolCounter, R);
+SD = new (BPAlloc) SymbolExtent(SymbolCounter, R);
 DataSet.InsertNode(SD, InsertPos);
 ++SymbolCounter;
   }
@@ -240,8 +236,7 @@
   void *InsertPos;
   SymExpr *SD = DataSet.FindNodeOrInsertPos(profile, InsertPos);
   if (!SD) {
-SD = BPAlloc.Allocate();
-new (SD) SymbolMetadata(SymbolCounter, R, S, T, LCtx, Count, SymbolTag);
+SD = new (BPAlloc) SymbolMetadata(SymbolCounter, R, S, T, LCtx, Count, SymbolTag);
 DataSet.InsertNode(SD, InsertPos);
 ++SymbolCounter;
   }
@@ -257,8 +252,7 @@
   void *InsertPos;
   SymExpr *data = DataSet.FindNodeOrInsertPos(ID, InsertPos);
   if (!data) {
-data = BPAlloc.Allocate();
-new (data) SymbolCast(Op, From, To);
+data = new (BPAlloc) SymbolCast(Op, From, To);
 DataSet.InsertNode(data, InsertPos);
   }
 
@@ -275,8 +269,7 @@
   SymExpr *data = DataSet.FindNodeOrInsertPos(ID, InsertPos);
 
   if (!data) {
-data = BPAlloc.Allocate();
-new (data) SymIntExpr(lhs, op, v, t);
+data = new (BPAlloc) SymIntExpr(lhs, op, v, t);
 DataSet.InsertNode(data, InsertPos);
   }
 
@@ -293,8 +286,7 @@
   SymExpr *data = DataSet.FindNodeOrInsertPos(ID, InsertPos);
 
   if (!data) {
-data = BPAlloc.Allocate();
-new (data) IntSymExpr(lhs, op, rhs, t);
+data = new (BPAlloc) IntSymExpr(lhs, op, rhs, t);
 DataSet.InsertNode(data, InsertPos);
   }
 
@@ -311,8 +303,7 @@
   SymExpr *data = DataSet.FindNodeOrInsertPos(ID, InsertPos);
 
   if (!data) {
-data = BPAlloc.Allocate();
-new (data) SymSymExpr(lhs, op, rhs, t);
+data = new (BPAlloc) SymSymExpr(lhs, op, rhs, t);
 DataSet.InsertNode(data, InsertPos);
   }
 
@@ -327,8 +318,7 @@
   void *InsertPos;
   SymExpr *data = DataSet.FindNodeOrInsertPos(ID, InsertPos);
   if (!data) {
-data = BPAlloc.Allocate();
-new (data) UnarySymExpr(Operand, Opc, T);
+data = new (BPAlloc) UnarySymExpr(Operand, Opc, T);
 DataSet.InsertNode(data, InsertPos);
   }
 
Index: clang/lib/StaticAnalyzer/Core/MemRegion.cpp
===
--- clang/lib/StaticAnalyzer/Core/MemRegion.cpp
+++ clang/lib/StaticAnalyzer/Core/MemRegion.cpp
@@ -73,8 +73,7 @@
   auto *R = cast_or_null(Regions.FindNodeOrInsertPos(ID, InsertPos));
 
   if (!R) {
-R = A.Allocate();
-new (R) RegionTy(arg1, superRegion);
+R = new (A) RegionTy(arg1, superRegion);
 Regions.InsertNode(R, InsertPos);
   }
 
@@ -90,8 +89,7 @@
   auto *R = cast_or_null(Regions.FindNodeOrInsertPos(ID, InsertPos));
 
   if (!R) {
-R = A.Allocate();
-new (R) RegionTy(arg1, arg2, superRegion);
+R = new (A) RegionTy(arg1, arg2, superRegion);
 Regions.InsertNode(R, InsertPos);
   }
 
@@ -109,8 +107,7 @@
   auto *R = cast_or_null(Regions.FindNodeOrInsertPos(ID, InsertPos));
 
   if (!R) {
-R = A.Allocate();
-new (R) RegionTy(arg1, arg2, arg3, superRegion);
+R = new (A) RegionTy(arg1, arg2, arg3, superRegion);
 Regions.InsertNode(R, InsertPos);
   }
 
@@ -834,8 +831,7 @@
 template 
 const REG 

[PATCH] D151818: [clang][analyzer][NFC] Use the operator new directly with the `BumpPtrAllocator`

2023-05-31 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr created this revision.
gribozavr added reviewers: NoQ, steakhal.
Herald added subscribers: manas, ASDenysPetrov, martong, dkrupp, donat.nagy, 
Szelethus, mikhail.ramalho, a.sidorin, szepet, baloghadamsoftware, xazax.hun.
Herald added a project: All.
gribozavr requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D151818

Files:
  clang/lib/Analysis/CFG.cpp
  clang/lib/StaticAnalyzer/Core/BasicValueFactory.cpp
  clang/lib/StaticAnalyzer/Core/ExplodedGraph.cpp
  clang/lib/StaticAnalyzer/Core/MemRegion.cpp
  clang/lib/StaticAnalyzer/Core/SymbolManager.cpp

Index: clang/lib/StaticAnalyzer/Core/SymbolManager.cpp
===
--- clang/lib/StaticAnalyzer/Core/SymbolManager.cpp
+++ clang/lib/StaticAnalyzer/Core/SymbolManager.cpp
@@ -170,8 +170,7 @@
   void *InsertPos;
   SymExpr *SD = DataSet.FindNodeOrInsertPos(profile, InsertPos);
   if (!SD) {
-SD = BPAlloc.Allocate();
-new (SD) SymbolRegionValue(SymbolCounter, R);
+SD = new (BPAlloc) SymbolRegionValue(SymbolCounter, R);
 DataSet.InsertNode(SD, InsertPos);
 ++SymbolCounter;
   }
@@ -189,8 +188,7 @@
   void *InsertPos;
   SymExpr *SD = DataSet.FindNodeOrInsertPos(profile, InsertPos);
   if (!SD) {
-SD = BPAlloc.Allocate();
-new (SD) SymbolConjured(SymbolCounter, E, LCtx, T, Count, SymbolTag);
+SD = new (BPAlloc) SymbolConjured(SymbolCounter, E, LCtx, T, Count, SymbolTag);
 DataSet.InsertNode(SD, InsertPos);
 ++SymbolCounter;
   }
@@ -206,8 +204,7 @@
   void *InsertPos;
   SymExpr *SD = DataSet.FindNodeOrInsertPos(profile, InsertPos);
   if (!SD) {
-SD = BPAlloc.Allocate();
-new (SD) SymbolDerived(SymbolCounter, parentSymbol, R);
+SD = new (BPAlloc) SymbolDerived(SymbolCounter, parentSymbol, R);
 DataSet.InsertNode(SD, InsertPos);
 ++SymbolCounter;
   }
@@ -222,8 +219,7 @@
   void *InsertPos;
   SymExpr *SD = DataSet.FindNodeOrInsertPos(profile, InsertPos);
   if (!SD) {
-SD = BPAlloc.Allocate();
-new (SD) SymbolExtent(SymbolCounter, R);
+SD = new (BPAlloc) SymbolExtent(SymbolCounter, R);
 DataSet.InsertNode(SD, InsertPos);
 ++SymbolCounter;
   }
@@ -240,8 +236,7 @@
   void *InsertPos;
   SymExpr *SD = DataSet.FindNodeOrInsertPos(profile, InsertPos);
   if (!SD) {
-SD = BPAlloc.Allocate();
-new (SD) SymbolMetadata(SymbolCounter, R, S, T, LCtx, Count, SymbolTag);
+SD = new (BPAlloc) SymbolMetadata(SymbolCounter, R, S, T, LCtx, Count, SymbolTag);
 DataSet.InsertNode(SD, InsertPos);
 ++SymbolCounter;
   }
@@ -257,8 +252,7 @@
   void *InsertPos;
   SymExpr *data = DataSet.FindNodeOrInsertPos(ID, InsertPos);
   if (!data) {
-data = BPAlloc.Allocate();
-new (data) SymbolCast(Op, From, To);
+data = new (BPAlloc) SymbolCast(Op, From, To);
 DataSet.InsertNode(data, InsertPos);
   }
 
@@ -275,8 +269,7 @@
   SymExpr *data = DataSet.FindNodeOrInsertPos(ID, InsertPos);
 
   if (!data) {
-data = BPAlloc.Allocate();
-new (data) SymIntExpr(lhs, op, v, t);
+data = new (BPAlloc) SymIntExpr(lhs, op, v, t);
 DataSet.InsertNode(data, InsertPos);
   }
 
@@ -293,8 +286,7 @@
   SymExpr *data = DataSet.FindNodeOrInsertPos(ID, InsertPos);
 
   if (!data) {
-data = BPAlloc.Allocate();
-new (data) IntSymExpr(lhs, op, rhs, t);
+data = new (BPAlloc) IntSymExpr(lhs, op, rhs, t);
 DataSet.InsertNode(data, InsertPos);
   }
 
@@ -311,8 +303,7 @@
   SymExpr *data = DataSet.FindNodeOrInsertPos(ID, InsertPos);
 
   if (!data) {
-data = BPAlloc.Allocate();
-new (data) SymSymExpr(lhs, op, rhs, t);
+data = new (BPAlloc) SymSymExpr(lhs, op, rhs, t);
 DataSet.InsertNode(data, InsertPos);
   }
 
@@ -327,8 +318,7 @@
   void *InsertPos;
   SymExpr *data = DataSet.FindNodeOrInsertPos(ID, InsertPos);
   if (!data) {
-data = BPAlloc.Allocate();
-new (data) UnarySymExpr(Operand, Opc, T);
+data = new (BPAlloc) UnarySymExpr(Operand, Opc, T);
 DataSet.InsertNode(data, InsertPos);
   }
 
Index: clang/lib/StaticAnalyzer/Core/MemRegion.cpp
===
--- clang/lib/StaticAnalyzer/Core/MemRegion.cpp
+++ clang/lib/StaticAnalyzer/Core/MemRegion.cpp
@@ -73,8 +73,7 @@
   auto *R = cast_or_null(Regions.FindNodeOrInsertPos(ID, InsertPos));
 
   if (!R) {
-R = A.Allocate();
-new (R) RegionTy(arg1, superRegion);
+R = new (A) RegionTy(arg1, superRegion);
 Regions.InsertNode(R, InsertPos);
   }
 
@@ -90,8 +89,7 @@
   auto *R = cast_or_null(Regions.FindNodeOrInsertPos(ID, InsertPos));
 
   if (!R) {
-R = A.Allocate();
-new (R) RegionTy(arg1, arg2, superRegion);
+R = new (A) RegionTy(arg1, arg2, superRegion);
 Regions.InsertNode(R, InsertPos);
   }
 
@@ -109,8 +107,7 @@
   auto *R = cast_or_null(Regions.FindNodeOrInsertPos(ID, InsertPos));
 
   if (!R) {
-R = A.Allocate();
-new 

[PATCH] D150985: [clang] Allow fp in atomic fetch max/min builtins

2023-05-31 Thread Artem Belevich via Phabricator via cfe-commits
tra added inline comments.



Comment at: clang/lib/Sema/SemaChecking.cpp:6576-6578
   if (!ValType->isFloatingType())
 return false;
+  if (!(AllowedType & AOAVT_FP))

Collapse into a single if statement: `if (!(ValType->isFloatingType() && 
(AllowedType & AOAVT_FP)))`



Comment at: clang/lib/Sema/SemaChecking.cpp:6588
+if (!IsAllowedValueType(ValType, ArithAllows)) {
+  assert(ArithAllows & AOAVT_Integer);
+  auto DID = ArithAllows & AOAVT_FP

Why do we expect a failed `IsAllowedValueType` check to fail only if we were 
allowed integers? Is that because we assume that all atomic instructions 
support integers?

If that's the case, I'd hoist the assertion and apply it right after we're done 
setting `ArithAllows`. Alternatively, we could discard `AOAVT_Integer` and call 
the enum `ArithOpExtraValueType`. Tracking a bit that's always set does not buy 
us much, though it does make the code a bit more uniform. Up to you.





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

https://reviews.llvm.org/D150985

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


[PATCH] D151770: [NFC][CLANG] Fix nullptr dereference issue in SetValueDataBasedOnQualType()

2023-05-31 Thread Soumi Manna via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG5bb069246573: [NFC][CLANG] Fix nullptr dereference issue in 
SetValueDataBasedOnQualType() (authored by Manna).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151770

Files:
  clang/lib/Interpreter/Interpreter.cpp


Index: clang/lib/Interpreter/Interpreter.cpp
===
--- clang/lib/Interpreter/Interpreter.cpp
+++ clang/lib/Interpreter/Interpreter.cpp
@@ -768,7 +768,7 @@
   if (const auto *ET = QT->getAs())
 QT = ET->getDecl()->getIntegerType();
 
-  switch (QT->getAs()->getKind()) {
+  switch (QT->castAs()->getKind()) {
   default:
 llvm_unreachable("unknown type kind!");
 #define X(type, name)  
\


Index: clang/lib/Interpreter/Interpreter.cpp
===
--- clang/lib/Interpreter/Interpreter.cpp
+++ clang/lib/Interpreter/Interpreter.cpp
@@ -768,7 +768,7 @@
   if (const auto *ET = QT->getAs())
 QT = ET->getDecl()->getIntegerType();
 
-  switch (QT->getAs()->getKind()) {
+  switch (QT->castAs()->getKind()) {
   default:
 llvm_unreachable("unknown type kind!");
 #define X(type, name)  \
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D150253: [RISCV] Add Zvfhmin extension for clang.

2023-05-31 Thread Craig Topper via Phabricator via cfe-commits
craig.topper reopened this revision.
craig.topper added a comment.
This revision is now accepted and ready to land.

The backend patch must go before the clang patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150253

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


  1   2   3   >