[PATCH] D148474: [Clang] Fix ResolveConstructorOverload to not select a conversion function if we are going use copy elision

2023-10-03 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik added a comment.

@dim the crash should be fixed by landing: 
https://github.com/llvm/llvm-project/pull/67373 I need to rebase and test


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

https://reviews.llvm.org/D148474

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


[clang] [RISCV] Mark the Zfa extension as non-experimental (PR #68113)

2023-10-03 Thread Craig Topper via cfe-commits

https://github.com/topperc requested changes to this pull request.

Please update the header comment at the top of RISCVInstrInfoZfa.td

https://github.com/llvm/llvm-project/pull/68113
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Handle consteval expression in array bounds expressions (PR #66222)

2023-10-03 Thread via cfe-commits

cor3ntin wrote:

@shafik ping!

https://github.com/llvm/llvm-project/pull/66222
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Correctly handle callees whose type is a Record type when classifying expressions (PR #68078)

2023-10-03 Thread via cfe-commits

https://github.com/cor3ntin edited 
https://github.com/llvm/llvm-project/pull/68078
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Correctly handle callees whose type is a Record type when classifying expressions (PR #68078)

2023-10-03 Thread via cfe-commits

https://github.com/cor3ntin edited 
https://github.com/llvm/llvm-project/pull/68078
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Do not try to classify dependent call expression (PR #68078)

2023-10-03 Thread via cfe-commits

https://github.com/cor3ntin edited 
https://github.com/llvm/llvm-project/pull/68078
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Inliner] Improve propagation of return attributes. (PR #67756)

2023-10-03 Thread Nikita Popov via cfe-commits

nikic wrote:

(Another alternative would be to use different check-prefixes for C/C++)

https://github.com/llvm/llvm-project/pull/67756
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Inliner] Improve propagation of return attributes. (PR #67756)

2023-10-03 Thread Simon Pilgrim via cfe-commits

RKSimon wrote:

> The X86 test split is fine if you want to pre-commit that now

Sorry bswap.c still needs cleaning up

https://github.com/llvm/llvm-project/pull/67756
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Inliner] Improve propagation of return attributes. (PR #67756)

2023-10-03 Thread Simon Pilgrim via cfe-commits


@@ -1,5 +1,4 @@
 // RUN: %clang_cc1 -x c -ffreestanding %s -triple=x86_64-apple-darwin 
-emit-llvm -o - | FileCheck %s
-// RUN: %clang_cc1 -x c++ -std=c++11 -ffreestanding %s 
-triple=x86_64-apple-darwin -emit-llvm -o - | FileCheck %s

RKSimon wrote:

It looks like the constexpr tests are still here?

https://github.com/llvm/llvm-project/pull/67756
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][modules] Remove preloaded SLocEntries from PCM files (PR #66962)

2023-10-03 Thread Tom Honermann via cfe-commits

tahonermann wrote:

> That said, isBeforeInTranslationUnit is slow already, and I don't think it's 
> hot in clang, moreso in tools like clang-tidy whose performance is 
> less-critical. So let's make it right, and then optimize it again if problems 
> arise.

It may not be a hot function in Clang itself, but it is quite hot for some 
downstream Clang forks. While at Coverity, I had to avoid direct use of it 
because it was far too slow. Anything that speeds it up would be appreciated.

https://github.com/llvm/llvm-project/pull/66962
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Inliner] Improve propagation of return attributes. (PR #67756)

2023-10-03 Thread Simon Pilgrim via cfe-commits

RKSimon wrote:

The X86 test split is fine if you want to pre-commit that now

https://github.com/llvm/llvm-project/pull/67756
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][codegen] Add a verifier IR pass before any further passes. (PR #68015)

2023-10-03 Thread Matheus Izvekov via cfe-commits

https://github.com/mizvekov closed 
https://github.com/llvm/llvm-project/pull/68015
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 1ab68d7 - [clang][codegen] Add a verifier IR pass before any further passes. (#68015)

2023-10-03 Thread via cfe-commits

Author: Matheus Izvekov
Date: 2023-10-03T18:05:54+02:00
New Revision: 1ab68d708aea5f8dd7d9d39dd1de8b23228814f0

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

LOG: [clang][codegen] Add a verifier IR pass before any further passes. (#68015)

This helps check clang generated good IR in the first place, as
otherwise this can cause UB in subsequent passes, with the final
verification pass not catching any issues.

This for example would have helped catch
https://github.com/llvm/llvm-project/issues/67937 earlier.

Added: 


Modified: 
clang/lib/CodeGen/BackendUtil.cpp
clang/test/CodeGen/code-coverage.c
clang/test/CodeGen/lto-newpm-pipeline.c

Removed: 




diff  --git a/clang/lib/CodeGen/BackendUtil.cpp 
b/clang/lib/CodeGen/BackendUtil.cpp
index b0fe8e03aa0f5f0..d066819871dfde3 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -923,6 +923,9 @@ void EmitAssemblyHelper::RunOptimizationPipeline(
   PB.crossRegisterProxies(LAM, FAM, CGAM, MAM);
 
   ModulePassManager MPM;
+  // Add a verifier pass, before any other passes, to catch CodeGen issues.
+  if (CodeGenOpts.VerifyModule)
+MPM.addPass(VerifierPass());
 
   if (!CodeGenOpts.DisableLLVMPasses) {
 // Map our optimization levels into one of the distinct levels used to
@@ -1020,21 +1023,23 @@ void EmitAssemblyHelper::RunOptimizationPipeline(
 }
 
 if (CodeGenOpts.FatLTO) {
-  MPM = PB.buildFatLTODefaultPipeline(Level, PrepareForThinLTO,
-  PrepareForThinLTO ||
-  shouldEmitRegularLTOSummary());
+  MPM.addPass(PB.buildFatLTODefaultPipeline(
+  Level, PrepareForThinLTO,
+  PrepareForThinLTO || shouldEmitRegularLTOSummary()));
 } else if (PrepareForThinLTO) {
-  MPM = PB.buildThinLTOPreLinkDefaultPipeline(Level);
+  MPM.addPass(PB.buildThinLTOPreLinkDefaultPipeline(Level));
 } else if (PrepareForLTO) {
-  MPM = PB.buildLTOPreLinkDefaultPipeline(Level);
+  MPM.addPass(PB.buildLTOPreLinkDefaultPipeline(Level));
 } else {
-  MPM = PB.buildPerModuleDefaultPipeline(Level);
+  MPM.addPass(PB.buildPerModuleDefaultPipeline(Level));
 }
   }
 
   // Add a verifier pass if requested. We don't have to do this if the action
   // requires code generation because there will already be a verifier pass in
   // the code-generation pipeline.
+  // Since we already added a verifier pass above, this
+  // might even not run the analysis, if previous passes caused no changes.
   if (!actionRequiresCodeGen(Action) && CodeGenOpts.VerifyModule)
 MPM.addPass(VerifierPass());
 

diff  --git a/clang/test/CodeGen/code-coverage.c 
b/clang/test/CodeGen/code-coverage.c
index af02a6ddaef990a..d7994bab35d81a0 100644
--- a/clang/test/CodeGen/code-coverage.c
+++ b/clang/test/CodeGen/code-coverage.c
@@ -15,10 +15,10 @@
 // RUN: %clang_cc1 -emit-llvm-bc -o /dev/null -fdebug-pass-manager 
-coverage-data-file=/dev/null %s 2>&1 | FileCheck --check-prefix=NEWPM %s
 // RUN: %clang_cc1 -emit-llvm-bc -o /dev/null -fdebug-pass-manager 
-coverage-data-file=/dev/null -O3 %s 2>&1 | FileCheck --check-prefix=NEWPM-O3 %s
 
-// NEWPM-NOT: Running pass
+// NEWPM: Running pass: VerifierPass
 // NEWPM: Running pass: GCOVProfilerPass
 
-// NEWPM-O3-NOT: Running pass
+// NEWPM-O3: Running pass: VerifierPass
 // NEWPM-O3: Running pass: Annotation2MetadataPass
 // NEWPM-O3: Running pass: ForceFunctionAttrsPass
 // NEWPM-O3: Running pass: GCOVProfilerPass

diff  --git a/clang/test/CodeGen/lto-newpm-pipeline.c 
b/clang/test/CodeGen/lto-newpm-pipeline.c
index 1aaa7d46f3ff06f..f58757efbf686f2 100644
--- a/clang/test/CodeGen/lto-newpm-pipeline.c
+++ b/clang/test/CodeGen/lto-newpm-pipeline.c
@@ -25,7 +25,9 @@
 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm-bc -o /dev/null 
-mllvm -verify-analysis-invalidation=0 -fdebug-pass-manager -flto=thin -Oz %s 
2>&1 | FileCheck %s \
 // RUN:   -check-prefix=CHECK-THIN-OPTIMIZED
 
-// CHECK-FULL-O0: Running pass: AlwaysInlinerPass
+// CHECK-FULL-O0: Running pass: VerifierPass
+// CHECK-FULL-O0-NEXT: Running analysis: VerifierAnalysis
+// CHECK-FULL-O0-NEXT: Running pass: AlwaysInlinerPass
 // CHECK-FULL-O0-NEXT: Running analysis: InnerAnalysisManagerProxy
 // CHECK-FULL-O0-NEXT: Running analysis: ProfileSummaryAnalysis
 // CHECK-FULL-O0-NEXT: Running pass: CoroConditionalWrapper
@@ -34,10 +36,11 @@
 // CHECK-FULL-O0-NEXT: Running pass: AnnotationRemarksPass
 // CHECK-FULL-O0-NEXT: Running analysis: TargetLibraryAnalysis
 // CHECK-FULL-O0-NEXT: Running pass: VerifierPass
-// CHECK-FULL-O0-NEXT: Running analysis: VerifierAnalysis
 // CHECK-FULL-O0-NEXT: Running pass: BitcodeWriterPass
 
-// CHECK-THIN-O0: Running pass: AlwaysInlinerP

[clang] [SYCL] Disable RTTI for SYCL device code (PR #68020)

2023-10-03 Thread via cfe-commits

https://github.com/elizabethandrews converted_to_draft 
https://github.com/llvm/llvm-project/pull/68020
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [SYCL] Disable RTTI for SYCL device code (PR #68020)

2023-10-03 Thread via cfe-commits




elizabethandrews wrote:

Without the diagnostic we have downstream, this change causes a seg fault when 
using dynamic_cast in kernel code. It passes without error without this change 
(although technically it shouldn't be allowed). 

I'm marking this PR as draft till I can work on upstreaming the diagnostic we 
have downstream as well. 

https://github.com/llvm/llvm-project/pull/68020
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][codegen] Add a verifier IR pass before any further passes. (PR #68015)

2023-10-03 Thread John McCall via cfe-commits

https://github.com/rjmccall approved this pull request.


https://github.com/llvm/llvm-project/pull/68015
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][codegen] Add a verifier IR pass before any further passes. (PR #68015)

2023-10-03 Thread John McCall via cfe-commits

rjmccall wrote:

Thank you.  If your PR is just changing things so that we run the existing 
verifier on the direct result of IR generation instead of only verifying it 
after a few passes run, I agree that it's the right thing to do.

https://github.com/llvm/llvm-project/pull/68015
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D138846: MC/DC in LLVM Source-Based Code Coverage: LLVM back-end and compiler-rt

2023-10-03 Thread Alan Phipps via Phabricator via cfe-commits
alanphipps added a comment.

Hi @hans @w2yehia  Please let me know if you have any additional concerns.  I'd 
like to reland this within the next day or so. Thank you!


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

https://reviews.llvm.org/D138846

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


[PATCH] D155775: [HIP][Clang][Driver][RFC] Add driver support for C++ Parallel Algorithm Offload

2023-10-03 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

In D155775#4652686 , @AlexVlx wrote:

> In D155775#4652683 , @thakis wrote:
>
>> This seems to break tests on Mac and windows, see eg 
>> http://45.33.8.238/macm1/70415/step_7.txt
>>
>> Please take a look and revert for now if it takes a while to fix.
>
> Whoops, thank you for flagging this, my bad. At the moment (and for the 
> foreseeable future) this is Linux only, so I think I'd rather XFAIL it on non 
> Linux targets, if that's OK.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155775

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


[clang] Bugfix for chosing the correct deduction guide (PR #66487)

2023-10-03 Thread Erich Keane via cfe-commits


@@ -390,6 +390,10 @@ Bug Fixes to C++ Support
   we now produce a diagnostic. Fixes:
   (`#65522 `_)
 
+- Fixed a bug where clang couldn't choose the correct deduction guide from
+  two implicitly generated deduction guides. One of them generated from a
+  non-templated constructor and the other from a templated constructor.
+

erichkeane wrote:

Perhaps reword to:

"Fixed a bug where clang incorrectly considered implicitly generated deduction 
guides from a non-templated constructor and a templated constructor as 
ambiguous, rather than prefer the non-templated constructor as specified in 
[standard.group]p3."

https://github.com/llvm/llvm-project/pull/66487
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] Bugfix for chosing the correct deduction guide (PR #66487)

2023-10-03 Thread Botond István Hprváth via cfe-commits

https://github.com/HoBoIs edited https://github.com/llvm/llvm-project/pull/66487
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [RISCV] Eliminate dead li after emitting VSETVLIs (PR #65934)

2023-10-03 Thread Yingwei Zheng via cfe-commits

dtcxzyw wrote:

Ping.

https://github.com/llvm/llvm-project/pull/65934
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D155775: [HIP][Clang][Driver][RFC] Add driver support for C++ Parallel Algorithm Offload

2023-10-03 Thread Alex Voicu via Phabricator via cfe-commits
AlexVlx added a comment.

In D155775#4652683 , @thakis wrote:

> This seems to break tests on Mac and windows, see eg 
> http://45.33.8.238/macm1/70415/step_7.txt
>
> Please take a look and revert for now if it takes a while to fix.

Whoops, thank you for flagging this, my bad. At the moment (and for the 
foreseeable future) this is Linux only, so I think I'd rather XFAIL it on non 
Linux targets, if that's OK.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155775

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


[clang] Bugfix for chosing the correct deduction guide (PR #66487)

2023-10-03 Thread Botond István Hprváth via cfe-commits

https://github.com/HoBoIs updated 
https://github.com/llvm/llvm-project/pull/66487

From 258462cc65403af147bb47cbeb95210df8e18cd3 Mon Sep 17 00:00:00 2001
From: hobois 
Date: Fri, 15 Sep 2023 09:28:21 +0200
Subject: [PATCH 1/2] Choose the correct deduction guide

If there are two guides, one of them generated from a non-templated constructor
and the other from a templated constructor, then the standard gives priority to
the first. Clang detected ambiguity before, now the correct guide is chosen.

As an unrelated minor change, fix the issue #64020, which could've led to
incorrect behavior if further development inserted code after a call to
isAddressSpaceSubsetOf() which specified the two parameters in the wrong order.
---
 clang/lib/Sema/SemaOverload.cpp | 17 -
 clang/lib/Sema/SemaTemplateInstantiateDecl.cpp  |  2 +-
 .../over.match.class.deduct/p2.cpp  | 10 ++
 3 files changed, 27 insertions(+), 2 deletions(-)

diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp
index 45a9e5dc98c032d..1bb81238520173a 100644
--- a/clang/lib/Sema/SemaOverload.cpp
+++ b/clang/lib/Sema/SemaOverload.cpp
@@ -10153,6 +10153,21 @@ bool clang::isBetterOverloadCandidate(
   //  -- F1 is the copy deduction candidate(16.3.1.8) and F2 is not
   if (Guide1->getDeductionCandidateKind() == DeductionCandidate::Copy)
 return true;
+  if (Guide2->getDeductionCandidateKind() == DeductionCandidate::Copy)
+return false;
+
+  //  --F1 is generated from a non-template constructor and F2 is generated
+  //  from a constructor template
+  const auto *Constructor1 = Guide1->getCorrespondingConstructor();
+  const auto *Constructor2 = Guide2->getCorrespondingConstructor();
+  if (Constructor1 && Constructor2) {
+bool isC1Templated = Constructor1->getTemplatedKind() !=
+ FunctionDecl::TemplatedKind::TK_NonTemplate;
+bool isC2Templated = Constructor2->getTemplatedKind() !=
+ FunctionDecl::TemplatedKind::TK_NonTemplate;
+if (isC1Templated != isC2Templated)
+  return isC2Templated;
+  }
 }
   }
 
@@ -10196,7 +10211,7 @@ bool clang::isBetterOverloadCandidate(
 if (AS1 != AS2) {
   if (Qualifiers::isAddressSpaceSupersetOf(AS2, AS1))
 return true;
-  if (Qualifiers::isAddressSpaceSupersetOf(AS2, AS1))
+  if (Qualifiers::isAddressSpaceSupersetOf(AS1, AS2))
 return false;
 }
   }
diff --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp 
b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
index 9e5f85b0f9166bd..b9c4a9db842b9ee 100644
--- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -2129,7 +2129,7 @@ Decl *TemplateDeclInstantiator::VisitFunctionDecl(
 Function = CXXDeductionGuideDecl::Create(
 SemaRef.Context, DC, D->getInnerLocStart(),
 InstantiatedExplicitSpecifier, NameInfo, T, TInfo,
-D->getSourceRange().getEnd(), /*Ctor=*/nullptr,
+D->getSourceRange().getEnd(), DGuide->getCorrespondingConstructor(),
 DGuide->getDeductionCandidateKind());
 Function->setAccess(D->getAccess());
   } else {
diff --git 
a/clang/test/CXX/over/over.match/over.match.funcs/over.match.class.deduct/p2.cpp
 
b/clang/test/CXX/over/over.match/over.match.funcs/over.match.class.deduct/p2.cpp
index 4eac0a1ac510f1d..d939d724dc7a0fd 100644
--- 
a/clang/test/CXX/over/over.match/over.match.funcs/over.match.class.deduct/p2.cpp
+++ 
b/clang/test/CXX/over/over.match/over.match.funcs/over.match.class.deduct/p2.cpp
@@ -85,3 +85,13 @@ int main() {
 
 
 }
+
+namespace deduceTemplatedConstructor{
+template  struct A {
+  A(T, T, int);
+  template
+A(int, T, U);
+};
+
+A x(1, 2, 3);   // no-error
+}

From 20a85c1ea2c83b73ac2a697d627c09910438041d Mon Sep 17 00:00:00 2001
From: hobois 
Date: Tue, 3 Oct 2023 17:30:23 +0200
Subject: [PATCH 2/2] Added the fix to relasenotes

---
 clang/docs/ReleaseNotes.rst | 4 
 1 file changed, 4 insertions(+)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 6be824771c583be..989b648e1fba561 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -390,6 +390,10 @@ Bug Fixes to C++ Support
   we now produce a diagnostic. Fixes:
   (`#65522 `_)
 
+- Fixed a bug where clang couldn't choose the correct deduction guide from
+  two implicitly generated deduction guides. One of them generated from a
+  non-templated constructor and the other from a templated constructor.
+
 Bug Fixes to AST Handling
 ^
 - Fixed an import failure of recursive friend class template.

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


[clang] [clang][Modules] Make `Module::Requirement` a struct (PR #67900)

2023-10-03 Thread David Stone via cfe-commits

https://github.com/davidstone updated 
https://github.com/llvm/llvm-project/pull/67900

>From b5e64ac8d36fef66cb8ef698f74997616d2957bc Mon Sep 17 00:00:00 2001
From: David Stone 
Date: Sat, 30 Sep 2023 22:57:34 -0600
Subject: [PATCH 1/2] [clang][Modules] Make `Module::Requirement` a struct

`Module::Requirement` was defined as a `std::pair`. This 
required a comment to explain what the data members mean and makes the usage 
harder to understand. Replace this with a struct with two members, 
`FeatureName` and `RequiredState`.
---
 clang/include/clang/Basic/Module.h|  7 ---
 clang/lib/Basic/Module.cpp| 10 +-
 clang/lib/Lex/PPDirectives.cpp|  2 +-
 clang/lib/Serialization/ASTWriter.cpp |  4 ++--
 4 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/clang/include/clang/Basic/Module.h 
b/clang/include/clang/Basic/Module.h
index 676fd372493a3aa..0a134b53d3d9801 100644
--- a/clang/include/clang/Basic/Module.h
+++ b/clang/include/clang/Basic/Module.h
@@ -281,9 +281,10 @@ class alignas(8) Module {
   /// found on the file system.
   SmallVector MissingHeaders;
 
-  /// An individual requirement: a feature name and a flag indicating
-  /// the required state of that feature.
-  using Requirement = std::pair;
+  struct Requirement {
+std::string FeatureName;
+bool RequiredState;
+  };
 
   /// The set of language features required to use this module.
   ///
diff --git a/clang/lib/Basic/Module.cpp b/clang/lib/Basic/Module.cpp
index 0455304ef7f2b1a..fff0067bc9f818f 100644
--- a/clang/lib/Basic/Module.cpp
+++ b/clang/lib/Basic/Module.cpp
@@ -140,8 +140,8 @@ bool Module::isUnimportable(const LangOptions &LangOpts,
   return true;
 }
 for (unsigned I = 0, N = Current->Requirements.size(); I != N; ++I) {
-  if (hasFeature(Current->Requirements[I].first, LangOpts, Target) !=
-  Current->Requirements[I].second) {
+  if (hasFeature(Current->Requirements[I].FeatureName, LangOpts, Target) !=
+  Current->Requirements[I].RequiredState) {
 Req = Current->Requirements[I];
 return true;
   }
@@ -312,7 +312,7 @@ bool Module::directlyUses(const Module *Requested) {
 void Module::addRequirement(StringRef Feature, bool RequiredState,
 const LangOptions &LangOpts,
 const TargetInfo &Target) {
-  Requirements.push_back(Requirement(std::string(Feature), RequiredState));
+  Requirements.push_back(Requirement{std::string(Feature), RequiredState});
 
   // If this feature is currently available, we're done.
   if (hasFeature(Feature, LangOpts, Target) == RequiredState)
@@ -497,9 +497,9 @@ void Module::print(raw_ostream &OS, unsigned Indent, bool 
Dump) const {
 for (unsigned I = 0, N = Requirements.size(); I != N; ++I) {
   if (I)
 OS << ", ";
-  if (!Requirements[I].second)
+  if (!Requirements[I].RequiredState)
 OS << "!";
-  OS << Requirements[I].first;
+  OS << Requirements[I].FeatureName;
 }
 OS << "\n";
   }
diff --git a/clang/lib/Lex/PPDirectives.cpp b/clang/lib/Lex/PPDirectives.cpp
index 7899bfa1c4f5842..579836d47201355 100644
--- a/clang/lib/Lex/PPDirectives.cpp
+++ b/clang/lib/Lex/PPDirectives.cpp
@@ -1915,7 +1915,7 @@ bool Preprocessor::checkModuleIsAvailable(const 
LangOptions &LangOpts,
 // FIXME: Track the location at which the requirement was specified, and
 // use it here.
 Diags.Report(M->DefinitionLoc, diag::err_module_unavailable)
-<< M->getFullModuleName() << Requirement.second << Requirement.first;
+<< M->getFullModuleName() << Requirement.RequiredState << 
Requirement.FeatureName;
   }
   return true;
 }
diff --git a/clang/lib/Serialization/ASTWriter.cpp 
b/clang/lib/Serialization/ASTWriter.cpp
index 201e2fcaaec91aa..f03b47ec3214d1b 100644
--- a/clang/lib/Serialization/ASTWriter.cpp
+++ b/clang/lib/Serialization/ASTWriter.cpp
@@ -2896,8 +2896,8 @@ void ASTWriter::WriteSubmodules(Module *WritingModule) {
 
 // Emit the requirements.
 for (const auto &R : Mod->Requirements) {
-  RecordData::value_type Record[] = {SUBMODULE_REQUIRES, R.second};
-  Stream.EmitRecordWithBlob(RequiresAbbrev, Record, R.first);
+  RecordData::value_type Record[] = {SUBMODULE_REQUIRES, R.RequiredState};
+  Stream.EmitRecordWithBlob(RequiresAbbrev, Record, R.FeatureName);
 }
 
 // Emit the umbrella header, if there is one.

>From c74e03c6c3df6aef31dc343a3732d5327b37338f Mon Sep 17 00:00:00 2001
From: David Stone 
Date: Sat, 30 Sep 2023 23:08:58 -0600
Subject: [PATCH 2/2] amend! [clang][Modules] Make `Module::Requirement` a
 struct

[clang][Modules] Make `Module::Requirement` a struct

`Module::Requirement` was defined as a `std::pair`. This 
required a comment to explain what the data members mean and makes the usage 
harder to understand. Replace this with a struct with two members, 
`FeatureName` and `RequiredState`.
---
 clang/lib/Basic/Module.cpp | 2 +-
 clang

[PATCH] D155775: [HIP][Clang][Driver][RFC] Add driver support for C++ Parallel Algorithm Offload

2023-10-03 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

Windows: http://45.33.8.238/win/84498/step_7.txt


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155775

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


[PATCH] D155775: [HIP][Clang][Driver][RFC] Add driver support for C++ Parallel Algorithm Offload

2023-10-03 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

This seems to break tests on Mac and windows, see eg 
http://45.33.8.238/macm1/70415/step_7.txt

Please take a look and revert for now if it takes a while to fix.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155775

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


[libclc] [SystemZ][z/OS] Implement executePostLayoutBinding for GOFFObjectWriter (PR #67868)

2023-10-03 Thread Neumann Hon via cfe-commits

https://github.com/Everybody0523 updated 
https://github.com/llvm/llvm-project/pull/67868

>From 80073957d9adf8d107515d49a741df2b2130f82d Mon Sep 17 00:00:00 2001
From: Neumann Hon 
Date: Fri, 29 Sep 2023 19:52:27 -0400
Subject: [PATCH] [SystemZ][z/OS] Implement executePostLayoutBinding for
 GOFFObjectWriter

Implement executePostLayoutBinding() for the GOFFObjectWriter. With this
patch, we can now emit the ESD/TXT Records that are required by
global variables and functions.
---
 llvm/include/llvm/BinaryFormat/GOFF.h |  13 +-
 llvm/include/llvm/MC/MCAssembler.h|   7 +
 llvm/include/llvm/MC/MCContext.h  |   3 +-
 llvm/include/llvm/MC/MCGOFFObjectWriter.h |   1 +
 llvm/include/llvm/MC/MCGOFFStreamer.h |  10 +-
 llvm/include/llvm/MC/MCSymbolGOFF.h   |  40 +
 .../CodeGen/TargetLoweringObjectFileImpl.cpp  |   4 +
 llvm/lib/MC/GOFFObjectWriter.cpp  | 709 +-
 llvm/lib/MC/MCGOFFStreamer.cpp|  50 ++
 llvm/lib/Target/SystemZ/SystemZAsmPrinter.cpp |  37 +
 llvm/lib/Target/SystemZ/SystemZAsmPrinter.h   |   2 +
 llvm/test/MC/GOFF/basic-goff-64.ll| 242 ++
 llvm/test/MC/GOFF/empty-goff.s|  18 +-
 13 files changed, 1116 insertions(+), 20 deletions(-)
 create mode 100644 llvm/test/MC/GOFF/basic-goff-64.ll

diff --git a/llvm/include/llvm/BinaryFormat/GOFF.h 
b/llvm/include/llvm/BinaryFormat/GOFF.h
index f1a30e41b736bda..e53f0fd421fbdb1 100644
--- a/llvm/include/llvm/BinaryFormat/GOFF.h
+++ b/llvm/include/llvm/BinaryFormat/GOFF.h
@@ -65,12 +65,7 @@ enum ESDNameSpaceId : uint8_t {
   ESD_NS_Parts = 3
 };
 
-enum ESDReserveQwords : uint8_t {
-  ESD_RQ_0 = 0,
-  ESD_RQ_1 = 1,
-  ESD_RQ_2 = 2,
-  ESD_RQ_3 = 3
-};
+enum ESDReserveQwords : uint8_t { ESD_RQ_0 = 0, ESD_RQ_1 = 1 };
 
 enum ESDAmode : uint8_t {
   ESD_AMODE_None = 0,
@@ -157,6 +152,12 @@ enum ESDAlignment : uint8_t {
   ESD_ALIGN_4Kpage = 12,
 };
 
+enum TXTRecordStyle : uint8_t {
+  TXT_RS_Byte = 0,
+  TXT_RS_Structured = 1,
+  TXT_RS_Unstructured = 2,
+};
+
 enum ENDEntryPointRequest : uint8_t {
   END_EPR_None = 0,
   END_EPR_EsdidOffset = 1,
diff --git a/llvm/include/llvm/MC/MCAssembler.h 
b/llvm/include/llvm/MC/MCAssembler.h
index 5e1fc738b1dab4b..2b7b62e29722146 100644
--- a/llvm/include/llvm/MC/MCAssembler.h
+++ b/llvm/include/llvm/MC/MCAssembler.h
@@ -134,6 +134,9 @@ class MCAssembler {
   /// List of declared file names
   std::vector> FileNames;
 
+  /// GOFF Csect names.
+  std::pair CsectNames;
+
   MCDwarfLineTableParams LTParams;
 
   /// The set of function symbols for which a .thumb_func directive has
@@ -483,6 +486,10 @@ class MCAssembler {
 FileNames.emplace_back(std::string(FileName), Symbols.size());
   }
 
+  std::pair const &getCsectNames() {
+return CsectNames;
+  }
+
   /// Write the necessary bundle padding to \p OS.
   /// Expects a fragment \p F containing instructions and its size \p FSize.
   void writeFragmentPadding(raw_ostream &OS, const MCEncodedFragment &F,
diff --git a/llvm/include/llvm/MC/MCContext.h b/llvm/include/llvm/MC/MCContext.h
index 68d6f3e59d2d41a..dd5709d3be14c7f 100644
--- a/llvm/include/llvm/MC/MCContext.h
+++ b/llvm/include/llvm/MC/MCContext.h
@@ -621,7 +621,8 @@ class MCContext {
unsigned EntrySize);
 
   MCSectionGOFF *getGOFFSection(StringRef Section, SectionKind Kind,
-MCSection *Parent, const MCExpr *SubsectionId);
+MCSection *Parent = nullptr,
+const MCExpr *SubsectionId = nullptr);
 
   MCSectionCOFF *getCOFFSection(StringRef Section, unsigned Characteristics,
 SectionKind Kind, StringRef COMDATSymName,
diff --git a/llvm/include/llvm/MC/MCGOFFObjectWriter.h 
b/llvm/include/llvm/MC/MCGOFFObjectWriter.h
index 85316a6fd5d0e17..26bddde706dc601 100644
--- a/llvm/include/llvm/MC/MCGOFFObjectWriter.h
+++ b/llvm/include/llvm/MC/MCGOFFObjectWriter.h
@@ -10,6 +10,7 @@
 #define LLVM_MC_MCGOFFOBJECTWRITER_H
 
 #include "llvm/MC/MCObjectWriter.h"
+#include "llvm/Support/Casting.h"
 
 namespace llvm {
 class MCObjectWriter;
diff --git a/llvm/include/llvm/MC/MCGOFFStreamer.h 
b/llvm/include/llvm/MC/MCGOFFStreamer.h
index 2345509b161da5b..235edc01e88d5a5 100644
--- a/llvm/include/llvm/MC/MCGOFFStreamer.h
+++ b/llvm/include/llvm/MC/MCGOFFStreamer.h
@@ -24,9 +24,13 @@ class MCGOFFStreamer : public MCObjectStreamer {
 
   ~MCGOFFStreamer() override;
 
-  bool emitSymbolAttribute(MCSymbol *Symbol, MCSymbolAttr Attribute) override {
-return false;
-  }
+  // state management
+  void initSections(bool NoExecStack, const MCSubtargetInfo &STI) override;
+
+  void switchSection(MCSection *Section,
+ const MCExpr *Subsection = nullptr) override;
+
+  bool emitSymbolAttribute(MCSymbol *Symbol, MCSymbolAttr Attribute) override;
   void emitCommonSymbol(MCSymbol *Symbol, uint64_t Size,
 

[clang] [diag] Silence `-Wfixed-enum-extension` in C23 (PR #68060)

2023-10-03 Thread Erich Keane via cfe-commits

https://github.com/erichkeane approved this pull request.


https://github.com/llvm/llvm-project/pull/68060
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [diag] Silence `-Wfixed-enum-extension` in C23 (PR #68060)

2023-10-03 Thread Shoaib Meenai via cfe-commits

https://github.com/smeenai updated 
https://github.com/llvm/llvm-project/pull/68060

>From b931e047168d2312f05c0fbf2813915cc4e06ae8 Mon Sep 17 00:00:00 2001
From: Shoaib Meenai 
Date: Mon, 2 Oct 2023 17:50:36 -0700
Subject: [PATCH 1/4] [diag] Silence `-Wfixed-enum-extension` in C23

The C23 standard supports enums with fixed underlying types (N3030 [1]),
so we shouldn't emit `-Wfixed-enum-extension` in C23 mode (since it's no
longer a Clang extension at that point).

[1] 
https://thephd.dev/_vendor/future_cxx/papers/C%20-%20Enhanced%20Enumerations.html
---
 clang/lib/Parse/ParseDecl.cpp |  2 +-
 clang/test/Sema/fixed-enum.c  | 12 
 2 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp
index a1491596ef6145c..735da4aafae1ca5 100644
--- a/clang/lib/Parse/ParseDecl.cpp
+++ b/clang/lib/Parse/ParseDecl.cpp
@@ -5019,7 +5019,7 @@ void Parser::ParseEnumSpecifier(SourceLocation StartLoc, 
DeclSpec &DS,
 else if (getLangOpts().MicrosoftExt)
   Diag(ColonLoc, diag::ext_ms_c_enum_fixed_underlying_type)
   << BaseRange;
-else
+else if (!getLangOpts().C23)
   Diag(ColonLoc, diag::ext_clang_c_enum_fixed_underlying_type)
   << BaseRange;
   }
diff --git a/clang/test/Sema/fixed-enum.c b/clang/test/Sema/fixed-enum.c
index c77f5b0cbe79c5b..73a3fd2b09114c0 100644
--- a/clang/test/Sema/fixed-enum.c
+++ b/clang/test/Sema/fixed-enum.c
@@ -4,13 +4,17 @@
 // RUN: %clang_cc1 -Weverything -std=c11 -xc -DC11 -verify %s
 // RUN: %clang_cc1 -pedantic-std=c11 -xc -DC11 -verify %s
 // RUN: %clang_cc1 -Weverything -std=c11 -xc -fms-extensions -DMS -verify %s
+// RUN: %clang_cc1 -Weverything -std=c2x -xc -DC23 -verify %s
+// RUN: %clang_cc1 -pedantic-std=c2x -xc -DC23 -verify %s
+// RUN: %clang_cc1 -Weverything -std=c23 -xc -DC23 -verify %s
+// RUN: %clang_cc1 -pedantic-std=c23 -xc -DC23 -verify %s
 
 enum X : int {e};
 #if defined(CXX11)
 // expected-warning@-2{{enumeration types with a fixed underlying type are 
incompatible with C++98}}
 #elif defined(CXX03)
 // expected-warning@-4{{enumeration types with a fixed underlying type are a 
C++11 extension}}
-#elif defined(OBJC)
+#elif defined(OBJC) || defined(C23)
 // No diagnostic
 #elif defined(C11)
 // expected-warning@-8{{enumeration types with a fixed underlying type are a 
Clang extension}}
@@ -21,19 +25,19 @@ enum X : int {e};
 // Don't warn about the forward declaration in any language mode.
 enum Fwd : int;
 enum Fwd : int { e2 };
-#ifndef OBJC
+#if !defined(OBJC) && !defined(C23)
 // expected-warning@-3 {{enumeration types with a fixed underlying type}}
 // expected-warning@-3 {{enumeration types with a fixed underlying type}}
 #endif
 
 // Always error on the incompatible redeclaration.
 enum BadFwd : int;
-#ifndef OBJC
+#if !defined(OBJC) && !defined(C23)
 // expected-warning@-2 {{enumeration types with a fixed underlying type}}
 #endif
 // expected-note@-4 {{previous declaration is here}}
 enum BadFwd : char { e3 };
-#ifndef OBJC
+#if !defined(OBJC) && !defined(C23)
 // expected-warning@-2 {{enumeration types with a fixed underlying type}}
 #endif
 // expected-error@-4 {{enumeration redeclared with different underlying type 
'char' (was 'int')}}

>From 862b7a64968ababc2d6b3495ba75271b764ca335 Mon Sep 17 00:00:00 2001
From: Shoaib Meenai 
Date: Tue, 3 Oct 2023 07:57:39 -0700
Subject: [PATCH 2/4] Address comment

---
 clang/lib/Parse/ParseDecl.cpp | 4 ++--
 clang/test/Sema/fixed-enum.c  | 1 +
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp
index 735da4aafae1ca5..3cad57e719aad97 100644
--- a/clang/lib/Parse/ParseDecl.cpp
+++ b/clang/lib/Parse/ParseDecl.cpp
@@ -5009,7 +5009,7 @@ void Parser::ParseEnumSpecifier(SourceLocation StartLoc, 
DeclSpec &DS,
 
   BaseRange = SourceRange(ColonLoc, 
DeclaratorInfo.getSourceRange().getEnd());
 
-  if (!getLangOpts().ObjC) {
+  if (!getLangOpts().ObjC && !getLangOpts().C23) {
 if (getLangOpts().CPlusPlus11)
   Diag(ColonLoc, diag::warn_cxx98_compat_enum_fixed_underlying_type)
   << BaseRange;
@@ -5019,7 +5019,7 @@ void Parser::ParseEnumSpecifier(SourceLocation StartLoc, 
DeclSpec &DS,
 else if (getLangOpts().MicrosoftExt)
   Diag(ColonLoc, diag::ext_ms_c_enum_fixed_underlying_type)
   << BaseRange;
-else if (!getLangOpts().C23)
+else
   Diag(ColonLoc, diag::ext_clang_c_enum_fixed_underlying_type)
   << BaseRange;
   }
diff --git a/clang/test/Sema/fixed-enum.c b/clang/test/Sema/fixed-enum.c
index 73a3fd2b09114c0..954ff8c452b80ca 100644
--- a/clang/test/Sema/fixed-enum.c
+++ b/clang/test/Sema/fixed-enum.c
@@ -8,6 +8,7 @@
 // RUN: %clang_cc1 -pedantic-std=c2x -xc -DC23 -verify %s
 // RUN: %clang_cc1 -Weverything -std=c23 -xc -DC23 -verify %s
 // RUN: %clang_cc1 -pedantic-std=c23 -xc -DC23 -verify 

[clang] [diag] Silence `-Wfixed-enum-extension` in C23 (PR #68060)

2023-10-03 Thread Erich Keane via cfe-commits


@@ -216,6 +216,9 @@ Improvements to Clang's diagnostics
 - The fix-it emitted by ``-Wformat`` for scoped enumerations now take the
   enumeration's underlying type into account instead of suggesting a type just
   based on the format string specifier being used.
+- ``-Wfixed-enum-extension`` and ``-Wmicrosoft-fixed-enunm`` are no longer

erichkeane wrote:

```suggestion
- ``-Wfixed-enum-extension`` and ``-Wmicrosoft-fixed-enum`` diagnostics are no 
longer
```

https://github.com/llvm/llvm-project/pull/68060
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [diag] Silence `-Wfixed-enum-extension` in C23 (PR #68060)

2023-10-03 Thread Shoaib Meenai via cfe-commits

https://github.com/smeenai updated 
https://github.com/llvm/llvm-project/pull/68060

>From b931e047168d2312f05c0fbf2813915cc4e06ae8 Mon Sep 17 00:00:00 2001
From: Shoaib Meenai 
Date: Mon, 2 Oct 2023 17:50:36 -0700
Subject: [PATCH 1/3] [diag] Silence `-Wfixed-enum-extension` in C23

The C23 standard supports enums with fixed underlying types (N3030 [1]),
so we shouldn't emit `-Wfixed-enum-extension` in C23 mode (since it's no
longer a Clang extension at that point).

[1] 
https://thephd.dev/_vendor/future_cxx/papers/C%20-%20Enhanced%20Enumerations.html
---
 clang/lib/Parse/ParseDecl.cpp |  2 +-
 clang/test/Sema/fixed-enum.c  | 12 
 2 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp
index a1491596ef6145c..735da4aafae1ca5 100644
--- a/clang/lib/Parse/ParseDecl.cpp
+++ b/clang/lib/Parse/ParseDecl.cpp
@@ -5019,7 +5019,7 @@ void Parser::ParseEnumSpecifier(SourceLocation StartLoc, 
DeclSpec &DS,
 else if (getLangOpts().MicrosoftExt)
   Diag(ColonLoc, diag::ext_ms_c_enum_fixed_underlying_type)
   << BaseRange;
-else
+else if (!getLangOpts().C23)
   Diag(ColonLoc, diag::ext_clang_c_enum_fixed_underlying_type)
   << BaseRange;
   }
diff --git a/clang/test/Sema/fixed-enum.c b/clang/test/Sema/fixed-enum.c
index c77f5b0cbe79c5b..73a3fd2b09114c0 100644
--- a/clang/test/Sema/fixed-enum.c
+++ b/clang/test/Sema/fixed-enum.c
@@ -4,13 +4,17 @@
 // RUN: %clang_cc1 -Weverything -std=c11 -xc -DC11 -verify %s
 // RUN: %clang_cc1 -pedantic-std=c11 -xc -DC11 -verify %s
 // RUN: %clang_cc1 -Weverything -std=c11 -xc -fms-extensions -DMS -verify %s
+// RUN: %clang_cc1 -Weverything -std=c2x -xc -DC23 -verify %s
+// RUN: %clang_cc1 -pedantic-std=c2x -xc -DC23 -verify %s
+// RUN: %clang_cc1 -Weverything -std=c23 -xc -DC23 -verify %s
+// RUN: %clang_cc1 -pedantic-std=c23 -xc -DC23 -verify %s
 
 enum X : int {e};
 #if defined(CXX11)
 // expected-warning@-2{{enumeration types with a fixed underlying type are 
incompatible with C++98}}
 #elif defined(CXX03)
 // expected-warning@-4{{enumeration types with a fixed underlying type are a 
C++11 extension}}
-#elif defined(OBJC)
+#elif defined(OBJC) || defined(C23)
 // No diagnostic
 #elif defined(C11)
 // expected-warning@-8{{enumeration types with a fixed underlying type are a 
Clang extension}}
@@ -21,19 +25,19 @@ enum X : int {e};
 // Don't warn about the forward declaration in any language mode.
 enum Fwd : int;
 enum Fwd : int { e2 };
-#ifndef OBJC
+#if !defined(OBJC) && !defined(C23)
 // expected-warning@-3 {{enumeration types with a fixed underlying type}}
 // expected-warning@-3 {{enumeration types with a fixed underlying type}}
 #endif
 
 // Always error on the incompatible redeclaration.
 enum BadFwd : int;
-#ifndef OBJC
+#if !defined(OBJC) && !defined(C23)
 // expected-warning@-2 {{enumeration types with a fixed underlying type}}
 #endif
 // expected-note@-4 {{previous declaration is here}}
 enum BadFwd : char { e3 };
-#ifndef OBJC
+#if !defined(OBJC) && !defined(C23)
 // expected-warning@-2 {{enumeration types with a fixed underlying type}}
 #endif
 // expected-error@-4 {{enumeration redeclared with different underlying type 
'char' (was 'int')}}

>From 862b7a64968ababc2d6b3495ba75271b764ca335 Mon Sep 17 00:00:00 2001
From: Shoaib Meenai 
Date: Tue, 3 Oct 2023 07:57:39 -0700
Subject: [PATCH 2/3] Address comment

---
 clang/lib/Parse/ParseDecl.cpp | 4 ++--
 clang/test/Sema/fixed-enum.c  | 1 +
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp
index 735da4aafae1ca5..3cad57e719aad97 100644
--- a/clang/lib/Parse/ParseDecl.cpp
+++ b/clang/lib/Parse/ParseDecl.cpp
@@ -5009,7 +5009,7 @@ void Parser::ParseEnumSpecifier(SourceLocation StartLoc, 
DeclSpec &DS,
 
   BaseRange = SourceRange(ColonLoc, 
DeclaratorInfo.getSourceRange().getEnd());
 
-  if (!getLangOpts().ObjC) {
+  if (!getLangOpts().ObjC && !getLangOpts().C23) {
 if (getLangOpts().CPlusPlus11)
   Diag(ColonLoc, diag::warn_cxx98_compat_enum_fixed_underlying_type)
   << BaseRange;
@@ -5019,7 +5019,7 @@ void Parser::ParseEnumSpecifier(SourceLocation StartLoc, 
DeclSpec &DS,
 else if (getLangOpts().MicrosoftExt)
   Diag(ColonLoc, diag::ext_ms_c_enum_fixed_underlying_type)
   << BaseRange;
-else if (!getLangOpts().C23)
+else
   Diag(ColonLoc, diag::ext_clang_c_enum_fixed_underlying_type)
   << BaseRange;
   }
diff --git a/clang/test/Sema/fixed-enum.c b/clang/test/Sema/fixed-enum.c
index 73a3fd2b09114c0..954ff8c452b80ca 100644
--- a/clang/test/Sema/fixed-enum.c
+++ b/clang/test/Sema/fixed-enum.c
@@ -8,6 +8,7 @@
 // RUN: %clang_cc1 -pedantic-std=c2x -xc -DC23 -verify %s
 // RUN: %clang_cc1 -Weverything -std=c23 -xc -DC23 -verify %s
 // RUN: %clang_cc1 -pedantic-std=c23 -xc -DC23 -verify 

[clang] [Clang] Fix constant evaluating a captured variable in a lambda (PR #68090)

2023-10-03 Thread via cfe-commits


@@ -8367,7 +8367,13 @@ bool LValueExprEvaluator::VisitVarDecl(const Expr *E, 
const VarDecl *VD) {
 
 if (auto *FD = Info.CurrentCall->LambdaCaptureFields.lookup(VD)) {
   // Start with 'Result' referring to the complete closure object...
-  Result = *Info.CurrentCall->This;
+  if (auto *MD = cast(Info.CurrentCall->Callee);
+  MD->isExplicitObjectMemberFunction()) {
+APValue *RefValue =
+Info.getParamSlot(Info.CurrentCall->Arguments, 
MD->getParamDecl(0));
+Result.setFrom(Info.Ctx, *RefValue);

cor3ntin wrote:

LValue has no assignment operator from APValue (because sometimes you need an 
ASTContext)

https://github.com/llvm/llvm-project/pull/68090
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libunwind] [AMDGPU] Add another SIFoldOperands instance after shrink (PR #67878)

2023-10-03 Thread Joe Nash via cfe-commits

Sisyph wrote:

> I've just tested this on 1 graphics shaders and it seems to make no 
> difference at all. I tried gfx900 and gfx1100. Can anyone else from the 
> graphics team confirm this?

I can confirm no difference on gfx1102

https://github.com/llvm/llvm-project/pull/67878
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] use absolute path for builtin headers during module compilation (PR #68023)

2023-10-03 Thread Richard Howell via cfe-commits

https://github.com/rmaz updated https://github.com/llvm/llvm-project/pull/68023

>From 3617539eecb4bfcb9f2a20a1ae1cff71b298 Mon Sep 17 00:00:00 2001
From: Richard Howell 
Date: Mon, 2 Oct 2023 11:10:52 -0700
Subject: [PATCH] [clang] use absolute path for builtin headers during module
 compilation

When including builtin headers as part of a system module, ensure
we use absolute paths to those headers. Otherwise the module will
fail to compile when specifying relative resource directories.
---
 clang/lib/Lex/ModuleMap.cpp|  4 
 .../Modules/Inputs/builtin-headers/module.modulemap|  3 +++
 clang/test/Modules/relative-resource-dir.m | 10 ++
 3 files changed, 17 insertions(+)
 create mode 100644 clang/test/Modules/Inputs/builtin-headers/module.modulemap
 create mode 100644 clang/test/Modules/relative-resource-dir.m

diff --git a/clang/lib/Lex/ModuleMap.cpp b/clang/lib/Lex/ModuleMap.cpp
index e8437572ebf4bf6..80ffdee2e025bc4 100644
--- a/clang/lib/Lex/ModuleMap.cpp
+++ b/clang/lib/Lex/ModuleMap.cpp
@@ -348,6 +348,10 @@ bool ModuleMap::resolveAsBuiltinHeader(
   if (!File)
 return false;
 
+  // Ensure the path to the module directory is absolute, otherwise
+  // builtin headers will fail to resolve when using relative resource
+  // directory paths without a -I.
+  SourceMgr.getFileManager().makeAbsolutePath(Path);
   auto Role = headerKindToRole(Header.Kind);
   Module::Header H = {Header.FileName, std::string(Path.str()), *File};
   addHeader(Mod, H, Role);
diff --git a/clang/test/Modules/Inputs/builtin-headers/module.modulemap 
b/clang/test/Modules/Inputs/builtin-headers/module.modulemap
new file mode 100644
index 000..78a5b730dc6a925
--- /dev/null
+++ b/clang/test/Modules/Inputs/builtin-headers/module.modulemap
@@ -0,0 +1,3 @@
+module ModuleWithBuiltinHeader [system] {
+header "float.h"
+}
\ No newline at end of file
diff --git a/clang/test/Modules/relative-resource-dir.m 
b/clang/test/Modules/relative-resource-dir.m
new file mode 100644
index 000..64b31f56be1d6a4
--- /dev/null
+++ b/clang/test/Modules/relative-resource-dir.m
@@ -0,0 +1,10 @@
+// REQUIRES: shell
+
+// RUN: EXPECTED_RESOURCE_DIR=`%clang -print-resource-dir` && \
+// RUN:  mkdir -p %t && rm -rf %t/resource-dir && \
+// RUN:  cp -R $EXPECTED_RESOURCE_DIR %t/resource-dir
+// RUN: cd %t && %clang -cc1 -x objective-c -fmodules -fmodule-format=obj \
+// RUN:   -fimplicit-module-maps -fmodules-cache-path=%t.mcp \
+// RUN:   -fbuiltin-headers-in-system-modules -resource-dir resource-dir \
+// RUN:   -emit-module %S/Inputs/builtin-headers/module.modulemap \
+// RUN:   -fmodule-name=ModuleWithBuiltinHeader -o %t.pcm

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


[clang] [AMDGPU] Add another SIFoldOperands instance after shrink (PR #67878)

2023-10-03 Thread Joe Nash via cfe-commits

Sisyph wrote:

> I've just tested this on 1 graphics shaders and it seems to make no 
> difference at all. I tried gfx900 and gfx1100. Can anyone else from the 
> graphics team confirm this?

I can confirm no difference on gfx1102

https://github.com/llvm/llvm-project/pull/67878
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [RISCV] Mark the Zfa extension as non-experimental (PR #68113)

2023-10-03 Thread via cfe-commits

github-actions[bot] wrote:




:warning: C/C++ code formatter, clang-format found issues in your code. 
:warning:



You can test this locally with the following command:


``bash
git-clang-format --diff 06a05f334698c10a60459d30b4074fabedf72c48 
83e868a92647efb783e43db48705b0db63188d84 -- clang/test/Driver/riscv-arch.c 
clang/test/Preprocessor/riscv-target-features.c 
llvm/lib/Support/RISCVISAInfo.cpp llvm/unittests/Support/RISCVISAInfoTest.cpp
``





View the diff from clang-format here.


``diff
diff --git a/llvm/unittests/Support/RISCVISAInfoTest.cpp 
b/llvm/unittests/Support/RISCVISAInfoTest.cpp
index 90e26a23e87c..8cb608d43f58 100644
--- a/llvm/unittests/Support/RISCVISAInfoTest.cpp
+++ b/llvm/unittests/Support/RISCVISAInfoTest.cpp
@@ -630,7 +630,7 @@ TEST(getTargetFeatureForExtension, 
RetrieveTargetFeatureFromOneExt) {
 
 TEST(RiscvExtensionsHelp, CheckExtensions) {
   std::string ExpectedOutput =
-R"(All available -march extensions for RISC-V
+  R"(All available -march extensions for RISC-V
 
 NameVersion   Description
 i   2.1   This is a long dummy description

``




https://github.com/llvm/llvm-project/pull/68113
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [diag] Silence `-Wfixed-enum-extension` in C23 (PR #68060)

2023-10-03 Thread Erich Keane via cfe-commits

https://github.com/erichkeane commented:

I believe this needs a release note as well (see docs/ReleaseNotes.rst), else 
this LGTM.

https://github.com/llvm/llvm-project/pull/68060
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [diag] Silence `-Wfixed-enum-extension` in C23 (PR #68060)

2023-10-03 Thread Shoaib Meenai via cfe-commits


@@ -5019,7 +5019,7 @@ void Parser::ParseEnumSpecifier(SourceLocation StartLoc, 
DeclSpec &DS,
 else if (getLangOpts().MicrosoftExt)
   Diag(ColonLoc, diag::ext_ms_c_enum_fixed_underlying_type)
   << BaseRange;
-else
+else if (!getLangOpts().C23)

smeenai wrote:

You're right, I hoisted the check up and added an additional test case for that 
combo.

https://github.com/llvm/llvm-project/pull/68060
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [diag] Silence `-Wfixed-enum-extension` in C23 (PR #68060)

2023-10-03 Thread Shoaib Meenai via cfe-commits

https://github.com/smeenai updated 
https://github.com/llvm/llvm-project/pull/68060

>From b931e047168d2312f05c0fbf2813915cc4e06ae8 Mon Sep 17 00:00:00 2001
From: Shoaib Meenai 
Date: Mon, 2 Oct 2023 17:50:36 -0700
Subject: [PATCH 1/2] [diag] Silence `-Wfixed-enum-extension` in C23

The C23 standard supports enums with fixed underlying types (N3030 [1]),
so we shouldn't emit `-Wfixed-enum-extension` in C23 mode (since it's no
longer a Clang extension at that point).

[1] 
https://thephd.dev/_vendor/future_cxx/papers/C%20-%20Enhanced%20Enumerations.html
---
 clang/lib/Parse/ParseDecl.cpp |  2 +-
 clang/test/Sema/fixed-enum.c  | 12 
 2 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp
index a1491596ef6145c..735da4aafae1ca5 100644
--- a/clang/lib/Parse/ParseDecl.cpp
+++ b/clang/lib/Parse/ParseDecl.cpp
@@ -5019,7 +5019,7 @@ void Parser::ParseEnumSpecifier(SourceLocation StartLoc, 
DeclSpec &DS,
 else if (getLangOpts().MicrosoftExt)
   Diag(ColonLoc, diag::ext_ms_c_enum_fixed_underlying_type)
   << BaseRange;
-else
+else if (!getLangOpts().C23)
   Diag(ColonLoc, diag::ext_clang_c_enum_fixed_underlying_type)
   << BaseRange;
   }
diff --git a/clang/test/Sema/fixed-enum.c b/clang/test/Sema/fixed-enum.c
index c77f5b0cbe79c5b..73a3fd2b09114c0 100644
--- a/clang/test/Sema/fixed-enum.c
+++ b/clang/test/Sema/fixed-enum.c
@@ -4,13 +4,17 @@
 // RUN: %clang_cc1 -Weverything -std=c11 -xc -DC11 -verify %s
 // RUN: %clang_cc1 -pedantic-std=c11 -xc -DC11 -verify %s
 // RUN: %clang_cc1 -Weverything -std=c11 -xc -fms-extensions -DMS -verify %s
+// RUN: %clang_cc1 -Weverything -std=c2x -xc -DC23 -verify %s
+// RUN: %clang_cc1 -pedantic-std=c2x -xc -DC23 -verify %s
+// RUN: %clang_cc1 -Weverything -std=c23 -xc -DC23 -verify %s
+// RUN: %clang_cc1 -pedantic-std=c23 -xc -DC23 -verify %s
 
 enum X : int {e};
 #if defined(CXX11)
 // expected-warning@-2{{enumeration types with a fixed underlying type are 
incompatible with C++98}}
 #elif defined(CXX03)
 // expected-warning@-4{{enumeration types with a fixed underlying type are a 
C++11 extension}}
-#elif defined(OBJC)
+#elif defined(OBJC) || defined(C23)
 // No diagnostic
 #elif defined(C11)
 // expected-warning@-8{{enumeration types with a fixed underlying type are a 
Clang extension}}
@@ -21,19 +25,19 @@ enum X : int {e};
 // Don't warn about the forward declaration in any language mode.
 enum Fwd : int;
 enum Fwd : int { e2 };
-#ifndef OBJC
+#if !defined(OBJC) && !defined(C23)
 // expected-warning@-3 {{enumeration types with a fixed underlying type}}
 // expected-warning@-3 {{enumeration types with a fixed underlying type}}
 #endif
 
 // Always error on the incompatible redeclaration.
 enum BadFwd : int;
-#ifndef OBJC
+#if !defined(OBJC) && !defined(C23)
 // expected-warning@-2 {{enumeration types with a fixed underlying type}}
 #endif
 // expected-note@-4 {{previous declaration is here}}
 enum BadFwd : char { e3 };
-#ifndef OBJC
+#if !defined(OBJC) && !defined(C23)
 // expected-warning@-2 {{enumeration types with a fixed underlying type}}
 #endif
 // expected-error@-4 {{enumeration redeclared with different underlying type 
'char' (was 'int')}}

>From 862b7a64968ababc2d6b3495ba75271b764ca335 Mon Sep 17 00:00:00 2001
From: Shoaib Meenai 
Date: Tue, 3 Oct 2023 07:57:39 -0700
Subject: [PATCH 2/2] Address comment

---
 clang/lib/Parse/ParseDecl.cpp | 4 ++--
 clang/test/Sema/fixed-enum.c  | 1 +
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp
index 735da4aafae1ca5..3cad57e719aad97 100644
--- a/clang/lib/Parse/ParseDecl.cpp
+++ b/clang/lib/Parse/ParseDecl.cpp
@@ -5009,7 +5009,7 @@ void Parser::ParseEnumSpecifier(SourceLocation StartLoc, 
DeclSpec &DS,
 
   BaseRange = SourceRange(ColonLoc, 
DeclaratorInfo.getSourceRange().getEnd());
 
-  if (!getLangOpts().ObjC) {
+  if (!getLangOpts().ObjC && !getLangOpts().C23) {
 if (getLangOpts().CPlusPlus11)
   Diag(ColonLoc, diag::warn_cxx98_compat_enum_fixed_underlying_type)
   << BaseRange;
@@ -5019,7 +5019,7 @@ void Parser::ParseEnumSpecifier(SourceLocation StartLoc, 
DeclSpec &DS,
 else if (getLangOpts().MicrosoftExt)
   Diag(ColonLoc, diag::ext_ms_c_enum_fixed_underlying_type)
   << BaseRange;
-else if (!getLangOpts().C23)
+else
   Diag(ColonLoc, diag::ext_clang_c_enum_fixed_underlying_type)
   << BaseRange;
   }
diff --git a/clang/test/Sema/fixed-enum.c b/clang/test/Sema/fixed-enum.c
index 73a3fd2b09114c0..954ff8c452b80ca 100644
--- a/clang/test/Sema/fixed-enum.c
+++ b/clang/test/Sema/fixed-enum.c
@@ -8,6 +8,7 @@
 // RUN: %clang_cc1 -pedantic-std=c2x -xc -DC23 -verify %s
 // RUN: %clang_cc1 -Weverything -std=c23 -xc -DC23 -verify %s
 // RUN: %clang_cc1 -pedantic-std=c23 -xc -DC23 -verify 

[clang] [Clang] Fix constant evaluating a captured variable in a lambda (PR #68090)

2023-10-03 Thread via cfe-commits

https://github.com/cor3ntin edited 
https://github.com/llvm/llvm-project/pull/68090
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Fix constant evaluating a captured variable in a lambda (PR #68090)

2023-10-03 Thread Shafik Yaghmour via cfe-commits


@@ -8367,7 +8367,13 @@ bool LValueExprEvaluator::VisitVarDecl(const Expr *E, 
const VarDecl *VD) {
 
 if (auto *FD = Info.CurrentCall->LambdaCaptureFields.lookup(VD)) {
   // Start with 'Result' referring to the complete closure object...
-  Result = *Info.CurrentCall->This;
+  if (auto *MD = cast(Info.CurrentCall->Callee);
+  MD->isExplicitObjectMemberFunction()) {
+APValue *RefValue =
+Info.getParamSlot(Info.CurrentCall->Arguments, 
MD->getParamDecl(0));
+Result.setFrom(Info.Ctx, *RefValue);

shafik wrote:

So what is the difference between calling `setFrom` and assigning to `Result` 
using assignment here?

https://github.com/llvm/llvm-project/pull/68090
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [RISCV] Mark the Zfa extension as non-experimental (PR #68113)

2023-10-03 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-driver


Changes

Following the version bump in #67964 and the bug fix in #68026 
I believe we're ready to mark Zfa as non-experimental. I'll note the GCC 
torture suite passes now with Zfa enabled (though it's more of a litmus test 
than anything else).

This PR is stacked on top of #67694 - only the most recent commit 
should be reviewed.

---

Patch is 22.26 KiB, truncated to 20.00 KiB below, full version: 
https://github.com/llvm/llvm-project/pull/68113.diff


21 Files Affected:

- (modified) clang/test/Driver/riscv-arch.c (+9-9) 
- (modified) clang/test/Preprocessor/riscv-target-features.c (+5-5) 
- (modified) llvm/docs/RISCVUsage.rst (+1-3) 
- (modified) llvm/docs/ReleaseNotes.rst (+1) 
- (modified) llvm/lib/Support/RISCVISAInfo.cpp (+1-1) 
- (modified) llvm/lib/Target/RISCV/RISCVFeatures.td (+1-1) 
- (modified) llvm/test/CodeGen/RISCV/attributes.ll (+4-4) 
- (modified) llvm/test/CodeGen/RISCV/double-zfa.ll (+2-2) 
- (modified) llvm/test/CodeGen/RISCV/fli-licm.ll (+2-2) 
- (modified) llvm/test/CodeGen/RISCV/float-zfa.ll (+2-2) 
- (modified) llvm/test/CodeGen/RISCV/half-zfa-fli.ll (+4-4) 
- (modified) llvm/test/CodeGen/RISCV/half-zfa.ll (+2-2) 
- (modified) llvm/test/CodeGen/RISCV/rvv/vsplats-zfa.ll (+2-2) 
- (modified) llvm/test/MC/RISCV/attribute-arch.s (+2-2) 
- (modified) llvm/test/MC/RISCV/rv32zfa-only-valid.s (+3-3) 
- (modified) llvm/test/MC/RISCV/zfa-double-invalid.s (+2-2) 
- (modified) llvm/test/MC/RISCV/zfa-half-invalid.s (+2-2) 
- (modified) llvm/test/MC/RISCV/zfa-invalid.s (+2-2) 
- (modified) llvm/test/MC/RISCV/zfa-valid.s (+6-6) 
- (modified) llvm/test/MC/RISCV/zfa-zfhmin-zvfh-valid.s (+6-6) 
- (modified) llvm/unittests/Support/RISCVISAInfoTest.cpp (+1-1) 


``diff
diff --git a/clang/test/Driver/riscv-arch.c b/clang/test/Driver/riscv-arch.c
index 92a6a59cba2317c..0ac81ea982f1b61 100644
--- a/clang/test/Driver/riscv-arch.c
+++ b/clang/test/Driver/riscv-arch.c
@@ -372,24 +372,24 @@
 // RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32-ZFHMIN %s
 // RV32-ZFHMIN: "-target-feature" "+zfhmin"
 
-// RUN: not %clang --target=riscv32-unknown-elf -march=rv32izfa -### %s \
+// RUN: not %clang --target=riscv32-unknown-elf -march=rv32iztso -### %s \
 // RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32-EXPERIMENTAL-NOFLAG 
%s
-// RV32-EXPERIMENTAL-NOFLAG: error: invalid arch name 'rv32izfa'
+// RV32-EXPERIMENTAL-NOFLAG: error: invalid arch name 'rv32iztso'
 // RV32-EXPERIMENTAL-NOFLAG: requires '-menable-experimental-extensions'
 
-// RUN: not %clang --target=riscv32-unknown-elf -march=rv32izfa 
-menable-experimental-extensions -### %s \
+// RUN: not %clang --target=riscv32-unknown-elf -march=rv32iztso 
-menable-experimental-extensions -### %s \
 // RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32-EXPERIMENTAL-NOVERS 
%s
-// RV32-EXPERIMENTAL-NOVERS: error: invalid arch name 'rv32izfa'
+// RV32-EXPERIMENTAL-NOVERS: error: invalid arch name 'rv32iztso'
 // RV32-EXPERIMENTAL-NOVERS: experimental extension requires explicit version 
number
 
-// RUN: not %clang --target=riscv32-unknown-elf -march=rv32izfa0p1 
-menable-experimental-extensions -### %s \
+// RUN: not %clang --target=riscv32-unknown-elf -march=rv32iztso0p7 
-menable-experimental-extensions -### %s \
 // RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32-EXPERIMENTAL-BADVERS 
%s
-// RV32-EXPERIMENTAL-BADVERS: error: invalid arch name 'rv32izfa0p1'
-// RV32-EXPERIMENTAL-BADVERS: unsupported version number 0.1 for experimental 
extension 'zfa' (this compiler supports 0.2)
+// RV32-EXPERIMENTAL-BADVERS: error: invalid arch name 'rv32iztso0p7'
+// RV32-EXPERIMENTAL-BADVERS: unsupported version number 0.7 for experimental 
extension 'ztso' (this compiler supports 0.1)
 
-// RUN: %clang --target=riscv32-unknown-elf -march=rv32izfa0p2 
-menable-experimental-extensions -### %s \
+// RUN: %clang --target=riscv32-unknown-elf -march=rv32iztso0p1 
-menable-experimental-extensions -### %s \
 // RUN: -fsyntax-only 2>&1 | FileCheck 
-check-prefix=RV32-EXPERIMENTAL-GOODVERS %s
-// RV32-EXPERIMENTAL-GOODVERS: "-target-feature" "+experimental-zfa"
+// RV32-EXPERIMENTAL-GOODVERS: "-target-feature" "+experimental-ztso"
 
 // RUN: %clang --target=riscv32-unknown-elf -march=rv32izbb1p0 -### %s \
 // RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32-ZBB %s
diff --git a/clang/test/Preprocessor/riscv-target-features.c 
b/clang/test/Preprocessor/riscv-target-features.c
index 4dd83cfa0620b90..242197e3f129a3f 100644
--- a/clang/test/Preprocessor/riscv-target-features.c
+++ b/clang/test/Preprocessor/riscv-target-features.c
@@ -1001,13 +1001,13 @@
 // RUN: -o - | FileCheck --check-prefix=CHECK-ZACAS-EXT %s
 // CHECK-ZACAS-EXT: __riscv_zacas 100{{$}}
 
-// RUN: %clang --target=riscv32-unknown-linux-gnu 
-menable-experimental-extensions \
-// RUN: -march=rv32izfa0p2 -x c -E -dM %s \
+// RUN: %clang --target=riscv32-unknown-linux-gnu \
+// RUN: -march=rv32izfa -x c -E -dM %s \
 // RUN: -o -

[clang] [RISCV] Mark the Zfa extension as non-experimental (PR #68113)

2023-10-03 Thread Alex Bradbury via cfe-commits

https://github.com/asb created https://github.com/llvm/llvm-project/pull/68113

Following the version bump in #67964 and the bug fix in #68026 I believe we're 
ready to mark Zfa as non-experimental. I'll note the GCC torture suite passes 
now with Zfa enabled (though it's more of a litmus test than anything else).

This PR is stacked on top of #67694 - only the most recent commit should be 
reviewed.

>From 79ab61e07a01e503f22e717c4b0e64b7741c59a0 Mon Sep 17 00:00:00 2001
From: Alex Bradbury 
Date: Mon, 2 Oct 2023 11:06:44 +0100
Subject: [PATCH 1/4] [RISCV] Update Zfa extension version to 1.0

The Zfa specification was recently ratified
. This
commit bumps the version to 1.0, but leaves it as an experimental
extension (to be done in a follow-on patch), so reviews can focus on
confirming there haven't been spec changes we have missed (which as
noted below, is more difficult than usual).

Because the development of the Zfa spec overlapped with the transition
of riscv-isa-manual from LaTeX to AsciiDoc, it's more difficult than
usual to confirm version changes. The linked PDF in RISCVUsage is for
some reason a 404. Key commit histories to review are:
* Changes to zfa.adoc on the main branch
  
* Changes to zfa.tex on the now defunct latex branch
  

>From reviewing these, I believe there have been no changes to the spec
since version 0.1/0.2 (sadly the AsciiDoc and LaTeX versions of the spec
are inconsistent about version numbering).

There hasn't been a GitHub release of the spec since Zfa was ratified
(though I've requested one
), so RISCVUsage
is updated to link to the current Zfa.adoc. I don't think we need to
block on this, as we expect to shortly move Zfa to non-experimental, at
which point we don't link to individual spec documents in RISCVUsage.
---
 clang/test/Driver/riscv-arch.c  | 4 ++--
 clang/test/Preprocessor/riscv-target-features.c | 6 +++---
 llvm/docs/RISCVUsage.rst| 2 +-
 llvm/docs/ReleaseNotes.rst  | 1 +
 llvm/lib/Support/RISCVISAInfo.cpp   | 2 +-
 llvm/test/CodeGen/RISCV/attributes.ll   | 4 ++--
 llvm/test/MC/RISCV/attribute-arch.s | 4 ++--
 7 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/clang/test/Driver/riscv-arch.c b/clang/test/Driver/riscv-arch.c
index 92a6a59cba2317c..4896c0184507dd4 100644
--- a/clang/test/Driver/riscv-arch.c
+++ b/clang/test/Driver/riscv-arch.c
@@ -385,9 +385,9 @@
 // RUN: not %clang --target=riscv32-unknown-elf -march=rv32izfa0p1 
-menable-experimental-extensions -### %s \
 // RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32-EXPERIMENTAL-BADVERS 
%s
 // RV32-EXPERIMENTAL-BADVERS: error: invalid arch name 'rv32izfa0p1'
-// RV32-EXPERIMENTAL-BADVERS: unsupported version number 0.1 for experimental 
extension 'zfa' (this compiler supports 0.2)
+// RV32-EXPERIMENTAL-BADVERS: unsupported version number 0.1 for experimental 
extension 'zfa' (this compiler supports 1.0)
 
-// RUN: %clang --target=riscv32-unknown-elf -march=rv32izfa0p2 
-menable-experimental-extensions -### %s \
+// RUN: %clang --target=riscv32-unknown-elf -march=rv32izfa1p0 
-menable-experimental-extensions -### %s \
 // RUN: -fsyntax-only 2>&1 | FileCheck 
-check-prefix=RV32-EXPERIMENTAL-GOODVERS %s
 // RV32-EXPERIMENTAL-GOODVERS: "-target-feature" "+experimental-zfa"
 
diff --git a/clang/test/Preprocessor/riscv-target-features.c 
b/clang/test/Preprocessor/riscv-target-features.c
index 4dd83cfa0620b90..4b9ec423200017f 100644
--- a/clang/test/Preprocessor/riscv-target-features.c
+++ b/clang/test/Preprocessor/riscv-target-features.c
@@ -1002,12 +1002,12 @@
 // CHECK-ZACAS-EXT: __riscv_zacas 100{{$}}
 
 // RUN: %clang --target=riscv32-unknown-linux-gnu 
-menable-experimental-extensions \
-// RUN: -march=rv32izfa0p2 -x c -E -dM %s \
+// RUN: -march=rv32izfa1p0 -x c -E -dM %s \
 // RUN: -o - | FileCheck --check-prefix=CHECK-ZFA-EXT %s
 // RUN: %clang --target=riscv64-unknown-linux-gnu 
-menable-experimental-extensions \
-// RUN: -march=rv64izfa0p2 -x c -E -dM %s \
+// RUN: -march=rv64izfa1p0 -x c -E -dM %s \
 // RUN: -o - | FileCheck --check-prefix=CHECK-ZFA-EXT %s
-// CHECK-ZFA-EXT: __riscv_zfa 2000{{$}}
+// CHECK-ZFA-EXT: __riscv_zfa 100{{$}}
 
 // RUN: %clang --target=riscv32 -menable-experimental-extensions \
 // RUN: -march=rv32izfbfmin0p8 -x c -E -dM %s \
diff --git a/llvm/docs/RISCVUsage.rst b/llvm/docs/RISCVUsage.rst
index 8d12d58738c609a..647c4c49500c161 100644
--- a/llvm/docs/RISCVUsage.rst
+++ b/llvm/docs/RISCVUsage.rst
@@ -197,7 +197,7 @@ The primary goal of experimental support is to assist in 
the process of ratifica
   LLVM implements the `1.0-rc1 draft specification 


[clang] [RISCV] Update Zfa extension version to 1.0 (PR #67964)

2023-10-03 Thread Alex Bradbury via cfe-commits

asb wrote:

> ⚠️ C/C++ code formatter, clang-format found issues in your code. ⚠️

This is a whitespace change > 20 lines away from the edit made in the test 
file, so I don't believe it's appropriate to reformat in this PR.

https://github.com/llvm/llvm-project/pull/67964
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [AMDGPU] Add another SIFoldOperands instance after shrink (PR #67878)

2023-10-03 Thread Jay Foad via cfe-commits

jayfoad wrote:

I've just tested this on 1 graphics shaders and it seems to make no 
difference at all. I tried gfx900 and gfx1100. Can anyone else from the 
graphics team confirm this?

https://github.com/llvm/llvm-project/pull/67878
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libunwind] [AMDGPU] Add another SIFoldOperands instance after shrink (PR #67878)

2023-10-03 Thread Jay Foad via cfe-commits

jayfoad wrote:

I've just tested this on 1 graphics shaders and it seems to make no 
difference at all. I tried gfx900 and gfx1100. Can anyone else from the 
graphics team confirm this?

https://github.com/llvm/llvm-project/pull/67878
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Fix constant evaluating a captured variable in a lambda (PR #68090)

2023-10-03 Thread Shafik Yaghmour via cfe-commits

shafik wrote:

Can you write a more detailed description explaining what the problem is what 
the fix is.

This is what usually ends up in the git log and we want that to be as 
descriptive as possible for folks who use it to understand changes quickly 
without digging into details.

https://github.com/llvm/llvm-project/pull/68090
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] remove duplicate ModuleId alias (PR #67899)

2023-10-03 Thread Chuanqi Xu via cfe-commits

https://github.com/ChuanqiXu9 closed 
https://github.com/llvm/llvm-project/pull/67899
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 06a05f3 - [NFC] remove duplicate ModuleId alias (#67899)

2023-10-03 Thread via cfe-commits

Author: David Stone
Date: 2023-10-03T22:43:51+08:00
New Revision: 06a05f334698c10a60459d30b4074fabedf72c48

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

LOG: [NFC] remove duplicate ModuleId alias (#67899)

[clang] Remove duplicate `ModuleId` alias

Added: 


Modified: 
clang/lib/Lex/ModuleMap.cpp

Removed: 




diff  --git a/clang/lib/Lex/ModuleMap.cpp b/clang/lib/Lex/ModuleMap.cpp
index e8437572ebf4bf6..f65a5f145c04395 100644
--- a/clang/lib/Lex/ModuleMap.cpp
+++ b/clang/lib/Lex/ModuleMap.cpp
@@ -1551,8 +1551,6 @@ namespace clang {
 /// (or the end of the file).
 void skipUntil(MMToken::TokenKind K);
 
-using ModuleId = SmallVector, 2>;
-
 bool parseModuleId(ModuleId &Id);
 void parseModuleDecl();
 void parseExternModuleDecl();



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


[clang] Bugfix for chosing the correct deduction guide (PR #66487)

2023-10-03 Thread Erich Keane via cfe-commits

erichkeane wrote:

> The paper where this came from is: https://wg21.link/P0620R0. most of this 
> paper was already implemented. Where is the paper tracking doc I need to 
> update? https://clang.llvm.org/cxx_status.html claims this paper is 
> implemented. Sorry if the following questions are trivial, I'm new to this. 
> In the release note should I put it under [Bug Fixes to C++ 
> Support](https://github.com/llvm/llvm-project/blob/main/clang/docs/ReleaseNotes.rst#bug-fixes-to-c-support)
>  or [Bug Fixes in This 
> Version](https://github.com/llvm/llvm-project/blob/main/clang/docs/ReleaseNotes.rst#id88)?
> 
> Where should I reference the standard in the PR? In the Description?

cxx_status.html is the paper tracking doc, if we claim it was already 
implemented than there is nothing to do there.

For release notes, ForC++Support seems like the right area for me.

I've confirmed that P06020R0 is in N4659 (Final draft for C++17), so you're 
right, there is no version checking we have to do.  Thanks for doing the leg 
work here!


https://github.com/llvm/llvm-project/pull/66487
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] Bugfix for chosing the correct deduction guide (PR #66487)

2023-10-03 Thread Erich Keane via cfe-commits

erichkeane wrote:

> The paper where this came from is: https://wg21.link/P0620R0. most of this 
> paper was already implemented. Where is the paper tracking doc I need to 
> update? https://clang.llvm.org/cxx_status.html claims this paper is 
> implemented. Sorry if the following questions are trivial, I'm new to this. 
> In the release note should I put it under [Bug Fixes to C++ 
> Support](https://github.com/llvm/llvm-project/blob/main/clang/docs/ReleaseNotes.rst#bug-fixes-to-c-support)
>  or [Bug Fixes in This 
> Version](https://github.com/llvm/llvm-project/blob/main/clang/docs/ReleaseNotes.rst#id88)?
> 
> Where should I reference the standard in the PR? In the Description?

cxx_status.html is the paper tracking doc, if we claim it was already 
implemented than there is nothing to do there.

For release notes, ForC++Support seems like the right area for me.

I've confirmed that P06020R0 is in N4659 (Final draft for C++17), so you're 
right, there is no version checking we have to do.  Thanks for doing the leg 
work here!


https://github.com/llvm/llvm-project/pull/66487
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Avoid need for SLocEntryLoaded BitVector (PR #67960)

2023-10-03 Thread Giulio Eulisse via cfe-commits

https://github.com/ktf updated https://github.com/llvm/llvm-project/pull/67960

>From 9fde224de6baa5b1fb3713d810ce835d4456b457 Mon Sep 17 00:00:00 2001
From: Giulio Eulisse <10544+...@users.noreply.github.com>
Date: Fri, 29 Sep 2023 08:37:57 +0200
Subject: [PATCH 1/9] Avoid need for SLocEntryLoaded BitVector

The BitVector is currently used to keep track of which entries of
LoadedSLocEntryTable have been loaded. Such information can be stored in
the SLocEntry itself. Moreover, thanks to the fact that
LoadedSLocEntryTable is now a PagedVector, we can simply consider
elements of unmaterialised pages as not loaded.

This trades reducing the number of OffsetBits by one for reducing memory
usage of the SourceManager by LoadedSLocEntryTable.size()/8 bytes.
---
 clang/include/clang/Basic/SourceManager.h | 16 ++
 clang/lib/Basic/SourceManager.cpp | 27 ++-
 llvm/include/llvm/ADT/PagedVector.h   |  6 +
 3 files changed, 29 insertions(+), 20 deletions(-)

diff --git a/clang/include/clang/Basic/SourceManager.h 
b/clang/include/clang/Basic/SourceManager.h
index c1b24eec2759c71..d450280303d6785 100644
--- a/clang/include/clang/Basic/SourceManager.h
+++ b/clang/include/clang/Basic/SourceManager.h
@@ -474,9 +474,10 @@ static_assert(sizeof(FileInfo) <= sizeof(ExpansionInfo),
 /// SourceManager keeps an array of these objects, and they are uniquely
 /// identified by the FileID datatype.
 class SLocEntry {
-  static constexpr int OffsetBits = 8 * sizeof(SourceLocation::UIntTy) - 1;
+  static constexpr int OffsetBits = 8 * sizeof(SourceLocation::UIntTy) - 2;
   SourceLocation::UIntTy Offset : OffsetBits;
   SourceLocation::UIntTy IsExpansion : 1;
+  SourceLocation::UIntTy Loaded : 1;
   union {
 FileInfo File;
 ExpansionInfo Expansion;
@@ -489,6 +490,8 @@ class SLocEntry {
 
   bool isExpansion() const { return IsExpansion; }
   bool isFile() const { return !isExpansion(); }
+  [[nodiscard]] bool isLoaded() const { return Loaded; }
+  void setLoaded(bool Value) { Loaded = Value; }
 
   const FileInfo &getFile() const {
 assert(isFile() && "Not a file SLocEntry!");
@@ -716,13 +719,7 @@ class SourceManager : public RefCountedBase 
{
   /// The highest possible offset is 2^31-1 (2^63-1 for 64-bit source
   /// locations), so CurrentLoadedOffset starts at 2^31 (2^63 resp.).
   static const SourceLocation::UIntTy MaxLoadedOffset =
-  1ULL << (8 * sizeof(SourceLocation::UIntTy) - 1);
-
-  /// A bitmap that indicates whether the entries of LoadedSLocEntryTable
-  /// have already been loaded from the external source.
-  ///
-  /// Same indexing as LoadedSLocEntryTable.
-  llvm::BitVector SLocEntryLoaded;
+  1ULL << (8 * sizeof(SourceLocation::UIntTy) - 2);
 
   /// An external source for source location entries.
   ExternalSLocEntrySource *ExternalSLocEntries = nullptr;
@@ -1710,7 +1707,8 @@ class SourceManager : public 
RefCountedBase {
   const SrcMgr::SLocEntry &getLoadedSLocEntry(unsigned Index,
   bool *Invalid = nullptr) const {
 assert(Index < LoadedSLocEntryTable.size() && "Invalid index");
-if (SLocEntryLoaded[Index])
+if (LoadedSLocEntryTable.isMaterialized(Index) &&
+LoadedSLocEntryTable[Index].isLoaded())
   return LoadedSLocEntryTable[Index];
 return loadSLocEntry(Index, Invalid);
   }
diff --git a/clang/lib/Basic/SourceManager.cpp 
b/clang/lib/Basic/SourceManager.cpp
index 3066cc53dbfd878..20e3f1252ddf077 100644
--- a/clang/lib/Basic/SourceManager.cpp
+++ b/clang/lib/Basic/SourceManager.cpp
@@ -336,7 +336,6 @@ void SourceManager::clearIDTables() {
   MainFileID = FileID();
   LocalSLocEntryTable.clear();
   LoadedSLocEntryTable.clear();
-  SLocEntryLoaded.clear();
   LastLineNoFileIDQuery = FileID();
   LastLineNoContentCache = nullptr;
   LastFileIDLookup = FileID();
@@ -373,7 +372,8 @@ void SourceManager::initializeForReplay(const SourceManager 
&Old) {
 
   // Ensure all SLocEntries are loaded from the external source.
   for (unsigned I = 0, N = Old.LoadedSLocEntryTable.size(); I != N; ++I)
-if (!Old.SLocEntryLoaded[I])
+if (!Old.LoadedSLocEntryTable.isMaterialized(I) ||
+!Old.LoadedSLocEntryTable[I].isLoaded())
   Old.loadSLocEntry(I, nullptr);
 
   // Inherit any content cache data from the old source manager.
@@ -430,12 +430,14 @@ ContentCache &SourceManager::createMemBufferContentCache(
 
 const SrcMgr::SLocEntry &SourceManager::loadSLocEntry(unsigned Index,
   bool *Invalid) const {
-  assert(!SLocEntryLoaded[Index]);
+  assert(!LoadedSLocEntryTable.isMaterialized(Index) ||
+ !LoadedSLocEntryTable[Index].isLoaded());
   if (ExternalSLocEntries->ReadSLocEntry(-(static_cast(Index) + 2))) {
 if (Invalid)
   *Invalid = true;
 // If the file of the SLocEntry changed we could still have loaded it.
-if (!SLocEntryLoaded[Index]) {
+if (!LoadedSLocEntryTable.isMaterialized(Index) |

[clang] Avoid need for SLocEntryLoaded BitVector (PR #67960)

2023-10-03 Thread Giulio Eulisse via cfe-commits

https://github.com/ktf updated https://github.com/llvm/llvm-project/pull/67960

>From 9fde224de6baa5b1fb3713d810ce835d4456b457 Mon Sep 17 00:00:00 2001
From: Giulio Eulisse <10544+...@users.noreply.github.com>
Date: Fri, 29 Sep 2023 08:37:57 +0200
Subject: [PATCH 1/8] Avoid need for SLocEntryLoaded BitVector

The BitVector is currently used to keep track of which entries of
LoadedSLocEntryTable have been loaded. Such information can be stored in
the SLocEntry itself. Moreover, thanks to the fact that
LoadedSLocEntryTable is now a PagedVector, we can simply consider
elements of unmaterialised pages as not loaded.

This trades reducing the number of OffsetBits by one for reducing memory
usage of the SourceManager by LoadedSLocEntryTable.size()/8 bytes.
---
 clang/include/clang/Basic/SourceManager.h | 16 ++
 clang/lib/Basic/SourceManager.cpp | 27 ++-
 llvm/include/llvm/ADT/PagedVector.h   |  6 +
 3 files changed, 29 insertions(+), 20 deletions(-)

diff --git a/clang/include/clang/Basic/SourceManager.h 
b/clang/include/clang/Basic/SourceManager.h
index c1b24eec2759c71..d450280303d6785 100644
--- a/clang/include/clang/Basic/SourceManager.h
+++ b/clang/include/clang/Basic/SourceManager.h
@@ -474,9 +474,10 @@ static_assert(sizeof(FileInfo) <= sizeof(ExpansionInfo),
 /// SourceManager keeps an array of these objects, and they are uniquely
 /// identified by the FileID datatype.
 class SLocEntry {
-  static constexpr int OffsetBits = 8 * sizeof(SourceLocation::UIntTy) - 1;
+  static constexpr int OffsetBits = 8 * sizeof(SourceLocation::UIntTy) - 2;
   SourceLocation::UIntTy Offset : OffsetBits;
   SourceLocation::UIntTy IsExpansion : 1;
+  SourceLocation::UIntTy Loaded : 1;
   union {
 FileInfo File;
 ExpansionInfo Expansion;
@@ -489,6 +490,8 @@ class SLocEntry {
 
   bool isExpansion() const { return IsExpansion; }
   bool isFile() const { return !isExpansion(); }
+  [[nodiscard]] bool isLoaded() const { return Loaded; }
+  void setLoaded(bool Value) { Loaded = Value; }
 
   const FileInfo &getFile() const {
 assert(isFile() && "Not a file SLocEntry!");
@@ -716,13 +719,7 @@ class SourceManager : public RefCountedBase 
{
   /// The highest possible offset is 2^31-1 (2^63-1 for 64-bit source
   /// locations), so CurrentLoadedOffset starts at 2^31 (2^63 resp.).
   static const SourceLocation::UIntTy MaxLoadedOffset =
-  1ULL << (8 * sizeof(SourceLocation::UIntTy) - 1);
-
-  /// A bitmap that indicates whether the entries of LoadedSLocEntryTable
-  /// have already been loaded from the external source.
-  ///
-  /// Same indexing as LoadedSLocEntryTable.
-  llvm::BitVector SLocEntryLoaded;
+  1ULL << (8 * sizeof(SourceLocation::UIntTy) - 2);
 
   /// An external source for source location entries.
   ExternalSLocEntrySource *ExternalSLocEntries = nullptr;
@@ -1710,7 +1707,8 @@ class SourceManager : public 
RefCountedBase {
   const SrcMgr::SLocEntry &getLoadedSLocEntry(unsigned Index,
   bool *Invalid = nullptr) const {
 assert(Index < LoadedSLocEntryTable.size() && "Invalid index");
-if (SLocEntryLoaded[Index])
+if (LoadedSLocEntryTable.isMaterialized(Index) &&
+LoadedSLocEntryTable[Index].isLoaded())
   return LoadedSLocEntryTable[Index];
 return loadSLocEntry(Index, Invalid);
   }
diff --git a/clang/lib/Basic/SourceManager.cpp 
b/clang/lib/Basic/SourceManager.cpp
index 3066cc53dbfd878..20e3f1252ddf077 100644
--- a/clang/lib/Basic/SourceManager.cpp
+++ b/clang/lib/Basic/SourceManager.cpp
@@ -336,7 +336,6 @@ void SourceManager::clearIDTables() {
   MainFileID = FileID();
   LocalSLocEntryTable.clear();
   LoadedSLocEntryTable.clear();
-  SLocEntryLoaded.clear();
   LastLineNoFileIDQuery = FileID();
   LastLineNoContentCache = nullptr;
   LastFileIDLookup = FileID();
@@ -373,7 +372,8 @@ void SourceManager::initializeForReplay(const SourceManager 
&Old) {
 
   // Ensure all SLocEntries are loaded from the external source.
   for (unsigned I = 0, N = Old.LoadedSLocEntryTable.size(); I != N; ++I)
-if (!Old.SLocEntryLoaded[I])
+if (!Old.LoadedSLocEntryTable.isMaterialized(I) ||
+!Old.LoadedSLocEntryTable[I].isLoaded())
   Old.loadSLocEntry(I, nullptr);
 
   // Inherit any content cache data from the old source manager.
@@ -430,12 +430,14 @@ ContentCache &SourceManager::createMemBufferContentCache(
 
 const SrcMgr::SLocEntry &SourceManager::loadSLocEntry(unsigned Index,
   bool *Invalid) const {
-  assert(!SLocEntryLoaded[Index]);
+  assert(!LoadedSLocEntryTable.isMaterialized(Index) ||
+ !LoadedSLocEntryTable[Index].isLoaded());
   if (ExternalSLocEntries->ReadSLocEntry(-(static_cast(Index) + 2))) {
 if (Invalid)
   *Invalid = true;
 // If the file of the SLocEntry changed we could still have loaded it.
-if (!SLocEntryLoaded[Index]) {
+if (!LoadedSLocEntryTable.isMaterialized(Index) |

[PATCH] D156565: Diagnose use of VLAs in C++ by default

2023-10-03 Thread Tom Honermann via Phabricator via cfe-commits
tahonermann added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:147-149
+def ext_vla_cxx_static_assert : ExtWarn<
+  "variable length arrays in C++ are a Clang extension; did you mean to use "
+  "'static_assert'?">, InGroup;

aaron.ballman wrote:
> tahonermann wrote:
> > I find the "did you mean to use 'static_assert'" phrasing awkward here 
> > since it is highly unlikely that someone intended to write 
> > `static_assert(x)` and instead wrote `int my_assert[x ? 1 : -1]`. Perhaps 
> > something like this?
> > 
> > "variable length arrays in C++ are a Clang extension; 'static_assert' can 
> > be used in this case".
> Eh, I'm on the fence. We're consistent about asking users "did you mean X?" 
> in our diagnostics and this follows the same pattern. "Did you mean to use X" 
> is not "is this a typo for X?" but "were you aware you could do X instead?" 
> So yeah, the wording is a bit awkward, but it's consistent with other 
> diagnostics and not really wrong either. Do you have strong feelings?
No, I don't have strong feelings on this.

I did recognize use of the widely used "did you mean" pattern, but my 
impression with those has been that they are generally employed in situations 
where similar syntax is involved (e.g., misspelled name, `.` vs `->`, `return` 
vs `co_return`, etc...) or where there might be some missing syntax (e.g., `()` 
following a function name or a missing `;`); cases where the programmer is 
likely to response "oh, yes I did!". This feels different since it is 
suggesting use of a distinct feature.


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

https://reviews.llvm.org/D156565

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


[clang] Avoid need for SLocEntryLoaded BitVector (PR #67960)

2023-10-03 Thread Vassil Vassilev via cfe-commits


@@ -489,6 +490,8 @@ class SLocEntry {
 
   bool isExpansion() const { return IsExpansion; }
   bool isFile() const { return !isExpansion(); }
+  bool isLoaded() const { return Loaded; }
+  void setLoaded(bool Value) { Loaded = Value; }

vgvassilev wrote:

```suggestion
  bool isLoaded() const { return IsLoaded; }
  void setLoaded(bool Value) { IsLoaded = Value; }
```

https://github.com/llvm/llvm-project/pull/67960
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Avoid need for SLocEntryLoaded BitVector (PR #67960)

2023-10-03 Thread Vassil Vassilev via cfe-commits


@@ -474,9 +474,10 @@ static_assert(sizeof(FileInfo) <= sizeof(ExpansionInfo),
 /// SourceManager keeps an array of these objects, and they are uniquely
 /// identified by the FileID datatype.
 class SLocEntry {
-  static constexpr int OffsetBits = 8 * sizeof(SourceLocation::UIntTy) - 1;
+  static constexpr int OffsetBits = 8 * sizeof(SourceLocation::UIntTy) - 2;
   SourceLocation::UIntTy Offset : OffsetBits;
   SourceLocation::UIntTy IsExpansion : 1;
+  SourceLocation::UIntTy Loaded : 1;

vgvassilev wrote:

```suggestion
  SourceLocation::UIntTy IsLoaded : 1;
```

https://github.com/llvm/llvm-project/pull/67960
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [RISCV] Update Zfa extension version to 1.0 (PR #67964)

2023-10-03 Thread via cfe-commits

github-actions[bot] wrote:




:warning: C/C++ code formatter, clang-format found issues in your code. 
:warning:



You can test this locally with the following command:


``bash
git-clang-format --diff b1295dd5c923c6828775406b4063de1531fd4782 
f21c479811de5cb476ef8d2abe0265b1bf8ea24f -- clang/test/Driver/riscv-arch.c 
clang/test/Preprocessor/riscv-target-features.c 
llvm/lib/Support/RISCVISAInfo.cpp llvm/unittests/Support/RISCVISAInfoTest.cpp
``





View the diff from clang-format here.


``diff
diff --git a/llvm/unittests/Support/RISCVISAInfoTest.cpp 
b/llvm/unittests/Support/RISCVISAInfoTest.cpp
index 4eeaab727c5c..f9cccb85270a 100644
--- a/llvm/unittests/Support/RISCVISAInfoTest.cpp
+++ b/llvm/unittests/Support/RISCVISAInfoTest.cpp
@@ -630,7 +630,7 @@ TEST(getTargetFeatureForExtension, 
RetrieveTargetFeatureFromOneExt) {
 
 TEST(RiscvExtensionsHelp, CheckExtensions) {
   std::string ExpectedOutput =
-R"(All available -march extensions for RISC-V
+  R"(All available -march extensions for RISC-V
 
 NameVersion   Description
 i   2.1   This is a long dummy description

``




https://github.com/llvm/llvm-project/pull/67964
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [diag] Silence `-Wfixed-enum-extension` in C23 (PR #68060)

2023-10-03 Thread Erich Keane via cfe-commits


@@ -5019,7 +5019,7 @@ void Parser::ParseEnumSpecifier(SourceLocation StartLoc, 
DeclSpec &DS,
 else if (getLangOpts().MicrosoftExt)
   Diag(ColonLoc, diag::ext_ms_c_enum_fixed_underlying_type)
   << BaseRange;
-else
+else if (!getLangOpts().C23)

erichkeane wrote:

Do we want C23 mode handled higher up?  At least above `MicrosoftExt`?  What if 
the person is compiling in C23 mode with Microsoft Extensions, they'd get the 
above warning incorrectly.

https://github.com/llvm/llvm-project/pull/68060
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D133361: [BPF] Attribute preserve_static_offset for structs

2023-10-03 Thread Erich Keane via Phabricator via cfe-commits
erichkeane accepted this revision.
erichkeane added a comment.
This revision is now accepted and ready to land.

2 nits on the CFE, else LGTM!  Obviously you still need an LLVM reviewer for 
the backend changes.




Comment at: clang/lib/CodeGen/CGExpr.cpp:3701
+  QualType PointeeType = E->getType()->getPointeeType();
+  if (PointeeType.isNull())
+return false;

We override `operator bool` to make this work.



Comment at: clang/lib/CodeGen/CGExpr.cpp:3703
+return false;
+  if (auto *BaseDecl = PointeeType->getAsRecordDecl())
+return hasBPFPreserveStaticOffset(BaseDecl);

if possible?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133361

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


[clang] Avoid need for SLocEntryLoaded BitVector (PR #67960)

2023-10-03 Thread Jakub Kuderski via cfe-commits

https://github.com/kuhar commented:

The ADT change looks good to me, I'm not familiar with the clang code though.

https://github.com/llvm/llvm-project/pull/67960
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [RISCV][AArch64] Don't allow -mvscale-min/max options to be passed to the clang driver. (PR #68065)

2023-10-03 Thread Craig Topper via cfe-commits

https://github.com/topperc closed 
https://github.com/llvm/llvm-project/pull/68065
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 8092933 - [RISCV][AArch64] Don't allow -mvscale-min/max options to be passed to the clang driver. (#68065)

2023-10-03 Thread via cfe-commits

Author: Craig Topper
Date: 2023-10-03T07:26:08-07:00
New Revision: 8092933246507a7b6c4385afbf0b9750a6d00de9

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

LOG: [RISCV][AArch64] Don't allow -mvscale-min/max options to be passed to the 
clang driver. (#68065)

The driver doesn't have code to pass these down to cc1. It just prints
an unused option warning. Remove them from the driver.

Added: 


Modified: 
clang/include/clang/Driver/Options.td

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index ff2130c93f28ea0..61e0729974c24d1 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -4589,13 +4589,11 @@ def msve_vector_bits_EQ : Joined<["-"], 
"msve-vector-bits=">, Group,
   MarshallingInfoInt>;
 def mvscale_max_EQ : Joined<["-"], "mvscale-max=">,
-  Group, Flags<[NoXarchOption]>,
-  Visibility<[ClangOption, CC1Option, FC1Option]>,
+  Visibility<[CC1Option, FC1Option]>,
   HelpText<"Specify the vscale maximum. Defaults to the"
" vector length agnostic value of \"0\". (AArch64/RISC-V only)">,
   MarshallingInfoInt>;



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


[clang] [RISCV] Update Zfa extension version to 1.0 (PR #67964)

2023-10-03 Thread Alex Bradbury via cfe-commits

https://github.com/asb updated https://github.com/llvm/llvm-project/pull/67964

>From 79ab61e07a01e503f22e717c4b0e64b7741c59a0 Mon Sep 17 00:00:00 2001
From: Alex Bradbury 
Date: Mon, 2 Oct 2023 11:06:44 +0100
Subject: [PATCH 1/3] [RISCV] Update Zfa extension version to 1.0

The Zfa specification was recently ratified
. This
commit bumps the version to 1.0, but leaves it as an experimental
extension (to be done in a follow-on patch), so reviews can focus on
confirming there haven't been spec changes we have missed (which as
noted below, is more difficult than usual).

Because the development of the Zfa spec overlapped with the transition
of riscv-isa-manual from LaTeX to AsciiDoc, it's more difficult than
usual to confirm version changes. The linked PDF in RISCVUsage is for
some reason a 404. Key commit histories to review are:
* Changes to zfa.adoc on the main branch
  
* Changes to zfa.tex on the now defunct latex branch
  

>From reviewing these, I believe there have been no changes to the spec
since version 0.1/0.2 (sadly the AsciiDoc and LaTeX versions of the spec
are inconsistent about version numbering).

There hasn't been a GitHub release of the spec since Zfa was ratified
(though I've requested one
), so RISCVUsage
is updated to link to the current Zfa.adoc. I don't think we need to
block on this, as we expect to shortly move Zfa to non-experimental, at
which point we don't link to individual spec documents in RISCVUsage.
---
 clang/test/Driver/riscv-arch.c  | 4 ++--
 clang/test/Preprocessor/riscv-target-features.c | 6 +++---
 llvm/docs/RISCVUsage.rst| 2 +-
 llvm/docs/ReleaseNotes.rst  | 1 +
 llvm/lib/Support/RISCVISAInfo.cpp   | 2 +-
 llvm/test/CodeGen/RISCV/attributes.ll   | 4 ++--
 llvm/test/MC/RISCV/attribute-arch.s | 4 ++--
 7 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/clang/test/Driver/riscv-arch.c b/clang/test/Driver/riscv-arch.c
index 92a6a59cba2317c..4896c0184507dd4 100644
--- a/clang/test/Driver/riscv-arch.c
+++ b/clang/test/Driver/riscv-arch.c
@@ -385,9 +385,9 @@
 // RUN: not %clang --target=riscv32-unknown-elf -march=rv32izfa0p1 
-menable-experimental-extensions -### %s \
 // RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32-EXPERIMENTAL-BADVERS 
%s
 // RV32-EXPERIMENTAL-BADVERS: error: invalid arch name 'rv32izfa0p1'
-// RV32-EXPERIMENTAL-BADVERS: unsupported version number 0.1 for experimental 
extension 'zfa' (this compiler supports 0.2)
+// RV32-EXPERIMENTAL-BADVERS: unsupported version number 0.1 for experimental 
extension 'zfa' (this compiler supports 1.0)
 
-// RUN: %clang --target=riscv32-unknown-elf -march=rv32izfa0p2 
-menable-experimental-extensions -### %s \
+// RUN: %clang --target=riscv32-unknown-elf -march=rv32izfa1p0 
-menable-experimental-extensions -### %s \
 // RUN: -fsyntax-only 2>&1 | FileCheck 
-check-prefix=RV32-EXPERIMENTAL-GOODVERS %s
 // RV32-EXPERIMENTAL-GOODVERS: "-target-feature" "+experimental-zfa"
 
diff --git a/clang/test/Preprocessor/riscv-target-features.c 
b/clang/test/Preprocessor/riscv-target-features.c
index 4dd83cfa0620b90..4b9ec423200017f 100644
--- a/clang/test/Preprocessor/riscv-target-features.c
+++ b/clang/test/Preprocessor/riscv-target-features.c
@@ -1002,12 +1002,12 @@
 // CHECK-ZACAS-EXT: __riscv_zacas 100{{$}}
 
 // RUN: %clang --target=riscv32-unknown-linux-gnu 
-menable-experimental-extensions \
-// RUN: -march=rv32izfa0p2 -x c -E -dM %s \
+// RUN: -march=rv32izfa1p0 -x c -E -dM %s \
 // RUN: -o - | FileCheck --check-prefix=CHECK-ZFA-EXT %s
 // RUN: %clang --target=riscv64-unknown-linux-gnu 
-menable-experimental-extensions \
-// RUN: -march=rv64izfa0p2 -x c -E -dM %s \
+// RUN: -march=rv64izfa1p0 -x c -E -dM %s \
 // RUN: -o - | FileCheck --check-prefix=CHECK-ZFA-EXT %s
-// CHECK-ZFA-EXT: __riscv_zfa 2000{{$}}
+// CHECK-ZFA-EXT: __riscv_zfa 100{{$}}
 
 // RUN: %clang --target=riscv32 -menable-experimental-extensions \
 // RUN: -march=rv32izfbfmin0p8 -x c -E -dM %s \
diff --git a/llvm/docs/RISCVUsage.rst b/llvm/docs/RISCVUsage.rst
index 8d12d58738c609a..647c4c49500c161 100644
--- a/llvm/docs/RISCVUsage.rst
+++ b/llvm/docs/RISCVUsage.rst
@@ -197,7 +197,7 @@ The primary goal of experimental support is to assist in 
the process of ratifica
   LLVM implements the `1.0-rc1 draft specification 
`_.
 
 ``experimental-zfa``
-  LLVM implements the `0.2 draft specification 
`__.
+  LLVM implements the `1.0 specification 


[clang] [clang][driver] Use platform specific calls to get the executable absolute path (PR #68091)

2023-10-03 Thread Björn Pettersson via cfe-commits

https://github.com/bjope edited https://github.com/llvm/llvm-project/pull/68091
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][driver] Use platform specific calls to get the executable absolute path (PR #68091)

2023-10-03 Thread Björn Pettersson via cfe-commits


@@ -331,6 +340,56 @@ static void SetInstallDir(SmallVectorImpl 
&argv,
   // path being a symlink.
   SmallString<128> InstalledPath(argv[0]);
 
+#if defined(__linux__)

bjope wrote:

I was kind of thinking the same. And then started to wonder about why 
SetInstallDir says "We do this manually, because we want to support that path 
being a symlink.". I don't really understand if that indicates that the 
installed dir should be set based on the symlinks path or not.

Afaict `Driver::ClangExecutable` already is computed via `getMainExecutable()`, 
right. 
And the Driver c'tor is setting both `Driver::Dir` and `Driver::InstalledDir` 
based on the path of the clang executable.

So is the problem here is that SetInstallDir is called after the above (having 
contructed `TheDriver`). Resulting in `InstalledDir` being changed into being 
relative to the symlink?

https://github.com/llvm/llvm-project/pull/68091
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Extension: allow recursive macros (PR #65851)

2023-10-03 Thread via cfe-commits

https://github.com/kelbon updated 
https://github.com/llvm/llvm-project/pull/65851

>From d10ce5dd9e49fe85eac2e1f93a65cb27b511a71f Mon Sep 17 00:00:00 2001
From: Kelbon Nik 
Date: Sat, 9 Sep 2023 17:51:15 +0400
Subject: [PATCH 01/18] add define2 pp directive

---
 clang/include/clang/Basic/TokenKinds.def |  1 +
 clang/include/clang/Lex/MacroInfo.h  | 19 +--
 clang/include/clang/Lex/Preprocessor.h   |  2 +-
 clang/lib/Basic/IdentifierTable.cpp  |  2 ++
 clang/lib/Format/WhitespaceManager.cpp   |  2 +-
 clang/lib/Lex/MacroInfo.cpp  |  3 ++-
 clang/lib/Lex/PPDirectives.cpp   | 16 +++-
 7 files changed, 27 insertions(+), 18 deletions(-)

diff --git a/clang/include/clang/Basic/TokenKinds.def 
b/clang/include/clang/Basic/TokenKinds.def
index 72e8df8c793a7b6..b227a6a5632f496 100644
--- a/clang/include/clang/Basic/TokenKinds.def
+++ b/clang/include/clang/Basic/TokenKinds.def
@@ -115,6 +115,7 @@ PPKEYWORD(__include_macros)
 
 // C99 6.10.3 - Macro Replacement.
 PPKEYWORD(define)
+PPKEYWORD(define2)
 PPKEYWORD(undef)
 
 // C99 6.10.4 - Line Control.
diff --git a/clang/include/clang/Lex/MacroInfo.h 
b/clang/include/clang/Lex/MacroInfo.h
index 00c1c3866bbd9ca..4f0c8e987610e50 100644
--- a/clang/include/clang/Lex/MacroInfo.h
+++ b/clang/include/clang/Lex/MacroInfo.h
@@ -102,6 +102,10 @@ class MacroInfo {
   /// like \#define A A.
   bool IsDisabled : 1;
 
+  // True if 'define2' used,
+  // ignores 'IsDisabled' and enables expansion anyway
+  bool AllowRecurse : 1;
+
   /// True if this macro is either defined in the main file and has
   /// been used, or if it is not defined in the main file.
   ///
@@ -278,18 +282,13 @@ class MacroInfo {
   /// Return true if this macro is enabled.
   ///
   /// In other words, that we are not currently in an expansion of this macro.
-  bool isEnabled() const { return !IsDisabled; }
-
-  void EnableMacro() {
-assert(IsDisabled && "Cannot enable an already-enabled macro!");
-IsDisabled = false;
-  }
+  bool isEnabled() const { return AllowRecurse || !IsDisabled; }
+  void setAllowRecursive(bool Allow) { AllowRecurse = Allow; }
+  bool isAllowRecurse() const { return AllowRecurse; }
 
-  void DisableMacro() {
-assert(!IsDisabled && "Cannot disable an already-disabled macro!");
-IsDisabled = true;
-  }
+  void EnableMacro() { IsDisabled = false; }
 
+  void DisableMacro() { IsDisabled = true; }
   /// Determine whether this macro was used for a header guard.
   bool isUsedForHeaderGuard() const { return UsedForHeaderGuard; }
 
diff --git a/clang/include/clang/Lex/Preprocessor.h 
b/clang/include/clang/Lex/Preprocessor.h
index 575d08b83fd3a02..01eac0939fe9e21 100644
--- a/clang/include/clang/Lex/Preprocessor.h
+++ b/clang/include/clang/Lex/Preprocessor.h
@@ -2754,7 +2754,7 @@ class Preprocessor {
   void replayPreambleConditionalStack();
 
   // Macro handling.
-  void HandleDefineDirective(Token &Tok, bool ImmediatelyAfterHeaderGuard);
+  void HandleDefineDirective(Token &Tok, bool ImmediatelyAfterHeaderGuard, 
bool AllowRecurse);
   void HandleUndefDirective();
 
   // Conditional Inclusion.
diff --git a/clang/lib/Basic/IdentifierTable.cpp 
b/clang/lib/Basic/IdentifierTable.cpp
index e5599d545541085..7300825ff6b826a 100644
--- a/clang/lib/Basic/IdentifierTable.cpp
+++ b/clang/lib/Basic/IdentifierTable.cpp
@@ -431,6 +431,8 @@ tok::PPKeywordKind IdentifierInfo::getPPKeywordID() const {
   unsigned Len = getLength();
   if (Len < 2) return tok::pp_not_keyword;
   const char *Name = getNameStart();
+  if (std::string_view(Name, Len) == "define2")
+return tok::pp_define2;
   switch (HASH(Len, Name[0], Name[2])) {
   default: return tok::pp_not_keyword;
   CASE( 2, 'i', '\0', if);
diff --git a/clang/lib/Format/WhitespaceManager.cpp 
b/clang/lib/Format/WhitespaceManager.cpp
index b7bd8d27dc976b1..d8ab76d6761553e 100644
--- a/clang/lib/Format/WhitespaceManager.cpp
+++ b/clang/lib/Format/WhitespaceManager.cpp
@@ -743,7 +743,7 @@ void WhitespaceManager::alignConsecutiveMacros() {
 if (!Current || Current->isNot(tok::identifier))
   return false;
 
-if (!Current->Previous || Current->Previous->isNot(tok::pp_define))
+if (!Current->Previous || !Current->Previous->isOneOf(tok::pp_define, 
tok::pp_define2))
   return false;
 
 // For a macro function, 0 spaces are required between the
diff --git a/clang/lib/Lex/MacroInfo.cpp b/clang/lib/Lex/MacroInfo.cpp
index 39bb0f44eff25ba..9c3619c7c909304 100644
--- a/clang/lib/Lex/MacroInfo.cpp
+++ b/clang/lib/Lex/MacroInfo.cpp
@@ -50,7 +50,7 @@ static_assert(MacroInfoSizeChecker::AsExpected,
 MacroInfo::MacroInfo(SourceLocation DefLoc)
 : Location(DefLoc), IsDefinitionLengthCached(false), IsFunctionLike(false),
   IsC99Varargs(false), IsGNUVarargs(false), IsBuiltinMacro(false),
-  HasCommaPasting(false), IsDisabled(false), IsUsed(false),
+  HasCommaPasting(false), IsDisabled(false), AllowRecurse(false), 
IsUsed(false),
   IsAllowRedefinitions

[clang] [clang] Implement constexpr bit_cast for vectors (PR #66894)

2023-10-03 Thread via cfe-commits

https://github.com/DaMatrix updated 
https://github.com/llvm/llvm-project/pull/66894

>From f24c57fdd4e9cd3208c661d2f716c0251cff1c5e Mon Sep 17 00:00:00 2001
From: DaPorkchop_ 
Date: Sun, 13 Aug 2023 22:39:12 +0200
Subject: [PATCH] [clang] Implement constexpr bit_cast for vectors

---
 .../include/clang/Basic/DiagnosticASTKinds.td |   3 +
 clang/lib/AST/ExprConstant.cpp| 247 +++---
 .../SemaCXX/constexpr-builtin-bit-cast.cpp|  61 +
 3 files changed, 217 insertions(+), 94 deletions(-)

diff --git a/clang/include/clang/Basic/DiagnosticASTKinds.td 
b/clang/include/clang/Basic/DiagnosticASTKinds.td
index d2656310e79c9b8..3f06e18783dd558 100644
--- a/clang/include/clang/Basic/DiagnosticASTKinds.td
+++ b/clang/include/clang/Basic/DiagnosticASTKinds.td
@@ -326,6 +326,9 @@ def note_constexpr_bit_cast_invalid_type : Note<
   "%select{type|member}1 is not allowed in a constant expression">;
 def note_constexpr_bit_cast_invalid_subtype : Note<
   "invalid type %0 is a %select{member|base}1 of %2">;
+def note_constexpr_bit_cast_invalid_vector : Note<
+  "bit_cast involving type %0 is not allowed in a constant expression; "
+  "element size %1 * element count %2 is not a multiple of the byte size %3">;
 def note_constexpr_bit_cast_indet_dest : Note<
   "indeterminate value can only initialize an object of type 'unsigned char'"
   "%select{, 'char',|}1 or 'std::byte'; %0 is invalid">;
diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index a142ea7c47a4730..f7280095e89faee 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -2732,53 +2732,6 @@ static bool truncateBitfieldValue(EvalInfo &Info, const 
Expr *E,
   return true;
 }
 
-static bool EvalAndBitcastToAPInt(EvalInfo &Info, const Expr *E,
-  llvm::APInt &Res) {
-  APValue SVal;
-  if (!Evaluate(SVal, Info, E))
-return false;
-  if (SVal.isInt()) {
-Res = SVal.getInt();
-return true;
-  }
-  if (SVal.isFloat()) {
-Res = SVal.getFloat().bitcastToAPInt();
-return true;
-  }
-  if (SVal.isVector()) {
-QualType VecTy = E->getType();
-unsigned VecSize = Info.Ctx.getTypeSize(VecTy);
-QualType EltTy = VecTy->castAs()->getElementType();
-unsigned EltSize = Info.Ctx.getTypeSize(EltTy);
-bool BigEndian = Info.Ctx.getTargetInfo().isBigEndian();
-Res = llvm::APInt::getZero(VecSize);
-for (unsigned i = 0; i < SVal.getVectorLength(); i++) {
-  APValue &Elt = SVal.getVectorElt(i);
-  llvm::APInt EltAsInt;
-  if (Elt.isInt()) {
-EltAsInt = Elt.getInt();
-  } else if (Elt.isFloat()) {
-EltAsInt = Elt.getFloat().bitcastToAPInt();
-  } else {
-// Don't try to handle vectors of anything other than int or float
-// (not sure if it's possible to hit this case).
-Info.FFDiag(E, diag::note_invalid_subexpr_in_const_expr);
-return false;
-  }
-  unsigned BaseEltSize = EltAsInt.getBitWidth();
-  if (BigEndian)
-Res |= EltAsInt.zextOrTrunc(VecSize).rotr(i*EltSize+BaseEltSize);
-  else
-Res |= EltAsInt.zextOrTrunc(VecSize).rotl(i*EltSize);
-}
-return true;
-  }
-  // Give up if the input isn't an int, float, or vector.  For example, we
-  // reject "(v4i16)(intptr_t)&a".
-  Info.FFDiag(E, diag::note_invalid_subexpr_in_const_expr);
-  return false;
-}
-
 /// Perform the given integer operation, which is known to need at most 
BitWidth
 /// bits, and check for overflow in the original type (if that type was not an
 /// unsigned type).
@@ -7008,10 +6961,11 @@ class APValueToBufferConverter {
   return visitArray(Val, Ty, Offset);
 case APValue::Struct:
   return visitRecord(Val, Ty, Offset);
+case APValue::Vector:
+  return visitVector(Val, Ty, Offset);
 
 case APValue::ComplexInt:
 case APValue::ComplexFloat:
-case APValue::Vector:
 case APValue::FixedPoint:
   // FIXME: We should support these.
 
@@ -7098,6 +7052,61 @@ class APValueToBufferConverter {
 return true;
   }
 
+  bool visitVector(const APValue &Val, QualType Ty, CharUnits Offset) {
+const VectorType *VTy = Ty->castAs();
+QualType EltTy = VTy->getElementType();
+unsigned NElts = VTy->getNumElements();
+unsigned EltSize =
+VTy->isExtVectorBoolType() ? 1 : Info.Ctx.getTypeSize(EltTy);
+
+if ((NElts * EltSize) % Info.Ctx.getCharWidth() != 0) {
+  // The vector's size in bits is not a multiple of the target's byte size,
+  // so its layout is unspecified. For now, we'll simply treat these cases
+  // as unsupported (this should only be possible with OpenCL bool vectors
+  // whose element count isn't a multiple of the byte size).
+  Info.FFDiag(BCE->getBeginLoc(),
+  diag::note_constexpr_bit_cast_invalid_vector)
+  << Ty.getCanonicalType() << EltSize << NElts
+  << Info.Ctx.getCharWidth();
+  return false;
+}
+
+if (VTy->isExtV

[clang] [Inliner] Improve propagation of return attributes. (PR #67756)

2023-10-03 Thread Nikita Popov via cfe-commits

nikic wrote:

It looks like x86-bswap.c still has the C++ guarded code in it.

Any thoughts on

> Though I think we might be better off passing `-no-enable-noundef-analysis` 
> to these tests, as noundef is really not what they want to test.

to avoid the test duplication?

https://github.com/llvm/llvm-project/pull/67756
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Complex div (PR #68106)

2023-10-03 Thread Zahira Ammarguellat via cfe-commits

https://github.com/zahiraam closed 
https://github.com/llvm/llvm-project/pull/68106
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D156565: Diagnose use of VLAs in C++ by default

2023-10-03 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman marked an inline comment as done.
aaron.ballman added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:147-149
+def ext_vla_cxx_static_assert : ExtWarn<
+  "variable length arrays in C++ are a Clang extension; did you mean to use "
+  "'static_assert'?">, InGroup;

tahonermann wrote:
> I find the "did you mean to use 'static_assert'" phrasing awkward here since 
> it is highly unlikely that someone intended to write `static_assert(x)` and 
> instead wrote `int my_assert[x ? 1 : -1]`. Perhaps something like this?
> 
> "variable length arrays in C++ are a Clang extension; 'static_assert' can be 
> used in this case".
Eh, I'm on the fence. We're consistent about asking users "did you mean X?" in 
our diagnostics and this follows the same pattern. "Did you mean to use X" is 
not "is this a typo for X?" but "were you aware you could do X instead?" So 
yeah, the wording is a bit awkward, but it's consistent with other diagnostics 
and not really wrong either. Do you have strong feelings?



Comment at: clang/lib/Sema/SemaType.cpp:2617
+  } else if (getLangOpts().CPlusPlus) {
+if (getLangOpts().CPlusPlus11 && IsStaticAssertLike(ArraySize, Context))
+  VLADiag = getLangOpts().GNUMode

jyknight wrote:
> aaron.ballman wrote:
> > jyknight wrote:
> > > Not sure whether to actually care, since C++98 is so old now, but, having 
> > > `-Wno-vla-extension-static-assert` work in C++98 mode seems like it'd be 
> > > quite useful, exactly because the usage cannot trivially be replaced by a 
> > > static_assert. So it's a bit unfortunate that we don't distinguish it 
> > > there.
> > > 
> > > Perhaps we should emit the same diagnostics in both 98/11, but with 
> > > slightly different text in 98?
> > That's effectively what we're doing here, right?
> > 
> > C++98 is told "variable length arrays (in C++) are a Clang extension" and 
> > in C++11 they're told "variable length arrays (in C++) are a Clang 
> > extension; did you mean to use 'static_assert'?"
> > 
> > Or am I misunderstanding you?
> In this patch, in C++98 mode, we diagnose everything under the flag 
> -Wvla-extension, and never under the flag -Wvla-extension-static-assert. My 
> point was that we ought to diagnose static-assert-like-VLAs under the 
> -Wvla-extension-static-assert flag even in C++98 mode.
Ah okay! That does make sense but would be hard to pull off. Because the 
existing code is based around picking which diagnostic ID to use, all of the 
related diagnostic IDs need to take the same kind of streaming arguments, that 
makes passing additional arguments to control `%select` behavior really awkward 
in this case. So I'd have to add an entire new diagnostic ID for the C++98 case 
and I'm not certain it's really worth it. e.g.
```
def ext_vla : Extension<"variable length arrays are a C99 feature">,
  InGroup;
// In C++ language modes, we warn by default as an extension, while in GNU++
// language modes, we warn as an extension but add the warning group to -Wall.
def ext_vla_cxx : ExtWarn<
  "variable length arrays in C++ are a Clang extension">,
  InGroup;
def ext_vla_cxx_in_gnu_mode : Extension,
  InGroup;
def ext_vla_cxx_static_assert : ExtWarn<
  "variable length arrays in C++ are a Clang extension; did you mean to use "
  "'static_assert'?">, InGroup;
def ext_vla_cxx_in_gnu_mode_static_assert : Extension<
  ext_vla_cxx_static_assert.Summary>, InGroup;
def ext_vla_cxx98_static_assert : ExtWarn<
  ext_vla_cxx.Summary>, InGroup;
def ext_vla_cxx98_in_gnu_mode_static_assert : Extension<
  ext_vla_cxx98_static_assert.Summary>, InGroup;
def warn_vla_used : Warning<"variable length array used">,
  InGroup, DefaultIgnore;
```
It's not the end of the world, but do you think it's worth it?



Comment at: clang/test/SemaCXX/vla-ext-diag.cpp:34
+   off-note {{function parameter 'n' with 
unknown value cannot be used in a constant expression}}
+}

tahonermann wrote:
> Perhaps add a test where the conditional expression is parenthesized.
>   int array4[(n ? 1 : -1)]; 
> 
> Adding tests for one side being of size 0 might be useful to demonstrate that 
> those are not intended to trigger the "use 'static_assert'" diagnostic. I 
> know some compilers don't diagnose on a size of 0 and so the static assert 
> idiom generally requires a negative number.
>   int array5[n ? 1 : 0]; // ok?
Good call on the additional test cases!


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

https://reviews.llvm.org/D156565

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


[clang] Complex div (PR #68106)

2023-10-03 Thread Zahira Ammarguellat via cfe-commits

https://github.com/zahiraam updated 
https://github.com/llvm/llvm-project/pull/68106

>From 2e06d07abe22526188c71c6e00ca9037620c9259 Mon Sep 17 00:00:00 2001
From: Ammarguellat 
Date: Tue, 3 Oct 2023 05:43:48 -0700
Subject: [PATCH 1/5] Testing.

---
 clang/lib/AST/Expr.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp
index 4f3837371b3fc5e..0d955c028f11454 100644
--- a/clang/lib/AST/Expr.cpp
+++ b/clang/lib/AST/Expr.cpp
@@ -726,7 +726,7 @@ StringRef 
PredefinedExpr::getIdentKindName(PredefinedExpr::IdentKind IK) {
 // expr" policy instead.
 std::string PredefinedExpr::ComputeName(IdentKind IK, const Decl *CurrentDecl) 
{
   ASTContext &Context = CurrentDecl->getASTContext();
-
+  // This is a just a test.
   if (IK == PredefinedExpr::FuncDName) {
 if (const NamedDecl *ND = dyn_cast(CurrentDecl)) {
   std::unique_ptr MC;

>From 2ffed4e994fd19b8f1929f15fce549a4e2f0d60c Mon Sep 17 00:00:00 2001
From: Ammarguellat 
Date: Tue, 3 Oct 2023 05:45:00 -0700
Subject: [PATCH 2/5] Testing again.

---
 clang/lib/AST/Expr.cpp | 1 +
 1 file changed, 1 insertion(+)

diff --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp
index 0d955c028f11454..ba2592d1e0d8d24 100644
--- a/clang/lib/AST/Expr.cpp
+++ b/clang/lib/AST/Expr.cpp
@@ -727,6 +727,7 @@ StringRef 
PredefinedExpr::getIdentKindName(PredefinedExpr::IdentKind IK) {
 std::string PredefinedExpr::ComputeName(IdentKind IK, const Decl *CurrentDecl) 
{
   ASTContext &Context = CurrentDecl->getASTContext();
   // This is a just a test.
+  // This is just yet another test.
   if (IK == PredefinedExpr::FuncDName) {
 if (const NamedDecl *ND = dyn_cast(CurrentDecl)) {
   std::unique_ptr MC;

>From 2c964ac67089bbf5b18f07bc7600a4f042a28e15 Mon Sep 17 00:00:00 2001
From: Ammarguellat 
Date: Tue, 3 Oct 2023 06:57:34 -0700
Subject: [PATCH 3/5] Testing.

---
 clang/test/Sema/t1.c | 1 +
 1 file changed, 1 insertion(+)
 create mode 100644 clang/test/Sema/t1.c

diff --git a/clang/test/Sema/t1.c b/clang/test/Sema/t1.c
new file mode 100644
index 000..876c72e57126c15
--- /dev/null
+++ b/clang/test/Sema/t1.c
@@ -0,0 +1 @@
+This is test file.

>From 819becc8b8f0a778c868e2ef85889dadf81f311f Mon Sep 17 00:00:00 2001
From: Zahira Ammarguellat 
Date: Tue, 3 Oct 2023 09:58:26 -0400
Subject: [PATCH 4/5] Delete clang/test/Sema/t1.c

---
 clang/test/Sema/t1.c | 1 -
 1 file changed, 1 deletion(-)
 delete mode 100644 clang/test/Sema/t1.c

diff --git a/clang/test/Sema/t1.c b/clang/test/Sema/t1.c
deleted file mode 100644
index 876c72e57126c15..000
--- a/clang/test/Sema/t1.c
+++ /dev/null
@@ -1 +0,0 @@
-This is test file.

>From f60fff7e5f1dc7c60bdb1bf6f53c2de9fda3bc10 Mon Sep 17 00:00:00 2001
From: Ammarguellat 
Date: Tue, 3 Oct 2023 06:59:09 -0700
Subject: [PATCH 5/5] Testing againg.

---
 clang/test/Sema/t2.c | 1 +
 1 file changed, 1 insertion(+)
 create mode 100644 clang/test/Sema/t2.c

diff --git a/clang/test/Sema/t2.c b/clang/test/Sema/t2.c
new file mode 100644
index 000..ffaccc943353266
--- /dev/null
+++ b/clang/test/Sema/t2.c
@@ -0,0 +1 @@
+This is another test.

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


[clang] Complex div (PR #68106)

2023-10-03 Thread Zahira Ammarguellat via cfe-commits

https://github.com/zahiraam updated 
https://github.com/llvm/llvm-project/pull/68106

>From 2e06d07abe22526188c71c6e00ca9037620c9259 Mon Sep 17 00:00:00 2001
From: Ammarguellat 
Date: Tue, 3 Oct 2023 05:43:48 -0700
Subject: [PATCH 1/4] Testing.

---
 clang/lib/AST/Expr.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp
index 4f3837371b3fc5e..0d955c028f11454 100644
--- a/clang/lib/AST/Expr.cpp
+++ b/clang/lib/AST/Expr.cpp
@@ -726,7 +726,7 @@ StringRef 
PredefinedExpr::getIdentKindName(PredefinedExpr::IdentKind IK) {
 // expr" policy instead.
 std::string PredefinedExpr::ComputeName(IdentKind IK, const Decl *CurrentDecl) 
{
   ASTContext &Context = CurrentDecl->getASTContext();
-
+  // This is a just a test.
   if (IK == PredefinedExpr::FuncDName) {
 if (const NamedDecl *ND = dyn_cast(CurrentDecl)) {
   std::unique_ptr MC;

>From 2ffed4e994fd19b8f1929f15fce549a4e2f0d60c Mon Sep 17 00:00:00 2001
From: Ammarguellat 
Date: Tue, 3 Oct 2023 05:45:00 -0700
Subject: [PATCH 2/4] Testing again.

---
 clang/lib/AST/Expr.cpp | 1 +
 1 file changed, 1 insertion(+)

diff --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp
index 0d955c028f11454..ba2592d1e0d8d24 100644
--- a/clang/lib/AST/Expr.cpp
+++ b/clang/lib/AST/Expr.cpp
@@ -727,6 +727,7 @@ StringRef 
PredefinedExpr::getIdentKindName(PredefinedExpr::IdentKind IK) {
 std::string PredefinedExpr::ComputeName(IdentKind IK, const Decl *CurrentDecl) 
{
   ASTContext &Context = CurrentDecl->getASTContext();
   // This is a just a test.
+  // This is just yet another test.
   if (IK == PredefinedExpr::FuncDName) {
 if (const NamedDecl *ND = dyn_cast(CurrentDecl)) {
   std::unique_ptr MC;

>From 2c964ac67089bbf5b18f07bc7600a4f042a28e15 Mon Sep 17 00:00:00 2001
From: Ammarguellat 
Date: Tue, 3 Oct 2023 06:57:34 -0700
Subject: [PATCH 3/4] Testing.

---
 clang/test/Sema/t1.c | 1 +
 1 file changed, 1 insertion(+)
 create mode 100644 clang/test/Sema/t1.c

diff --git a/clang/test/Sema/t1.c b/clang/test/Sema/t1.c
new file mode 100644
index 000..876c72e57126c15
--- /dev/null
+++ b/clang/test/Sema/t1.c
@@ -0,0 +1 @@
+This is test file.

>From 819becc8b8f0a778c868e2ef85889dadf81f311f Mon Sep 17 00:00:00 2001
From: Zahira Ammarguellat 
Date: Tue, 3 Oct 2023 09:58:26 -0400
Subject: [PATCH 4/4] Delete clang/test/Sema/t1.c

---
 clang/test/Sema/t1.c | 1 -
 1 file changed, 1 deletion(-)
 delete mode 100644 clang/test/Sema/t1.c

diff --git a/clang/test/Sema/t1.c b/clang/test/Sema/t1.c
deleted file mode 100644
index 876c72e57126c15..000
--- a/clang/test/Sema/t1.c
+++ /dev/null
@@ -1 +0,0 @@
-This is test file.

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


[clang] Complex div (PR #68106)

2023-10-03 Thread Zahira Ammarguellat via cfe-commits

https://github.com/zahiraam updated 
https://github.com/llvm/llvm-project/pull/68106

>From 2e06d07abe22526188c71c6e00ca9037620c9259 Mon Sep 17 00:00:00 2001
From: Ammarguellat 
Date: Tue, 3 Oct 2023 05:43:48 -0700
Subject: [PATCH 1/3] Testing.

---
 clang/lib/AST/Expr.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp
index 4f3837371b3fc5e..0d955c028f11454 100644
--- a/clang/lib/AST/Expr.cpp
+++ b/clang/lib/AST/Expr.cpp
@@ -726,7 +726,7 @@ StringRef 
PredefinedExpr::getIdentKindName(PredefinedExpr::IdentKind IK) {
 // expr" policy instead.
 std::string PredefinedExpr::ComputeName(IdentKind IK, const Decl *CurrentDecl) 
{
   ASTContext &Context = CurrentDecl->getASTContext();
-
+  // This is a just a test.
   if (IK == PredefinedExpr::FuncDName) {
 if (const NamedDecl *ND = dyn_cast(CurrentDecl)) {
   std::unique_ptr MC;

>From 2ffed4e994fd19b8f1929f15fce549a4e2f0d60c Mon Sep 17 00:00:00 2001
From: Ammarguellat 
Date: Tue, 3 Oct 2023 05:45:00 -0700
Subject: [PATCH 2/3] Testing again.

---
 clang/lib/AST/Expr.cpp | 1 +
 1 file changed, 1 insertion(+)

diff --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp
index 0d955c028f11454..ba2592d1e0d8d24 100644
--- a/clang/lib/AST/Expr.cpp
+++ b/clang/lib/AST/Expr.cpp
@@ -727,6 +727,7 @@ StringRef 
PredefinedExpr::getIdentKindName(PredefinedExpr::IdentKind IK) {
 std::string PredefinedExpr::ComputeName(IdentKind IK, const Decl *CurrentDecl) 
{
   ASTContext &Context = CurrentDecl->getASTContext();
   // This is a just a test.
+  // This is just yet another test.
   if (IK == PredefinedExpr::FuncDName) {
 if (const NamedDecl *ND = dyn_cast(CurrentDecl)) {
   std::unique_ptr MC;

>From 2c964ac67089bbf5b18f07bc7600a4f042a28e15 Mon Sep 17 00:00:00 2001
From: Ammarguellat 
Date: Tue, 3 Oct 2023 06:57:34 -0700
Subject: [PATCH 3/3] Testing.

---
 clang/test/Sema/t1.c | 1 +
 1 file changed, 1 insertion(+)
 create mode 100644 clang/test/Sema/t1.c

diff --git a/clang/test/Sema/t1.c b/clang/test/Sema/t1.c
new file mode 100644
index 000..876c72e57126c15
--- /dev/null
+++ b/clang/test/Sema/t1.c
@@ -0,0 +1 @@
+This is test file.

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


[clang] Complex div (PR #68106)

2023-10-03 Thread Zahira Ammarguellat via cfe-commits

https://github.com/zahiraam created 
https://github.com/llvm/llvm-project/pull/68106

None

>From 2e06d07abe22526188c71c6e00ca9037620c9259 Mon Sep 17 00:00:00 2001
From: Ammarguellat 
Date: Tue, 3 Oct 2023 05:43:48 -0700
Subject: [PATCH 1/2] Testing.

---
 clang/lib/AST/Expr.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp
index 4f3837371b3fc5e..0d955c028f11454 100644
--- a/clang/lib/AST/Expr.cpp
+++ b/clang/lib/AST/Expr.cpp
@@ -726,7 +726,7 @@ StringRef 
PredefinedExpr::getIdentKindName(PredefinedExpr::IdentKind IK) {
 // expr" policy instead.
 std::string PredefinedExpr::ComputeName(IdentKind IK, const Decl *CurrentDecl) 
{
   ASTContext &Context = CurrentDecl->getASTContext();
-
+  // This is a just a test.
   if (IK == PredefinedExpr::FuncDName) {
 if (const NamedDecl *ND = dyn_cast(CurrentDecl)) {
   std::unique_ptr MC;

>From 2ffed4e994fd19b8f1929f15fce549a4e2f0d60c Mon Sep 17 00:00:00 2001
From: Ammarguellat 
Date: Tue, 3 Oct 2023 05:45:00 -0700
Subject: [PATCH 2/2] Testing again.

---
 clang/lib/AST/Expr.cpp | 1 +
 1 file changed, 1 insertion(+)

diff --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp
index 0d955c028f11454..ba2592d1e0d8d24 100644
--- a/clang/lib/AST/Expr.cpp
+++ b/clang/lib/AST/Expr.cpp
@@ -727,6 +727,7 @@ StringRef 
PredefinedExpr::getIdentKindName(PredefinedExpr::IdentKind IK) {
 std::string PredefinedExpr::ComputeName(IdentKind IK, const Decl *CurrentDecl) 
{
   ASTContext &Context = CurrentDecl->getASTContext();
   // This is a just a test.
+  // This is just yet another test.
   if (IK == PredefinedExpr::FuncDName) {
 if (const NamedDecl *ND = dyn_cast(CurrentDecl)) {
   std::unique_ptr MC;

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


[clang-tools-extra] [IPSCCP] Variable not visible at Og: (PR #66745)

2023-10-03 Thread Carlos Alberto Enciso via cfe-commits


@@ -371,6 +372,52 @@ static bool runIPSCCP(
   StoreInst *SI = cast(GV->user_back());
   SI->eraseFromParent();
 }
+
+// Try to create a debug constant expression for the glbal variable
+// initializer value.
+SmallVector GVEs;
+GV->getDebugInfo(GVEs);
+if (GVEs.size() == 1) {
+  DIBuilder DIB(M);
+
+  // Create integer constant expression.
+  auto createIntExpression = [&DIB](const Constant *CV) -> DIExpression * {
+const APInt &API = dyn_cast(CV)->getValue();
+std::optional InitIntOpt;
+if (API.isNonNegative())
+  InitIntOpt = API.tryZExtValue();
+else if (auto Temp = API.trySExtValue(); Temp.has_value())
+  // Transform a signed optional to unsigned optional.
+  InitIntOpt = (uint64_t)Temp.value();
+return DIB.createConstantValueExpression(InitIntOpt.value());
+  };
+
+  const Constant *CV = GV->getInitializer();
+  Type *Ty = GV->getValueType();
+  if (Ty->isIntegerTy()) {
+GVEs[0]->replaceOperandWith(1, createIntExpression(CV));
+  } else if (Ty->isFloatTy() || Ty->isDoubleTy()) {
+const APFloat &APF = dyn_cast(CV)->getValueAPF();
+DIExpression *NewExpr = DIB.createConstantValueExpression(
+APF.bitcastToAPInt().getZExtValue());
+GVEs[0]->replaceOperandWith(1, NewExpr);
+  } else if (Ty->isPointerTy()) {
+if (isa(CV)) {
+  GVEs[0]->replaceOperandWith(1, DIB.createConstantValueExpression(0));
+} else {
+  if (const ConstantExpr *CE = dyn_cast(CV)) {
+if (CE->getNumOperands() == 1) {
+  const Value *V = CE->getOperand(0);
+  const Constant *CV = dyn_cast(V);
+  if (CV && !isa(CV))
+if (const ConstantInt *CI = dyn_cast(CV))
+  GVEs[0]->replaceOperandWith(1, createIntExpression(CI));
+}
+  }
+}
+  }
+}

CarlosAlbertoEnciso wrote:

Replaced with your suggested change.

https://github.com/llvm/llvm-project/pull/66745
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [IPSCCP] Variable not visible at Og: (PR #66745)

2023-10-03 Thread Carlos Alberto Enciso via cfe-commits


@@ -371,6 +372,52 @@ static bool runIPSCCP(
   StoreInst *SI = cast(GV->user_back());
   SI->eraseFromParent();
 }
+
+// Try to create a debug constant expression for the glbal variable
+// initializer value.
+SmallVector GVEs;
+GV->getDebugInfo(GVEs);
+if (GVEs.size() == 1) {
+  DIBuilder DIB(M);
+
+  // Create integer constant expression.
+  auto createIntExpression = [&DIB](const Constant *CV) -> DIExpression * {
+const APInt &API = dyn_cast(CV)->getValue();
+std::optional InitIntOpt;
+if (API.isNonNegative())
+  InitIntOpt = API.tryZExtValue();
+else if (auto Temp = API.trySExtValue(); Temp.has_value())
+  // Transform a signed optional to unsigned optional.
+  InitIntOpt = (uint64_t)Temp.value();
+return DIB.createConstantValueExpression(InitIntOpt.value());
+  };
+
+  const Constant *CV = GV->getInitializer();
+  Type *Ty = GV->getValueType();
+  if (Ty->isIntegerTy()) {
+GVEs[0]->replaceOperandWith(1, createIntExpression(CV));
+  } else if (Ty->isFloatTy() || Ty->isDoubleTy()) {
+const APFloat &APF = dyn_cast(CV)->getValueAPF();
+DIExpression *NewExpr = DIB.createConstantValueExpression(
+APF.bitcastToAPInt().getZExtValue());
+GVEs[0]->replaceOperandWith(1, NewExpr);
+  } else if (Ty->isPointerTy()) {
+if (isa(CV)) {
+  GVEs[0]->replaceOperandWith(1, DIB.createConstantValueExpression(0));
+} else {
+  if (const ConstantExpr *CE = dyn_cast(CV)) {
+if (CE->getNumOperands() == 1) {
+  const Value *V = CE->getOperand(0);
+  const Constant *CV = dyn_cast(V);
+  if (CV && !isa(CV))
+if (const ConstantInt *CI = dyn_cast(CV))
+  GVEs[0]->replaceOperandWith(1, createIntExpression(CI));
+}
+  }
+}
+  }
+}

CarlosAlbertoEnciso wrote:

Replaced with your suggested change.

https://github.com/llvm/llvm-project/pull/66745
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [IPSCCP] Variable not visible at Og: (PR #66745)

2023-10-03 Thread Carlos Alberto Enciso via cfe-commits


@@ -371,6 +372,52 @@ static bool runIPSCCP(
   StoreInst *SI = cast(GV->user_back());
   SI->eraseFromParent();
 }
+
+// Try to create a debug constant expression for the glbal variable
+// initializer value.
+SmallVector GVEs;
+GV->getDebugInfo(GVEs);
+if (GVEs.size() == 1) {
+  DIBuilder DIB(M);
+
+  // Create integer constant expression.
+  auto createIntExpression = [&DIB](const Constant *CV) -> DIExpression * {
+const APInt &API = dyn_cast(CV)->getValue();
+std::optional InitIntOpt;
+if (API.isNonNegative())
+  InitIntOpt = API.tryZExtValue();
+else if (auto Temp = API.trySExtValue(); Temp.has_value())
+  // Transform a signed optional to unsigned optional.
+  InitIntOpt = (uint64_t)Temp.value();
+return DIB.createConstantValueExpression(InitIntOpt.value());
+  };
+
+  const Constant *CV = GV->getInitializer();
+  Type *Ty = GV->getValueType();
+  if (Ty->isIntegerTy()) {
+GVEs[0]->replaceOperandWith(1, createIntExpression(CV));
+  } else if (Ty->isFloatTy() || Ty->isDoubleTy()) {
+const APFloat &APF = dyn_cast(CV)->getValueAPF();

CarlosAlbertoEnciso wrote:

Changed to `cast`

https://github.com/llvm/llvm-project/pull/66745
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [IPSCCP] Variable not visible at Og: (PR #66745)

2023-10-03 Thread Carlos Alberto Enciso via cfe-commits


@@ -371,6 +372,52 @@ static bool runIPSCCP(
   StoreInst *SI = cast(GV->user_back());
   SI->eraseFromParent();
 }
+
+// Try to create a debug constant expression for the glbal variable
+// initializer value.
+SmallVector GVEs;
+GV->getDebugInfo(GVEs);
+if (GVEs.size() == 1) {
+  DIBuilder DIB(M);
+
+  // Create integer constant expression.
+  auto createIntExpression = [&DIB](const Constant *CV) -> DIExpression * {
+const APInt &API = dyn_cast(CV)->getValue();
+std::optional InitIntOpt;
+if (API.isNonNegative())
+  InitIntOpt = API.tryZExtValue();
+else if (auto Temp = API.trySExtValue(); Temp.has_value())
+  // Transform a signed optional to unsigned optional.
+  InitIntOpt = (uint64_t)Temp.value();
+return DIB.createConstantValueExpression(InitIntOpt.value());
+  };
+
+  const Constant *CV = GV->getInitializer();
+  Type *Ty = GV->getValueType();
+  if (Ty->isIntegerTy()) {
+GVEs[0]->replaceOperandWith(1, createIntExpression(CV));
+  } else if (Ty->isFloatTy() || Ty->isDoubleTy()) {
+const APFloat &APF = dyn_cast(CV)->getValueAPF();

CarlosAlbertoEnciso wrote:

Changed to `cast`

https://github.com/llvm/llvm-project/pull/66745
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [IPSCCP] Variable not visible at Og: (PR #66745)

2023-10-03 Thread Carlos Alberto Enciso via cfe-commits


@@ -371,6 +372,52 @@ static bool runIPSCCP(
   StoreInst *SI = cast(GV->user_back());
   SI->eraseFromParent();
 }
+
+// Try to create a debug constant expression for the glbal variable
+// initializer value.
+SmallVector GVEs;
+GV->getDebugInfo(GVEs);
+if (GVEs.size() == 1) {
+  DIBuilder DIB(M);
+
+  // Create integer constant expression.
+  auto createIntExpression = [&DIB](const Constant *CV) -> DIExpression * {
+const APInt &API = dyn_cast(CV)->getValue();
+std::optional InitIntOpt;
+if (API.isNonNegative())
+  InitIntOpt = API.tryZExtValue();
+else if (auto Temp = API.trySExtValue(); Temp.has_value())
+  // Transform a signed optional to unsigned optional.
+  InitIntOpt = (uint64_t)Temp.value();
+return DIB.createConstantValueExpression(InitIntOpt.value());
+  };
+
+  const Constant *CV = GV->getInitializer();
+  Type *Ty = GV->getValueType();
+  if (Ty->isIntegerTy()) {
+GVEs[0]->replaceOperandWith(1, createIntExpression(CV));

CarlosAlbertoEnciso wrote:

The function `replaceOperandWith` takes that into consideration.

https://github.com/llvm/llvm-project/pull/66745
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [IPSCCP] Variable not visible at Og: (PR #66745)

2023-10-03 Thread Carlos Alberto Enciso via cfe-commits


@@ -371,6 +372,52 @@ static bool runIPSCCP(
   StoreInst *SI = cast(GV->user_back());
   SI->eraseFromParent();
 }
+
+// Try to create a debug constant expression for the glbal variable
+// initializer value.
+SmallVector GVEs;
+GV->getDebugInfo(GVEs);
+if (GVEs.size() == 1) {
+  DIBuilder DIB(M);
+
+  // Create integer constant expression.
+  auto createIntExpression = [&DIB](const Constant *CV) -> DIExpression * {
+const APInt &API = dyn_cast(CV)->getValue();
+std::optional InitIntOpt;
+if (API.isNonNegative())
+  InitIntOpt = API.tryZExtValue();
+else if (auto Temp = API.trySExtValue(); Temp.has_value())
+  // Transform a signed optional to unsigned optional.
+  InitIntOpt = (uint64_t)Temp.value();
+return DIB.createConstantValueExpression(InitIntOpt.value());
+  };
+
+  const Constant *CV = GV->getInitializer();
+  Type *Ty = GV->getValueType();
+  if (Ty->isIntegerTy()) {
+GVEs[0]->replaceOperandWith(1, createIntExpression(CV));

CarlosAlbertoEnciso wrote:

The function `replaceOperandWith` takes that into consideration.

https://github.com/llvm/llvm-project/pull/66745
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [IPSCCP] Variable not visible at Og: (PR #66745)

2023-10-03 Thread Carlos Alberto Enciso via cfe-commits


@@ -371,6 +372,52 @@ static bool runIPSCCP(
   StoreInst *SI = cast(GV->user_back());
   SI->eraseFromParent();
 }
+
+// Try to create a debug constant expression for the glbal variable
+// initializer value.
+SmallVector GVEs;
+GV->getDebugInfo(GVEs);
+if (GVEs.size() == 1) {
+  DIBuilder DIB(M);
+
+  // Create integer constant expression.
+  auto createIntExpression = [&DIB](const Constant *CV) -> DIExpression * {
+const APInt &API = dyn_cast(CV)->getValue();
+std::optional InitIntOpt;
+if (API.isNonNegative())
+  InitIntOpt = API.tryZExtValue();
+else if (auto Temp = API.trySExtValue(); Temp.has_value())
+  // Transform a signed optional to unsigned optional.
+  InitIntOpt = (uint64_t)Temp.value();
+return DIB.createConstantValueExpression(InitIntOpt.value());

CarlosAlbertoEnciso wrote:

Changed to use `cast`.

https://github.com/llvm/llvm-project/pull/66745
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [IPSCCP] Variable not visible at Og: (PR #66745)

2023-10-03 Thread Carlos Alberto Enciso via cfe-commits


@@ -371,6 +372,52 @@ static bool runIPSCCP(
   StoreInst *SI = cast(GV->user_back());
   SI->eraseFromParent();
 }
+
+// Try to create a debug constant expression for the glbal variable
+// initializer value.
+SmallVector GVEs;
+GV->getDebugInfo(GVEs);
+if (GVEs.size() == 1) {
+  DIBuilder DIB(M);
+
+  // Create integer constant expression.
+  auto createIntExpression = [&DIB](const Constant *CV) -> DIExpression * {
+const APInt &API = dyn_cast(CV)->getValue();
+std::optional InitIntOpt;
+if (API.isNonNegative())
+  InitIntOpt = API.tryZExtValue();
+else if (auto Temp = API.trySExtValue(); Temp.has_value())
+  // Transform a signed optional to unsigned optional.
+  InitIntOpt = (uint64_t)Temp.value();
+return DIB.createConstantValueExpression(InitIntOpt.value());

CarlosAlbertoEnciso wrote:

Changed to use `cast`.

https://github.com/llvm/llvm-project/pull/66745
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [IPSCCP] Variable not visible at Og: (PR #66745)

2023-10-03 Thread Carlos Alberto Enciso via cfe-commits


@@ -371,6 +372,52 @@ static bool runIPSCCP(
   StoreInst *SI = cast(GV->user_back());
   SI->eraseFromParent();
 }
+
+// Try to create a debug constant expression for the glbal variable
+// initializer value.
+SmallVector GVEs;
+GV->getDebugInfo(GVEs);
+if (GVEs.size() == 1) {
+  DIBuilder DIB(M);
+
+  // Create integer constant expression.
+  auto createIntExpression = [&DIB](const Constant *CV) -> DIExpression * {
+const APInt &API = dyn_cast(CV)->getValue();
+std::optional InitIntOpt;
+if (API.isNonNegative())
+  InitIntOpt = API.tryZExtValue();
+else if (auto Temp = API.trySExtValue(); Temp.has_value())
+  // Transform a signed optional to unsigned optional.
+  InitIntOpt = (uint64_t)Temp.value();

CarlosAlbertoEnciso wrote:

Using instead `static_cast`

https://github.com/llvm/llvm-project/pull/66745
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [IPSCCP] Variable not visible at Og: (PR #66745)

2023-10-03 Thread Carlos Alberto Enciso via cfe-commits


@@ -371,6 +372,52 @@ static bool runIPSCCP(
   StoreInst *SI = cast(GV->user_back());
   SI->eraseFromParent();
 }
+
+// Try to create a debug constant expression for the glbal variable
+// initializer value.
+SmallVector GVEs;
+GV->getDebugInfo(GVEs);
+if (GVEs.size() == 1) {
+  DIBuilder DIB(M);
+
+  // Create integer constant expression.
+  auto createIntExpression = [&DIB](const Constant *CV) -> DIExpression * {
+const APInt &API = dyn_cast(CV)->getValue();
+std::optional InitIntOpt;
+if (API.isNonNegative())
+  InitIntOpt = API.tryZExtValue();
+else if (auto Temp = API.trySExtValue(); Temp.has_value())
+  // Transform a signed optional to unsigned optional.
+  InitIntOpt = (uint64_t)Temp.value();

CarlosAlbertoEnciso wrote:

Using instead `static_cast`

https://github.com/llvm/llvm-project/pull/66745
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [flang][Driver] Support -rpath, -shared, and -static in the frontend (PR #66702)

2023-10-03 Thread Tarun Prabhu via cfe-commits

tarunprabhu wrote:

Thanks @DavidTruby. 

For this particular patch, the main concern is how the compiler flags are 
mapped to the corresponding linker flags on Windows. All of that work is done 
by clang, and I haven't touched any of it so I am not worried about 
correctness. 

The two main concerns are:

1) What are the linker flags in Windows corresponding to -static and -shared on 
*nix. 
2) Do the checks in the test need to be expanded to account for different 
linkers on Windows.



https://github.com/llvm/llvm-project/pull/66702
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [IPSCCP] Variable not visible at Og: (PR #66745)

2023-10-03 Thread Carlos Alberto Enciso via cfe-commits


@@ -371,6 +372,52 @@ static bool runIPSCCP(
   StoreInst *SI = cast(GV->user_back());
   SI->eraseFromParent();
 }
+
+// Try to create a debug constant expression for the glbal variable
+// initializer value.

CarlosAlbertoEnciso wrote:

Moving the code to a helper function.

https://github.com/llvm/llvm-project/pull/66745
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [IPSCCP] Variable not visible at Og: (PR #66745)

2023-10-03 Thread Carlos Alberto Enciso via cfe-commits


@@ -371,6 +372,52 @@ static bool runIPSCCP(
   StoreInst *SI = cast(GV->user_back());
   SI->eraseFromParent();
 }
+
+// Try to create a debug constant expression for the glbal variable
+// initializer value.

CarlosAlbertoEnciso wrote:

Moving the code to a helper function.

https://github.com/llvm/llvm-project/pull/66745
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [IPSCCP] Variable not visible at Og: (PR #66745)

2023-10-03 Thread Carlos Alberto Enciso via cfe-commits

https://github.com/CarlosAlbertoEnciso updated 
https://github.com/llvm/llvm-project/pull/66745

>From b24943f63025822a5c5ba90c4a7b47f7123ec4db Mon Sep 17 00:00:00 2001
From: Carlos Alberto Enciso 
Date: Mon, 18 Sep 2023 12:29:17 +0100
Subject: [PATCH] [IPSCCP] Variable not visible at Og:

https://bugs.llvm.org/show_bug.cgi?id=51559
https://github.com/llvm/llvm-project/issues/50901

IPSCCP pass removes the global variable and does not
create a constant expression for the initializer value.
---
 llvm/lib/Transforms/IPO/SCCP.cpp |  47 +++
 llvm/test/Transforms/SCCP/pr50901.ll | 184 +++
 2 files changed, 231 insertions(+)
 create mode 100644 llvm/test/Transforms/SCCP/pr50901.ll

diff --git a/llvm/lib/Transforms/IPO/SCCP.cpp b/llvm/lib/Transforms/IPO/SCCP.cpp
index 84f5bbf7039416b..e09769e00148143 100644
--- a/llvm/lib/Transforms/IPO/SCCP.cpp
+++ b/llvm/lib/Transforms/IPO/SCCP.cpp
@@ -22,6 +22,7 @@
 #include "llvm/Analysis/ValueTracking.h"
 #include "llvm/IR/AttributeMask.h"
 #include "llvm/IR/Constants.h"
+#include "llvm/IR/DIBuilder.h"
 #include "llvm/IR/IntrinsicInst.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/ModRef.h"
@@ -371,6 +372,52 @@ static bool runIPSCCP(
   StoreInst *SI = cast(GV->user_back());
   SI->eraseFromParent();
 }
+
+// Try to create a debug constant expression for the glbal variable
+// initializer value.
+SmallVector GVEs;
+GV->getDebugInfo(GVEs);
+if (GVEs.size() == 1) {
+  DIBuilder DIB(M);
+
+  // Create integer constant expression.
+  auto createIntExpression = [&DIB](const Constant *CV) -> DIExpression * {
+const APInt &API = dyn_cast(CV)->getValue();
+std::optional InitIntOpt;
+if (API.isNonNegative())
+  InitIntOpt = API.tryZExtValue();
+else if (auto Temp = API.trySExtValue(); Temp.has_value())
+  // Transform a signed optional to unsigned optional.
+  InitIntOpt = (uint64_t)Temp.value();
+return DIB.createConstantValueExpression(InitIntOpt.value());
+  };
+
+  const Constant *CV = GV->getInitializer();
+  Type *Ty = GV->getValueType();
+  if (Ty->isIntegerTy()) {
+GVEs[0]->replaceOperandWith(1, createIntExpression(CV));
+  } else if (Ty->isFloatTy() || Ty->isDoubleTy()) {
+const APFloat &APF = dyn_cast(CV)->getValueAPF();
+DIExpression *NewExpr = DIB.createConstantValueExpression(
+APF.bitcastToAPInt().getZExtValue());
+GVEs[0]->replaceOperandWith(1, NewExpr);
+  } else if (Ty->isPointerTy()) {
+if (isa(CV)) {
+  GVEs[0]->replaceOperandWith(1, DIB.createConstantValueExpression(0));
+} else {
+  if (const ConstantExpr *CE = dyn_cast(CV)) {
+if (CE->getNumOperands() == 1) {
+  const Value *V = CE->getOperand(0);
+  const Constant *CV = dyn_cast(V);
+  if (CV && !isa(CV))
+if (const ConstantInt *CI = dyn_cast(CV))
+  GVEs[0]->replaceOperandWith(1, createIntExpression(CI));
+}
+  }
+}
+  }
+}
+
 MadeChanges = true;
 M.eraseGlobalVariable(GV);
 ++NumGlobalConst;
diff --git a/llvm/test/Transforms/SCCP/pr50901.ll 
b/llvm/test/Transforms/SCCP/pr50901.ll
new file mode 100644
index 000..56961d2e32db41c
--- /dev/null
+++ b/llvm/test/Transforms/SCCP/pr50901.ll
@@ -0,0 +1,184 @@
+; RUN: opt -passes=ipsccp -S -o - < %s | FileCheck %s
+
+; Global variables g_11, g_22, g_33, g_44, g_55, g_66 and g_77
+; are not visible in the debugger.
+
+;  1   int   g_1 = -4;
+;  2   float g_2 = 4.44;
+;  3   char  g_3 = 'a';
+;  4   unsigned  g_4 = 4;
+;  5   bool  g_5 = true;
+;  6   int  *g_6 = nullptr;
+;  7   float*g_7 = nullptr;
+;  8
+;  9   static int   g_11 = -5;
+; 10   static float g_22 = 5.55;
+; 11   static char  g_33 = 'b';
+; 12   static unsigned  g_44 = 5;
+; 13   static bool  g_55 = true;
+; 14   static int  *g_66 = nullptr;
+; 15   static float*g_77 = (float *)(55 + 15);
+; 16
+; 17   void bar() {
+; 18 g_1 = g_11;
+; 19 g_2 = g_22;
+; 20 g_3 = g_33;
+; 21 g_4 = g_44;
+; 22 g_5 = g_55;
+; 23 g_6 = g_66;
+; 24 g_7 = g_77;
+; 25   }
+; 26
+; 27   int main() {
+; 28 {
+; 29   bar();
+; 30 }
+; 31   }
+
+; CHECK: ![[G1:[0-9]+]] = !DIGlobalVariableExpression(var: ![[DBG1:[0-9]+]], 
expr: !DIExpression(DW_OP_constu, 18446744073709551611, DW_OP_stack_value))
+; CHECK-DAG: ![[DBG1]] = distinct !DIGlobalVariable(name: "g_11", {{.*}}
+; CHECK: ![[G2:[0-9]+]] = !DIGlobalVariableExpression(var: ![[DBG2:[0-9]+]], 
expr: !DIExpression(DW_OP_constu, 1085381018, DW_OP_stack_value))
+; CHECK-DAG: ![[DBG2]] = distinct !DIGlobalVariable(name: "g_22", {{.*}}
+; CHECK: ![[G3:[0-9]+]] = !DIGlobalVariableExpression(var: ![[DBG3:[0-9]+]], 
expr: !DIExpression(DW_OP_constu, 98, DW_OP_stack_value))
+; CHECK-DAG: ![[DBG3]] = distinct !

[clang-tools-extra] [IPSCCP] Variable not visible at Og: (PR #66745)

2023-10-03 Thread J. Ryan Stinnett via cfe-commits

https://github.com/jryans edited https://github.com/llvm/llvm-project/pull/66745
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [IPSCCP] Variable not visible at Og: (PR #66745)

2023-10-03 Thread J. Ryan Stinnett via cfe-commits

https://github.com/jryans edited https://github.com/llvm/llvm-project/pull/66745
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [IPSCCP] Variable not visible at Og: (PR #66745)

2023-10-03 Thread Carlos Alberto Enciso via cfe-commits

https://github.com/CarlosAlbertoEnciso updated 
https://github.com/llvm/llvm-project/pull/66745

>From b24943f63025822a5c5ba90c4a7b47f7123ec4db Mon Sep 17 00:00:00 2001
From: Carlos Alberto Enciso 
Date: Mon, 18 Sep 2023 12:29:17 +0100
Subject: [PATCH] [IPSCCP] Variable not visible at Og:

https://bugs.llvm.org/show_bug.cgi?id=51559
https://github.com/llvm/llvm-project/issues/50901

IPSCCP pass removes the global variable and does not
create a constant expression for the initializer value.
---
 llvm/lib/Transforms/IPO/SCCP.cpp |  47 +++
 llvm/test/Transforms/SCCP/pr50901.ll | 184 +++
 2 files changed, 231 insertions(+)
 create mode 100644 llvm/test/Transforms/SCCP/pr50901.ll

diff --git a/llvm/lib/Transforms/IPO/SCCP.cpp b/llvm/lib/Transforms/IPO/SCCP.cpp
index 84f5bbf7039416b..e09769e00148143 100644
--- a/llvm/lib/Transforms/IPO/SCCP.cpp
+++ b/llvm/lib/Transforms/IPO/SCCP.cpp
@@ -22,6 +22,7 @@
 #include "llvm/Analysis/ValueTracking.h"
 #include "llvm/IR/AttributeMask.h"
 #include "llvm/IR/Constants.h"
+#include "llvm/IR/DIBuilder.h"
 #include "llvm/IR/IntrinsicInst.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/ModRef.h"
@@ -371,6 +372,52 @@ static bool runIPSCCP(
   StoreInst *SI = cast(GV->user_back());
   SI->eraseFromParent();
 }
+
+// Try to create a debug constant expression for the glbal variable
+// initializer value.
+SmallVector GVEs;
+GV->getDebugInfo(GVEs);
+if (GVEs.size() == 1) {
+  DIBuilder DIB(M);
+
+  // Create integer constant expression.
+  auto createIntExpression = [&DIB](const Constant *CV) -> DIExpression * {
+const APInt &API = dyn_cast(CV)->getValue();
+std::optional InitIntOpt;
+if (API.isNonNegative())
+  InitIntOpt = API.tryZExtValue();
+else if (auto Temp = API.trySExtValue(); Temp.has_value())
+  // Transform a signed optional to unsigned optional.
+  InitIntOpt = (uint64_t)Temp.value();
+return DIB.createConstantValueExpression(InitIntOpt.value());
+  };
+
+  const Constant *CV = GV->getInitializer();
+  Type *Ty = GV->getValueType();
+  if (Ty->isIntegerTy()) {
+GVEs[0]->replaceOperandWith(1, createIntExpression(CV));
+  } else if (Ty->isFloatTy() || Ty->isDoubleTy()) {
+const APFloat &APF = dyn_cast(CV)->getValueAPF();
+DIExpression *NewExpr = DIB.createConstantValueExpression(
+APF.bitcastToAPInt().getZExtValue());
+GVEs[0]->replaceOperandWith(1, NewExpr);
+  } else if (Ty->isPointerTy()) {
+if (isa(CV)) {
+  GVEs[0]->replaceOperandWith(1, DIB.createConstantValueExpression(0));
+} else {
+  if (const ConstantExpr *CE = dyn_cast(CV)) {
+if (CE->getNumOperands() == 1) {
+  const Value *V = CE->getOperand(0);
+  const Constant *CV = dyn_cast(V);
+  if (CV && !isa(CV))
+if (const ConstantInt *CI = dyn_cast(CV))
+  GVEs[0]->replaceOperandWith(1, createIntExpression(CI));
+}
+  }
+}
+  }
+}
+
 MadeChanges = true;
 M.eraseGlobalVariable(GV);
 ++NumGlobalConst;
diff --git a/llvm/test/Transforms/SCCP/pr50901.ll 
b/llvm/test/Transforms/SCCP/pr50901.ll
new file mode 100644
index 000..56961d2e32db41c
--- /dev/null
+++ b/llvm/test/Transforms/SCCP/pr50901.ll
@@ -0,0 +1,184 @@
+; RUN: opt -passes=ipsccp -S -o - < %s | FileCheck %s
+
+; Global variables g_11, g_22, g_33, g_44, g_55, g_66 and g_77
+; are not visible in the debugger.
+
+;  1   int   g_1 = -4;
+;  2   float g_2 = 4.44;
+;  3   char  g_3 = 'a';
+;  4   unsigned  g_4 = 4;
+;  5   bool  g_5 = true;
+;  6   int  *g_6 = nullptr;
+;  7   float*g_7 = nullptr;
+;  8
+;  9   static int   g_11 = -5;
+; 10   static float g_22 = 5.55;
+; 11   static char  g_33 = 'b';
+; 12   static unsigned  g_44 = 5;
+; 13   static bool  g_55 = true;
+; 14   static int  *g_66 = nullptr;
+; 15   static float*g_77 = (float *)(55 + 15);
+; 16
+; 17   void bar() {
+; 18 g_1 = g_11;
+; 19 g_2 = g_22;
+; 20 g_3 = g_33;
+; 21 g_4 = g_44;
+; 22 g_5 = g_55;
+; 23 g_6 = g_66;
+; 24 g_7 = g_77;
+; 25   }
+; 26
+; 27   int main() {
+; 28 {
+; 29   bar();
+; 30 }
+; 31   }
+
+; CHECK: ![[G1:[0-9]+]] = !DIGlobalVariableExpression(var: ![[DBG1:[0-9]+]], 
expr: !DIExpression(DW_OP_constu, 18446744073709551611, DW_OP_stack_value))
+; CHECK-DAG: ![[DBG1]] = distinct !DIGlobalVariable(name: "g_11", {{.*}}
+; CHECK: ![[G2:[0-9]+]] = !DIGlobalVariableExpression(var: ![[DBG2:[0-9]+]], 
expr: !DIExpression(DW_OP_constu, 1085381018, DW_OP_stack_value))
+; CHECK-DAG: ![[DBG2]] = distinct !DIGlobalVariable(name: "g_22", {{.*}}
+; CHECK: ![[G3:[0-9]+]] = !DIGlobalVariableExpression(var: ![[DBG3:[0-9]+]], 
expr: !DIExpression(DW_OP_constu, 98, DW_OP_stack_value))
+; CHECK-DAG: ![[DBG3]] = distinct !

[clang] [AArch64][FMV] Add rcpc3 support, introduce bits for features extensi… (PR #68104)

2023-10-03 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang


Changes

…on and initialization.

The patch implements FEAT_LRCPC3 support (Load-Acquire RCpc instructions 
version 3) in Function Multi Versioning. To maintain compatibility while 
features list grows extension bit FEAT_EXT and initialization bit FEAT_INIT are 
reserved.

---
Full diff: https://github.com/llvm/llvm-project/pull/68104.diff


5 Files Affected:

- (modified) clang/test/CodeGen/attr-target-version.c (+27-27) 
- (modified) clang/test/Sema/attr-target-clones-aarch64.c (+1-1) 
- (modified) clang/test/SemaCXX/attr-target-version.cpp (+1) 
- (modified) compiler-rt/lib/builtins/cpu_model.c (+9-2) 
- (modified) llvm/include/llvm/TargetParser/AArch64TargetParser.h (+29-26) 


``diff
diff --git a/clang/test/CodeGen/attr-target-version.c 
b/clang/test/CodeGen/attr-target-version.c
index 8d4a4f137569ccd..a7cd6f7bf802c55 100644
--- a/clang/test/CodeGen/attr-target-version.c
+++ b/clang/test/CodeGen/attr-target-version.c
@@ -35,7 +35,7 @@ inline int __attribute__((target_version("sve+sve-bf16"))) 
fmv_inline(void) { re
 inline int __attribute__((target_version("sve2-aes+sve2-sha3"))) 
fmv_inline(void) { return 5; }
 inline int __attribute__((target_version("sve2+sve2-pmull128+sve2-bitperm"))) 
fmv_inline(void) { return 9; }
 inline int __attribute__((target_version("sve2-sm4+memtag2"))) 
fmv_inline(void) { return 10; }
-inline int __attribute__((target_version("memtag3"))) fmv_inline(void) { 
return 11; }
+inline int __attribute__((target_version("memtag3+rcpc3"))) fmv_inline(void) { 
return 11; }
 inline int __attribute__((target_version("default"))) fmv_inline(void) { 
return 3; }
 
 __attribute__((target_version("ls64"))) int fmv_e(void);
@@ -289,68 +289,68 @@ int hoo(void) {
 // CHECK-NEXT:ret ptr @fmv_inline._Msha3Mi8mmMf32mm
 // CHECK:   resolver_else6:
 // CHECK-NEXT:[[TMP16:%.*]] = load i64, ptr @__aarch64_cpu_features, align 
8
-// CHECK-NEXT:[[TMP17:%.*]] = and i64 [[TMP16]], 19791209299968
-// CHECK-NEXT:[[TMP18:%.*]] = icmp eq i64 [[TMP17]], 19791209299968
+// CHECK-NEXT:[[TMP17:%.*]] = and i64 [[TMP16]], 288265560523800576
+// CHECK-NEXT:[[TMP18:%.*]] = icmp eq i64 [[TMP17]], 288265560523800576
 // CHECK-NEXT:[[TMP19:%.*]] = and i1 true, [[TMP18]]
 // CHECK-NEXT:br i1 [[TMP19]], label [[RESOLVER_RETURN7:%.*]], label 
[[RESOLVER_ELSE8:%.*]]
 // CHECK:   resolver_return7:
-// CHECK-NEXT:ret ptr @fmv_inline._Msve2-sm4Mmemtag2
+// CHECK-NEXT:ret ptr @fmv_inline._Mrcpc3Mmemtag3
 // CHECK:   resolver_else8:
 // CHECK-NEXT:[[TMP20:%.*]] = load i64, ptr @__aarch64_cpu_features, align 
8
-// CHECK-NEXT:[[TMP21:%.*]] = and i64 [[TMP20]], 1236950581248
-// CHECK-NEXT:[[TMP22:%.*]] = icmp eq i64 [[TMP21]], 1236950581248
+// CHECK-NEXT:[[TMP21:%.*]] = and i64 [[TMP20]], 19791209299968
+// CHECK-NEXT:[[TMP22:%.*]] = icmp eq i64 [[TMP21]], 19791209299968
 // CHECK-NEXT:[[TMP23:%.*]] = and i1 true, [[TMP22]]
 // CHECK-NEXT:br i1 [[TMP23]], label [[RESOLVER_RETURN9:%.*]], label 
[[RESOLVER_ELSE10:%.*]]
 // CHECK:   resolver_return9:
-// CHECK-NEXT:ret ptr @fmv_inline._Msve2-aesMsve2-sha3
+// CHECK-NEXT:ret ptr @fmv_inline._Msve2-sm4Mmemtag2
 // CHECK:   resolver_else10:
 // CHECK-NEXT:[[TMP24:%.*]] = load i64, ptr @__aarch64_cpu_features, align 
8
-// CHECK-NEXT:[[TMP25:%.*]] = and i64 [[TMP24]], 4295098368
-// CHECK-NEXT:[[TMP26:%.*]] = icmp eq i64 [[TMP25]], 4295098368
+// CHECK-NEXT:[[TMP25:%.*]] = and i64 [[TMP24]], 1236950581248
+// CHECK-NEXT:[[TMP26:%.*]] = icmp eq i64 [[TMP25]], 1236950581248
 // CHECK-NEXT:[[TMP27:%.*]] = and i1 true, [[TMP26]]
 // CHECK-NEXT:br i1 [[TMP27]], label [[RESOLVER_RETURN11:%.*]], label 
[[RESOLVER_ELSE12:%.*]]
 // CHECK:   resolver_return11:
-// CHECK-NEXT:ret ptr @fmv_inline._MditMsve-ebf16
+// CHECK-NEXT:ret ptr @fmv_inline._Msve2-aesMsve2-sha3
 // CHECK:   resolver_else12:
 // CHECK-NEXT:[[TMP28:%.*]] = load i64, ptr @__aarch64_cpu_features, align 
8
-// CHECK-NEXT:[[TMP29:%.*]] = and i64 [[TMP28]], 3221225472
-// CHECK-NEXT:[[TMP30:%.*]] = icmp eq i64 [[TMP29]], 3221225472
+// CHECK-NEXT:[[TMP29:%.*]] = and i64 [[TMP28]], 4295098368
+// CHECK-NEXT:[[TMP30:%.*]] = icmp eq i64 [[TMP29]], 4295098368
 // CHECK-NEXT:[[TMP31:%.*]] = and i1 true, [[TMP30]]
 // CHECK-NEXT:br i1 [[TMP31]], label [[RESOLVER_RETURN13:%.*]], label 
[[RESOLVER_ELSE14:%.*]]
 // CHECK:   resolver_return13:
-// CHECK-NEXT:ret ptr @fmv_inline._MsveMsve-bf16
+// CHECK-NEXT:ret ptr @fmv_inline._MditMsve-ebf16
 // CHECK:   resolver_else14:
 // CHECK-NEXT:[[TMP32:%.*]] = load i64, ptr @__aarch64_cpu_features, align 
8
-// CHECK-NEXT:[[TMP33:%.*]] = and i64 [[TMP32]], 20971520
-// CHECK-NEXT:[[TMP34:%.*]] = icmp eq i64 [[TMP33]], 20971520
+// CHECK-NEXT:[[TMP33:%.*]] = and i64 [[TMP32]], 3221225472
+// CHECK-NEXT:[[TMP34:%.*]] = icmp eq i64 [[TMP33]]

[clang] [clang][driver] Use platform specific calls to get the executable absolute path (PR #68091)

2023-10-03 Thread Aaron Ballman via cfe-commits


@@ -331,6 +340,56 @@ static void SetInstallDir(SmallVectorImpl 
&argv,
   // path being a symlink.
   SmallString<128> InstalledPath(argv[0]);
 
+#if defined(__linux__)

AaronBallman wrote:

Can we use 
[`getMainExecutable()`](https://github.com/llvm/llvm-project/blob/1f0126902876cb42a7502047e62bdf512fd96b02/llvm/include/llvm/Support/FileSystem.h#L1345)
 instead?

(This sort of system-specific logic should live in LLVM's Support directory so 
that we don't sprinkle host-specific preprocessor conditionals all over, but 
better still if we can use our existing facilities rather than invent new ones.)

https://github.com/llvm/llvm-project/pull/68091
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [AArch64][FMV] Add rcpc3 support, introduce bits for features extensi… (PR #68104)

2023-10-03 Thread Pavel Iliin via cfe-commits

https://github.com/ilinpv created 
https://github.com/llvm/llvm-project/pull/68104

…on and initialization.

The patch implements FEAT_LRCPC3 support (Load-Acquire RCpc instructions 
version 3) in Function Multi Versioning. To maintain compatibility while 
features list grows extension bit FEAT_EXT and initialization bit FEAT_INIT are 
reserved.

>From 38264c4bb4ca6ce408b3f362dcd5855f6166119c Mon Sep 17 00:00:00 2001
From: Pavel Iliin 
Date: Tue, 3 Oct 2023 01:05:08 +0100
Subject: [PATCH] [AArch64][FMV] Add rcpc3 support, introduce bits for features
 extension and initialization.

The patch implements FEAT_LRCPC3 support (Load-Acquire RCpc
instructions version 3) in Function Multi Versioning. To maintain
compatibility while features list grows extension bit FEAT_EXT and
initialization bit FEAT_INIT are reserved.
---
 clang/test/CodeGen/attr-target-version.c  | 54 +-
 clang/test/Sema/attr-target-clones-aarch64.c  |  2 +-
 clang/test/SemaCXX/attr-target-version.cpp|  1 +
 compiler-rt/lib/builtins/cpu_model.c  | 11 +++-
 .../llvm/TargetParser/AArch64TargetParser.h   | 55 ++-
 5 files changed, 67 insertions(+), 56 deletions(-)

diff --git a/clang/test/CodeGen/attr-target-version.c 
b/clang/test/CodeGen/attr-target-version.c
index 8d4a4f137569ccd..a7cd6f7bf802c55 100644
--- a/clang/test/CodeGen/attr-target-version.c
+++ b/clang/test/CodeGen/attr-target-version.c
@@ -35,7 +35,7 @@ inline int __attribute__((target_version("sve+sve-bf16"))) 
fmv_inline(void) { re
 inline int __attribute__((target_version("sve2-aes+sve2-sha3"))) 
fmv_inline(void) { return 5; }
 inline int __attribute__((target_version("sve2+sve2-pmull128+sve2-bitperm"))) 
fmv_inline(void) { return 9; }
 inline int __attribute__((target_version("sve2-sm4+memtag2"))) 
fmv_inline(void) { return 10; }
-inline int __attribute__((target_version("memtag3"))) fmv_inline(void) { 
return 11; }
+inline int __attribute__((target_version("memtag3+rcpc3"))) fmv_inline(void) { 
return 11; }
 inline int __attribute__((target_version("default"))) fmv_inline(void) { 
return 3; }
 
 __attribute__((target_version("ls64"))) int fmv_e(void);
@@ -289,68 +289,68 @@ int hoo(void) {
 // CHECK-NEXT:ret ptr @fmv_inline._Msha3Mi8mmMf32mm
 // CHECK:   resolver_else6:
 // CHECK-NEXT:[[TMP16:%.*]] = load i64, ptr @__aarch64_cpu_features, align 
8
-// CHECK-NEXT:[[TMP17:%.*]] = and i64 [[TMP16]], 19791209299968
-// CHECK-NEXT:[[TMP18:%.*]] = icmp eq i64 [[TMP17]], 19791209299968
+// CHECK-NEXT:[[TMP17:%.*]] = and i64 [[TMP16]], 288265560523800576
+// CHECK-NEXT:[[TMP18:%.*]] = icmp eq i64 [[TMP17]], 288265560523800576
 // CHECK-NEXT:[[TMP19:%.*]] = and i1 true, [[TMP18]]
 // CHECK-NEXT:br i1 [[TMP19]], label [[RESOLVER_RETURN7:%.*]], label 
[[RESOLVER_ELSE8:%.*]]
 // CHECK:   resolver_return7:
-// CHECK-NEXT:ret ptr @fmv_inline._Msve2-sm4Mmemtag2
+// CHECK-NEXT:ret ptr @fmv_inline._Mrcpc3Mmemtag3
 // CHECK:   resolver_else8:
 // CHECK-NEXT:[[TMP20:%.*]] = load i64, ptr @__aarch64_cpu_features, align 
8
-// CHECK-NEXT:[[TMP21:%.*]] = and i64 [[TMP20]], 1236950581248
-// CHECK-NEXT:[[TMP22:%.*]] = icmp eq i64 [[TMP21]], 1236950581248
+// CHECK-NEXT:[[TMP21:%.*]] = and i64 [[TMP20]], 19791209299968
+// CHECK-NEXT:[[TMP22:%.*]] = icmp eq i64 [[TMP21]], 19791209299968
 // CHECK-NEXT:[[TMP23:%.*]] = and i1 true, [[TMP22]]
 // CHECK-NEXT:br i1 [[TMP23]], label [[RESOLVER_RETURN9:%.*]], label 
[[RESOLVER_ELSE10:%.*]]
 // CHECK:   resolver_return9:
-// CHECK-NEXT:ret ptr @fmv_inline._Msve2-aesMsve2-sha3
+// CHECK-NEXT:ret ptr @fmv_inline._Msve2-sm4Mmemtag2
 // CHECK:   resolver_else10:
 // CHECK-NEXT:[[TMP24:%.*]] = load i64, ptr @__aarch64_cpu_features, align 
8
-// CHECK-NEXT:[[TMP25:%.*]] = and i64 [[TMP24]], 4295098368
-// CHECK-NEXT:[[TMP26:%.*]] = icmp eq i64 [[TMP25]], 4295098368
+// CHECK-NEXT:[[TMP25:%.*]] = and i64 [[TMP24]], 1236950581248
+// CHECK-NEXT:[[TMP26:%.*]] = icmp eq i64 [[TMP25]], 1236950581248
 // CHECK-NEXT:[[TMP27:%.*]] = and i1 true, [[TMP26]]
 // CHECK-NEXT:br i1 [[TMP27]], label [[RESOLVER_RETURN11:%.*]], label 
[[RESOLVER_ELSE12:%.*]]
 // CHECK:   resolver_return11:
-// CHECK-NEXT:ret ptr @fmv_inline._MditMsve-ebf16
+// CHECK-NEXT:ret ptr @fmv_inline._Msve2-aesMsve2-sha3
 // CHECK:   resolver_else12:
 // CHECK-NEXT:[[TMP28:%.*]] = load i64, ptr @__aarch64_cpu_features, align 
8
-// CHECK-NEXT:[[TMP29:%.*]] = and i64 [[TMP28]], 3221225472
-// CHECK-NEXT:[[TMP30:%.*]] = icmp eq i64 [[TMP29]], 3221225472
+// CHECK-NEXT:[[TMP29:%.*]] = and i64 [[TMP28]], 4295098368
+// CHECK-NEXT:[[TMP30:%.*]] = icmp eq i64 [[TMP29]], 4295098368
 // CHECK-NEXT:[[TMP31:%.*]] = and i1 true, [[TMP30]]
 // CHECK-NEXT:br i1 [[TMP31]], label [[RESOLVER_RETURN13:%.*]], label 
[[RESOLVER_ELSE14:%.*]]
 // CHECK:   resolver_return13:
-// CHECK-NEXT:ret ptr @fmv_inline._M

[clang] [clang-format] Fix alignment in presence of template functions (PR #68029)

2023-10-03 Thread Björn Schäpers via cfe-commits

https://github.com/HazardyKnusperkeks closed 
https://github.com/llvm/llvm-project/pull/68029
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 1f01269 - [clang-format] Fix alignment in presence of template functions (#68029)

2023-10-03 Thread via cfe-commits

Author: Björn Schäpers
Date: 2023-10-03T15:35:30+02:00
New Revision: 1f0126902876cb42a7502047e62bdf512fd96b02

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

LOG: [clang-format] Fix alignment in presence of template functions (#68029)

Fixes #68102.

Added: 


Modified: 
clang/lib/Format/WhitespaceManager.cpp
clang/unittests/Format/FormatTest.cpp

Removed: 




diff  --git a/clang/lib/Format/WhitespaceManager.cpp 
b/clang/lib/Format/WhitespaceManager.cpp
index 762729d1c4166a5..2cbde3da212ec65 100644
--- a/clang/lib/Format/WhitespaceManager.cpp
+++ b/clang/lib/Format/WhitespaceManager.cpp
@@ -372,9 +372,10 @@ AlignTokenSequence(const FormatStyle &Style, unsigned 
Start, unsigned End,
   return true;
 }
 
-// Continued function call
+// Continued (template) function call.
 if (ScopeStart > Start + 1 &&
-Changes[ScopeStart - 2].Tok->is(tok::identifier) &&
+Changes[ScopeStart - 2].Tok->isOneOf(tok::identifier,
+ TT_TemplateCloser) &&
 Changes[ScopeStart - 1].Tok->is(tok::l_paren) &&
 Changes[ScopeStart].Tok->isNot(TT_LambdaLSquare)) {
   if (Changes[i].Tok->MatchingParen &&

diff  --git a/clang/unittests/Format/FormatTest.cpp 
b/clang/unittests/Format/FormatTest.cpp
index 63ef294ce9d2949..246de2f89fccc9d 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -18525,12 +18525,17 @@ TEST_F(FormatTest, AlignConsecutiveAssignments) {
" a_longer_name_for_wrap}};",
Alignment);
 
-  Alignment.ColumnLimit = 60;
+  Alignment = getLLVMStyleWithColumns(60);
+  Alignment.AlignConsecutiveAssignments.Enabled = true;
   verifyFormat("using II = typename TI>::I;\n"
"using I  = std::conditional_t= 0,\n"
"  std::ic,\n"
"  std::ic>;",
Alignment);
+  verifyFormat("SomeName = Foo;\n"
+   "X= func(long,\n"
+   "arrg);",
+   Alignment);
 }
 
 TEST_F(FormatTest, AlignConsecutiveBitFields) {



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


[clang] [clang-format] Fix alignment in presence of template functions (PR #68029)

2023-10-03 Thread Björn Schäpers via cfe-commits

HazardyKnusperkeks wrote:

> Can you add an issue to show the incorrect format before this patch?

Done.

https://github.com/llvm/llvm-project/pull/68029
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-format] Fix alignment in presence of template functions (PR #68029)

2023-10-03 Thread Björn Schäpers via cfe-commits

https://github.com/HazardyKnusperkeks edited 
https://github.com/llvm/llvm-project/pull/68029
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D148381: [Clang] Implement the 'counted_by' attribute

2023-10-03 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/lib/Sema/SemaDeclAttr.cpp:8420-8428
+if (Result.getResultKind() == LookupResult::Found) {
+  SourceRange SR = CBA->getCountedByFieldLoc();
+  Diag(SR.getBegin(),
+   diag::err_flexible_array_counted_by_attr_field_not_found_in_struct)
+  << CBA->getCountedByField() << SR;
+
+  SR = Result.getAsSingle()->getSourceRange();

void wrote:
> aaron.ballman wrote:
> > The logic here still seems incorrect. I was expecting the code to look more 
> > like this:
> > ```
> > bool Sema::CheckCountedByAttr(Scope *S, const FieldDecl *FD) {
> >   const RecordDecl *RD = FD->getParent();
> >   const auto *CBA = FD->getAttr();
> >   const IdentifierInfo *FieldName = CBA->getCountedByField();
> >   DeclarationNameInfo NameInfo(FieldName,
> >CBA->getCountedByFieldLoc().getBegin());
> >   LookupResult Result(*this, NameInfo, Sema::LookupMemberName);
> > 
> >   LookupName(Result, S);
> >   if (Result.empty()) {
> > CXXScopeSpec SS;
> > DeclFilterCCC Filter(const_cast > *>(FieldName));
> > if (DiagnoseEmptyLookup(S, SS, Result, Filter, nullptr, std::nullopt,
> > const_cast > *>(FD->getDeclContext(
> >   return true;
> >   }
> > 
> >   const FieldDecl *Field = Result.getAsSingle();
> >   LangOptions::StrictFlexArraysLevelKind StrictFlexArraysLevel =
> >   Context.getLangOpts().getStrictFlexArraysLevel();
> >   ...
> > ```
> > I tested this locally on code like:
> > ```
> > struct not_a_fam {
> >   int foo;
> >   int fam[] __attribute__((counted_by(fob)));
> > };
> > ```
> > and get a diagnostic like: 
> > ```
> > C:\Users\aballman\OneDrive - Intel Corporation\Desktop\test.c:3:39: error: 
> > use of undeclared identifier 'fob'; did you
> >   mean 'foo'?
> > 3 |   int fam[] __attribute__((counted_by(fob)));
> >   |   ^~~
> >   |   foo
> > C:\Users\aballman\OneDrive - Intel Corporation\Desktop\test.c:2:7: note: 
> > 'foo' declared here
> > 2 |   int foo;
> >   |   ^
> > 1 error generated.
> > ```
> > Note, I had to add a constructor to `DeclFilterCCC` to expose the base 
> > class constructor, and modify `DiagnoseEmptyLookup()` like this:
> > ```
> > diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
> > index 2ed31a90c5dc..3c4ade391a5e 100644
> > --- a/clang/lib/Sema/SemaExpr.cpp
> > +++ b/clang/lib/Sema/SemaExpr.cpp
> > @@ -2458,7 +2458,8 @@ bool Sema::DiagnoseDependentMemberLookup(const 
> > LookupResult &R) {
> >  bool Sema::DiagnoseEmptyLookup(Scope *S, CXXScopeSpec &SS, LookupResult &R,
> > CorrectionCandidateCallback &CCC,
> > TemplateArgumentListInfo 
> > *ExplicitTemplateArgs,
> > -   ArrayRef Args, TypoExpr **Out) {
> > +   ArrayRef Args, DeclContext 
> > *LookupCtx,
> > +   TypoExpr **Out) {
> >DeclarationName Name = R.getLookupName();
> > 
> >unsigned diagnostic = diag::err_undeclared_var_use;
> > @@ -2474,7 +2475,9 @@ bool Sema::DiagnoseEmptyLookup(Scope *S, CXXScopeSpec 
> > &SS, LookupResult &R,
> >// unqualified lookup.  This is useful when (for example) the
> >// original lookup would not have found something because it was a
> >// dependent name.
> > -  DeclContext *DC = SS.isEmpty() ? CurContext : nullptr;
> > +  DeclContext *DC =
> > +  LookupCtx ? LookupCtx : (SS.isEmpty() ? CurContext : nullptr);
> > +  DeclContext *OrigLookupCtx = DC;
> >while (DC) {
> >  if (isa(DC)) {
> >LookupQualifiedName(R, DC);
> > @@ -2517,12 +2520,12 @@ bool Sema::DiagnoseEmptyLookup(Scope *S, 
> > CXXScopeSpec &SS, LookupResult &R,
> >emitEmptyLookupTypoDiagnostic(TC, *this, SS, Name, TypoLoc, Args,
> >  diagnostic, diagnostic_suggest);
> >  },
> > -nullptr, CTK_ErrorRecovery);
> > +nullptr, CTK_ErrorRecovery, OrigLookupCtx);
> >  if (*Out)
> >return true;
> > -  } else if (S &&
> > - (Corrected = CorrectTypo(R.getLookupNameInfo(), 
> > R.getLookupKind(),
> > -  S, &SS, CCC, CTK_ErrorRecovery))) {
> > +  } else if (S && (Corrected = CorrectTypo(R.getLookupNameInfo(),
> > +   R.getLookupKind(), S, &SS, CCC,
> > +   CTK_ErrorRecovery, 
> > OrigLookupCtx))) {
> >  std::string CorrectedStr(Corrected.getAsString(getLangOpts()));
> >  bool DroppedSpecifier =
> >  Corrected.WillReplaceSpecifier() && Name.getAsString() == 
> > CorrectedStr;
> > @@ -2812,7 +2815,7 @@ Sema::ActOnIdExpression(Scope *S, CXXScopeSpec &SS,
> >  // a template name, but we happen to have always already looked up the 
> > name
> > 

<    1   2   3   4   5   >