[clang] c004d75 - [clang][Interp] Disable some RVO tests

2022-10-14 Thread Timm Bäder via cfe-commits

Author: Timm Bäder
Date: 2022-10-14T10:45:23+02:00
New Revision: c004d7534dcefcfebc3e07a7fa12f5492be80279

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

LOG: [clang][Interp] Disable some RVO tests

Apparently this breaks a couple of builders:
https://lab.llvm.org/buildbot/#/builders/139/builds/29552
https://lab.llvm.org/buildbot/#/builders/216/builds/11240

Added: 


Modified: 
clang/test/AST/Interp/records.cpp

Removed: 




diff  --git a/clang/test/AST/Interp/records.cpp 
b/clang/test/AST/Interp/records.cpp
index 1e61d4845a43..ae0287b1347d 100644
--- a/clang/test/AST/Interp/records.cpp
+++ b/clang/test/AST/Interp/records.cpp
@@ -48,6 +48,7 @@ static_assert(ints2.a == -20, "");
 static_assert(ints2.b == -30, "");
 static_assert(!ints2.c, "");
 
+#if 0
 constexpr Ints getInts() {
   return {64, 128, true};
 }
@@ -55,6 +56,7 @@ constexpr Ints ints3 = getInts();
 static_assert(ints3.a == 64, "");
 static_assert(ints3.b == 128, "");
 static_assert(ints3.c, "");
+#endif
 
 constexpr Ints ints4 = {
   .a = 40 * 50,
@@ -118,10 +120,12 @@ constexpr const C* getPointer() {
 }
 static_assert(getPointer()->a == 100, "");
 
+#if 0
 constexpr C RVOAndParams(const C *c) {
   return C();
 }
 constexpr C RVOAndParamsResult = RVOAndParams();
+#endif
 
 constexpr int locals() {
   C c;



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


[clang] 2f35705 - [Interp] Silence warning in release builds. NFC.

2022-10-14 Thread Benjamin Kramer via cfe-commits

Author: Benjamin Kramer
Date: 2022-10-14T10:38:32+02:00
New Revision: 2f357054d705459c534a74781e4dc24debe78fcb

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

LOG: [Interp] Silence warning in release builds. NFC.

Added: 


Modified: 
clang/lib/AST/Interp/EvalEmitter.cpp

Removed: 




diff  --git a/clang/lib/AST/Interp/EvalEmitter.cpp 
b/clang/lib/AST/Interp/EvalEmitter.cpp
index 94cd1ba9bf94..aa4396f135d2 100644
--- a/clang/lib/AST/Interp/EvalEmitter.cpp
+++ b/clang/lib/AST/Interp/EvalEmitter.cpp
@@ -113,6 +113,7 @@ bool EvalEmitter::emitCall(const Function *Func, const 
SourceInfo ) {
 bool EvalEmitter::emitCallVoid(const Function *Func, const SourceInfo ) {
   APValue VoidResult;
   InterpFrame *before = S.Current;
+  (void)before;
   S.Current = new InterpFrame(S, const_cast(Func), {});
   bool Success = Interpret(S, VoidResult);
   assert(VoidResult.isAbsent());



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


[PATCH] D135951: [X86][WIP] SUPPORT RAO-INT

2022-10-14 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/D135951

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/Headers/cpuid.h
  clang/test/Driver/x86-target-features.c
  clang/test/Preprocessor/x86_target_features.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/X86InstrInfo.td
  llvm/lib/Target/X86/X86InstrRAOINT.td
  llvm/test/MC/Disassembler/X86/rao-int.txt
  llvm/test/MC/Disassembler/X86/x86-64-rao-int.txt
  llvm/test/MC/X86/rao-int-att.s
  llvm/test/MC/X86/rao-int-intel.s
  llvm/test/MC/X86/x86-64-rao-int-att.s
  llvm/test/MC/X86/x86-64-rao-int-intel.s

Index: llvm/test/MC/X86/x86-64-rao-int-intel.s
===
--- /dev/null
+++ llvm/test/MC/X86/x86-64-rao-int-intel.s
@@ -0,0 +1,193 @@
+// RUN: llvm-mc -triple x86_64-unknown-unknown -x86-asm-syntax=intel -output-asm-variant=1 --show-encoding %s | FileCheck %s
+
+// CHECK:  aadd qword ptr [rbp + 8*r14 + 268435456], r9
+// CHECK: encoding: [0x4e,0x0f,0x38,0xfc,0x8c,0xf5,0x00,0x00,0x00,0x10]
+   aadd qword ptr [rbp + 8*r14 + 268435456], r9
+
+// CHECK:  aadd qword ptr [r8 + 4*rax + 291], r9
+// CHECK: encoding: [0x4d,0x0f,0x38,0xfc,0x8c,0x80,0x23,0x01,0x00,0x00]
+   aadd qword ptr [r8 + 4*rax + 291], r9
+
+// CHECK:  aadd qword ptr [rip], r9
+// CHECK: encoding: [0x4c,0x0f,0x38,0xfc,0x0d,0x00,0x00,0x00,0x00]
+   aadd qword ptr [rip], r9
+
+// CHECK:  aadd qword ptr [2*rbp - 512], r9
+// CHECK: encoding: [0x4c,0x0f,0x38,0xfc,0x0c,0x6d,0x00,0xfe,0xff,0xff]
+   aadd qword ptr [2*rbp - 512], r9
+
+// CHECK:  aadd qword ptr [rcx + 2032], r9
+// CHECK: encoding: [0x4c,0x0f,0x38,0xfc,0x89,0xf0,0x07,0x00,0x00]
+   aadd qword ptr [rcx + 2032], r9
+
+// CHECK:  aadd qword ptr [rdx - 2048], r9
+// CHECK: encoding: [0x4c,0x0f,0x38,0xfc,0x8a,0x00,0xf8,0xff,0xff]
+   aadd qword ptr [rdx - 2048], r9
+
+// CHECK:  aadd dword ptr [esp + 8*esi + 268435456], ebx
+// CHECK: encoding: [0x67,0x0f,0x38,0xfc,0x9c,0xf4,0x00,0x00,0x00,0x10]
+   aadd dword ptr [esp + 8*esi + 268435456], ebx
+
+// CHECK:  aadd dword ptr [edi + 4*eax + 291], ebx
+// CHECK: encoding: [0x67,0x0f,0x38,0xfc,0x9c,0x87,0x23,0x01,0x00,0x00]
+   aadd dword ptr [edi + 4*eax + 291], ebx
+
+// CHECK:  aadd dword ptr [eax], ebx
+// CHECK: encoding: [0x67,0x0f,0x38,0xfc,0x18]
+   aadd dword ptr [eax], ebx
+
+// CHECK:  aadd dword ptr [2*ebp - 512], ebx
+// CHECK: encoding: [0x67,0x0f,0x38,0xfc,0x1c,0x6d,0x00,0xfe,0xff,0xff]
+   aadd dword ptr [2*ebp - 512], ebx
+
+// CHECK:  aadd dword ptr [ecx + 2032], ebx
+// CHECK: encoding: [0x67,0x0f,0x38,0xfc,0x99,0xf0,0x07,0x00,0x00]
+   aadd dword ptr [ecx + 2032], ebx
+
+// CHECK:  aadd dword ptr [edx - 2048], ebx
+// CHECK: encoding: [0x67,0x0f,0x38,0xfc,0x9a,0x00,0xf8,0xff,0xff]
+   aadd dword ptr [edx - 2048], ebx
+
+// CHECK:  aand qword ptr [rbp + 8*r14 + 268435456], r9
+// CHECK: encoding: [0x66,0x4e,0x0f,0x38,0xfc,0x8c,0xf5,0x00,0x00,0x00,0x10]
+   aand qword ptr [rbp + 8*r14 + 268435456], r9
+
+// CHECK:  aand qword ptr [r8 + 4*rax + 291], r9
+// CHECK: encoding: [0x66,0x4d,0x0f,0x38,0xfc,0x8c,0x80,0x23,0x01,0x00,0x00]
+   aand qword ptr [r8 + 4*rax + 291], r9
+
+// CHECK:  aand qword ptr [rip], r9
+// CHECK: encoding: [0x66,0x4c,0x0f,0x38,0xfc,0x0d,0x00,0x00,0x00,0x00]
+   aand qword ptr [rip], r9
+
+// CHECK:  aand qword ptr [2*rbp - 512], r9
+// CHECK: encoding: [0x66,0x4c,0x0f,0x38,0xfc,0x0c,0x6d,0x00,0xfe,0xff,0xff]
+   aand qword ptr [2*rbp - 512], r9
+
+// CHECK:  aand qword ptr [rcx + 2032], r9
+// CHECK: encoding: [0x66,0x4c,0x0f,0x38,0xfc,0x89,0xf0,0x07,0x00,0x00]
+   aand qword ptr [rcx + 2032], r9
+
+// CHECK:  aand qword ptr [rdx - 2048], r9
+// CHECK: encoding: [0x66,0x4c,0x0f,0x38,0xfc,0x8a,0x00,0xf8,0xff,0xff]
+   aand qword ptr [rdx - 2048], r9
+
+// CHECK:  aand dword ptr [esp + 8*esi + 268435456], ebx
+// CHECK: encoding: [0x67,0x66,0x0f,0x38,0xfc,0x9c,0xf4,0x00,0x00,0x00,0x10]
+   aand dword ptr [esp + 8*esi + 268435456], ebx
+
+// CHECK:  aand dword ptr [edi + 4*eax + 291], ebx
+// CHECK: encoding: 

[PATCH] D135930: [X86] Add AVX-NE-CONVERT instructions.

2022-10-14 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon added inline comments.



Comment at: clang/test/CodeGen/X86/avxneconvert-builtins.c:2
+// RUN: %clang_cc1 %s -ffreestanding -triple=x86_64-unknown-unknown 
-target-feature +avx2 -target-feature +avxneconvert \
+// RUN: -target-feature +avx512fp16 -emit-llvm -o - -Wall -Werror -pedantic 
-Wno-gnu-statement-expression | FileCheck %s
+

32-bit test coverage?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135930

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


[PATCH] D135938: [X86] Add AVX-VNNI-INT8 instructions.

2022-10-14 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon added inline comments.



Comment at: clang/test/CodeGen/avxvnniint8-builtins.c:1
+// RUN: %clang_cc1 -flax-vector-conversions=none -ffreestanding %s 
-triple=x86_64-unknown-unknown -target-feature +avxvnniint8 -emit-llvm -o - 
-Wall -Werror | FileCheck %s
+

32-bit test coverage?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135938

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


[PATCH] D135937: [X86] Support -march=meteorlake

2022-10-14 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon added inline comments.



Comment at: llvm/lib/Target/X86/X86.td:1424
+def : ProcModel<"meteorlake", SLMModel, ProcessorFeatures.ADLFeatures,
+ProcessorFeatures.TRMTuning>;
 

This should be with the alderlake/raptorlake defs below (and use ADL 
model/features/tuning)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135937

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


[PATCH] D135936: [X86] Support -march=raptorlake

2022-10-14 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon added inline comments.



Comment at: llvm/lib/Support/Host.cpp:828
+  *Subtype = X86::INTEL_COREI7_RAPTORLAKE;
+  break;
 // Icelake Xeon:

newline to separate the defs



Comment at: llvm/lib/Target/X86/X86.td:1423
 ProcessorFeatures.TRMTuning>;
+def : ProcModel<"raptorlake", SLMModel, ProcessorFeatures.ADLFeatures,
+ProcessorFeatures.TRMTuning>;

Shouldn't this be next to alderlake and use AlderlakePModel + ADLTuning?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135936

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


[PATCH] D134361: [clang][Interp] Fix copy constructors of structs with array members

2022-10-14 Thread Timm Bäder 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 rG33b52836de6e: [clang][Interp] Fix using default copy 
constructors (authored by tbaeder).

Changed prior to commit:
  https://reviews.llvm.org/D134361?vs=463522=467710#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134361

Files:
  clang/lib/AST/Interp/ByteCodeExprGen.cpp
  clang/lib/AST/Interp/ByteCodeExprGen.h
  clang/lib/AST/Interp/ByteCodeStmtGen.cpp
  clang/test/AST/Interp/records.cpp

Index: clang/test/AST/Interp/records.cpp
===
--- clang/test/AST/Interp/records.cpp
+++ clang/test/AST/Interp/records.cpp
@@ -32,6 +32,9 @@
 static_assert(ints.b == 30, "");
 static_assert(ints.c, "");
 static_assert(ints.getTen() == 10, "");
+static_assert(ints.numbers[0] == 1, "");
+static_assert(ints.numbers[1] == 2, "");
+static_assert(ints.numbers[2] == 3, "");
 
 constexpr const BoolPair  = ints.bp;
 static_assert(BP.first, "");
@@ -62,11 +65,17 @@
 static_assert(ints4.a == (40 * 50), "");
 static_assert(ints4.b == 0, "");
 static_assert(ints4.c, "");
-
-
-// FIXME: Implement initialization by DeclRefExpr.
-//constexpr Ints ints4 = ints3;  TODO
-
+static_assert(ints4.numbers[0] == 1, "");
+static_assert(ints4.numbers[1] == 2, "");
+static_assert(ints4.numbers[2] == 3, "");
+
+constexpr Ints ints5 = ints4;
+static_assert(ints5.a == (40 * 50), "");
+static_assert(ints5.b == 0, "");
+static_assert(ints5.c, "");
+static_assert(ints5.numbers[0] == 1, "");
+static_assert(ints5.numbers[1] == 2, "");
+static_assert(ints5.numbers[2] == 3, "");
 
 
 struct Ints2 {
Index: clang/lib/AST/Interp/ByteCodeStmtGen.cpp
===
--- clang/lib/AST/Interp/ByteCodeStmtGen.cpp
+++ clang/lib/AST/Interp/ByteCodeStmtGen.cpp
@@ -105,7 +105,7 @@
   const Record::Field *F = R->getField(Member);
 
   if (Optional T = this->classify(InitExpr->getType())) {
-if (!this->emitDupPtr(InitExpr))
+if (!this->emitThis(InitExpr))
   return false;
 
 if (!this->visit(InitExpr))
@@ -116,7 +116,7 @@
   } else {
 // Non-primitive case. Get a pointer to the field-to-initialize
 // on the stack and call visitInitialzer() for it.
-if (!this->emitDupPtr(InitExpr))
+if (!this->emitThis(InitExpr))
   return false;
 
 if (!this->emitGetPtrField(F->Offset, InitExpr))
Index: clang/lib/AST/Interp/ByteCodeExprGen.h
===
--- clang/lib/AST/Interp/ByteCodeExprGen.h
+++ clang/lib/AST/Interp/ByteCodeExprGen.h
@@ -34,6 +34,7 @@
 template  class VariableScope;
 template  class DeclScope;
 template  class OptionScope;
+template  class ArrayIndexScope;
 
 /// Compilation context for expressions.
 template 
@@ -85,6 +86,8 @@
   bool VisitConstantExpr(const ConstantExpr *E);
   bool VisitUnaryExprOrTypeTraitExpr(const UnaryExprOrTypeTraitExpr *E);
   bool VisitMemberExpr(const MemberExpr *E);
+  bool VisitArrayInitIndexExpr(const ArrayInitIndexExpr *E);
+  bool VisitOpaqueValueExpr(const OpaqueValueExpr *E);
 
 protected:
   bool visitExpr(const Expr *E) override;
@@ -199,6 +202,7 @@
   friend class RecordScope;
   friend class DeclScope;
   friend class OptionScope;
+  friend class ArrayIndexScope;
 
   /// Emits a zero initializer.
   bool visitZeroInitializer(PrimType T, const Expr *E);
@@ -260,7 +264,7 @@
   /// Current scope.
   VariableScope *VarScope = nullptr;
 
-  /// Current argument index.
+  /// Current argument index. Needed to emit ArrayInitIndexExpr.
   llvm::Optional ArrayIndex;
 
   /// Flag indicating if return value is to be discarded.
@@ -362,6 +366,20 @@
   }
 };
 
+template  class ArrayIndexScope final {
+public:
+  ArrayIndexScope(ByteCodeExprGen *Ctx, uint64_t Index) : Ctx(Ctx) {
+OldArrayIndex = Ctx->ArrayIndex;
+Ctx->ArrayIndex = Index;
+  }
+
+  ~ArrayIndexScope() { Ctx->ArrayIndex = OldArrayIndex; }
+
+private:
+  ByteCodeExprGen *Ctx;
+  Optional OldArrayIndex;
+};
+
 } // namespace interp
 } // namespace clang
 
Index: clang/lib/AST/Interp/ByteCodeExprGen.cpp
===
--- clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -326,6 +326,18 @@
   return false;
 }
 
+template 
+bool ByteCodeExprGen::VisitArrayInitIndexExpr(
+const ArrayInitIndexExpr *E) {
+  assert(ArrayIndex);
+  return this->emitConstUint64(*ArrayIndex, E);
+}
+
+template 
+bool ByteCodeExprGen::VisitOpaqueValueExpr(const OpaqueValueExpr *E) {
+  return this->visit(E->getSourceExpr());
+}
+
 template  bool ByteCodeExprGen::discard(const Expr *E) {
   OptionScope Scope(this, /*NewDiscardResult=*/true);
   return this->Visit(E);
@@ -628,6 +640,32 @@
 return true;
   } 

[PATCH] D134175: [clang][Interp] Implement record instance functions and returning struct types

2022-10-14 Thread Timm Bäder 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 rGcb5f205828e6: [clang][Interp] Implement nested struct 
initialization (authored by tbaeder).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134175

Files:
  clang/lib/AST/Interp/ByteCodeExprGen.cpp
  clang/lib/AST/Interp/ByteCodeStmtGen.cpp
  clang/test/AST/Interp/records.cpp

Index: clang/test/AST/Interp/records.cpp
===
--- clang/test/AST/Interp/records.cpp
+++ clang/test/AST/Interp/records.cpp
@@ -12,7 +12,8 @@
   int a = 20;
   int b = 30;
   bool c = true;
-  // BoolPair bp = {true, false}; FIXME
+  BoolPair bp = {true, false};
+  int numbers[3] = {1,2,3};
 
   static const int five = 5;
   static constexpr int getFive() {
@@ -32,6 +33,13 @@
 static_assert(ints.c, "");
 static_assert(ints.getTen() == 10, "");
 
+constexpr const BoolPair  = ints.bp;
+static_assert(BP.first, "");
+static_assert(!BP.second, "");
+static_assert(ints.bp.first, "");
+static_assert(!ints.bp.second, "");
+
+
 constexpr Ints ints2{-20, -30, false};
 static_assert(ints2.a == -20, "");
 static_assert(ints2.b == -30, "");
Index: clang/lib/AST/Interp/ByteCodeStmtGen.cpp
===
--- clang/lib/AST/Interp/ByteCodeStmtGen.cpp
+++ clang/lib/AST/Interp/ByteCodeStmtGen.cpp
@@ -102,10 +102,9 @@
 for (const auto *Init : Ctor->inits()) {
   const FieldDecl *Member = Init->getMember();
   const Expr *InitExpr = Init->getInit();
+  const Record::Field *F = R->getField(Member);
 
   if (Optional T = this->classify(InitExpr->getType())) {
-const Record::Field *F = R->getField(Member);
-
 if (!this->emitDupPtr(InitExpr))
   return false;
 
@@ -115,7 +114,19 @@
 if (!this->emitInitField(*T, F->Offset, InitExpr))
   return false;
   } else {
-assert(false && "Handle initializer for non-primitive values");
+// Non-primitive case. Get a pointer to the field-to-initialize
+// on the stack and call visitInitialzer() for it.
+if (!this->emitDupPtr(InitExpr))
+  return false;
+
+if (!this->emitGetPtrField(F->Offset, InitExpr))
+  return false;
+
+if (!this->visitInitializer(InitExpr))
+  return false;
+
+if (!this->emitPopPtr(InitExpr))
+  return false;
   }
 }
   }
Index: clang/lib/AST/Interp/ByteCodeExprGen.cpp
===
--- clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -613,9 +613,11 @@
   return false;
   } else if (Optional T = classify(InitType)) {
 // Visit the primitive element like normal.
+if (!this->emitDupPtr(Init))
+  return false;
 if (!this->visit(Init))
   return false;
-if (!this->emitInitElem(*T, ElementIndex, Init))
+if (!this->emitInitElemPop(*T, ElementIndex, Init))
   return false;
   } else {
 assert(false && "Unhandled type in array initializer initlist");
@@ -623,12 +625,13 @@
 
   ++ElementIndex;
 }
-
-  } else {
-assert(false && "Unknown expression for array initialization");
+return true;
+  } else if (const auto *DIE = dyn_cast(Initializer)) {
+return this->visitInitializer(DIE->getExpr());
   }
 
-  return true;
+  assert(false && "Unknown expression for array initialization");
+  return false;
 }
 
 template 
@@ -683,7 +686,10 @@
 
   return this->visit(CE);
 }
+  } else if (const auto *DIE = dyn_cast(Initializer)) {
+return this->visitInitializer(DIE->getExpr());
   }
+
   return false;
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D134699: [clang][Interp] Implement This pointer passing to methods

2022-10-14 Thread Timm Bäder via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
tbaeder marked an inline comment as done.
Closed by commit rG0ddd13acc9e9: [clang][Interp] Implement This pointer passing 
to methods (authored by tbaeder).

Changed prior to commit:
  https://reviews.llvm.org/D134699?vs=465966=467708#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134699

Files:
  clang/lib/AST/Interp/ByteCodeEmitter.cpp
  clang/lib/AST/Interp/ByteCodeExprGen.cpp
  clang/lib/AST/Interp/ByteCodeExprGen.h
  clang/lib/AST/Interp/ByteCodeStmtGen.cpp
  clang/lib/AST/Interp/Disasm.cpp
  clang/lib/AST/Interp/EvalEmitter.cpp
  clang/lib/AST/Interp/Function.cpp
  clang/lib/AST/Interp/Function.h
  clang/lib/AST/Interp/Interp.cpp
  clang/lib/AST/Interp/InterpFrame.cpp
  clang/lib/AST/Interp/InterpFrame.h
  clang/test/AST/Interp/records.cpp

Index: clang/test/AST/Interp/records.cpp
===
--- clang/test/AST/Interp/records.cpp
+++ clang/test/AST/Interp/records.cpp
@@ -1,7 +1,6 @@
 // RUN: %clang_cc1 -fexperimental-new-constant-interpreter -verify %s
 // RUN: %clang_cc1 -verify=ref %s
 
-// ref-no-diagnostics
 // expected-no-diagnostics
 
 struct BoolPair {
@@ -38,7 +37,6 @@
 static_assert(ints2.b == -30, "");
 static_assert(!ints2.c, "");
 
-#if 0
 constexpr Ints getInts() {
   return {64, 128, true};
 }
@@ -46,7 +44,6 @@
 static_assert(ints3.a == 64, "");
 static_assert(ints3.b == 128, "");
 static_assert(ints3.c, "");
-#endif
 
 constexpr Ints ints4 = {
   .a = 40 * 50,
@@ -103,3 +100,38 @@
   return 
 }
 static_assert(getPointer()->a == 100, "");
+
+constexpr C RVOAndParams(const C *c) {
+  return C();
+}
+constexpr C RVOAndParamsResult = RVOAndParams();
+
+constexpr int locals() {
+  C c;
+  c.a = 10;
+
+  // Assignment, not an initializer.
+  // c = C(); FIXME
+  c.a = 10;
+
+
+  // Assignment, not an initializer.
+  //c = RVOAndParams(); FIXME
+
+  return c.a;
+}
+static_assert(locals() == 10, "");
+
+namespace thisPointer {
+  struct S {
+constexpr int get12() { return 12; }
+  };
+
+  constexpr int foo() { // ref-error {{never produces a constant expression}}
+S *s = nullptr;
+return s->get12(); // ref-note 2{{member call on dereferenced null pointer}}
+  }
+  // FIXME: The new interpreter doesn't reject this currently.
+  static_assert(foo() == 12, ""); // ref-error {{not an integral constant expression}} \
+  // ref-note {{in call to 'foo()'}}
+};
Index: clang/lib/AST/Interp/InterpFrame.h
===
--- clang/lib/AST/Interp/InterpFrame.h
+++ clang/lib/AST/Interp/InterpFrame.h
@@ -35,6 +35,11 @@
   InterpFrame(InterpState , Function *Func, InterpFrame *Caller,
   CodePtr RetPC, Pointer &);
 
+  /// Creates a new frame with the values that make sense.
+  /// I.e., the caller is the current frame of S,
+  /// and the This() pointer is the current Pointer on the top of S's stack,
+  InterpFrame(InterpState , Function *Func, CodePtr RetPC);
+
   /// Destroys the frame, killing all live pointers to stack slots.
   ~InterpFrame();
 
Index: clang/lib/AST/Interp/InterpFrame.cpp
===
--- clang/lib/AST/Interp/InterpFrame.cpp
+++ clang/lib/AST/Interp/InterpFrame.cpp
@@ -36,6 +36,36 @@
   }
 }
 
+InterpFrame::InterpFrame(InterpState , Function *Func, CodePtr RetPC)
+: Caller(S.Current), S(S), Func(Func), RetPC(RetPC),
+  ArgSize(Func ? Func->getArgSize() : 0),
+  Args(static_cast(S.Stk.top())), FrameOffset(S.Stk.size()) {
+  assert(Func);
+
+  // As per our calling convention, the this pointer is
+  // part of the ArgSize.
+  // If the function has RVO, the RVO pointer is first.
+  // If the fuction has a This pointer, that one is next.
+  // Then follow the actual arguments (but those are handled
+  // in getParamPointer()).
+  if (Func->hasThisPointer()) {
+if (Func->hasRVO())
+  This = stackRef(sizeof(Pointer));
+else
+  This = stackRef(0);
+  }
+
+  if (unsigned FrameSize = Func->getFrameSize()) {
+Locals = std::make_unique(FrameSize);
+for (auto  : Func->scopes()) {
+  for (auto  : Scope.locals()) {
+Block *B = new (localBlock(Local.Offset)) Block(Local.Desc);
+B->invokeCtor();
+  }
+}
+  }
+}
+
 InterpFrame::~InterpFrame() {
   if (Func && Func->isConstructor() && This.isBaseClass())
 This.initialize();
Index: clang/lib/AST/Interp/Interp.cpp
===
--- clang/lib/AST/Interp/Interp.cpp
+++ clang/lib/AST/Interp/Interp.cpp
@@ -55,8 +55,7 @@
 
 template ::T>
 static bool Call(InterpState , CodePtr , const Function *Func) {
-  S.Current =
-  new InterpFrame(S, const_cast(Func), S.Current, PC, {});
+  S.Current = new 

[PATCH] D134057: [clang][Interp] Start implementing record types

2022-10-14 Thread Timm Bäder via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
tbaeder marked an inline comment as done.
Closed by commit rG1942a2538b86: [clang][Interp] Start implementing record 
types (authored by tbaeder).

Changed prior to commit:
  https://reviews.llvm.org/D134057?vs=461148=467707#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134057

Files:
  clang/lib/AST/Interp/ByteCodeExprGen.cpp
  clang/lib/AST/Interp/ByteCodeExprGen.h
  clang/lib/AST/Interp/ByteCodeStmtGen.cpp
  clang/lib/AST/Interp/Interp.h
  clang/lib/AST/Interp/Record.h
  clang/test/AST/Interp/records.cpp
  clang/test/AST/Interp/references.cpp

Index: clang/test/AST/Interp/references.cpp
===
--- clang/test/AST/Interp/references.cpp
+++ clang/test/AST/Interp/references.cpp
@@ -83,9 +83,8 @@
   S s{1, 2};
 
   int  = s.i;
-  j += 10;
+  j = j + 10;
 
   return j;
 }
-// FIXME: Should be accepted.
-static_assert(RefToMemberExpr() == 11, ""); // expected-error {{not an integral constant expression}}
+static_assert(RefToMemberExpr() == 11, "");
Index: clang/test/AST/Interp/records.cpp
===
--- /dev/null
+++ clang/test/AST/Interp/records.cpp
@@ -0,0 +1,105 @@
+// RUN: %clang_cc1 -fexperimental-new-constant-interpreter -verify %s
+// RUN: %clang_cc1 -verify=ref %s
+
+// ref-no-diagnostics
+// expected-no-diagnostics
+
+struct BoolPair {
+  bool first;
+  bool second;
+};
+
+struct Ints {
+  int a = 20;
+  int b = 30;
+  bool c = true;
+  // BoolPair bp = {true, false}; FIXME
+
+  static const int five = 5;
+  static constexpr int getFive() {
+return five;
+  }
+
+  constexpr int getTen() const {
+return 10;
+  }
+};
+
+static_assert(Ints::getFive() == 5, "");
+
+constexpr Ints ints;
+static_assert(ints.a == 20, "");
+static_assert(ints.b == 30, "");
+static_assert(ints.c, "");
+static_assert(ints.getTen() == 10, "");
+
+constexpr Ints ints2{-20, -30, false};
+static_assert(ints2.a == -20, "");
+static_assert(ints2.b == -30, "");
+static_assert(!ints2.c, "");
+
+#if 0
+constexpr Ints getInts() {
+  return {64, 128, true};
+}
+constexpr Ints ints3 = getInts();
+static_assert(ints3.a == 64, "");
+static_assert(ints3.b == 128, "");
+static_assert(ints3.c, "");
+#endif
+
+constexpr Ints ints4 = {
+  .a = 40 * 50,
+  .b = 0,
+  .c = (ints.a > 0),
+
+};
+static_assert(ints4.a == (40 * 50), "");
+static_assert(ints4.b == 0, "");
+static_assert(ints4.c, "");
+
+
+// FIXME: Implement initialization by DeclRefExpr.
+//constexpr Ints ints4 = ints3;  TODO
+
+
+
+struct Ints2 {
+  int a = 10;
+  int b;
+};
+// FIXME: Broken in the new constant interpreter.
+//   Should be rejected, but without asan errors.
+//constexpr Ints2 ints2;
+
+class C {
+  public:
+int a;
+int b;
+
+  constexpr C() : a(100), b(200) {}
+};
+
+constexpr C c;
+static_assert(c.a == 100, "");
+static_assert(c.b == 200, "");
+
+constexpr int getB() {
+  C c;
+  int  = c.b;
+
+  j = j * 2;
+
+  return c.b;
+}
+static_assert(getB() == 400, "");
+
+constexpr int getA(const C ) {
+  return c.a;
+}
+static_assert(getA(c) == 100, "");
+
+constexpr const C* getPointer() {
+  return 
+}
+static_assert(getPointer()->a == 100, "");
Index: clang/lib/AST/Interp/Record.h
===
--- clang/lib/AST/Interp/Record.h
+++ clang/lib/AST/Interp/Record.h
@@ -67,6 +67,7 @@
   }
 
   unsigned getNumFields() const { return Fields.size(); }
+  const Field *getField(unsigned I) const { return [I]; }
   Field *getField(unsigned I) { return [I]; }
 
   using const_base_iter = BaseList::const_iterator;
Index: clang/lib/AST/Interp/Interp.h
===
--- clang/lib/AST/Interp/Interp.h
+++ clang/lib/AST/Interp/Interp.h
@@ -492,6 +492,9 @@
   return true;
 }
 
+/// 1) Pops the value from the stack
+/// 2) Pops a pointer from the stack
+/// 3) Writes the value to field I of the pointer
 template ::T>
 bool InitField(InterpState , CodePtr OpPC, uint32_t I) {
   const T  = S.Stk.pop();
Index: clang/lib/AST/Interp/ByteCodeStmtGen.cpp
===
--- clang/lib/AST/Interp/ByteCodeStmtGen.cpp
+++ clang/lib/AST/Interp/ByteCodeStmtGen.cpp
@@ -94,10 +94,6 @@
   // Classify the return type.
   ReturnType = this->classify(F->getReturnType());
 
-  // Set up fields and context if a constructor.
-  if (auto *MD = dyn_cast(F))
-return this->bail(MD);
-
   if (auto *Body = F->getBody())
 if (!visitStmt(Body))
   return false;
Index: clang/lib/AST/Interp/ByteCodeExprGen.h
===
--- clang/lib/AST/Interp/ByteCodeExprGen.h
+++ clang/lib/AST/Interp/ByteCodeExprGen.h
@@ -71,6 +71,7 @@
   bool 

[PATCH] D135569: [clang][Interp] Don't run functions immediately after compiling them

2022-10-14 Thread Timm Bäder via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG1928da1ef73c: [clang][Interp] Dont run functions 
immediately after compiling them (authored by tbaeder).

Changed prior to commit:
  https://reviews.llvm.org/D135569?vs=466462=467706#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135569

Files:
  clang/lib/AST/Interp/Context.cpp


Index: clang/lib/AST/Interp/Context.cpp
===
--- clang/lib/AST/Interp/Context.cpp
+++ clang/lib/AST/Interp/Context.cpp
@@ -39,11 +39,7 @@
 }
   }
 
-  if (!Func->isConstexpr())
-return false;
-
-  APValue Dummy;
-  return Run(Parent, Func, Dummy);
+  return Func->isConstexpr();
 }
 
 bool Context::evaluateAsRValue(State , const Expr *E, APValue ) {


Index: clang/lib/AST/Interp/Context.cpp
===
--- clang/lib/AST/Interp/Context.cpp
+++ clang/lib/AST/Interp/Context.cpp
@@ -39,11 +39,7 @@
 }
   }
 
-  if (!Func->isConstexpr())
-return false;
-
-  APValue Dummy;
-  return Run(Parent, Func, Dummy);
+  return Func->isConstexpr();
 }
 
 bool Context::evaluateAsRValue(State , const Expr *E, APValue ) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 33b5283 - [clang][Interp] Fix using default copy constructors

2022-10-14 Thread Timm Bäder via cfe-commits

Author: Timm Bäder
Date: 2022-10-14T10:21:53+02:00
New Revision: 33b52836de6e093acea15f24b6ae633f969d194a

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

LOG: [clang][Interp] Fix using default copy constructors

Implement ArrayInitLoopExprs, which are used in copy constructors to
copy arrays. Also fix problems encountered while doing that.

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

Added: 


Modified: 
clang/lib/AST/Interp/ByteCodeExprGen.cpp
clang/lib/AST/Interp/ByteCodeExprGen.h
clang/lib/AST/Interp/ByteCodeStmtGen.cpp
clang/test/AST/Interp/records.cpp

Removed: 




diff  --git a/clang/lib/AST/Interp/ByteCodeExprGen.cpp 
b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
index 66e373e427c8..b9e7f4e2cdad 100644
--- a/clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -326,6 +326,18 @@ bool ByteCodeExprGen::VisitMemberExpr(const 
MemberExpr *E) {
   return false;
 }
 
+template 
+bool ByteCodeExprGen::VisitArrayInitIndexExpr(
+const ArrayInitIndexExpr *E) {
+  assert(ArrayIndex);
+  return this->emitConstUint64(*ArrayIndex, E);
+}
+
+template 
+bool ByteCodeExprGen::VisitOpaqueValueExpr(const OpaqueValueExpr *E) {
+  return this->visit(E->getSourceExpr());
+}
+
 template  bool ByteCodeExprGen::discard(const Expr *E) 
{
   OptionScope Scope(this, /*NewDiscardResult=*/true);
   return this->Visit(E);
@@ -628,6 +640,32 @@ bool ByteCodeExprGen::visitArrayInitializer(const 
Expr *Initializer) {
 return true;
   } else if (const auto *DIE = dyn_cast(Initializer)) {
 return this->visitInitializer(DIE->getExpr());
+  } else if (const auto *AILE = dyn_cast(Initializer)) {
+// TODO: This compiles to quite a lot of bytecode if the array is larger.
+//   Investigate compiling this to a loop, or at least try to use
+//   the AILE's Common expr.
+const Expr *SubExpr = AILE->getSubExpr();
+size_t Size = AILE->getArraySize().getZExtValue();
+Optional ElemT = classify(SubExpr->getType());
+
+if (!ElemT)
+  return false;
+
+for (size_t I = 0; I != Size; ++I) {
+  ArrayIndexScope IndexScope(this, I);
+  if (!this->emitDupPtr(SubExpr))
+return false;
+
+  if (!this->visit(SubExpr))
+return false;
+
+  if (!this->emitInitElem(*ElemT, I, Initializer))
+return false;
+
+  if (!this->emitPopPtr(Initializer))
+return false;
+}
+return true;
   }
 
   assert(false && "Unknown expression for array initialization");
@@ -642,13 +680,20 @@ bool 
ByteCodeExprGen::visitRecordInitializer(const Expr *Initializer) {
   if (const auto CtorExpr = dyn_cast(Initializer)) {
 const Function *Func = getFunction(CtorExpr->getConstructor());
 
-if (!Func)
+if (!Func || !Func->isConstexpr())
   return false;
 
 // The This pointer is already on the stack because this is an initializer,
 // but we need to dup() so the call() below has its own copy.
 if (!this->emitDupPtr(Initializer))
   return false;
+
+// Constructor arguments.
+for (const auto *Arg : CtorExpr->arguments()) {
+  if (!this->visit(Arg))
+return false;
+}
+
 return this->emitCallVoid(Func, Initializer);
   } else if (const auto *InitList = dyn_cast(Initializer)) {
 const Record *R = getRecord(InitList->getType());
@@ -657,15 +702,26 @@ bool 
ByteCodeExprGen::visitRecordInitializer(const Expr *Initializer) {
 for (const Expr *Init : InitList->inits()) {
   const Record::Field *FieldToInit = R->getField(InitIndex);
 
-  if (Optional T = classify(Init->getType())) {
-if (!this->emitDupPtr(Initializer))
-  return false;
+  if (!this->emitDupPtr(Initializer))
+return false;
 
+  if (Optional T = classify(Init->getType())) {
 if (!this->visit(Init))
   return false;
 
 if (!this->emitInitField(*T, FieldToInit->Offset, Initializer))
   return false;
+  } else {
+// Non-primitive case. Get a pointer to the field-to-initialize
+// on the stack and recurse into visitInitializer().
+if (!this->emitGetPtrField(FieldToInit->Offset, Init))
+  return false;
+
+if (!this->visitInitializer(Init))
+  return false;
+
+if (!this->emitPopPtr(Initializer))
+  return false;
   }
   ++InitIndex;
 }

diff  --git a/clang/lib/AST/Interp/ByteCodeExprGen.h 
b/clang/lib/AST/Interp/ByteCodeExprGen.h
index 14356ec9cdee..32ff72aa36fb 100644
--- a/clang/lib/AST/Interp/ByteCodeExprGen.h
+++ b/clang/lib/AST/Interp/ByteCodeExprGen.h
@@ -34,6 +34,7 @@ template  class RecordScope;
 template  class VariableScope;
 template  class DeclScope;
 template  class OptionScope;
+template  class ArrayIndexScope;
 
 /// 

[clang] cb5f205 - [clang][Interp] Implement nested struct initialization

2022-10-14 Thread Timm Bäder via cfe-commits

Author: Timm Bäder
Date: 2022-10-14T10:21:53+02:00
New Revision: cb5f205828e696fb23cfe3de57af83d151ffad38

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

LOG: [clang][Interp] Implement nested struct initialization

Recurse into visitInitializer() if necessary.

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

Added: 


Modified: 
clang/lib/AST/Interp/ByteCodeExprGen.cpp
clang/lib/AST/Interp/ByteCodeStmtGen.cpp
clang/test/AST/Interp/records.cpp

Removed: 




diff  --git a/clang/lib/AST/Interp/ByteCodeExprGen.cpp 
b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
index d743e3a22342..66e373e427c8 100644
--- a/clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -613,9 +613,11 @@ bool ByteCodeExprGen::visitArrayInitializer(const 
Expr *Initializer) {
   return false;
   } else if (Optional T = classify(InitType)) {
 // Visit the primitive element like normal.
+if (!this->emitDupPtr(Init))
+  return false;
 if (!this->visit(Init))
   return false;
-if (!this->emitInitElem(*T, ElementIndex, Init))
+if (!this->emitInitElemPop(*T, ElementIndex, Init))
   return false;
   } else {
 assert(false && "Unhandled type in array initializer initlist");
@@ -623,12 +625,13 @@ bool 
ByteCodeExprGen::visitArrayInitializer(const Expr *Initializer) {
 
   ++ElementIndex;
 }
-
-  } else {
-assert(false && "Unknown expression for array initialization");
+return true;
+  } else if (const auto *DIE = dyn_cast(Initializer)) {
+return this->visitInitializer(DIE->getExpr());
   }
 
-  return true;
+  assert(false && "Unknown expression for array initialization");
+  return false;
 }
 
 template 
@@ -683,7 +686,10 @@ bool 
ByteCodeExprGen::visitRecordInitializer(const Expr *Initializer) {
 
   return this->visit(CE);
 }
+  } else if (const auto *DIE = dyn_cast(Initializer)) {
+return this->visitInitializer(DIE->getExpr());
   }
+
   return false;
 }
 

diff  --git a/clang/lib/AST/Interp/ByteCodeStmtGen.cpp 
b/clang/lib/AST/Interp/ByteCodeStmtGen.cpp
index 54a0f50d198b..b4a61ebed0e7 100644
--- a/clang/lib/AST/Interp/ByteCodeStmtGen.cpp
+++ b/clang/lib/AST/Interp/ByteCodeStmtGen.cpp
@@ -102,10 +102,9 @@ bool ByteCodeStmtGen::visitFunc(const 
FunctionDecl *F) {
 for (const auto *Init : Ctor->inits()) {
   const FieldDecl *Member = Init->getMember();
   const Expr *InitExpr = Init->getInit();
+  const Record::Field *F = R->getField(Member);
 
   if (Optional T = this->classify(InitExpr->getType())) {
-const Record::Field *F = R->getField(Member);
-
 if (!this->emitDupPtr(InitExpr))
   return false;
 
@@ -115,7 +114,19 @@ bool ByteCodeStmtGen::visitFunc(const 
FunctionDecl *F) {
 if (!this->emitInitField(*T, F->Offset, InitExpr))
   return false;
   } else {
-assert(false && "Handle initializer for non-primitive values");
+// Non-primitive case. Get a pointer to the field-to-initialize
+// on the stack and call visitInitialzer() for it.
+if (!this->emitDupPtr(InitExpr))
+  return false;
+
+if (!this->emitGetPtrField(F->Offset, InitExpr))
+  return false;
+
+if (!this->visitInitializer(InitExpr))
+  return false;
+
+if (!this->emitPopPtr(InitExpr))
+  return false;
   }
 }
   }

diff  --git a/clang/test/AST/Interp/records.cpp 
b/clang/test/AST/Interp/records.cpp
index ab363ffc8770..8d62b53d622a 100644
--- a/clang/test/AST/Interp/records.cpp
+++ b/clang/test/AST/Interp/records.cpp
@@ -12,7 +12,8 @@ struct Ints {
   int a = 20;
   int b = 30;
   bool c = true;
-  // BoolPair bp = {true, false}; FIXME
+  BoolPair bp = {true, false};
+  int numbers[3] = {1,2,3};
 
   static const int five = 5;
   static constexpr int getFive() {
@@ -32,6 +33,13 @@ static_assert(ints.b == 30, "");
 static_assert(ints.c, "");
 static_assert(ints.getTen() == 10, "");
 
+constexpr const BoolPair  = ints.bp;
+static_assert(BP.first, "");
+static_assert(!BP.second, "");
+static_assert(ints.bp.first, "");
+static_assert(!ints.bp.second, "");
+
+
 constexpr Ints ints2{-20, -30, false};
 static_assert(ints2.a == -20, "");
 static_assert(ints2.b == -30, "");



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


[clang] 0ddd13a - [clang][Interp] Implement This pointer passing to methods

2022-10-14 Thread Timm Bäder via cfe-commits

Author: Timm Bäder
Date: 2022-10-14T10:21:53+02:00
New Revision: 0ddd13acc9e9b820c8f610c9006ef59aef8e5320

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

LOG: [clang][Interp] Implement This pointer passing to methods

Implement passing the this pointer to member functions and constructors.
The this pointer is passed via the stack. This changes the functions to
explicitly track whether they have a RVO pointer and a this pointer.

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

Added: 


Modified: 
clang/lib/AST/Interp/ByteCodeEmitter.cpp
clang/lib/AST/Interp/ByteCodeExprGen.cpp
clang/lib/AST/Interp/ByteCodeExprGen.h
clang/lib/AST/Interp/ByteCodeStmtGen.cpp
clang/lib/AST/Interp/Disasm.cpp
clang/lib/AST/Interp/EvalEmitter.cpp
clang/lib/AST/Interp/Function.cpp
clang/lib/AST/Interp/Function.h
clang/lib/AST/Interp/Interp.cpp
clang/lib/AST/Interp/InterpFrame.cpp
clang/lib/AST/Interp/InterpFrame.h
clang/test/AST/Interp/records.cpp

Removed: 




diff  --git a/clang/lib/AST/Interp/ByteCodeEmitter.cpp 
b/clang/lib/AST/Interp/ByteCodeEmitter.cpp
index 20e054ab87df..7fa189ad0806 100644
--- a/clang/lib/AST/Interp/ByteCodeEmitter.cpp
+++ b/clang/lib/AST/Interp/ByteCodeEmitter.cpp
@@ -31,8 +31,21 @@ Expected ByteCodeEmitter::compileFunc(const 
FunctionDecl *F) {
 
   // If the return is not a primitive, a pointer to the storage where the value
   // is initialized in is passed as the first argument.
+  // See 'RVO' elsewhere in the code.
   QualType Ty = F->getReturnType();
+  bool HasRVO = false;
   if (!Ty->isVoidType() && !Ctx.classify(Ty)) {
+HasRVO = true;
+ParamTypes.push_back(PT_Ptr);
+ParamOffset += align(primSize(PT_Ptr));
+  }
+
+  // If the function decl is a member decl, the next parameter is
+  // the 'this' pointer. This parameter is pop()ed from the
+  // InterStack when calling the function.
+  bool HasThisPointer = false;
+  if (const auto *MD = dyn_cast(F); MD && MD->isInstance()) {
+HasThisPointer = true;
 ParamTypes.push_back(PT_Ptr);
 ParamOffset += align(primSize(PT_Ptr));
   }
@@ -55,8 +68,9 @@ Expected ByteCodeEmitter::compileFunc(const 
FunctionDecl *F) {
   }
 
   // Create a handle over the emitted code.
-  Function *Func = P.createFunction(F, ParamOffset, std::move(ParamTypes),
-std::move(ParamDescriptors));
+  Function *Func =
+  P.createFunction(F, ParamOffset, std::move(ParamTypes),
+   std::move(ParamDescriptors), HasThisPointer, HasRVO);
   // Compile the function body.
   if (!F->isConstexpr() || !visitFunc(F)) {
 // Return a dummy function if compilation failed.

diff  --git a/clang/lib/AST/Interp/ByteCodeExprGen.cpp 
b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
index 2e8343504e5a..d743e3a22342 100644
--- a/clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -637,34 +637,16 @@ bool 
ByteCodeExprGen::visitRecordInitializer(const Expr *Initializer) {
   assert(Initializer->getType()->isRecordType());
 
   if (const auto CtorExpr = dyn_cast(Initializer)) {
-const CXXConstructorDecl *Ctor = CtorExpr->getConstructor();
-const RecordDecl *RD = Ctor->getParent();
-const Record *R = getRecord(RD);
-
-for (const auto *Init : Ctor->inits()) {
-  const FieldDecl *Member = Init->getMember();
-  const Expr *InitExpr = Init->getInit();
-
-  if (Optional T = classify(InitExpr->getType())) {
-const Record::Field *F = R->getField(Member);
-
-if (!this->emitDupPtr(Initializer))
-  return false;
+const Function *Func = getFunction(CtorExpr->getConstructor());
 
-if (!this->visit(InitExpr))
-  return false;
-
-if (!this->emitInitField(*T, F->Offset, Initializer))
-  return false;
-  } else {
-assert(false && "Handle initializer for non-primitive values");
-  }
-}
+if (!Func)
+  return false;
 
-// FIXME: Actually visit() the constructor Body
-const Stmt *Body = Ctor->getBody();
-(void)Body;
-return true;
+// The This pointer is already on the stack because this is an initializer,
+// but we need to dup() so the call() below has its own copy.
+if (!this->emitDupPtr(Initializer))
+  return false;
+return this->emitCallVoid(Func, Initializer);
   } else if (const auto *InitList = dyn_cast(Initializer)) {
 const Record *R = getRecord(InitList->getType());
 
@@ -688,7 +670,10 @@ bool 
ByteCodeExprGen::visitRecordInitializer(const Expr *Initializer) {
 return true;
   } else if (const CallExpr *CE = dyn_cast(Initializer)) {
 const Decl *Callee = CE->getCalleeDecl();
-const Function *Func = P.getFunction(dyn_cast(Callee));
+const Function 

[clang] 1942a25 - [clang][Interp] Start implementing record types

2022-10-14 Thread Timm Bäder via cfe-commits

Author: Timm Bäder
Date: 2022-10-14T10:21:53+02:00
New Revision: 1942a2538b86fe55b9723800db950391cc05402b

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

LOG: [clang][Interp] Start implementing record types

Implement simple constructors as well as member access expressions.

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

Added: 
clang/test/AST/Interp/records.cpp

Modified: 
clang/lib/AST/Interp/ByteCodeExprGen.cpp
clang/lib/AST/Interp/ByteCodeExprGen.h
clang/lib/AST/Interp/ByteCodeStmtGen.cpp
clang/lib/AST/Interp/Interp.h
clang/lib/AST/Interp/Record.h
clang/test/AST/Interp/references.cpp

Removed: 




diff  --git a/clang/lib/AST/Interp/ByteCodeExprGen.cpp 
b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
index e23727aad256..2e8343504e5a 100644
--- a/clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -304,6 +304,28 @@ bool 
ByteCodeExprGen::VisitUnaryExprOrTypeTraitExpr(
   return false;
 }
 
+template 
+bool ByteCodeExprGen::VisitMemberExpr(const MemberExpr *E) {
+  // 'Base.Member'
+  const Expr *Base = E->getBase();
+  const ValueDecl *Member = E->getMemberDecl();
+
+  if (!this->visit(Base))
+return false;
+
+  // Base above gives us a pointer on the stack.
+  // TODO: Implement non-FieldDecl members.
+  if (const auto *FD = dyn_cast(Member)) {
+const RecordDecl *RD = FD->getParent();
+const Record *R = getRecord(RD);
+const Record::Field *F = R->getField(FD);
+// Leave a pointer to the field on the stack.
+return this->emitGetPtrField(F->Offset, E);
+  }
+
+  return false;
+}
+
 template  bool ByteCodeExprGen::discard(const Expr *E) 
{
   OptionScope Scope(this, /*NewDiscardResult=*/true);
   return this->Visit(E);
@@ -609,6 +631,78 @@ bool ByteCodeExprGen::visitArrayInitializer(const 
Expr *Initializer) {
   return true;
 }
 
+template 
+bool ByteCodeExprGen::visitRecordInitializer(const Expr *Initializer) 
{
+  Initializer = Initializer->IgnoreParenImpCasts();
+  assert(Initializer->getType()->isRecordType());
+
+  if (const auto CtorExpr = dyn_cast(Initializer)) {
+const CXXConstructorDecl *Ctor = CtorExpr->getConstructor();
+const RecordDecl *RD = Ctor->getParent();
+const Record *R = getRecord(RD);
+
+for (const auto *Init : Ctor->inits()) {
+  const FieldDecl *Member = Init->getMember();
+  const Expr *InitExpr = Init->getInit();
+
+  if (Optional T = classify(InitExpr->getType())) {
+const Record::Field *F = R->getField(Member);
+
+if (!this->emitDupPtr(Initializer))
+  return false;
+
+if (!this->visit(InitExpr))
+  return false;
+
+if (!this->emitInitField(*T, F->Offset, Initializer))
+  return false;
+  } else {
+assert(false && "Handle initializer for non-primitive values");
+  }
+}
+
+// FIXME: Actually visit() the constructor Body
+const Stmt *Body = Ctor->getBody();
+(void)Body;
+return true;
+  } else if (const auto *InitList = dyn_cast(Initializer)) {
+const Record *R = getRecord(InitList->getType());
+
+unsigned InitIndex = 0;
+for (const Expr *Init : InitList->inits()) {
+  const Record::Field *FieldToInit = R->getField(InitIndex);
+
+  if (Optional T = classify(Init->getType())) {
+if (!this->emitDupPtr(Initializer))
+  return false;
+
+if (!this->visit(Init))
+  return false;
+
+if (!this->emitInitField(*T, FieldToInit->Offset, Initializer))
+  return false;
+  }
+  ++InitIndex;
+}
+
+return true;
+  } else if (const CallExpr *CE = dyn_cast(Initializer)) {
+const Decl *Callee = CE->getCalleeDecl();
+const Function *Func = P.getFunction(dyn_cast(Callee));
+
+if (Func->hasRVO()) {
+  // RVO functions expect a pointer to initialize on the stack.
+  // Dup our existing pointer so it has its own copy to use.
+  if (!this->emitDupPtr(Initializer))
+return false;
+
+  return this->visit(CE);
+}
+  }
+
+  return false;
+}
+
 template 
 bool ByteCodeExprGen::visitInitializer(const Expr *Initializer) {
   QualType InitializerType = Initializer->getType();
@@ -616,6 +710,9 @@ bool ByteCodeExprGen::visitInitializer(const Expr 
*Initializer) {
   if (InitializerType->isArrayType())
 return visitArrayInitializer(Initializer);
 
+  if (InitializerType->isRecordType())
+return visitRecordInitializer(Initializer);
+
   // Otherwise, visit the expression like normal.
   return this->Visit(Initializer);
 }
@@ -755,6 +852,8 @@ bool ByteCodeExprGen::VisitCallExpr(const CallExpr 
*E) {
 return this->emitCall(*T, Func, E);
   return this->emitCallVoid(Func, E);
 } else {
+  if (Func->hasRVO())
+return 

[clang] 1928da1 - [clang][Interp] Don't run functions immediately after compiling them

2022-10-14 Thread Timm Bäder via cfe-commits

Author: Timm Bäder
Date: 2022-10-14T10:21:53+02:00
New Revision: 1928da1ef73c383ea4daeffb41691882bdb074c2

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

LOG: [clang][Interp] Don't run functions immediately after compiling them

This doesn't make much sense with functions that expect valid parameters
and/or a certain call stack on the caller side like This/RVO pointers.

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

Added: 


Modified: 
clang/lib/AST/Interp/Context.cpp

Removed: 




diff  --git a/clang/lib/AST/Interp/Context.cpp 
b/clang/lib/AST/Interp/Context.cpp
index 9f3f5542fe83..7ce3397e6a4f 100644
--- a/clang/lib/AST/Interp/Context.cpp
+++ b/clang/lib/AST/Interp/Context.cpp
@@ -39,11 +39,7 @@ bool Context::isPotentialConstantExpr(State , const 
FunctionDecl *FD) {
 }
   }
 
-  if (!Func->isConstexpr())
-return false;
-
-  APValue Dummy;
-  return Run(Parent, Func, Dummy);
+  return Func->isConstexpr();
 }
 
 bool Context::evaluateAsRValue(State , const Expr *E, APValue ) {



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


[clang] 773b468 - [clang][Interp][NFC] Add a TODO comment

2022-10-14 Thread Timm Bäder via cfe-commits

Author: Timm Bäder
Date: 2022-10-14T10:21:52+02:00
New Revision: 773b468543c8c5f0a226c0757a503cb9a40650a5

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

LOG: [clang][Interp][NFC] Add a TODO comment

We can ignore casts where FromT and ToT are the same type. But that's a
performance optimization that I'd like to do later. For now, this code
is doing the right thing.

Added: 


Modified: 
clang/lib/AST/Interp/ByteCodeExprGen.cpp

Removed: 




diff  --git a/clang/lib/AST/Interp/ByteCodeExprGen.cpp 
b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
index 9264357c568a3..e23727aad256e 100644
--- a/clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -127,6 +127,7 @@ bool ByteCodeExprGen::VisitCastExpr(const CastExpr 
*CE) {
 if (!this->Visit(SubExpr))
   return false;
 
+// TODO: Emit this only if FromT != ToT.
 return this->emitCast(*FromT, *ToT, CE);
   }
 



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


[clang] 0e93b6b - [clang][Interp][NFC] Add more tests for if expressions

2022-10-14 Thread Timm Bäder via cfe-commits

Author: Timm Bäder
Date: 2022-10-14T10:21:53+02:00
New Revision: 0e93b6bd51a0f002e37e76d6efa8e71dde6d3e5f

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

LOG: [clang][Interp][NFC] Add more tests for if expressions

Rename the old if_consteval.cpp to just if.cpp and add tests for the
if declaration.

Added: 
clang/test/AST/Interp/if.cpp

Modified: 


Removed: 
clang/test/AST/Interp/if_consteval.cpp



diff  --git a/clang/test/AST/Interp/if.cpp b/clang/test/AST/Interp/if.cpp
new file mode 100644
index 0..5d35868cd00ec
--- /dev/null
+++ b/clang/test/AST/Interp/if.cpp
@@ -0,0 +1,46 @@
+// RUN: %clang_cc1 -std=c++2b -fsyntax-only 
-fexperimental-new-constant-interpreter %s -verify
+// RUN: %clang_cc1 -std=c++2b -fsyntax-only %s -verify=ref
+
+// expected-no-diagnostics
+// ref-no-diagnostics
+
+namespace ConstEval {
+  constexpr int f() {
+int i = 0;
+if consteval {
+  i = 1;
+}
+return i;
+  }
+  static_assert(f() == 1, "");
+
+  constexpr int f2() {
+int i = 0;
+if !consteval {
+i = 12;
+  if consteval {
+i = i + 1;
+  }
+}
+return i;
+  }
+  static_assert(f2() == 0, "");
+};
+
+namespace InitDecl {
+  constexpr bool f() {
+if (int i = 5; i != 10) {
+  return true;
+}
+return false;
+  }
+  static_assert(f(), "");
+
+  constexpr bool f2() {
+if (bool b = false; b) {
+  return true;
+}
+return false;
+  }
+  static_assert(!f2(), "");
+};

diff  --git a/clang/test/AST/Interp/if_consteval.cpp 
b/clang/test/AST/Interp/if_consteval.cpp
deleted file mode 100644
index 1a3ff9b91d720..0
--- a/clang/test/AST/Interp/if_consteval.cpp
+++ /dev/null
@@ -1,28 +0,0 @@
-// RUN: %clang_cc1 -std=c++2b -fsyntax-only 
-fexperimental-new-constant-interpreter %s -verify
-// RUN: %clang_cc1 -std=c++2b -fsyntax-only %s -verify
-// expected-no-diagnostics
-
-constexpr void f() {
-  int i = 0;
-  if consteval {
-i = 1;
-  }
-  else {
-i = 2;
-  }
-
-  if consteval {
-i = 1;
-  }
-
-  if !consteval {
-i = 1;
-  }
-
-  if !consteval {
-i = 1;
-  }
-  else {
-i = 1;
-  }
-}



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


[PATCH] D135933: [X86] Add CMPCCXADD instructions.

2022-10-14 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon added inline comments.



Comment at: clang/test/CodeGen/X86/cmpccxadd-builtins-error.c:2
+// RUN: %clang_cc1 %s -ffreestanding -triple=x86_64-unknown-unknown \
+// RUN: -target-feature +cmpccxadd  -emit-llvm -fsyntax-only -verify
+

Add 32-bit test coverage to ensure the intrinsics aren't visible?



Comment at: llvm/CMakeLists.txt:887
+  list(APPEND features_enabled_by_default
+   ${LLVM_INTELFEATURE_PREFIX}_ISA_CMPCCXADD)
 

What is this for?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135933

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


[PATCH] D135932: [X86] Add AVX-IFMA instructions.

2022-10-14 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon added inline comments.



Comment at: clang/test/CodeGen/avxifma-builtins.c:1
+// RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-apple-darwin 
-target-feature +avxifma -emit-llvm -o - -Wall -Werror | FileCheck %s
+

32-bit test coverage?



Comment at: clang/test/Preprocessor/predefined-arch-macros-x86.c:35
 // X86_64_V3:  #define __AVX2__ 1
-// X86_64_V3-NEXT: #define __AVX__ 1
+// X86_64_V3 : #define __AVX__ 1
 // X86_64_V3:  #define __BMI2__ 1

?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135932

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


[PATCH] D135518: [clangAST] support TypeLoc in TextNodeDumper

2022-10-14 Thread Tobias Ribizel via Phabricator via cfe-commits
upsj added a comment.

Let me backtrack my previous question: I misremembered where AddChild is 
actually being called in the traversal (ASTNodeTraverser, not TextNodeDumper), 
so I'll see if adding this to the JSON output is feasible


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

https://reviews.llvm.org/D135518

___
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-14 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder added inline comments.



Comment at: clang/lib/AST/Interp/ByteCodeExprGen.cpp:241
+  // Pointer arithmethic special case. This is supported for one of
+  // LHS and RHS being a pointer type and the other being an integer type.
+  if (BO->getType()->isPointerType()) {

shafik wrote:
> I am not sure if this is the right place to handle this but there are a bunch 
> of other cases.
> 
> - `nullptr` can have `0` added or subtracted
> - You can only do addition/subtraction from a pointer if the result in within 
> bounds or one after the end
> - You can subtract two pointers if they point to the same object.
> 
> godbolt: https://godbolt.org/z/5YTY93z8M
I will probably move this special case out of the function and into its own.
Thanks for the tests, I think this should all already work except for adding 
two pointers. I'll update the diff once I checked that out.


Repository:
  rG LLVM Github Monorepo

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] D135025: [clang][Interp] Support base class constructors

2022-10-14 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder marked an inline comment as done.
tbaeder added inline comments.



Comment at: clang/test/AST/Interp/records.cpp:209
+  static_assert(d.getA() == 20);
+  static_assert(d.getB() == 30);
+};

aaron.ballman wrote:
> I'd appreciate some more failure test cases, if they're not already covered 
> elsewhere:
> ```
> struct Base {
>   int Val;
> };
> 
> struct Derived : Base {
>   int OtherVal;
> 
>   constexpr Derived(int i) : OtherVal(i) {}
> };
> 
> // Something here should be diagnosed; either because the Derived ctor is not 
> a
> // valid constexpr function or because we're accessing an uninitialized 
> member.
> constexpr Derived D(12);
> static_assert(D.Val == 0);
> 
> 
> // Another test is when a constexpr ctor calls a non-constexpr base class 
> ctor.
> struct AnotherBase {
>   int Val;
>   constexpr AnotherBase(int i) : Val(12 / i) {}
> };
> 
> struct AnotherDerived : AnotherBase {
>   constexpr AnotherDerived(int i) : AnotherBase(i) {}
> };
> constexpr AnotherDerived Derp(0);
> 
> // Skipping the derived class constructor is also
> // interesting to consider:
> struct YetAnotherBase {
>   int Val;
>   constexpr YetAnotherBase(int i) : Val(i) {}
> };
> 
> struct YetAnotherDerived : YetAnotherBase {
>   using YetAnotherBase::YetAnotherBase;
>   
>   int OtherVal;
> 
>   constexpr bool doit() const { return Val == OtherVal; }
> };
> 
> constexpr YetAnotherDerived Oops(0);
> ```
Thanks for the tests. I added them but it doesn't look very good.


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

https://reviews.llvm.org/D135025

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


[PATCH] D135025: [clang][Interp] Support base class constructors

2022-10-14 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder updated this revision to Diff 467699.
tbaeder marked an inline comment as done.

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

https://reviews.llvm.org/D135025

Files:
  clang/lib/AST/Interp/ByteCodeExprGen.cpp
  clang/lib/AST/Interp/ByteCodeExprGen.h
  clang/lib/AST/Interp/ByteCodeStmtGen.cpp
  clang/lib/AST/Interp/Opcodes.td
  clang/test/AST/Interp/records.cpp

Index: clang/test/AST/Interp/records.cpp
===
--- clang/test/AST/Interp/records.cpp
+++ clang/test/AST/Interp/records.cpp
@@ -1,8 +1,6 @@
 // RUN: %clang_cc1 -fexperimental-new-constant-interpreter -verify %s
 // RUN: %clang_cc1 -verify=ref %s
 
-// expected-no-diagnostics
-
 struct BoolPair {
   bool first;
   bool second;
@@ -169,3 +167,110 @@
 static_assert(LT2.v[0].second == false, "");
 static_assert(LT2.v[2].first == true, "");
 static_assert(LT2.v[2].second == false, "");
+
+class Base {
+public:
+  int i;
+  constexpr Base() : i(10) {}
+  constexpr Base(int i) : i(i) {}
+};
+
+class A : public Base {
+public:
+  constexpr A() : Base(100) {}
+  constexpr A(int a) : Base(a) {}
+};
+constexpr A a{};
+static_assert(a.i == 100, "");
+constexpr A a2{12};
+static_assert(a2.i == 12, "");
+static_assert(a2.i == 200, ""); // ref-error {{static assertion failed}} \
+// ref-note {{evaluates to '12 == 200'}} \
+// expected-error {{static assertion failed}} \
+// expected-note {{evaluates to '12 == 200'}}
+
+namespace MI {
+  class A {
+  public:
+int a;
+constexpr A(int a) : a(a) {}
+  };
+
+  class B {
+  public:
+int b;
+constexpr B(int b) : b(b) {}
+  };
+
+  class C : public A, public B {
+  public:
+constexpr C() : A(10), B(20) {}
+  };
+  constexpr C c = {};
+  static_assert(c.a == 10);
+  static_assert(c.b == 20);
+
+
+  class D : private A, private B {
+public:
+constexpr D() : A(20), B(30) {}
+constexpr int getA() const { return a; }
+constexpr int getB() const { return b; }
+  };
+  constexpr D d = {};
+  static_assert(d.getA() == 20);
+  static_assert(d.getB() == 30);
+};
+
+namespace DeriveFailures {
+  struct Base { // ref-note 2{{declared here}}
+int Val;
+  };
+
+  struct Derived : Base {
+int OtherVal;
+
+constexpr Derived(int i) : OtherVal(i) {} // ref-error {{never produces a constant expression}} \
+  // ref-note 2{{non-constexpr constructor 'Base' cannot be used in a constant expression}}
+  };
+
+  // FIXME: This is currently not being diagnosed with the new constant interpreter.
+  constexpr Derived D(12); // ref-error {{must be initialized by a constant expression}} \
+   // ref-note {{in call to 'Derived(12)'}} \
+   // ref-note {{declared here}} \
+   // expected-error {{must be initialized by a constant expression}}
+  static_assert(D.Val == 0); // ref-error {{not an integral constant expression}} \
+ // ref-note {{initializer of 'D' is not a constant expression}}
+
+  struct AnotherBase {
+int Val;
+constexpr AnotherBase(int i) : Val(12 / i) {} //ref-note {{division by zero}} \
+  //expected-note {{division by zero}}
+  };
+
+  struct AnotherDerived : AnotherBase {
+constexpr AnotherDerived(int i) : AnotherBase(i) {}
+  };
+  constexpr AnotherBase Derp(0); // ref-error {{must be initialized by a constant expression}} \
+ // ref-note {{in call to 'AnotherBase(0)'}} \
+ // expected-error {{must be initialized by a constant expression}} \
+ // expected-note {{in call to 'AnotherBase(}}
+ // FIXME Previous note uses the wrong value
+
+  struct YetAnotherBase {
+int Val;
+constexpr YetAnotherBase(int i) : Val(i) {}
+  };
+
+  struct YetAnotherDerived : YetAnotherBase {
+using YetAnotherBase::YetAnotherBase; //ref-note {{declared here}}
+int OtherVal;
+
+constexpr bool doit() const { return Val == OtherVal; }
+  };
+
+  constexpr YetAnotherDerived Oops(0); // ref-error {{must be initialized by a constant expression}} \
+   // ref-note {{constructor inherited from base class 'YetAnotherBase' cannot be used in a constant expression}} \
+   // expected-error {{must be initialized by a constant expression}}
+   // FIXME: Missing reason for rejection.
+};
Index: clang/lib/AST/Interp/Opcodes.td
===
--- clang/lib/AST/Interp/Opcodes.td
+++ clang/lib/AST/Interp/Opcodes.td
@@ -54,6 +54,11 @@
   list Types;
 }
 
+def IntegerTypeClass : TypeClass {
+  let Types = [Sint8, Uint8, Sint16, Uint16, 

[PATCH] D135859: [Includecleaner] Introduce RefType to ast walking

2022-10-14 Thread Haojian Wu via Phabricator via cfe-commits
hokein added inline comments.



Comment at: clang-tools-extra/include-cleaner/lib/AnalysisInternal.h:33
+/// Indicates the relation between the reference and the target.
+enum class RefType {
+  /// Target is explicit from the reference, e.g. function call.

I'm wondering what's our plan of supporting policy (different coding-style may 
have different decisions about which includes are used)?

IIUC, the RefType is part of the picture, providing fine-grained information 
about each reference, and the caller can make their decisions based on it?

Thinking about the `Implicit` type, I think cases like non-spelled constructor 
call, implicit conversion calls (maybe more?) fall into this type, if we 
support `Policy.Constructor`, and `Policy.Conversion`, how do we distinguish 
with these cases? We can probably do some ad-hoc checks on the `TargetDecl`, 
but I'm not sure that the tuple `` will 
provide enough information to implement different policy .



Comment at: clang-tools-extra/include-cleaner/lib/AnalysisInternal.h:36
+  Explicit,
+  /// Target isn't spelled, e.g. default constructor call.
+  Implicit,

nit: `default constructor call` is vague -- `S s = S();` it is a default 
constructor call, but it is not implicit, maybe more specific by giving a 
simple example, like default constructor call in `S s;`?



Comment at: clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp:12
 #include "gtest/gtest.h"
+#include 
+#include 

nit: it seems unused.



Comment at: clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp:177
 TEST(WalkAST, ConstructExprs) {
-  testWalk("struct ^S {};", "S ^t;");
-  testWalk("struct S { ^S(int); };", "S ^t(42);");
+  testWalk("struct $implicit^S {};", "S ^t;");
+  testWalk("struct S { $explicit^S(int); };", "S ^t(42);");

maybe add this following case, I think it will mark the the constructor `S()` 
implicit. 

```
struct S { S(); };
S ^t;
```



Comment at: clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp:178
+  testWalk("struct $implicit^S {};", "S ^t;");
+  testWalk("struct S { $explicit^S(int); };", "S ^t(42);");
 }

nit: also  add an implicit case

```
S t = 42; 
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135859

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


[PATCH] D135518: [clangAST] support TypeLoc in TextNodeDumper

2022-10-14 Thread Tobias Ribizel via Phabricator via cfe-commits
upsj added inline comments.



Comment at: clang/include/clang/AST/TextNodeDumper.h:337
+  void VisitConstantArrayTypeLoc(ConstantArrayTypeLoc TL);
+  void VisitVariableArrayTypeLoc(VariableArrayTypeLoc TL);
+  void VisitDependentSizedArrayTypeLoc(DependentSizedArrayTypeLoc TL);

aaron.ballman wrote:
> Should you also handle `IncompleteArrayTypeLoc` as well?
Not sure about this one, since it has no additional metadata - the type 
location visitor already prints out the type class name


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

https://reviews.llvm.org/D135518

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


[PATCH] D135518: [clangAST] support TypeLoc in TextNodeDumper

2022-10-14 Thread Tobias Ribizel via Phabricator via cfe-commits
upsj updated this revision to Diff 467698.
upsj marked 6 inline comments as done.
upsj added a comment.

I incorporated the `cast`, `ASTContext` and `StringRef` suggestions. About 
JSONDumper, I was surprised to see that it doesn't seem to use `AddChild` for 
the AST hierarchy at all, so I'm not quite clear how (if?) it builds a nested 
output. What's the easiest way to invoke it?


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

https://reviews.llvm.org/D135518

Files:
  clang/include/clang/AST/ASTNodeTraverser.h
  clang/include/clang/AST/TextNodeDumper.h
  clang/include/clang/AST/TypeLoc.h
  clang/lib/AST/TextNodeDumper.cpp
  clang/lib/AST/TypeLoc.cpp

Index: clang/lib/AST/TypeLoc.cpp
===
--- clang/lib/AST/TypeLoc.cpp
+++ clang/lib/AST/TypeLoc.cpp
@@ -57,6 +57,22 @@
 
 namespace {
 
+class TypeNamer : public TypeLocVisitor {
+public:
+#define ABSTRACT_TYPELOC(CLASS, PARENT)
+#define TYPELOC(CLASS, PARENT) \
+  llvm::StringRef Visit##CLASS##TypeLoc(CLASS##TypeLoc TyLoc) { return #CLASS; }
+#include "clang/AST/TypeLocNodes.def"
+};
+
+} // namespace
+
+llvm::StringRef TypeLoc::getTypeLocClassName() const {
+  return TypeNamer().Visit(*this);
+}
+
+namespace {
+
 class TypeAligner : public TypeLocVisitor {
 public:
 #define ABSTRACT_TYPELOC(CLASS, PARENT)
Index: clang/lib/AST/TextNodeDumper.cpp
===
--- clang/lib/AST/TextNodeDumper.cpp
+++ clang/lib/AST/TextNodeDumper.cpp
@@ -17,6 +17,7 @@
 #include "clang/AST/DeclTemplate.h"
 #include "clang/AST/LocInfoType.h"
 #include "clang/AST/Type.h"
+#include "clang/AST/TypeLocVisitor.h"
 #include "clang/Basic/Module.h"
 #include "clang/Basic/SourceManager.h"
 #include "clang/Basic/Specifiers.h"
@@ -239,6 +240,18 @@
   OS << " " << T.split().Quals.getAsString();
 }
 
+void TextNodeDumper::Visit(TypeLoc TL) {
+  {
+ColorScope Color(OS, ShowColors, TypeColor);
+OS << TL.getTypeLocClassName() << "TypeLoc";
+  }
+  dumpSourceRange(TL.getSourceRange());
+  OS << " ";
+  dumpBareType(TL.getType(), false);
+
+  TypeLocVisitor::Visit(TL);
+}
+
 void TextNodeDumper::Visit(const Decl *D) {
   if (!D) {
 ColorScope Color(OS, ShowColors, NullColor);
@@ -1622,6 +1635,116 @@
 OS << " expansions " << *N;
 }
 
+void TextNodeDumper::VisitQualifiedTypeLoc(QualifiedTypeLoc TL) {
+  OS << " " << TL.getType().split().Quals.getAsString();
+}
+
+void TextNodeDumper::VisitRValueReferenceTypeLoc(ReferenceTypeLoc TL) {
+  VisitReferenceType(cast(TL.getType().getTypePtr()));
+}
+
+void TextNodeDumper::VisitArrayTypeLoc(ArrayTypeLoc TL) {
+  if (Context)
+VisitArrayType(Context->getAsArrayType(TL.getType()));
+}
+
+void TextNodeDumper::VisitConstantArrayTypeLoc(ConstantArrayTypeLoc TL) {
+  if (Context)
+VisitConstantArrayType(Context->getAsConstantArrayType(TL.getType()));
+}
+
+void TextNodeDumper::VisitVariableArrayTypeLoc(VariableArrayTypeLoc TL) {
+  if (Context)
+VisitVariableArrayType(Context->getAsVariableArrayType(TL.getType()));
+}
+
+void TextNodeDumper::VisitDependentSizedArrayTypeLoc(
+DependentSizedArrayTypeLoc TL) {
+  if (Context)
+VisitDependentSizedArrayType(
+Context->getAsDependentSizedArrayType(TL.getType()));
+}
+
+void TextNodeDumper::VisitDependentSizedExtVectorTypeLoc(
+DependentSizedExtVectorTypeLoc TL) {
+  VisitDependentSizedExtVectorType(
+  cast(TL.getType().getTypePtr()));
+}
+
+void TextNodeDumper::VisitVectorTypeLoc(VectorTypeLoc TL) {
+  VisitVectorType(cast(TL.getType().getTypePtr()));
+}
+
+void TextNodeDumper::VisitFunctionTypeLoc(FunctionTypeLoc TL) {
+  VisitFunctionType(cast(TL.getType().getTypePtr()));
+}
+
+void TextNodeDumper::VisitFunctionProtoTypeLoc(FunctionProtoTypeLoc TL) {
+  VisitFunctionProtoType(cast(TL.getType().getTypePtr()));
+}
+
+void TextNodeDumper::VisitUnresolvedUsingTypeLoc(UnresolvedUsingTypeLoc TL) {
+  VisitUnresolvedUsingType(
+  cast(TL.getType().getTypePtr()));
+}
+
+void TextNodeDumper::VisitUsingTypeLoc(UsingTypeLoc TL) {
+  VisitUsingType(cast(TL.getType().getTypePtr()));
+}
+
+void TextNodeDumper::VisitTypedefTypeLoc(TypedefTypeLoc TL) {
+  VisitTypedefType(cast(TL.getType().getTypePtr()));
+}
+
+void TextNodeDumper::VisitUnaryTransformTypeLoc(UnaryTransformTypeLoc TL) {
+  VisitUnaryTransformType(cast(TL.getType().getTypePtr()));
+}
+
+void TextNodeDumper::VisitTagTypeLoc(TagTypeLoc TL) {
+  VisitTagType(cast(TL.getType().getTypePtr()));
+}
+
+void TextNodeDumper::VisitTemplateTypeParmTypeLoc(TemplateTypeParmTypeLoc TL) {
+  VisitTemplateTypeParmType(
+  cast(TL.getType().getTypePtr()));
+}
+
+void TextNodeDumper::VisitSubstTemplateTypeParmTypeLoc(
+SubstTemplateTypeParmTypeLoc TL) {
+  VisitSubstTemplateTypeParmType(
+  cast(TL.getType().getTypePtr()));
+}
+
+void TextNodeDumper::VisitAutoTypeLoc(AutoTypeLoc TL) {
+  VisitAutoType(cast(TL.getType().getTypePtr()));

[PATCH] D129443: [clang-format] Add option for aligning requires clause body

2022-10-14 Thread Owen Pan via Phabricator via cfe-commits
owenpan added a comment.

In D129443#3857608 , @rymiel wrote:

> Changing the default LLVM style would change the output of all the 
> requires-related test cases in `FormatTest.Concepts`. Should I change these 
> test cases to use the new indentation or pass the `REI_Keyword` style to them?

I prefer the latter so as to minimize the diff.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129443

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


[PATCH] D135013: [clang][Interp] Array initialization via ImplicitValueInitExpr

2022-10-14 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder added a comment.

Thanks for the reproducer!




Comment at: clang/lib/AST/Interp/ByteCodeExprGen.cpp:748
+  } else {
+assert(false && "default initializer for non-primitive type");
+  }

shafik wrote:
> I guess this covers both arrays and class types?
Yes. But now that I look at it, the check should probably be outside of the 
loop.


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

https://reviews.llvm.org/D135013

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


[PATCH] D135013: [clang][Interp] Array initialization via ImplicitValueInitExpr

2022-10-14 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder updated this revision to Diff 467691.
tbaeder marked 2 inline comments as done.

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

https://reviews.llvm.org/D135013

Files:
  clang/lib/AST/Interp/ByteCodeExprGen.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
@@ -98,3 +98,15 @@
 struct fred y [] = { [0] = { .s[0] = 'q' } };
 #endif
 #pragma clang diagnostic pop
+
+namespace DefaultInit {
+  template 
+  struct B {
+T a[N];
+  };
+
+  int f() {
+ constexpr B arr = {};
+ constexpr int x = arr.a[0];
+  }
+};
Index: clang/lib/AST/Interp/ByteCodeExprGen.cpp
===
--- clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -720,6 +720,28 @@
   if (!this->emitPopPtr(Initializer))
 return false;
 }
+return true;
+  } else if (const auto *IVIE = dyn_cast(Initializer)) {
+auto ArrayType = IVIE->getType()->getAsArrayTypeUnsafe();
+assert(ArrayType);
+const auto *CAT = dyn_cast(ArrayType);
+const size_t NumElems = CAT->getSize().getZExtValue();
+Optional ElemT = classify(CAT->getElementType());
+
+if (ElemT) {
+  // TODO(perf): For int and bool types, we can probably just skip this
+  //   since we memset our Block*s to 0 and so we have the desired value
+  //   without this.
+  for (size_t I = 0; I != NumElems; ++I) {
+if (!this->emitZero(*ElemT, Initializer))
+  return false;
+if (!this->emitInitElem(*ElemT, I, Initializer))
+  return false;
+  }
+} else {
+  assert(false && "default initializer for non-primitive type");
+}
+
 return true;
   }
 


Index: clang/test/AST/Interp/arrays.cpp
===
--- clang/test/AST/Interp/arrays.cpp
+++ clang/test/AST/Interp/arrays.cpp
@@ -98,3 +98,15 @@
 struct fred y [] = { [0] = { .s[0] = 'q' } };
 #endif
 #pragma clang diagnostic pop
+
+namespace DefaultInit {
+  template 
+  struct B {
+T a[N];
+  };
+
+  int f() {
+ constexpr B arr = {};
+ constexpr int x = arr.a[0];
+  }
+};
Index: clang/lib/AST/Interp/ByteCodeExprGen.cpp
===
--- clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -720,6 +720,28 @@
   if (!this->emitPopPtr(Initializer))
 return false;
 }
+return true;
+  } else if (const auto *IVIE = dyn_cast(Initializer)) {
+auto ArrayType = IVIE->getType()->getAsArrayTypeUnsafe();
+assert(ArrayType);
+const auto *CAT = dyn_cast(ArrayType);
+const size_t NumElems = CAT->getSize().getZExtValue();
+Optional ElemT = classify(CAT->getElementType());
+
+if (ElemT) {
+  // TODO(perf): For int and bool types, we can probably just skip this
+  //   since we memset our Block*s to 0 and so we have the desired value
+  //   without this.
+  for (size_t I = 0; I != NumElems; ++I) {
+if (!this->emitZero(*ElemT, Initializer))
+  return false;
+if (!this->emitInitElem(*ElemT, I, Initializer))
+  return false;
+  }
+} else {
+  assert(false && "default initializer for non-primitive type");
+}
+
 return true;
   }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D134410: [clang][CodeGen] Add noundef metadata to load instructions (preliminary)

2022-10-14 Thread John McIver via Phabricator via cfe-commits
jmciver updated this revision to Diff 467690.
jmciver edited the summary of this revision.
jmciver added a comment.

Updating D134410 : [clang][CodeGen] Add 
noundef metadata to load instructions (preliminary)

Resolve merge conflicts due to the adoption of the ptr type in openmp tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134410

Files:
  clang/lib/CodeGen/CGExpr.cpp
  clang/test/CodeGen/X86/avx-builtins.c
  clang/test/CodeGen/X86/avx512bw-builtins.c
  clang/test/CodeGen/X86/avx512f-builtins.c
  clang/test/CodeGen/X86/avx512fp16-builtins.c
  clang/test/CodeGen/X86/avx512vl-builtins.c
  clang/test/CodeGen/X86/avx512vlbw-builtins.c
  clang/test/CodeGen/X86/sse-builtins.c
  clang/test/CodeGen/X86/sse2-builtins.c
  clang/test/CodeGen/aarch64-ls64-inline-asm.c
  clang/test/CodeGen/aarch64-ls64.c
  clang/test/CodeGen/memcpy-inline-builtin.c
  clang/test/CodeGen/tbaa-array.cpp
  clang/test/CodeGen/tbaa-base.cpp
  clang/test/CodeGen/tbaa.cpp
  clang/test/CodeGen/ubsan-pass-object-size.c
  clang/test/CodeGenCXX/attr-likelihood-if-branch-weights.cpp
  clang/test/CodeGenCXX/attr-likelihood-switch-branch-weights.cpp
  clang/test/CodeGenCXX/builtin-bit-cast-no-tbaa.cpp
  clang/test/CodeGenCXX/debug-info-line.cpp
  clang/test/CodeGenCXX/pr12251.cpp
  clang/test/CodeGenCXX/pragma-followup_inner.cpp
  clang/test/OpenMP/cancel_codegen.cpp
  clang/test/OpenMP/cancellation_point_codegen.cpp
  clang/test/OpenMP/distribute_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_reduction_task_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_private_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_proc_bind_codegen.cpp
  clang/test/OpenMP/distribute_simd_codegen.cpp
  clang/test/OpenMP/distribute_simd_private_codegen.cpp
  clang/test/OpenMP/distribute_simd_reduction_codegen.cpp
  clang/test/OpenMP/for_reduction_task_codegen.cpp
  clang/test/OpenMP/irbuilder_safelen.cpp
  clang/test/OpenMP/irbuilder_safelen_order_concurrent.cpp
  clang/test/OpenMP/irbuilder_simdlen.cpp
  clang/test/OpenMP/irbuilder_simdlen_safelen.cpp
  clang/test/OpenMP/master_taskloop_in_reduction_codegen.cpp
  clang/test/OpenMP/master_taskloop_simd_in_reduction_codegen.cpp
  clang/test/OpenMP/nvptx_target_parallel_reduction_codegen_tbaa_PR46146.cpp
  clang/test/OpenMP/ordered_codegen.cpp
  clang/test/OpenMP/parallel_for_reduction_task_codegen.cpp
  clang/test/OpenMP/parallel_for_simd_aligned_codegen.cpp
  clang/test/OpenMP/parallel_for_simd_codegen.cpp
  clang/test/OpenMP/parallel_master_reduction_task_codegen.cpp
  clang/test/OpenMP/parallel_master_taskloop_codegen.cpp
  clang/test/OpenMP/parallel_master_taskloop_lastprivate_codegen.cpp
  clang/test/OpenMP/parallel_master_taskloop_simd_codegen.cpp
  clang/test/OpenMP/parallel_master_taskloop_simd_lastprivate_codegen.cpp
  clang/test/OpenMP/parallel_reduction_task_codegen.cpp
  clang/test/OpenMP/parallel_sections_reduction_task_codegen.cpp
  clang/test/OpenMP/sections_reduction_task_codegen.cpp
  clang/test/OpenMP/target_defaultmap_codegen_01.cpp
  clang/test/OpenMP/target_in_reduction_codegen.cpp
  clang/test/OpenMP/target_is_device_ptr_codegen.cpp
  clang/test/OpenMP/target_map_codegen_00.cpp
  clang/test/OpenMP/target_map_codegen_01.cpp
  clang/test/OpenMP/target_map_codegen_02.cpp
  clang/test/OpenMP/target_map_codegen_04.cpp
  clang/test/OpenMP/target_map_codegen_05.cpp
  clang/test/OpenMP/target_map_codegen_07.cpp
  clang/test/OpenMP/target_map_codegen_11.cpp
  clang/test/OpenMP/target_map_codegen_13.cpp
  clang/test/OpenMP/target_map_codegen_14.cpp
  clang/test/OpenMP/target_map_codegen_15.cpp
  clang/test/OpenMP/target_map_codegen_17.cpp
  clang/test/OpenMP/target_map_codegen_26.cpp
  clang/test/OpenMP/target_map_codegen_27.cpp
  clang/test/OpenMP/target_map_codegen_29.cpp
  clang/test/OpenMP/target_parallel_codegen.cpp
  clang/test/OpenMP/target_parallel_for_codegen.cpp
  clang/test/OpenMP/target_parallel_for_reduction_task_codegen.cpp
  clang/test/OpenMP/target_parallel_for_simd_codegen.cpp
  clang/test/OpenMP/target_parallel_reduction_task_codegen.cpp
  clang/test/OpenMP/target_teams_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_codegen.cpp
  
clang/test/OpenMP/target_teams_distribute_parallel_for_reduction_task_codegen.cpp
  
clang/test/OpenMP/target_teams_distribute_parallel_for_simd_collapse_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_simd_if_codegen.cpp
  
clang/test/OpenMP/target_teams_distribute_parallel_for_simd_proc_bind_codegen.cpp
  
clang/test/OpenMP/target_teams_distribute_parallel_for_simd_reduction_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_simd_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_simd_collapse_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_simd_reduction_codegen.cpp
  clang/test/OpenMP/target_update_codegen.cpp
  

[PATCH] D134699: [clang][Interp] Implement This pointer passing to methods

2022-10-14 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder marked an inline comment as done.
tbaeder added inline comments.



Comment at: clang/lib/AST/Interp/EvalEmitter.cpp:108
 
-  S.Current =
-  new InterpFrame(S, const_cast(Func), S.Current, {}, {});
+  S.Current = new InterpFrame(S, const_cast(Func), {});
   // Result of call will be on the stack and needs to be handled by the caller.

aaron.ballman wrote:
> Not related to this review: it'd be nice to fix the interface so we get const 
> correct behavior rather than needing to use `const_cast` like this.
Already have a local patch for this!


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

https://reviews.llvm.org/D134699

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


<    1   2   3