[PATCH] D136022: [clang] Add time profile for constant evaluation

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



Comment at: clang/lib/AST/ExprConstant.cpp:15257
+  });
+
   // FIXME: Evaluating initializers for large array and record types can cause

what about `Expr::EvaluateASRvalue` and `Expr::isPotentialConstantExpression`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136022

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


[PATCH] D132975: [CMake] Add clang-bolt target

2022-10-16 Thread Amir Ayupov via Phabricator via cfe-commits
Amir added a comment.

In D132975#3861334 , @phosek wrote:

> In D132975#3860896 , @Amir wrote:
>
>> In D132975#3763264 , @phosek wrote:
>>
>>> This was already on my list of build system features I'd like to implement 
>>> and I'm glad someone else is already looking into it, thank you! I have two 
>>> high level comments about your approach.
>>>
>>> The first one is related to the use of Clang build as the training data. I 
>>> think that Clang build is both unnecessarily heavyweight, but also not 
>>> particularly representative of typical workloads (most Clang users don't 
>>> use it to build Clang). Ideally, we would give vendors the flexibility to 
>>> supply their own training data. I'd prefer reusing the existing 
>>> perf-training 
>>>  
>>> setup to do so. In fact, I'd imagine most vendors would likely use the same 
>>> training data for both PGO and BOLT and that use case should be supported.
>>
>> Do you happen to know any existing perf-training sets? Or is there a simple 
>> way to create one?
>
> I'm working on a script for generating perf-training sets from Ninja-based 
> build systems, I can contribute it to LLVM if you think it'd be useful.

Yes, that would be super useful. BOLT should then also leverage that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132975

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


[PATCH] D132434: Add noread_thread_id attribute to intrinsics

2022-10-16 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu abandoned this revision.
ChuanqiXu added a comment.

We prefer https://reviews.llvm.org/D135550


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132434

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


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

2022-10-16 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu added a comment.

We prefer https://reviews.llvm.org/D135550


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

https://reviews.llvm.org/D132352

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


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

2022-10-16 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu added a comment.

We prefer https://reviews.llvm.org/D135550


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

https://reviews.llvm.org/D132352

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


[clang] 1104c70 - [C++20] [Coroutines] Add ReleaseNotes about addressing thread identifiaction problems

2022-10-16 Thread Chuanqi Xu via cfe-commits

Author: Chuanqi Xu
Date: 2022-10-17T10:46:14+08:00
New Revision: 1104c70f96de7abe90b4ff51870ed046862c79fb

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

LOG: [C++20] [Coroutines] Add ReleaseNotes about addressing thread 
identifiaction problems

The thread identification problems in coroutines are addressed now in
1cedc51ff5a2a4f51a4c7e8bb04bd. Although the original problem occurs in
LLVM optimizer. The C++ users have strong feeling about it. So it may be
necessary to add a ReleaseNote in clang for it.

Closes https://github.com/llvm/llvm-project/issues/47177
Closes https://github.com/llvm/llvm-project/issues/47179

Added: 


Modified: 
clang/docs/ReleaseNotes.rst

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index d946b5d8216a..6eaec2a5f3e9 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -248,6 +248,9 @@ Bug Fixes
   not satisfied in the event of an instantiation failures in a requires 
expression's
   parameter list. We previously handled this correctly in a constraint 
evaluation
   context, but not in a requires clause evaluated as a boolean.
+- Address the thread identification problems in coroutines.
+  `Issue 47177 `_
+  `Issue 47179 `_
 
 Improvements to Clang's diagnostics
 ^^^



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


[PATCH] D132975: [CMake] Add clang-bolt target

2022-10-16 Thread Petr Hosek via Phabricator via cfe-commits
phosek added a comment.

In D132975#3860896 , @Amir wrote:

> In D132975#3763264 , @phosek wrote:
>
>> This was already on my list of build system features I'd like to implement 
>> and I'm glad someone else is already looking into it, thank you! I have two 
>> high level comments about your approach.
>>
>> The first one is related to the use of Clang build as the training data. I 
>> think that Clang build is both unnecessarily heavyweight, but also not 
>> particularly representative of typical workloads (most Clang users don't use 
>> it to build Clang). Ideally, we would give vendors the flexibility to supply 
>> their own training data. I'd prefer reusing the existing perf-training 
>>  
>> setup to do so. In fact, I'd imagine most vendors would likely use the same 
>> training data for both PGO and BOLT and that use case should be supported.
>
> Do you happen to know any existing perf-training sets? Or is there a simple 
> way to create one?

I'm working on a script for generating perf-training sets from Ninja-based 
build systems, I can contribute it to LLVM if you think it'd be useful.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132975

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


[PATCH] D136040: [X86] Support PREFETCHI instructions

2022-10-16 Thread Phoebe Wang via Phabricator via cfe-commits
pengfei updated this revision to Diff 468109.
pengfei added a comment.

Fix lit fails.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136040

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Driver/Options.td
  clang/lib/Basic/Targets/X86.cpp
  clang/lib/Basic/Targets/X86.h
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Headers/CMakeLists.txt
  clang/lib/Headers/cpuid.h
  clang/lib/Headers/prfchiintrin.h
  clang/lib/Headers/x86gprintrin.h
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/X86/prefetchi-builtins.c
  clang/test/Driver/x86-target-features.c
  clang/test/Sema/builtin-prefetch.c
  llvm/include/llvm/Support/X86TargetParser.def
  llvm/lib/Support/Host.cpp
  llvm/lib/Support/X86TargetParser.cpp
  llvm/lib/Target/X86/X86.td
  llvm/lib/Target/X86/X86DiscriminateMemOps.cpp
  llvm/lib/Target/X86/X86Instr3DNow.td
  llvm/lib/Target/X86/X86InstrInfo.td
  llvm/lib/Target/X86/X86InstrSSE.td
  llvm/lib/Target/X86/X86Subtarget.h
  llvm/test/CodeGen/X86/prefetch.ll
  llvm/test/MC/Disassembler/X86/x86-64.txt
  llvm/test/MC/X86/PREFETCH-64.s

Index: llvm/test/MC/X86/PREFETCH-64.s
===
--- llvm/test/MC/X86/PREFETCH-64.s
+++ llvm/test/MC/X86/PREFETCH-64.s
@@ -168,3 +168,50 @@
 // CHECK: encoding: [0x0f,0x0d,0x12]
 prefetchwt1 (%rdx) 
 
+// CHECK: prefetchit0 485498096
+// CHECK: encoding: [0x0f,0x18,0x3c,0x25,0xf0,0x1c,0xf0,0x1c]
+prefetchit0 485498096
+
+// CHECK: prefetchit0 64(%rdx)
+// CHECK: encoding: [0x0f,0x18,0x7a,0x40]
+prefetchit0 64(%rdx)
+
+// CHECK: prefetchit0 64(%rdx,%rax,4)
+// CHECK: encoding: [0x0f,0x18,0x7c,0x82,0x40]
+prefetchit0 64(%rdx,%rax,4)
+
+// CHECK: prefetchit0 -64(%rdx,%rax,4)
+// CHECK: encoding: [0x0f,0x18,0x7c,0x82,0xc0]
+prefetchit0 -64(%rdx,%rax,4)
+
+// CHECK: prefetchit0 64(%rdx,%rax)
+// CHECK: encoding: [0x0f,0x18,0x7c,0x02,0x40]
+prefetchit0 64(%rdx,%rax)
+
+// CHECK: prefetchit0 (%rdx)
+// CHECK: encoding: [0x0f,0x18,0x3a]
+prefetchit0 (%rdx)
+
+// CHECK: prefetchit1 485498096
+// CHECK: encoding: [0x0f,0x18,0x34,0x25,0xf0,0x1c,0xf0,0x1c]
+prefetchit1 485498096
+
+// CHECK: prefetchit1 64(%rdx)
+// CHECK: encoding: [0x0f,0x18,0x72,0x40]
+prefetchit1 64(%rdx)
+
+// CHECK: prefetchit1 64(%rdx,%rax,4)
+// CHECK: encoding: [0x0f,0x18,0x74,0x82,0x40]
+prefetchit1 64(%rdx,%rax,4)
+
+// CHECK: prefetchit1 -64(%rdx,%rax,4)
+// CHECK: encoding: [0x0f,0x18,0x74,0x82,0xc0]
+prefetchit1 -64(%rdx,%rax,4)
+
+// CHECK: prefetchit1 64(%rdx,%rax)
+// CHECK: encoding: [0x0f,0x18,0x74,0x02,0x40]
+prefetchit1 64(%rdx,%rax)
+
+// CHECK: prefetchit1 (%rdx)
+// CHECK: encoding: [0x0f,0x18,0x32]
+prefetchit1 (%rdx)
Index: llvm/test/MC/Disassembler/X86/x86-64.txt
===
--- llvm/test/MC/Disassembler/X86/x86-64.txt
+++ llvm/test/MC/Disassembler/X86/x86-64.txt
@@ -761,3 +761,9 @@
 
 # CHECK: rdpru
 0x0f,0x01,0xfd
+
+# CHECK: prefetchit0 (%rip)
+0x0f,0x18,0x3d,0x00,0x00,0x00,0x00
+
+# CHECK: prefetchit1 (%rip)
+0x0f,0x18,0x35,0x00,0x00,0x00,0x00
Index: llvm/test/CodeGen/X86/prefetch.ll
===
--- llvm/test/CodeGen/X86/prefetch.ll
+++ llvm/test/CodeGen/X86/prefetch.ll
@@ -11,6 +11,8 @@
 ; RUN: llc < %s -mtriple=i686-- -mattr=-sse,+3dnow,+prefetchwt1 | FileCheck %s -check-prefix=PREFETCHWT1
 ; RUN: llc < %s -mtriple=i686-- -mattr=+3dnow | FileCheck %s -check-prefix=3DNOW
 ; RUN: llc < %s -mtriple=i686-- -mattr=+3dnow,+prfchw | FileCheck %s -check-prefix=3DNOW
+; RUN: llc < %s -mtriple=i686-- -mattr=+sse,+prefetchwt1,+prefetchi | FileCheck %s -check-prefix=PREFETCHWT1
+; RUN: llc < %s -mtriple=x86_64-- -mattr=+prefetchwt1,+prefetchi | FileCheck %s -check-prefix=PREFETCHI
 
 ; Rules:
 ; 3dnow by itself get you just the single prefetch instruction with no hints
@@ -33,6 +35,8 @@
 ; SSE-NEXT:prefetcht1 (%eax)
 ; SSE-NEXT:prefetcht0 (%eax)
 ; SSE-NEXT:prefetchnta (%eax)
+; SSE-NEXT:prefetcht0 (%eax)
+; SSE-NEXT:prefetcht1 (%eax)
 ; SSE-NEXT:retl
 ;
 ; PRFCHWSSE-LABEL: t:
@@ -46,6 +50,8 @@
 ; PRFCHWSSE-NEXT:prefetchw (%eax)
 ; PRFCHWSSE-NEXT:prefetchw (%eax)
 ; PRFCHWSSE-NEXT:prefetchw (%eax)
+; PRFCHWSSE-NEXT:prefetcht0 (%eax)
+; PRFCHWSSE-NEXT:prefetcht1 (%eax)
 ; PRFCHWSSE-NEXT:retl
 ;
 ; PREFETCHWT1-LABEL: t:
@@ -59,6 +65,8 @@
 ; PREFETCHWT1-NEXT:prefetchwt1 (%eax)
 ; PREFETCHWT1-NEXT:prefetchw (%eax)
 ; PREFETCHWT1-NEXT:prefetchwt1 (%eax)
+; PREFETCHWT1-NEXT:prefetcht0 (%eax)
+; PREFETCHWT1-NEXT:prefetcht1 (%eax)
 ; PREFETCHWT1-NEXT:retl
 ;
 ; 3DNOW-LABEL: t:
@@ -72,7 +80,23 @@
 ; 3DNOW-NEXT:prefetchw (%eax)
 ; 3DNOW-NEXT:prefetchw (%eax)
 ; 3DNOW-NEXT:prefetchw (%eax)
+; 3DNOW-NEXT:prefetch (%eax)
+; 3DNOW-NEXT:prefetch (%eax)
 ; 3DNOW-NEXT:retl
+;
+; PREFETCHI-LABEL: t:
+; PREFETCHI:   # %bb.0: # %entry
+; PREFETCHI

[PATCH] D133338: [clang][PowerPC] PPC64 VAArg use coerced integer type for direct aggregate fits in register

2022-10-16 Thread Ting Wang via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGee703b5cb134: [clang][PowerPC] PPC64 VAArg fix 
right-alignment for aggregates fit in register (authored by tingwang).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D18

Files:
  clang/lib/CodeGen/TargetInfo.cpp
  clang/test/CodeGen/PowerPC/ppc64-align-struct.c

Index: clang/test/CodeGen/PowerPC/ppc64-align-struct.c
===
--- clang/test/CodeGen/PowerPC/ppc64-align-struct.c
+++ clang/test/CodeGen/PowerPC/ppc64-align-struct.c
@@ -128,12 +128,12 @@
   return y;
 }
 
-// Error pattern will be fixed in https://reviews.llvm.org/D18
 // CHECK: define{{.*}} void @test8va(ptr noalias sret(%struct.test8) align 1 %[[AGG_RESULT:.*]], i32 noundef signext %x, ...)
 // CHECK: %[[CUR:[^ ]+]] = load ptr, ptr %ap
 // CHECK: %[[NEXT:[^ ]+]] = getelementptr inbounds i8, ptr %[[CUR]], i64 8
 // CHECK: store ptr %[[NEXT]], ptr %ap
-// CHECK: call void @llvm.memcpy.p0.p0.i64(ptr align 1 %[[AGG_RESULT]], ptr align 8 %[[CUR]], i64 1, i1 false)
+// CHECK: [[T0:%.*]] = getelementptr inbounds i8, ptr %[[CUR]], i64 7
+// CHECK: call void @llvm.memcpy.p0.p0.i64(ptr align 1 %[[AGG_RESULT]], ptr align 1 [[T0]], i64 1, i1 false)
 struct test8 test8va (int x, ...)
 {
   struct test8 y;
@@ -144,12 +144,12 @@
   return y;
 }
 
-// Error pattern will be fixed in https://reviews.llvm.org/D18
 // CHECK: define{{.*}} void @test9va(ptr noalias sret(%struct.test9) align 1 %[[AGG_RESULT:.*]], i32 noundef signext %x, ...)
 // CHECK: %[[CUR:[^ ]+]] = load ptr, ptr %ap
 // CHECK: %[[NEXT:[^ ]+]] = getelementptr inbounds i8, ptr %[[CUR]], i64 8
 // CHECK: store ptr %[[NEXT]], ptr %ap
-// CHECK: call void @llvm.memcpy.p0.p0.i64(ptr align 1 %[[AGG_RESULT]], ptr align 8 %[[CUR]], i64 2, i1 false)
+// CHECK: [[T0:%.*]] = getelementptr inbounds i8, ptr %[[CUR]], i64 6
+// CHECK: call void @llvm.memcpy.p0.p0.i64(ptr align 1 %[[AGG_RESULT]], ptr align 2 [[T0]], i64 2, i1 false)
 struct test9 test9va (int x, ...)
 {
   struct test9 y;
Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -322,13 +322,17 @@
 ///   leaving one or more empty slots behind as padding.  If this
 ///   is false, the returned address might be less-aligned than
 ///   DirectAlign.
+/// \param ForceRightAdjust - Default is false. On big-endian platform and
+///   if the argument is smaller than a slot, set this flag will force
+///   right-adjust the argument in its slot irrespective of the type.
 static Address emitVoidPtrDirectVAArg(CodeGenFunction &CGF,
   Address VAListAddr,
   llvm::Type *DirectTy,
   CharUnits DirectSize,
   CharUnits DirectAlign,
   CharUnits SlotSize,
-  bool AllowHigherAlign) {
+  bool AllowHigherAlign,
+  bool ForceRightAdjust = false) {
   // Cast the element type to i8* if necessary.  Some platforms define
   // va_list as a struct containing an i8* instead of just an i8*.
   if (VAListAddr.getElementType() != CGF.Int8PtrTy)
@@ -354,7 +358,7 @@
   // If the argument is smaller than a slot, and this is a big-endian
   // target, the argument will be right-adjusted in its slot.
   if (DirectSize < SlotSize && CGF.CGM.getDataLayout().isBigEndian() &&
-  !DirectTy->isStructTy()) {
+  (!DirectTy->isStructTy() || ForceRightAdjust)) {
 Addr = CGF.Builder.CreateConstInBoundsByteGEP(Addr, SlotSize - DirectSize);
   }
 
@@ -375,11 +379,15 @@
 ///   an argument type with an alignment greater than the slot size
 ///   will be emitted on a higher-alignment address, potentially
 ///   leaving one or more empty slots behind as padding.
+/// \param ForceRightAdjust - Default is false. On big-endian platform and
+///   if the argument is smaller than a slot, set this flag will force
+///   right-adjust the argument in its slot irrespective of the type.
 static Address emitVoidPtrVAArg(CodeGenFunction &CGF, Address VAListAddr,
 QualType ValueTy, bool IsIndirect,
 TypeInfoChars ValueInfo,
 CharUnits SlotSizeAndAlign,
-bool AllowHigherAlign) {
+bool AllowHigherAlign,
+bool ForceRightAdjust = false) {
   // The size and alignment of the value that was passed directly.
   CharUnits DirectSize, DirectAlign;
   if (IsIndirect) {
@@ -395,9 +403,9 @@
   if (IsIndirect)

[clang] ee703b5 - [clang][PowerPC] PPC64 VAArg fix right-alignment for aggregates fit in register

2022-10-16 Thread Ting Wang via cfe-commits

Author: Ting Wang
Date: 2022-10-16T22:01:47-04:00
New Revision: ee703b5cb134d182c2b589360714feab97f6a1cc

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

LOG: [clang][PowerPC] PPC64 VAArg fix right-alignment for aggregates fit in 
register

PPC64 ABI pass aggregates smaller than a register into the least
significant bits of the register. In the case of variadic functions,
they will end up right-aligned in their argument slots in the argument
area on big-endian targets. Apply right-alignment for these aggregates.

Fixes #55900.

Reviewed By: rjmccall

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

Added: 


Modified: 
clang/lib/CodeGen/TargetInfo.cpp
clang/test/CodeGen/PowerPC/ppc64-align-struct.c

Removed: 




diff  --git a/clang/lib/CodeGen/TargetInfo.cpp 
b/clang/lib/CodeGen/TargetInfo.cpp
index bfe0fbec2ad5..8253d15c26df 100644
--- a/clang/lib/CodeGen/TargetInfo.cpp
+++ b/clang/lib/CodeGen/TargetInfo.cpp
@@ -322,13 +322,17 @@ static llvm::Value 
*emitRoundPointerUpToAlignment(CodeGenFunction &CGF,
 ///   leaving one or more empty slots behind as padding.  If this
 ///   is false, the returned address might be less-aligned than
 ///   DirectAlign.
+/// \param ForceRightAdjust - Default is false. On big-endian platform and
+///   if the argument is smaller than a slot, set this flag will force
+///   right-adjust the argument in its slot irrespective of the type.
 static Address emitVoidPtrDirectVAArg(CodeGenFunction &CGF,
   Address VAListAddr,
   llvm::Type *DirectTy,
   CharUnits DirectSize,
   CharUnits DirectAlign,
   CharUnits SlotSize,
-  bool AllowHigherAlign) {
+  bool AllowHigherAlign,
+  bool ForceRightAdjust = false) {
   // Cast the element type to i8* if necessary.  Some platforms define
   // va_list as a struct containing an i8* instead of just an i8*.
   if (VAListAddr.getElementType() != CGF.Int8PtrTy)
@@ -354,7 +358,7 @@ static Address emitVoidPtrDirectVAArg(CodeGenFunction &CGF,
   // If the argument is smaller than a slot, and this is a big-endian
   // target, the argument will be right-adjusted in its slot.
   if (DirectSize < SlotSize && CGF.CGM.getDataLayout().isBigEndian() &&
-  !DirectTy->isStructTy()) {
+  (!DirectTy->isStructTy() || ForceRightAdjust)) {
 Addr = CGF.Builder.CreateConstInBoundsByteGEP(Addr, SlotSize - DirectSize);
   }
 
@@ -375,11 +379,15 @@ static Address emitVoidPtrDirectVAArg(CodeGenFunction 
&CGF,
 ///   an argument type with an alignment greater than the slot size
 ///   will be emitted on a higher-alignment address, potentially
 ///   leaving one or more empty slots behind as padding.
+/// \param ForceRightAdjust - Default is false. On big-endian platform and
+///   if the argument is smaller than a slot, set this flag will force
+///   right-adjust the argument in its slot irrespective of the type.
 static Address emitVoidPtrVAArg(CodeGenFunction &CGF, Address VAListAddr,
 QualType ValueTy, bool IsIndirect,
 TypeInfoChars ValueInfo,
 CharUnits SlotSizeAndAlign,
-bool AllowHigherAlign) {
+bool AllowHigherAlign,
+bool ForceRightAdjust = false) {
   // The size and alignment of the value that was passed directly.
   CharUnits DirectSize, DirectAlign;
   if (IsIndirect) {
@@ -395,9 +403,9 @@ static Address emitVoidPtrVAArg(CodeGenFunction &CGF, 
Address VAListAddr,
   if (IsIndirect)
 DirectTy = DirectTy->getPointerTo(0);
 
-  Address Addr =
-  emitVoidPtrDirectVAArg(CGF, VAListAddr, DirectTy, DirectSize, 
DirectAlign,
- SlotSizeAndAlign, AllowHigherAlign);
+  Address Addr = emitVoidPtrDirectVAArg(CGF, VAListAddr, DirectTy, DirectSize,
+DirectAlign, SlotSizeAndAlign,
+AllowHigherAlign, ForceRightAdjust);
 
   if (IsIndirect) {
 Addr = Address(CGF.Builder.CreateLoad(Addr), ElementTy, ValueInfo.Align);
@@ -5451,8 +5459,21 @@ Address PPC64_SVR4_ABIInfo::EmitVAArg(CodeGenFunction 
&CGF, Address VAListAddr,
   }
 
   // Otherwise, just use the general rule.
-  return emitVoidPtrVAArg(CGF, VAListAddr, Ty, /*Indirect*/ false,
-  TypeInfo, SlotSize, /*AllowHigher*/ true);
+  //
+  // The PPC64 ABI passes some arguments in integer registers, even to variadic
+  // functions. To allow va_list to use 

[PATCH] D136041: [clang][DebugInfo] Emit DISubprogram for extern functions with reserved names

2022-10-16 Thread Eduard Zingerman via Phabricator via cfe-commits
eddyz87 added a reviewer: aprantl.
eddyz87 added a comment.

Hello Adrian, I've noticed that you was tagged as a reviewer in a somewhat 
related revision: https://reviews.llvm.org/D133060, so decided to tag you here.
Could you please take a look?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136041

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


[PATCH] D136041: [clang][DebugInfo] Emit DISubprogram for extern functions with reserved names

2022-10-16 Thread Eduard Zingerman via Phabricator via cfe-commits
eddyz87 created this revision.
Herald added subscribers: hiraditya, kristof.beyls.
Herald added a project: All.
eddyz87 updated this revision to Diff 468102.
eddyz87 added a comment.
eddyz87 published this revision for review.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

Rebase


Callsite `DISubprogram` entries are not generated for:

- builtin functions;
- external functions with reserved names (e.g. names starting from "__").

This limitation was added by the commit [1] as a workaround for the
situation described in [2] that triggered the IR verifier error.
The goal of the present commit is to lift this limitation by adjusting
the IR verifier logic.

The logic behind [1] is to avoid the following situation:

- a `DISubprogram` is added for some builtin function;
- there is some location where this builtin is also emitted by a transformation 
(w/o debug location);
- the `Verifier::visitCallBase` sees a call to a function with `DISubprogram` 
but w/o debug location and emits an error.

Here is an updated example of such situation taken from [2]:

  extern "C" int memcmp(void *, void *, long);
  
  struct a { int b; int c; int d; };
  
  struct e { int f[1000]; };
  
  bool foo(e g, e &h) {
// DISubprogram for memcmp is created here when [1] is commented out
return memcmp(&g, &h, sizeof(e));
  }
  
  bool bar(a &g, a &h) {
// memcmp might be generated here by MergeICmps
return g.b == h.b && g.c == h.c && g.d == h.d;
  }

This triggers the verifier error when:

- compiled for AArch64: `clang++ -c -g -Oz -target 
aarch64-unknown-linux-android21 test.cpp`;
- [1] check is commented out.

Instead of forbidding generation of `DISubprogram` entries as in [1]
one can instead adjust the verifier to additionally check if callee
has a body. Functions w/o bodies cannot be inlined and thus verifier
warning is not necessary.

E.g. `llvm::InlineFunction` requires functions for which
`GlobalValue::isDeclaration() == false`.

[1] 568db780bb7267651a902da8e85bc59fc89aea70 

[2] https://bugs.chromium.org/p/chromium/issues/detail?id=1022296


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D136041

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/test/CodeGen/debug-info-extern-call.c
  llvm/lib/IR/Verifier.cpp
  llvm/test/Verifier/callsite-dbgloc.ll


Index: llvm/test/Verifier/callsite-dbgloc.ll
===
--- llvm/test/Verifier/callsite-dbgloc.ll
+++ llvm/test/Verifier/callsite-dbgloc.ll
@@ -45,6 +45,9 @@
   call void @j()
 ; CHECK: inlinable function call in a function with debug info must have a 
!dbg location
   call void @k()
+; CHECK-NOT: inlinable function call in a function with debug info must have a 
!dbg location
+; CHECK-NOT: @i
+  call void (...) @i()
   ret void, !dbg !13
 }
 
Index: llvm/lib/IR/Verifier.cpp
===
--- llvm/lib/IR/Verifier.cpp
+++ llvm/lib/IR/Verifier.cpp
@@ -3466,9 +3466,11 @@
   // Verify that each inlinable callsite of a debug-info-bearing function in a
   // debug-info-bearing function has a debug location attached to it. Failure 
to
   // do so causes assertion failures when the inliner sets up inline scope info
-  // (Interposable functions are not inlinable).
+  // (Interposable functions are not inlinable as are functions w/o
+  //  declarations).
   if (Call.getFunction()->getSubprogram() && Call.getCalledFunction() &&
   !Call.getCalledFunction()->isInterposable() &&
+  !Call.getCalledFunction()->isDeclaration() &&
   Call.getCalledFunction()->getSubprogram())
 CheckDI(Call.getDebugLoc(),
 "inlinable function call in a function with "
Index: clang/test/CodeGen/debug-info-extern-call.c
===
--- clang/test/CodeGen/debug-info-extern-call.c
+++ clang/test/CodeGen/debug-info-extern-call.c
@@ -29,8 +29,8 @@
 // DECLS-FOR-EXTERN: [[FN1_TYPES]] = !{[[X_TYPE:![0-9]+]],
 // DECLS-FOR-EXTERN: [[X_TYPE]] = !DIDerivedType(tag: DW_TAG_typedef, name: 
"x",
 // DECLS-FOR-EXTERN-SAME: baseType: [[INT_TYPE]])
-// DECLS-FOR-EXTERN-NOT: !DISubprogram(name: "memcmp"
-// DECLS-FOR-EXTERN-NOT: !DISubprogram(name: "__some_reserved_name"
+// DECLS-FOR-EXTERN: !DISubprogram(name: "memcmp"
+// DECLS-FOR-EXTERN: !DISubprogram(name: "__some_reserved_name"
 
 // NO-DECLS-FOR-EXTERN-NOT: !DISubprogram(name: "fn1"
 // NO-DECLS-FOR-EXTERN-NOT: !DISubprogram(name: "memcmp"
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -4228,17 +4228,11 @@
   if (Func->getSubprogram())
 return;
 
-  // Do not emit a declaration subprogram for a builtin, a function with 
nodebug
-  // attribute, or if call site info isn't required. Also, elide de

[PATCH] D135640: fix vectorization analysis msg for runtime checks

2022-10-16 Thread Josh Milthorpe via Phabricator via cfe-commits
milthorpe updated this revision to Diff 468103.
milthorpe added a comment.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Update vectorization analysis msg in clang frontend test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135640

Files:
  clang/test/Frontend/optimization-remark-options.c
  llvm/lib/Transforms/Vectorize/LoopVectorize.cpp


Index: llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
===
--- llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -10345,8 +10345,8 @@
 return OptimizationRemarkAnalysisAliasing(
DEBUG_TYPE, "CantReorderMemOps", L->getStartLoc(),
L->getHeader())
-   << "loop not vectorized: cannot prove it is safe to reorder "
-  "memory operations";
+   << "loop not vectorized: it is not profitable to reorder memory 
"
+  "operations with runtime checks";
   });
   LLVM_DEBUG(dbgs() << "LV: Too many memory checks needed.\n");
   Hints.emitRemarkWithHints();
Index: clang/test/Frontend/optimization-remark-options.c
===
--- clang/test/Frontend/optimization-remark-options.c
+++ clang/test/Frontend/optimization-remark-options.c
@@ -12,7 +12,7 @@
   return v;
 }
 
-// CHECK: {{.*}}:18:3: remark: loop not vectorized: cannot prove it is safe to 
reorder memory operations; allow reordering by specifying '#pragma clang loop 
vectorize(enable)' before the loop. If the arrays will always be independent 
specify '#pragma clang loop vectorize(assume_safety)' before the loop or 
provide the '__restrict__' qualifier with the independent array arguments. 
Erroneous results will occur if these options are incorrectly applied!
+// CHECK: {{.*}}:18:3: remark: loop not vectorized: it is not profitable to 
reorder memory operations with runtime checks; allow reordering by specifying 
'#pragma clang loop vectorize(enable)' before the loop. If the arrays will 
always be independent specify '#pragma clang loop vectorize(assume_safety)' 
before the loop or provide the '__restrict__' qualifier with the independent 
array arguments. Erroneous results will occur if these options are incorrectly 
applied!
 
 void foo2(int *dw, int *uw, int *A, int *B, int *C, int *D, int N) {
   for (long i = 0; i < N; i++) {


Index: llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
===
--- llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -10345,8 +10345,8 @@
 return OptimizationRemarkAnalysisAliasing(
DEBUG_TYPE, "CantReorderMemOps", L->getStartLoc(),
L->getHeader())
-   << "loop not vectorized: cannot prove it is safe to reorder "
-  "memory operations";
+   << "loop not vectorized: it is not profitable to reorder memory "
+  "operations with runtime checks";
   });
   LLVM_DEBUG(dbgs() << "LV: Too many memory checks needed.\n");
   Hints.emitRemarkWithHints();
Index: clang/test/Frontend/optimization-remark-options.c
===
--- clang/test/Frontend/optimization-remark-options.c
+++ clang/test/Frontend/optimization-remark-options.c
@@ -12,7 +12,7 @@
   return v;
 }
 
-// CHECK: {{.*}}:18:3: remark: loop not vectorized: cannot prove it is safe to reorder memory operations; allow reordering by specifying '#pragma clang loop vectorize(enable)' before the loop. If the arrays will always be independent specify '#pragma clang loop vectorize(assume_safety)' before the loop or provide the '__restrict__' qualifier with the independent array arguments. Erroneous results will occur if these options are incorrectly applied!
+// CHECK: {{.*}}:18:3: remark: loop not vectorized: it is not profitable to reorder memory operations with runtime checks; allow reordering by specifying '#pragma clang loop vectorize(enable)' before the loop. If the arrays will always be independent specify '#pragma clang loop vectorize(assume_safety)' before the loop or provide the '__restrict__' qualifier with the independent array arguments. Erroneous results will occur if these options are incorrectly applied!
 
 void foo2(int *dw, int *uw, int *A, int *B, int *C, int *D, int N) {
   for (long i = 0; i < N; i++) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D136022: [clang] Add time profile for constant evaluation

2022-10-16 Thread Joe Loser via Phabricator via cfe-commits
jloser added a comment.

I like the idea of this — +1 for the direction.  I'd like to see some tests 
through before I approve.

Thanks for working on this!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136022

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


[PATCH] D133375: [CMake] Remove CLANG_DEFAULT_STD_C/CLANG_DEFAULT_STD_CXX

2022-10-16 Thread Fangrui Song via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG3baadff896ed: [CMake] Remove 
CLANG_DEFAULT_STD_C/CLANG_DEFAULT_STD_CXX (authored by MaskRay).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133375

Files:
  clang/CMakeLists.txt
  clang/include/clang/Config/config.h.cmake
  clang/lib/Basic/LangStandards.cpp
  clang/test/Preprocessor/lang-std.cpp
  clang/test/lit.cfg.py
  clang/test/lit.site.cfg.py.in
  llvm/utils/gn/secondary/clang/include/clang/Config/BUILD.gn
  llvm/utils/gn/secondary/clang/test/BUILD.gn
  utils/bazel/llvm-project-overlay/clang/include/clang/Config/config.h

Index: utils/bazel/llvm-project-overlay/clang/include/clang/Config/config.h
===
--- utils/bazel/llvm-project-overlay/clang/include/clang/Config/config.h
+++ utils/bazel/llvm-project-overlay/clang/include/clang/Config/config.h
@@ -28,24 +28,6 @@
 /* Default linker to use. */
 #define CLANG_DEFAULT_LINKER ""
 
-/* Default C/ObjC standard to use. */
-/* #undef CLANG_DEFAULT_STD_C */
-/* Always #define something so that missing the config.h #include at use sites
- * becomes a compile error.
- */
-#ifndef CLANG_DEFAULT_STD_C
-#define CLANG_DEFAULT_STD_C LangStandard::lang_unspecified
-#endif
-
-/* Default C++/ObjC++ standard to use. */
-/* #undef CLANG_DEFAULT_STD_CXX */
-/* Always #define something so that missing the config.h #include at use sites
- * becomes a compile error.
- */
-#ifndef CLANG_DEFAULT_STD_CXX
-#define CLANG_DEFAULT_STD_CXX LangStandard::lang_unspecified
-#endif
-
 /* Default C++ stdlib to use. */
 #define CLANG_DEFAULT_CXX_STDLIB ""
 
Index: llvm/utils/gn/secondary/clang/test/BUILD.gn
===
--- llvm/utils/gn/secondary/clang/test/BUILD.gn
+++ llvm/utils/gn/secondary/clang/test/BUILD.gn
@@ -46,7 +46,6 @@
 "LLVM_WITH_Z3=0",
 "CLANG_BUILD_EXAMPLES=0",
 "CLANG_BUILT_STANDALONE=0",
-"CLANG_DEFAULT_STD_CXX=",
 "CLANG_DEFAULT_CXX_STDLIB=",  # Empty string means "default value" here.
 "CLANG_DEFAULT_PIE_ON_LINUX=0",
 "CLANG_PLUGIN_SUPPORT=0",  # FIXME: Analysis/plugins need global -fPIC
Index: llvm/utils/gn/secondary/clang/include/clang/Config/BUILD.gn
===
--- llvm/utils/gn/secondary/clang/include/clang/Config/BUILD.gn
+++ llvm/utils/gn/secondary/clang/include/clang/Config/BUILD.gn
@@ -11,8 +11,6 @@
 "BUG_REPORT_URL=https://github.com/llvm/llvm-project/issues/";,
 "CLANG_DEFAULT_PIE_ON_LINUX=1",
 "CLANG_DEFAULT_LINKER=",
-"CLANG_DEFAULT_STD_C=",
-"CLANG_DEFAULT_STD_CXX=",
 "CLANG_DEFAULT_CXX_STDLIB=",
 "CLANG_DEFAULT_RTLIB=",
 "CLANG_DEFAULT_OBJCOPY=objcopy",
Index: clang/test/lit.site.cfg.py.in
===
--- clang/test/lit.site.cfg.py.in
+++ clang/test/lit.site.cfg.py.in
@@ -24,7 +24,6 @@
 config.have_zstd = @LLVM_ENABLE_ZSTD@
 config.clang_arcmt = @CLANG_ENABLE_ARCMT@
 config.clang_default_pie_on_linux = @CLANG_DEFAULT_PIE_ON_LINUX@
-config.clang_default_std_cxx = "@CLANG_DEFAULT_STD_CXX@"
 config.clang_default_cxx_stdlib = "@CLANG_DEFAULT_CXX_STDLIB@"
 config.clang_staticanalyzer = @CLANG_ENABLE_STATIC_ANALYZER@
 config.clang_staticanalyzer_z3 = @LLVM_WITH_Z3@
Index: clang/test/lit.cfg.py
===
--- clang/test/lit.cfg.py
+++ clang/test/lit.cfg.py
@@ -126,9 +126,6 @@
 if config.clang_default_pie_on_linux:
 config.available_features.add('default-pie-on-linux')
 
-if config.clang_default_std_cxx != '':
-config.available_features.add('default-std-cxx')
-
 # Set available features we allow tests to conditionalize on.
 #
 if config.clang_default_cxx_stdlib != '':
Index: clang/test/Preprocessor/lang-std.cpp
===
--- clang/test/Preprocessor/lang-std.cpp
+++ clang/test/Preprocessor/lang-std.cpp
@@ -1,5 +1,5 @@
-// UNSUPPORTED: default-std-cxx, ps4, ps5
-/// Test default standards when CLANG_DEFAULT_STD_CXX is unspecified.
+// UNSUPPORTED: ps4, ps5
+/// Test default standards.
 /// PS4/PS5 default to gnu++14.
 
 // RUN: %clang_cc1 -dM -E %s | FileCheck --check-prefix=CXX17 %s
Index: clang/lib/Basic/LangStandards.cpp
===
--- clang/lib/Basic/LangStandards.cpp
+++ clang/lib/Basic/LangStandards.cpp
@@ -58,23 +58,14 @@
 return LangStandard::lang_cuda;
   case Language::Asm:
   case Language::C:
-if (CLANG_DEFAULT_STD_C != LangStandard::lang_unspecified)
-  return CLANG_DEFAULT_STD_C;
-
 // The PS4 uses C99 as the default C standard.
 if (T.isPS4())
   return LangStandard::lang_gnu99;
 return LangStandard::lang_gnu17;
   case Language:

[clang] 3baadff - [CMake] Remove CLANG_DEFAULT_STD_C/CLANG_DEFAULT_STD_CXX

2022-10-16 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2022-10-16T13:15:44-07:00
New Revision: 3baadff896eddfa09fcd458d120bac95491992a7

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

LOG: [CMake] Remove CLANG_DEFAULT_STD_C/CLANG_DEFAULT_STD_CXX

When Clang is used as a cross compiler, it should respect the target
platform default. Defaulting to a configure-time 
CLANG_DEFAULT_STD_C/CLANG_DEFAULT_STD_CXX
does not make much sense.

When Clang is used as a single-platform compiler, we should use Clang
configuration file (https://discourse.llvm.org/t/configuration-files/42529
https://clang.llvm.org/docs/UsersManual.html#configuration-files).

The Gentoo needs from D34365 has been satisfied by a configuration file.

Reviewed By: mgorny

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

Added: 


Modified: 
clang/CMakeLists.txt
clang/include/clang/Config/config.h.cmake
clang/lib/Basic/LangStandards.cpp
clang/test/Preprocessor/lang-std.cpp
clang/test/lit.cfg.py
clang/test/lit.site.cfg.py.in
llvm/utils/gn/secondary/clang/include/clang/Config/BUILD.gn
llvm/utils/gn/secondary/clang/test/BUILD.gn
utils/bazel/llvm-project-overlay/clang/include/clang/Config/config.h

Removed: 




diff  --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt
index 875bd27e13206..87ce418424c96 100644
--- a/clang/CMakeLists.txt
+++ b/clang/CMakeLists.txt
@@ -189,12 +189,6 @@ set(CLANG_SPAWN_CC1 OFF CACHE BOOL
 
 option(CLANG_DEFAULT_PIE_ON_LINUX "Default to -fPIE and -pie on linux-gnu" ON)
 
-# TODO: verify the values against LangStandards.def?
-set(CLANG_DEFAULT_STD_C "" CACHE STRING
-  "Default standard to use for C/ObjC code (IDENT from LangStandards.def, 
empty for platform default)")
-set(CLANG_DEFAULT_STD_CXX "" CACHE STRING
-  "Default standard to use for C++/ObjC++ code (IDENT from LangStandards.def, 
empty for platform default)")
-
 set(CLANG_DEFAULT_LINKER "" CACHE STRING
   "Default linker to use (linker name or absolute path, empty for platform 
default)")
 

diff  --git a/clang/include/clang/Config/config.h.cmake 
b/clang/include/clang/Config/config.h.cmake
index 3ffc2a12a89fe..fdae92ba0edbb 100644
--- a/clang/include/clang/Config/config.h.cmake
+++ b/clang/include/clang/Config/config.h.cmake
@@ -14,24 +14,6 @@
 /* Default linker to use. */
 #define CLANG_DEFAULT_LINKER "${CLANG_DEFAULT_LINKER}"
 
-/* Default C/ObjC standard to use. */
-#cmakedefine CLANG_DEFAULT_STD_C LangStandard::lang_${CLANG_DEFAULT_STD_C}
-/* Always #define something so that missing the config.h #include at use sites
- * becomes a compile error.
- */
-#ifndef CLANG_DEFAULT_STD_C
-#define CLANG_DEFAULT_STD_C LangStandard::lang_unspecified
-#endif
-
-/* Default C++/ObjC++ standard to use. */
-#cmakedefine CLANG_DEFAULT_STD_CXX LangStandard::lang_${CLANG_DEFAULT_STD_CXX}
-/* Always #define something so that missing the config.h #include at use sites
- * becomes a compile error.
- */
-#ifndef CLANG_DEFAULT_STD_CXX
-#define CLANG_DEFAULT_STD_CXX LangStandard::lang_unspecified
-#endif
-
 /* Default C++ stdlib to use. */
 #define CLANG_DEFAULT_CXX_STDLIB "${CLANG_DEFAULT_CXX_STDLIB}"
 

diff  --git a/clang/lib/Basic/LangStandards.cpp 
b/clang/lib/Basic/LangStandards.cpp
index 92e8ab347dda1..4b36f7bf4786c 100644
--- a/clang/lib/Basic/LangStandards.cpp
+++ b/clang/lib/Basic/LangStandards.cpp
@@ -58,23 +58,14 @@ LangStandard::Kind 
clang::getDefaultLanguageStandard(clang::Language Lang,
 return LangStandard::lang_cuda;
   case Language::Asm:
   case Language::C:
-if (CLANG_DEFAULT_STD_C != LangStandard::lang_unspecified)
-  return CLANG_DEFAULT_STD_C;
-
 // The PS4 uses C99 as the default C standard.
 if (T.isPS4())
   return LangStandard::lang_gnu99;
 return LangStandard::lang_gnu17;
   case Language::ObjC:
-if (CLANG_DEFAULT_STD_C != LangStandard::lang_unspecified)
-  return CLANG_DEFAULT_STD_C;
-
 return LangStandard::lang_gnu11;
   case Language::CXX:
   case Language::ObjCXX:
-if (CLANG_DEFAULT_STD_CXX != LangStandard::lang_unspecified)
-  return CLANG_DEFAULT_STD_CXX;
-
 if (T.isPS())
   return LangStandard::lang_gnucxx14;
 return LangStandard::lang_gnucxx17;

diff  --git a/clang/test/Preprocessor/lang-std.cpp 
b/clang/test/Preprocessor/lang-std.cpp
index 538f1b1976dad..e8260147f40ee 100644
--- a/clang/test/Preprocessor/lang-std.cpp
+++ b/clang/test/Preprocessor/lang-std.cpp
@@ -1,5 +1,5 @@
-// UNSUPPORTED: default-std-cxx, ps4, ps5
-/// Test default standards when CLANG_DEFAULT_STD_CXX is unspecified.
+// UNSUPPORTED: ps4, ps5
+/// Test default standards.
 /// PS4/PS5 default to gnu++14.
 
 // RUN: %clang_cc1 -dM -E %s | FileCheck --check-prefix=CXX17 %s

diff  --git a/clang/test/lit.cfg.py b/clang/test/lit.cfg.py
index 055fd0a4324e3..8cad77b57219b 100644
---

[PATCH] D136033: [clangd] Add an option to specify a workspece-level config file

2022-10-16 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

I have some concerns about adding an undefined "workspace" concept, and in 
general extending the config system in a way that's hard to use (because of the 
need to customize flags per workspace). Maybe best to discuss on the bug? 
https://github.com/clangd/clangd/issues/1336


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136033

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


[clang] d72de36 - [clang] Use llvm::find (NFC)

2022-10-16 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2022-10-16T12:33:47-07:00
New Revision: d72de36da3bc5b0bd98ea680147cacca57518831

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

LOG: [clang] Use llvm::find (NFC)

Added: 


Modified: 
clang/lib/Driver/ToolChains/Arch/CSKY.cpp
clang/lib/Tooling/ArgumentsAdjusters.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Arch/CSKY.cpp 
b/clang/lib/Driver/ToolChains/Arch/CSKY.cpp
index 3a8f927856092..814f9849ef05d 100644
--- a/clang/lib/Driver/ToolChains/Arch/CSKY.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/CSKY.cpp
@@ -99,7 +99,7 @@ getCSKYFPUFeatures(const Driver &D, const Arg *A, const 
ArgList &Args,
   auto RemoveTargetFPUFeature =
   [&Features](ArrayRef FPUFeatures) {
 for (auto FPUFeature : FPUFeatures) {
-  auto it = std::find(Features.begin(), Features.end(), FPUFeature);
+  auto it = llvm::find(Features, FPUFeature);
   if (it != Features.end())
 Features.erase(it);
 }

diff  --git a/clang/lib/Tooling/ArgumentsAdjusters.cpp 
b/clang/lib/Tooling/ArgumentsAdjusters.cpp
index 7f5dc4d62f11b..e40df62573784 100644
--- a/clang/lib/Tooling/ArgumentsAdjusters.cpp
+++ b/clang/lib/Tooling/ArgumentsAdjusters.cpp
@@ -122,7 +122,7 @@ ArgumentsAdjuster getInsertArgumentAdjuster(const 
CommandLineArguments &Extra,
 
 CommandLineArguments::iterator I;
 if (Pos == ArgumentInsertPosition::END) {
-  I = std::find(Return.begin(), Return.end(), "--");
+  I = llvm::find(Return, "--");
 } else {
   I = Return.begin();
   ++I; // To leave the program name in place



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


[PATCH] D135953: [IncludeCleaner] Introduce decl to location mapping

2022-10-16 Thread Thorsten via Phabricator via cfe-commits
tschuett added a comment.

We support Apple Clang 9.3, but `std:variant` ships with Apple Clang 10.0. :-(


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135953

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


[PATCH] D135439: Keep configuration file search directories in ExpansionContext. NFC

2022-10-16 Thread Michał Górny via Phabricator via cfe-commits
mgorny added inline comments.



Comment at: llvm/include/llvm/Support/CommandLine.h:2138
+  /// directories specified by SearchDirs field.
+  bool findConfigFile(StringRef FileName, std::string &FilePath);
+

I'm sorry if I'm missing something obvious but is there a specific reason 
you're using `std::string` here when pretty much all prior call sites were 
using `SmallString`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135439

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


[PATCH] D135953: [IncludeCleaner] Introduce decl to location mapping

2022-10-16 Thread Thorsten via Phabricator via cfe-commits
tschuett added inline comments.



Comment at: clang-tools-extra/include-cleaner/lib/AnalysisInternal.h:64
 
+using SymbolLocation = std::variant;
+/// A set of locations that provides the declaration, while indicating if

sammccall wrote:
> This is an important public API concept ==> It should be documented and part 
> of a public header, I think
IIRC, the supported Apple Clang does not support `std::variant` yet. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135953

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


[clang] 647e48c - [clang] Use std::clamp (NFC)

2022-10-16 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2022-10-16T10:11:29-07:00
New Revision: 647e48cf5f6094ad874766c1471410641b1b86bd

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

LOG: [clang] Use std::clamp (NFC)

Note that the constructor of MipsABIInfo guarantees that
MinABIStackAlignInBytes <= StackAlignInBytes, so we can use std::clamp
safely.

Added: 


Modified: 
clang/lib/CodeGen/TargetInfo.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/TargetInfo.cpp 
b/clang/lib/CodeGen/TargetInfo.cpp
index 74997f0f9e9d..bfe0fbec2ad5 100644
--- a/clang/lib/CodeGen/TargetInfo.cpp
+++ b/clang/lib/CodeGen/TargetInfo.cpp
@@ -7845,7 +7845,7 @@ void MSP430TargetCodeGenInfo::setTargetAttributes(
 namespace {
 class MipsABIInfo : public ABIInfo {
   bool IsO32;
-  unsigned MinABIStackAlignInBytes, StackAlignInBytes;
+  const unsigned MinABIStackAlignInBytes, StackAlignInBytes;
   void CoerceToIntArgs(uint64_t TySize,
SmallVectorImpl &ArgList) const;
   llvm::Type* HandleAggregates(QualType Ty, uint64_t TySize) const;
@@ -8022,8 +8022,8 @@ MipsABIInfo::classifyArgumentType(QualType Ty, uint64_t 
&Offset) const {
   uint64_t TySize = getContext().getTypeSize(Ty);
   uint64_t Align = getContext().getTypeAlign(Ty) / 8;
 
-  Align = std::min(std::max(Align, (uint64_t)MinABIStackAlignInBytes),
-   (uint64_t)StackAlignInBytes);
+  Align = std::clamp(Align, (uint64_t)MinABIStackAlignInBytes,
+ (uint64_t)StackAlignInBytes);
   unsigned CurrOffset = llvm::alignTo(Offset, Align);
   Offset = CurrOffset + llvm::alignTo(TySize, Align * 8) / 8;
 



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


[clang] 4ad4487 - [clang] Use llvm::is_contained (NFC)

2022-10-16 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2022-10-16T09:19:08-07:00
New Revision: 4ad44872c4e88f78a6d6906c345ad502dd92a455

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

LOG: [clang] Use llvm::is_contained (NFC)

Added: 


Modified: 
clang/include/clang/AST/OpenMPClause.h

Removed: 




diff  --git a/clang/include/clang/AST/OpenMPClause.h 
b/clang/include/clang/AST/OpenMPClause.h
index 23b4a9517192c..1a4ec43705bc3 100644
--- a/clang/include/clang/AST/OpenMPClause.h
+++ b/clang/include/clang/AST/OpenMPClause.h
@@ -8965,9 +8965,7 @@ class OMPChildren final
   const CapturedStmt *
   getCapturedStmt(OpenMPDirectiveKind RegionKind,
   ArrayRef CaptureRegions) const {
-assert(llvm::any_of(
-   CaptureRegions,
-   [=](const OpenMPDirectiveKind K) { return K == RegionKind; }) &&
+assert(llvm::is_contained(CaptureRegions, RegionKind) &&
"RegionKind not found in OpenMP CaptureRegions.");
 auto *CS = cast(getAssociatedStmt());
 for (auto ThisCaptureRegion : CaptureRegions) {



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


[PATCH] D136040: [X86] Support PREFETCHI instructions

2022-10-16 Thread Phoebe Wang via Phabricator via cfe-commits
pengfei updated this revision to Diff 468080.
pengfei added a comment.

Fix lit fails.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136040

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Driver/Options.td
  clang/lib/Basic/Targets/X86.cpp
  clang/lib/Basic/Targets/X86.h
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Headers/cpuid.h
  clang/lib/Headers/prfchiintrin.h
  clang/lib/Headers/x86gprintrin.h
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/X86/prefetchi-builtins.c
  clang/test/Driver/x86-target-features.c
  clang/test/Sema/builtin-prefetch.c
  llvm/include/llvm/Support/X86TargetParser.def
  llvm/lib/Support/Host.cpp
  llvm/lib/Support/X86TargetParser.cpp
  llvm/lib/Target/X86/X86.td
  llvm/lib/Target/X86/X86DiscriminateMemOps.cpp
  llvm/lib/Target/X86/X86Instr3DNow.td
  llvm/lib/Target/X86/X86InstrInfo.td
  llvm/lib/Target/X86/X86InstrSSE.td
  llvm/lib/Target/X86/X86Subtarget.h
  llvm/test/CodeGen/X86/prefetch.ll
  llvm/test/MC/Disassembler/X86/x86-64.txt
  llvm/test/MC/X86/PREFETCH-64.s

Index: llvm/test/MC/X86/PREFETCH-64.s
===
--- llvm/test/MC/X86/PREFETCH-64.s
+++ llvm/test/MC/X86/PREFETCH-64.s
@@ -168,3 +168,50 @@
 // CHECK: encoding: [0x0f,0x0d,0x12]
 prefetchwt1 (%rdx) 
 
+// CHECK: prefetchit0 485498096
+// CHECK: encoding: [0x0f,0x18,0x3c,0x25,0xf0,0x1c,0xf0,0x1c]
+prefetchit0 485498096
+
+// CHECK: prefetchit0 64(%rdx)
+// CHECK: encoding: [0x0f,0x18,0x7a,0x40]
+prefetchit0 64(%rdx)
+
+// CHECK: prefetchit0 64(%rdx,%rax,4)
+// CHECK: encoding: [0x0f,0x18,0x7c,0x82,0x40]
+prefetchit0 64(%rdx,%rax,4)
+
+// CHECK: prefetchit0 -64(%rdx,%rax,4)
+// CHECK: encoding: [0x0f,0x18,0x7c,0x82,0xc0]
+prefetchit0 -64(%rdx,%rax,4)
+
+// CHECK: prefetchit0 64(%rdx,%rax)
+// CHECK: encoding: [0x0f,0x18,0x7c,0x02,0x40]
+prefetchit0 64(%rdx,%rax)
+
+// CHECK: prefetchit0 (%rdx)
+// CHECK: encoding: [0x0f,0x18,0x3a]
+prefetchit0 (%rdx)
+
+// CHECK: prefetchit1 485498096
+// CHECK: encoding: [0x0f,0x18,0x34,0x25,0xf0,0x1c,0xf0,0x1c]
+prefetchit1 485498096
+
+// CHECK: prefetchit1 64(%rdx)
+// CHECK: encoding: [0x0f,0x18,0x72,0x40]
+prefetchit1 64(%rdx)
+
+// CHECK: prefetchit1 64(%rdx,%rax,4)
+// CHECK: encoding: [0x0f,0x18,0x74,0x82,0x40]
+prefetchit1 64(%rdx,%rax,4)
+
+// CHECK: prefetchit1 -64(%rdx,%rax,4)
+// CHECK: encoding: [0x0f,0x18,0x74,0x82,0xc0]
+prefetchit1 -64(%rdx,%rax,4)
+
+// CHECK: prefetchit1 64(%rdx,%rax)
+// CHECK: encoding: [0x0f,0x18,0x74,0x02,0x40]
+prefetchit1 64(%rdx,%rax)
+
+// CHECK: prefetchit1 (%rdx)
+// CHECK: encoding: [0x0f,0x18,0x32]
+prefetchit1 (%rdx)
Index: llvm/test/MC/Disassembler/X86/x86-64.txt
===
--- llvm/test/MC/Disassembler/X86/x86-64.txt
+++ llvm/test/MC/Disassembler/X86/x86-64.txt
@@ -761,3 +761,9 @@
 
 # CHECK: rdpru
 0x0f,0x01,0xfd
+
+# CHECK: prefetchit0 (%rip)
+0x0f,0x18,0x3d,0x00,0x00,0x00,0x00
+
+# CHECK: prefetchit1 (%rip)
+0x0f,0x18,0x35,0x00,0x00,0x00,0x00
Index: llvm/test/CodeGen/X86/prefetch.ll
===
--- llvm/test/CodeGen/X86/prefetch.ll
+++ llvm/test/CodeGen/X86/prefetch.ll
@@ -11,6 +11,8 @@
 ; RUN: llc < %s -mtriple=i686-- -mattr=-sse,+3dnow,+prefetchwt1 | FileCheck %s -check-prefix=PREFETCHWT1
 ; RUN: llc < %s -mtriple=i686-- -mattr=+3dnow | FileCheck %s -check-prefix=3DNOW
 ; RUN: llc < %s -mtriple=i686-- -mattr=+3dnow,+prfchw | FileCheck %s -check-prefix=3DNOW
+; RUN: llc < %s -mtriple=i686-- -mattr=+sse,+prefetchwt1,+prefetchi | FileCheck %s -check-prefix=PREFETCHWT1
+; RUN: llc < %s -mtriple=x86_64-- -mattr=+prefetchwt1,+prefetchi | FileCheck %s -check-prefix=PREFETCHI
 
 ; Rules:
 ; 3dnow by itself get you just the single prefetch instruction with no hints
@@ -33,6 +35,8 @@
 ; SSE-NEXT:prefetcht1 (%eax)
 ; SSE-NEXT:prefetcht0 (%eax)
 ; SSE-NEXT:prefetchnta (%eax)
+; SSE-NEXT:prefetcht0 (%eax)
+; SSE-NEXT:prefetcht1 (%eax)
 ; SSE-NEXT:retl
 ;
 ; PRFCHWSSE-LABEL: t:
@@ -46,6 +50,8 @@
 ; PRFCHWSSE-NEXT:prefetchw (%eax)
 ; PRFCHWSSE-NEXT:prefetchw (%eax)
 ; PRFCHWSSE-NEXT:prefetchw (%eax)
+; PRFCHWSSE-NEXT:prefetcht0 (%eax)
+; PRFCHWSSE-NEXT:prefetcht1 (%eax)
 ; PRFCHWSSE-NEXT:retl
 ;
 ; PREFETCHWT1-LABEL: t:
@@ -59,6 +65,8 @@
 ; PREFETCHWT1-NEXT:prefetchwt1 (%eax)
 ; PREFETCHWT1-NEXT:prefetchw (%eax)
 ; PREFETCHWT1-NEXT:prefetchwt1 (%eax)
+; PREFETCHWT1-NEXT:prefetcht0 (%eax)
+; PREFETCHWT1-NEXT:prefetcht1 (%eax)
 ; PREFETCHWT1-NEXT:retl
 ;
 ; 3DNOW-LABEL: t:
@@ -72,7 +80,23 @@
 ; 3DNOW-NEXT:prefetchw (%eax)
 ; 3DNOW-NEXT:prefetchw (%eax)
 ; 3DNOW-NEXT:prefetchw (%eax)
+; 3DNOW-NEXT:prefetch (%eax)
+; 3DNOW-NEXT:prefetch (%eax)
 ; 3DNOW-NEXT:retl
+;
+; PREFETCHI-LABEL: t:
+; PREFETCHI:   # %bb.0: # %entry
+; PREFETCHI-NEXT:prefetcht2 (%rdi)
+; PREF

[PATCH] D136040: [X86] Support PREFETCHI instructions

2022-10-16 Thread Phoebe Wang via Phabricator via cfe-commits
pengfei created this revision.
Herald added a subscriber: hiraditya.
Herald added a project: All.
pengfei requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

For more details about these instructions, please refer to the latest ISE 
document: 
https://www.intel.com/content/www/us/en/develop/download/intel-architecture-instruction-set-extensions-programming-reference.html


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D136040

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Driver/Options.td
  clang/lib/Basic/Targets/X86.cpp
  clang/lib/Basic/Targets/X86.h
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Headers/cpuid.h
  clang/lib/Headers/prfchiintrin.h
  clang/lib/Headers/x86gprintrin.h
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/X86/prefetchi-builtins.c
  clang/test/Driver/x86-target-features.c
  clang/test/Sema/builtin-prefetch.c
  llvm/include/llvm/Support/X86TargetParser.def
  llvm/lib/Support/Host.cpp
  llvm/lib/Support/X86TargetParser.cpp
  llvm/lib/Target/X86/X86.td
  llvm/lib/Target/X86/X86DiscriminateMemOps.cpp
  llvm/lib/Target/X86/X86InstrInfo.td
  llvm/lib/Target/X86/X86InstrSSE.td
  llvm/lib/Target/X86/X86Subtarget.h
  llvm/test/CodeGen/X86/prefetch.ll
  llvm/test/MC/Disassembler/X86/x86-64.txt
  llvm/test/MC/X86/PREFETCH-64.s

Index: llvm/test/MC/X86/PREFETCH-64.s
===
--- llvm/test/MC/X86/PREFETCH-64.s
+++ llvm/test/MC/X86/PREFETCH-64.s
@@ -168,3 +168,50 @@
 // CHECK: encoding: [0x0f,0x0d,0x12]
 prefetchwt1 (%rdx) 
 
+// CHECK: prefetchit0 485498096
+// CHECK: encoding: [0x0f,0x18,0x3c,0x25,0xf0,0x1c,0xf0,0x1c]
+prefetchit0 485498096
+
+// CHECK: prefetchit0 64(%rdx)
+// CHECK: encoding: [0x0f,0x18,0x7a,0x40]
+prefetchit0 64(%rdx)
+
+// CHECK: prefetchit0 64(%rdx,%rax,4)
+// CHECK: encoding: [0x0f,0x18,0x7c,0x82,0x40]
+prefetchit0 64(%rdx,%rax,4)
+
+// CHECK: prefetchit0 -64(%rdx,%rax,4)
+// CHECK: encoding: [0x0f,0x18,0x7c,0x82,0xc0]
+prefetchit0 -64(%rdx,%rax,4)
+
+// CHECK: prefetchit0 64(%rdx,%rax)
+// CHECK: encoding: [0x0f,0x18,0x7c,0x02,0x40]
+prefetchit0 64(%rdx,%rax)
+
+// CHECK: prefetchit0 (%rdx)
+// CHECK: encoding: [0x0f,0x18,0x3a]
+prefetchit0 (%rdx)
+
+// CHECK: prefetchit1 485498096
+// CHECK: encoding: [0x0f,0x18,0x34,0x25,0xf0,0x1c,0xf0,0x1c]
+prefetchit1 485498096
+
+// CHECK: prefetchit1 64(%rdx)
+// CHECK: encoding: [0x0f,0x18,0x72,0x40]
+prefetchit1 64(%rdx)
+
+// CHECK: prefetchit1 64(%rdx,%rax,4)
+// CHECK: encoding: [0x0f,0x18,0x74,0x82,0x40]
+prefetchit1 64(%rdx,%rax,4)
+
+// CHECK: prefetchit1 -64(%rdx,%rax,4)
+// CHECK: encoding: [0x0f,0x18,0x74,0x82,0xc0]
+prefetchit1 -64(%rdx,%rax,4)
+
+// CHECK: prefetchit1 64(%rdx,%rax)
+// CHECK: encoding: [0x0f,0x18,0x74,0x02,0x40]
+prefetchit1 64(%rdx,%rax)
+
+// CHECK: prefetchit1 (%rdx)
+// CHECK: encoding: [0x0f,0x18,0x32]
+prefetchit1 (%rdx)
Index: llvm/test/MC/Disassembler/X86/x86-64.txt
===
--- llvm/test/MC/Disassembler/X86/x86-64.txt
+++ llvm/test/MC/Disassembler/X86/x86-64.txt
@@ -761,3 +761,9 @@
 
 # CHECK: rdpru
 0x0f,0x01,0xfd
+
+# CHECK: prefetchit0 (%rip)
+0x0f,0x18,0x3d,0x00,0x00,0x00,0x00
+
+# CHECK: prefetchit1 (%rip)
+0x0f,0x18,0x35,0x00,0x00,0x00,0x00
Index: llvm/test/CodeGen/X86/prefetch.ll
===
--- llvm/test/CodeGen/X86/prefetch.ll
+++ llvm/test/CodeGen/X86/prefetch.ll
@@ -11,6 +11,8 @@
 ; RUN: llc < %s -mtriple=i686-- -mattr=-sse,+3dnow,+prefetchwt1 | FileCheck %s -check-prefix=PREFETCHWT1
 ; RUN: llc < %s -mtriple=i686-- -mattr=+3dnow | FileCheck %s -check-prefix=3DNOW
 ; RUN: llc < %s -mtriple=i686-- -mattr=+3dnow,+prfchw | FileCheck %s -check-prefix=3DNOW
+; RUN: llc < %s -mtriple=i686-- -mattr=+sse,+prefetchwt1,+prefetchi | FileCheck %s -check-prefix=PREFETCHWT1
+; RUN: llc < %s -mtriple=x86_64-- -mattr=+prefetchwt1,+prefetchi | FileCheck %s -check-prefix=PREFETCHI
 
 ; Rules:
 ; 3dnow by itself get you just the single prefetch instruction with no hints
@@ -33,6 +35,8 @@
 ; SSE-NEXT:prefetcht1 (%eax)
 ; SSE-NEXT:prefetcht0 (%eax)
 ; SSE-NEXT:prefetchnta (%eax)
+; SSE-NEXT:prefetcht0 (%eax)
+; SSE-NEXT:prefetcht1 (%eax)
 ; SSE-NEXT:retl
 ;
 ; PRFCHWSSE-LABEL: t:
@@ -46,6 +50,8 @@
 ; PRFCHWSSE-NEXT:prefetchw (%eax)
 ; PRFCHWSSE-NEXT:prefetchw (%eax)
 ; PRFCHWSSE-NEXT:prefetchw (%eax)
+; PRFCHWSSE-NEXT:prefetcht0 (%eax)
+; PRFCHWSSE-NEXT:prefetcht1 (%eax)
 ; PRFCHWSSE-NEXT:retl
 ;
 ; PREFETCHWT1-LABEL: t:
@@ -59,6 +65,8 @@
 ; PREFETCHWT1-NEXT:prefetchwt1 (%eax)
 ; PREFETCHWT1-NEXT:prefetchw (%eax)
 ; PREFETCHWT1-NEXT:prefetchwt1 (%eax)
+; PREFETCHWT1-NEXT:prefetcht0 (%eax)
+; PREFETCHWT1-NEXT:prefetcht1 (%eax)
 ; PREFETCHWT1-NEXT:retl
 ;
 ; 3DNOW-LABEL: t:
@@ -72,7 +80,24 @@
 ; 3DNOW-NEXT:prefetchw (%eax)
 ; 3DNOW-NEXT:

[PATCH] D134128: Resubmit an implemention for constrained template template parameters [P0857R0 Part B]

2022-10-16 Thread Liming Liu via Phabricator via cfe-commits
lime added a comment.

I think I located the problem. In the line 1014 of the file 
`SemaTemplateInstantiateDecl.cpp`, the requires clause is not instantiated as 
the parameters of the template parameter list, and these parameters have been 
instantiated with a shallower depth. So that's the reason why the depths are 
not confirm between the `T` in `template  class>` and the 
constraints on the instantiated parameters. I guess adjusting depths should be 
unnecessary in `IsAtLeastAsConstrained`, if the requires clause was correctly 
instantiated, so are changes related to `SemaConcept.cpp`. I will work on this 
later.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134128

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


[PATCH] D136036: [Clang] Add __has_constexpr_builtin support

2022-10-16 Thread Evgeny Shulgin via Phabricator via cfe-commits
Izaron updated this revision to Diff 468068.
Izaron added a comment.

Changed `llvm_unreachable` to just `return false`. I thought it is more secure.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136036

Files:
  clang/include/clang/Basic/Builtins.def
  clang/include/clang/Basic/Builtins.h
  clang/include/clang/Lex/Preprocessor.h
  clang/lib/AST/ExprConstant.cpp
  clang/lib/Lex/PPMacroExpansion.cpp
  clang/test/Preprocessor/feature_tests.cpp

Index: clang/test/Preprocessor/feature_tests.cpp
===
--- clang/test/Preprocessor/feature_tests.cpp
+++ clang/test/Preprocessor/feature_tests.cpp
@@ -42,3 +42,17 @@
 #if __has_builtin(__builtin_insanity)
 #error Clang should not have this
 #endif
+
+// Check __has_constexpr_builtin
+#if  !__has_constexpr_builtin(__builtin_fmax) || \
+ !__has_constexpr_builtin(__builtin_fmin)
+#error Clang should have these constexpr builtins
+#endif
+
+#if  __has_constexpr_builtin(__builtin_cbrt)
+#error This builtin should not be constexpr in Clang
+#endif
+
+#if  __has_constexpr_builtin(__builtin_insanity)
+#error This is not a builtin in Clang
+#endif
Index: clang/lib/Lex/PPMacroExpansion.cpp
===
--- clang/lib/Lex/PPMacroExpansion.cpp
+++ clang/lib/Lex/PPMacroExpansion.cpp
@@ -367,11 +367,13 @@
   }
 
   // Clang Extensions.
-  Ident__FILE_NAME__  = RegisterBuiltinMacro(*this, "__FILE_NAME__");
-  Ident__has_feature  = RegisterBuiltinMacro(*this, "__has_feature");
-  Ident__has_extension= RegisterBuiltinMacro(*this, "__has_extension");
-  Ident__has_builtin  = RegisterBuiltinMacro(*this, "__has_builtin");
-  Ident__has_attribute= RegisterBuiltinMacro(*this, "__has_attribute");
+  Ident__FILE_NAME__ = RegisterBuiltinMacro(*this, "__FILE_NAME__");
+  Ident__has_feature = RegisterBuiltinMacro(*this, "__has_feature");
+  Ident__has_extension = RegisterBuiltinMacro(*this, "__has_extension");
+  Ident__has_builtin = RegisterBuiltinMacro(*this, "__has_builtin");
+  Ident__has_constexpr_builtin =
+  RegisterBuiltinMacro(*this, "__has_constexpr_builtin");
+  Ident__has_attribute = RegisterBuiltinMacro(*this, "__has_attribute");
   if (!getLangOpts().CPlusPlus)
 Ident__has_c_attribute = RegisterBuiltinMacro(*this, "__has_c_attribute");
   else
@@ -1735,6 +1737,18 @@
   .Default(false);
 }
   });
+  } else if (II == Ident__has_constexpr_builtin) {
+EvaluateFeatureLikeBuiltinMacro(
+OS, Tok, II, *this, false,
+[this](Token &Tok, bool &HasLexedNextToken) -> int {
+  IdentifierInfo *II = ExpectFeatureIdentifierInfo(
+  Tok, *this, diag::err_feature_check_malformed);
+  if (!II)
+return false;
+  unsigned BuiltinOp = II->getBuiltinID();
+  return BuiltinOp != 0 &&
+ this->getBuiltinInfo().isConstantEvaluated(BuiltinOp);
+});
   } else if (II == Ident__is_identifier) {
 EvaluateFeatureLikeBuiltinMacro(OS, Tok, II, *this, false,
   [](Token &Tok, bool &HasLexedNextToken) -> int {
@@ -1763,8 +1777,7 @@
 
 return false;
   });
-  } else if (II == Ident__has_cpp_attribute ||
- II == Ident__has_c_attribute) {
+  } else if (II == Ident__has_cpp_attribute || II == Ident__has_c_attribute) {
 bool IsCXX = II == Ident__has_cpp_attribute;
 EvaluateFeatureLikeBuiltinMacro(OS, Tok, II, *this, true,
 [&](Token &Tok, bool &HasLexedNextToken) -> int {
@@ -1794,8 +1807,7 @@
getLangOpts())
 : 0;
 });
-  } else if (II == Ident__has_include ||
- II == Ident__has_include_next) {
+  } else if (II == Ident__has_include || II == Ident__has_include_next) {
 // The argument to these two builtins should be a parenthesized
 // file name string literal using angle brackets (<>) or
 // double-quotes ("").
Index: clang/lib/AST/ExprConstant.cpp
===
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -1954,8 +1954,8 @@
   return true;
 }
 
-/// Should this call expression be treated as a constant?
-static bool IsConstantCall(const CallExpr *E) {
+/// Should this call expression be treated as a no-op?
+static bool IsNoOpCall(const CallExpr *E) {
   unsigned Builtin = E->getBuiltinCallee();
   return (Builtin == Builtin::BI__builtin___CFStringMakeConstantString ||
   Builtin == Builtin::BI__builtin___NSStringMakeConstantString ||
@@ -2006,7 +2006,7 @@
   case Expr::ObjCBoxedExprClass:
 return cast(E)->isExpressibleAsConstantInitializer();
   case Expr::CallExprClass:
-return IsConstantCall(cast(E));
+return IsNoOpCall(cast(E));
   // For GCC compatibility, &&label has static storage duration.
   case Expr::AddrLabelExprClass:
 

[clang] dd3d8dd - [OpenMP][OpenMPIRBuilder] Migrate OffloadEntriesInfoManager from clang to OMPIRbuilder

2022-10-16 Thread Jan Sjodin via cfe-commits

Author: Jan Sjodin
Date: 2022-10-16T08:32:40-04:00
New Revision: dd3d8ddb5f65ff73441276d7dec744c81e3bf9ca

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

LOG: [OpenMP][OpenMPIRBuilder] Migrate OffloadEntriesInfoManager from clang to 
OMPIRbuilder

This patch moves the implementation of the OffloadEntriesInfoManager
to the OMPIRbuilder. This class will later be used by flang as well.

Reviewed By: jdoerfert

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

Added: 


Modified: 
clang/lib/CodeGen/CGOpenMPRuntime.cpp
clang/lib/CodeGen/CGOpenMPRuntime.h
llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp 
b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
index 0260b4cdc157..1c211b2d7ad3 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -1060,7 +1060,7 @@ static FieldDecl *addFieldToRecordDecl(ASTContext &C, 
DeclContext *DC,
 CGOpenMPRuntime::CGOpenMPRuntime(CodeGenModule &CGM, StringRef FirstSeparator,
  StringRef Separator)
 : CGM(CGM), FirstSeparator(FirstSeparator), Separator(Separator),
-  OMPBuilder(CGM.getModule()), OffloadEntriesInfoManager(CGM) {
+  OMPBuilder(CGM.getModule()), OffloadEntriesInfoManager() {
   KmpCriticalNameTy = llvm::ArrayType::get(CGM.Int32Ty, /*NumElements*/ 8);
 
   // Initialize Types used in OpenMPIRBuilder from OMPKinds.def
@@ -1914,7 +1914,8 @@ bool 
CGOpenMPRuntime::emitDeclareTargetVarDefinition(const VarDecl *VD,
 Out.clear();
 OffloadEntriesInfoManager.registerTargetRegionEntryInfo(
 DeviceID, FileID, Twine(Buffer, "_ctor").toStringRef(Out), Line, Ctor,
-ID, OffloadEntriesInfoManagerTy::OMPTargetRegionEntryCtor);
+ID, llvm::OffloadEntriesInfoManager::OMPTargetRegionEntryCtor,
+CGM.getLangOpts().OpenMPIsDevice);
   }
   if (VD->getType().isDestructedType() != QualType::DK_none) {
 llvm::Constant *Dtor;
@@ -1960,7 +1961,8 @@ bool 
CGOpenMPRuntime::emitDeclareTargetVarDefinition(const VarDecl *VD,
 Out.clear();
 OffloadEntriesInfoManager.registerTargetRegionEntryInfo(
 DeviceID, FileID, Twine(Buffer, "_dtor").toStringRef(Out), Line, Dtor,
-ID, OffloadEntriesInfoManagerTy::OMPTargetRegionEntryDtor);
+ID, llvm::OffloadEntriesInfoManager::OMPTargetRegionEntryDtor,
+CGM.getLangOpts().OpenMPIsDevice);
   }
   return CGM.getLangOpts().OpenMPIsDevice;
 }
@@ -2951,143 +2953,6 @@ enum KmpTaskTFields {
 };
 } // anonymous namespace
 
-bool CGOpenMPRuntime::OffloadEntriesInfoManagerTy::empty() const {
-  return OffloadEntriesTargetRegion.empty() &&
- OffloadEntriesDeviceGlobalVar.empty();
-}
-
-/// Initialize target region entry.
-void CGOpenMPRuntime::OffloadEntriesInfoManagerTy::
-initializeTargetRegionEntryInfo(unsigned DeviceID, unsigned FileID,
-StringRef ParentName, unsigned LineNum,
-unsigned Order) {
-  assert(CGM.getLangOpts().OpenMPIsDevice && "Initialization of entries is "
- "only required for the device "
- "code generation.");
-  OffloadEntriesTargetRegion[DeviceID][FileID][ParentName][LineNum] =
-  OffloadEntryInfoTargetRegion(Order, /*Addr=*/nullptr, /*ID=*/nullptr,
-   OMPTargetRegionEntryTargetRegion);
-  ++OffloadingEntriesNum;
-}
-
-void CGOpenMPRuntime::OffloadEntriesInfoManagerTy::
-registerTargetRegionEntryInfo(unsigned DeviceID, unsigned FileID,
-  StringRef ParentName, unsigned LineNum,
-  llvm::Constant *Addr, llvm::Constant *ID,
-  OMPTargetRegionEntryKind Flags) {
-  // If we are emitting code for a target, the entry is already initialized,
-  // only has to be registered.
-  if (CGM.getLangOpts().OpenMPIsDevice) {
-// This could happen if the device compilation is invoked standalone.
-if (!hasTargetRegionEntryInfo(DeviceID, FileID, ParentName, LineNum))
-  return;
-auto &Entry =
-OffloadEntriesTargetRegion[DeviceID][FileID][ParentName][LineNum];
-Entry.setAddress(Addr);
-Entry.setID(ID);
-Entry.setFlags(Flags);
-  } else {
-if (Flags ==
-OffloadEntriesInfoManagerTy::OMPTargetRegionEntryTargetRegion &&
-hasTargetRegionEntryInfo(DeviceID, FileID, ParentName, LineNum,
- /*IgnoreAddressId*/ true))
-  return;
-assert(!hasTargetRegionEntryInfo(DeviceID, FileID, ParentName, LineNum) &&
-  

[PATCH] D136036: [Clang] Add __has_builtin_constexpr support

2022-10-16 Thread Evgeny Shulgin via Phabricator via cfe-commits
Izaron updated this revision to Diff 468063.
Izaron added a comment.

Slightly changed the test.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136036

Files:
  clang/include/clang/Basic/Builtins.def
  clang/include/clang/Basic/Builtins.h
  clang/include/clang/Lex/Preprocessor.h
  clang/lib/AST/ExprConstant.cpp
  clang/lib/Lex/PPMacroExpansion.cpp
  clang/test/Preprocessor/feature_tests.cpp

Index: clang/test/Preprocessor/feature_tests.cpp
===
--- clang/test/Preprocessor/feature_tests.cpp
+++ clang/test/Preprocessor/feature_tests.cpp
@@ -42,3 +42,17 @@
 #if __has_builtin(__builtin_insanity)
 #error Clang should not have this
 #endif
+
+// Check __has_constexpr_builtin
+#if  !__has_constexpr_builtin(__builtin_fmax) || \
+ !__has_constexpr_builtin(__builtin_fmin)
+#error Clang should have these constexpr builtins
+#endif
+
+#if  __has_constexpr_builtin(__builtin_cbrt)
+#error This builtin should not be constexpr in Clang
+#endif
+
+#if  __has_constexpr_builtin(__builtin_insanity)
+#error This is not a builtin in Clang
+#endif
Index: clang/lib/Lex/PPMacroExpansion.cpp
===
--- clang/lib/Lex/PPMacroExpansion.cpp
+++ clang/lib/Lex/PPMacroExpansion.cpp
@@ -367,11 +367,13 @@
   }
 
   // Clang Extensions.
-  Ident__FILE_NAME__  = RegisterBuiltinMacro(*this, "__FILE_NAME__");
-  Ident__has_feature  = RegisterBuiltinMacro(*this, "__has_feature");
-  Ident__has_extension= RegisterBuiltinMacro(*this, "__has_extension");
-  Ident__has_builtin  = RegisterBuiltinMacro(*this, "__has_builtin");
-  Ident__has_attribute= RegisterBuiltinMacro(*this, "__has_attribute");
+  Ident__FILE_NAME__ = RegisterBuiltinMacro(*this, "__FILE_NAME__");
+  Ident__has_feature = RegisterBuiltinMacro(*this, "__has_feature");
+  Ident__has_extension = RegisterBuiltinMacro(*this, "__has_extension");
+  Ident__has_builtin = RegisterBuiltinMacro(*this, "__has_builtin");
+  Ident__has_constexpr_builtin =
+  RegisterBuiltinMacro(*this, "__has_constexpr_builtin");
+  Ident__has_attribute = RegisterBuiltinMacro(*this, "__has_attribute");
   if (!getLangOpts().CPlusPlus)
 Ident__has_c_attribute = RegisterBuiltinMacro(*this, "__has_c_attribute");
   else
@@ -1735,6 +1737,18 @@
   .Default(false);
 }
   });
+  } else if (II == Ident__has_constexpr_builtin) {
+EvaluateFeatureLikeBuiltinMacro(
+OS, Tok, II, *this, false,
+[this](Token &Tok, bool &HasLexedNextToken) -> int {
+  IdentifierInfo *II = ExpectFeatureIdentifierInfo(
+  Tok, *this, diag::err_feature_check_malformed);
+  if (!II)
+return false;
+  unsigned BuiltinOp = II->getBuiltinID();
+  return BuiltinOp != 0 &&
+ this->getBuiltinInfo().isConstantEvaluated(BuiltinOp);
+});
   } else if (II == Ident__is_identifier) {
 EvaluateFeatureLikeBuiltinMacro(OS, Tok, II, *this, false,
   [](Token &Tok, bool &HasLexedNextToken) -> int {
@@ -1763,8 +1777,7 @@
 
 return false;
   });
-  } else if (II == Ident__has_cpp_attribute ||
- II == Ident__has_c_attribute) {
+  } else if (II == Ident__has_cpp_attribute || II == Ident__has_c_attribute) {
 bool IsCXX = II == Ident__has_cpp_attribute;
 EvaluateFeatureLikeBuiltinMacro(OS, Tok, II, *this, true,
 [&](Token &Tok, bool &HasLexedNextToken) -> int {
@@ -1794,8 +1807,7 @@
getLangOpts())
 : 0;
 });
-  } else if (II == Ident__has_include ||
- II == Ident__has_include_next) {
+  } else if (II == Ident__has_include || II == Ident__has_include_next) {
 // The argument to these two builtins should be a parenthesized
 // file name string literal using angle brackets (<>) or
 // double-quotes ("").
Index: clang/lib/AST/ExprConstant.cpp
===
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -1954,8 +1954,8 @@
   return true;
 }
 
-/// Should this call expression be treated as a constant?
-static bool IsConstantCall(const CallExpr *E) {
+/// Should this call expression be treated as a no-op?
+static bool IsNoOpCall(const CallExpr *E) {
   unsigned Builtin = E->getBuiltinCallee();
   return (Builtin == Builtin::BI__builtin___CFStringMakeConstantString ||
   Builtin == Builtin::BI__builtin___NSStringMakeConstantString ||
@@ -2006,7 +2006,7 @@
   case Expr::ObjCBoxedExprClass:
 return cast(E)->isExpressibleAsConstantInitializer();
   case Expr::CallExprClass:
-return IsConstantCall(cast(E));
+return IsNoOpCall(cast(E));
   // For GCC compatibility, &&label has static storage duration.
   case Expr::AddrLabelExprClass:
 return true;
@@ -7405,6 +7405,12 @@
 
   bool ZeroIni

[PATCH] D136036: [Clang] Add __has_builtin_constexpr support

2022-10-16 Thread Evgeny Shulgin via Phabricator via cfe-commits
Izaron added a comment.

A builtin is considered "constexpr" if it has `E` in its attributes in 
`Builtins.def`.

The list of constexpr builtins is consistent, the code in `ExprConstant.cpp` 
(where the actual constant evaluation of builtins is being done) guards it.
If builtin is not marked with `E`, it surely won't be evaluated, and vice versa 
- if builtin is marked but there is no code for evaluating it, there is a 
`llvm_unreachable`.

This macro will be needed because we are making constexpr `` and 
``. We will conditionally make the functions constexpr until all 
supported compilers have full support.

We had a discussion where we found out that we need `__has_builtin_constexpr`: 
https://discourse.llvm.org/t/how-do-we-plan-to-make-constexpr-cmath-and-cstdlib/65930
 Please read it if you wonder why we need it =) Thank you for your attention!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136036

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


[PATCH] D136036: [Clang] Add __has_builtin_constexpr support

2022-10-16 Thread Evgeny Shulgin via Phabricator via cfe-commits
Izaron created this revision.
Izaron added reviewers: rsmith, aaron.ballman, cor3ntin, philnik, yaxunl, tra, 
cjdb.
Herald added a project: All.
Izaron requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

The `__has_builtin_constexpr` macro can be used to check
whether the builtin in constant-evaluated by Clang frontend.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D136036

Files:
  clang/include/clang/Basic/Builtins.def
  clang/include/clang/Basic/Builtins.h
  clang/include/clang/Lex/Preprocessor.h
  clang/lib/AST/ExprConstant.cpp
  clang/lib/Lex/PPMacroExpansion.cpp
  clang/test/Preprocessor/feature_tests.cpp

Index: clang/test/Preprocessor/feature_tests.cpp
===
--- clang/test/Preprocessor/feature_tests.cpp
+++ clang/test/Preprocessor/feature_tests.cpp
@@ -42,3 +42,17 @@
 #if __has_builtin(__builtin_insanity)
 #error Clang should not have this
 #endif
+
+// Check __has_constexpr_builtin
+#if  !__has_constexpr_builtin(__builtin_fmax) || \
+ !__has_builtin(__builtin_fmin)
+#error Clang should have these constexpr builtins
+#endif
+
+#if  __has_constexpr_builtin(__builtin_cbrt)
+#error This builtin should not be constexpr in Clang
+#endif
+
+#if  __has_constexpr_builtin(__builtin_insanity)
+#error This is not a builtin in Clang
+#endif
Index: clang/lib/Lex/PPMacroExpansion.cpp
===
--- clang/lib/Lex/PPMacroExpansion.cpp
+++ clang/lib/Lex/PPMacroExpansion.cpp
@@ -367,11 +367,13 @@
   }
 
   // Clang Extensions.
-  Ident__FILE_NAME__  = RegisterBuiltinMacro(*this, "__FILE_NAME__");
-  Ident__has_feature  = RegisterBuiltinMacro(*this, "__has_feature");
-  Ident__has_extension= RegisterBuiltinMacro(*this, "__has_extension");
-  Ident__has_builtin  = RegisterBuiltinMacro(*this, "__has_builtin");
-  Ident__has_attribute= RegisterBuiltinMacro(*this, "__has_attribute");
+  Ident__FILE_NAME__ = RegisterBuiltinMacro(*this, "__FILE_NAME__");
+  Ident__has_feature = RegisterBuiltinMacro(*this, "__has_feature");
+  Ident__has_extension = RegisterBuiltinMacro(*this, "__has_extension");
+  Ident__has_builtin = RegisterBuiltinMacro(*this, "__has_builtin");
+  Ident__has_constexpr_builtin =
+  RegisterBuiltinMacro(*this, "__has_constexpr_builtin");
+  Ident__has_attribute = RegisterBuiltinMacro(*this, "__has_attribute");
   if (!getLangOpts().CPlusPlus)
 Ident__has_c_attribute = RegisterBuiltinMacro(*this, "__has_c_attribute");
   else
@@ -1735,6 +1737,18 @@
   .Default(false);
 }
   });
+  } else if (II == Ident__has_constexpr_builtin) {
+EvaluateFeatureLikeBuiltinMacro(
+OS, Tok, II, *this, false,
+[this](Token &Tok, bool &HasLexedNextToken) -> int {
+  IdentifierInfo *II = ExpectFeatureIdentifierInfo(
+  Tok, *this, diag::err_feature_check_malformed);
+  if (!II)
+return false;
+  unsigned BuiltinOp = II->getBuiltinID();
+  return BuiltinOp != 0 &&
+ this->getBuiltinInfo().isConstantEvaluated(BuiltinOp);
+});
   } else if (II == Ident__is_identifier) {
 EvaluateFeatureLikeBuiltinMacro(OS, Tok, II, *this, false,
   [](Token &Tok, bool &HasLexedNextToken) -> int {
@@ -1763,8 +1777,7 @@
 
 return false;
   });
-  } else if (II == Ident__has_cpp_attribute ||
- II == Ident__has_c_attribute) {
+  } else if (II == Ident__has_cpp_attribute || II == Ident__has_c_attribute) {
 bool IsCXX = II == Ident__has_cpp_attribute;
 EvaluateFeatureLikeBuiltinMacro(OS, Tok, II, *this, true,
 [&](Token &Tok, bool &HasLexedNextToken) -> int {
@@ -1794,8 +1807,7 @@
getLangOpts())
 : 0;
 });
-  } else if (II == Ident__has_include ||
- II == Ident__has_include_next) {
+  } else if (II == Ident__has_include || II == Ident__has_include_next) {
 // The argument to these two builtins should be a parenthesized
 // file name string literal using angle brackets (<>) or
 // double-quotes ("").
Index: clang/lib/AST/ExprConstant.cpp
===
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -1954,8 +1954,8 @@
   return true;
 }
 
-/// Should this call expression be treated as a constant?
-static bool IsConstantCall(const CallExpr *E) {
+/// Should this call expression be treated as a no-op?
+static bool IsNoOpCall(const CallExpr *E) {
   unsigned Builtin = E->getBuiltinCallee();
   return (Builtin == Builtin::BI__builtin___CFStringMakeConstantString ||
   Builtin == Builtin::BI__builtin___NSStringMakeConstantString ||
@@ -2006,7 +2006,7 @@
   case Expr::ObjCBoxedExprClass:
 return cast(E)->isExpressibleAsConstantInitializer();
   case Expr::CallExprClass:
-return IsConstantCal

[PATCH] D135858: [clang][Interp] Support pointer arithmethic in binary operators

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



Comment at: clang/lib/AST/Interp/Interp.h:970
+  if (!Pointer::hasSameArray(LHS, RHS)) {
+// TODO: Diagnose.
+return false;

This is also not being diagnosed (only rejected) by the current interpreter. 
But would be nice to have an error message.


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

https://reviews.llvm.org/D135858

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


[PATCH] D135858: [clang][Interp] Support pointer arithmethic in binary operators

2022-10-16 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder updated this revision to Diff 468060.

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

https://reviews.llvm.org/D135858

Files:
  clang/lib/AST/Interp/ByteCodeExprGen.cpp
  clang/lib/AST/Interp/ByteCodeExprGen.h
  clang/lib/AST/Interp/Interp.h
  clang/lib/AST/Interp/Opcodes.td
  clang/lib/AST/Interp/Pointer.cpp
  clang/test/AST/Interp/arrays.cpp

Index: clang/test/AST/Interp/arrays.cpp
===
--- clang/test/AST/Interp/arrays.cpp
+++ clang/test/AST/Interp/arrays.cpp
@@ -37,6 +37,56 @@
 static_assert(getElement(1) == 4, "");
 static_assert(getElement(5) == 36, "");
 
+constexpr int data[] = {5, 4, 3, 2, 1};
+constexpr int getElement(const int *Arr, int index) {
+  return *(Arr + index);
+}
+
+static_assert(getElement(data, 1) == 4, "");
+static_assert(getElement(data, 4) == 1, "");
+
+constexpr int getElementFromEnd(const int *Arr, int size, int index) {
+  return *(Arr + size - index - 1);
+}
+static_assert(getElementFromEnd(data, 5, 0) == 1, "");
+static_assert(getElementFromEnd(data, 5, 4) == 5, "");
+
+
+constexpr static int arr[2] = {1,2};
+constexpr static int arr2[2] = {3,4};
+constexpr int *p1 = nullptr;
+constexpr int *p2 = p1 + 1; // expected-error {{must be initialized by a constant expression}} \
+// expected-note {{cannot perform pointer arithmetic on null pointer}} \
+// ref-error {{must be initialized by a constant expression}} \
+// ref-note {{cannot perform pointer arithmetic on null pointer}}
+constexpr int *p3 = p1 + 0;
+constexpr int *p4 = p1 - 0;
+constexpr int *p5 =  0 + p1;
+constexpr int *p6 =  0 - p1; // expected-error {{invalid operands to binary expression}} \
+ // ref-error {{invalid operands to binary expression}}
+
+constexpr int const * ap1 = &arr[0];
+constexpr int const * ap2 = ap1 + 3; // expected-error {{must be initialized by a constant expression}} \
+ // expected-note {{cannot refer to element 3 of array of 2}} \
+ // ref-error {{must be initialized by a constant expression}} \
+ // ref-note {{cannot refer to element 3 of array of 2}}
+
+constexpr auto ap3 = arr - 1; // expected-error {{must be initialized by a constant expression}} \
+  // expected-note {{cannot refer to element -1}} \
+  // ref-error {{must be initialized by a constant expression}} \
+  // ref-note {{cannot refer to element -1}}
+constexpr int k1 = &arr[1] - &arr[0];
+static_assert(k1 == 1, "");
+static_assert((&arr[0] - &arr[1]) == -1, "");
+
+constexpr int k2 = &arr2[1] - &arr[0]; // expected-error {{must be initialized by a constant expression}} \
+   // ref-error {{must be initialized by a constant expression}}
+
+static_assert((arr + 0) == arr, "");
+static_assert(&arr[0] == arr, "");
+static_assert(*(&arr[0]) == 1, "");
+static_assert(*(&arr[1]) == 2, "");
+
 
 template
 constexpr T getElementOf(T* array, int i) {
@@ -52,7 +102,6 @@
 static_assert(getElementOfArray(foo[2], 3) == &m, "");
 
 
-constexpr int data[] = {5, 4, 3, 2, 1};
 static_assert(data[0] == 4, ""); // expected-error{{failed}} \
  // expected-note{{5 == 4}} \
  // ref-error{{failed}} \
Index: clang/lib/AST/Interp/Pointer.cpp
===
--- clang/lib/AST/Interp/Pointer.cpp
+++ clang/lib/AST/Interp/Pointer.cpp
@@ -201,5 +201,5 @@
 }
 
 bool Pointer::hasSameArray(const Pointer &A, const Pointer &B) {
-  return A.Base == B.Base && A.getFieldDesc()->IsArray;
+  return hasSameBase(A, B) && A.Base == B.Base && A.getFieldDesc()->IsArray;
 }
Index: clang/lib/AST/Interp/Opcodes.td
===
--- clang/lib/AST/Interp/Opcodes.td
+++ clang/lib/AST/Interp/Opcodes.td
@@ -411,6 +411,12 @@
   let HasGroup = 1;
 }
 
+// Pointer, Pointer] - [Integral]
+def SubPtr : Opcode {
+  let Types = [IntegerTypeClass];
+  let HasGroup = 1;
+}
+
 //===--===//
 // Binary operators.
 //===--===//
Index: clang/lib/AST/Interp/Interp.h
===
--- clang/lib/AST/Interp/Interp.h
+++ clang/lib/AST/Interp/Interp.h
@@ -350,6 +350,16 @@
   } else {
 unsigned VL = LHS.getByteOffset();
 unsigned VR = RHS.getByteOffset();
+
+// In our Pointer class, a pointer to an array and a pointer to the first
+// element in the same array are NOT equal. They have the same Base value,
+// but a different Offset. This is a pretty rare case, so we fix this here
+// by comparing p

[PATCH] D135871: [clang-format][NFC] Handle language specific stuff at the top...

2022-10-16 Thread Owen Pan via Phabricator via cfe-commits
owenpan accepted this revision.
owenpan added a comment.
This revision is now accepted and ready to land.

LGTM




Comment at: clang/lib/Format/TokenAnnotator.cpp:3121
+  return 1;
+if (Right.is(tok::period))
+  return 500;

HazardyKnusperkeks wrote:
> owenpan wrote:
> > Otherwise, it wouldn't be NFC.
> It was Left == :: || Right == .
It's NFC because we are still checking Right.is... below.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135871

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