[clang] [clang][Interp] Integral pointers (PR #84159)

2024-04-11 Thread Simon Pilgrim via cfe-commits
@@ -22,7 +22,11 @@ class FunctionPointer final { const Function *Func; public: - FunctionPointer() : Func(nullptr) {} + // FIXME: We might want to track the fact that the Function pointer + // has been created from an integer and is most likely garbage anyway. + Function

[clang] [clang][Interp] Integral pointers (PR #84159)

2024-04-11 Thread Timm Baeder via cfe-commits
@@ -22,7 +22,11 @@ class FunctionPointer final { const Function *Func; public: - FunctionPointer() : Func(nullptr) {} + // FIXME: We might want to track the fact that the Function pointer + // has been created from an integer and is most likely garbage anyway. + Function

[clang] [clang][Interp] Integral pointers (PR #84159)

2024-04-11 Thread Timm Baeder via cfe-commits
@@ -22,7 +22,11 @@ class FunctionPointer final { const Function *Func; public: - FunctionPointer() : Func(nullptr) {} + // FIXME: We might want to track the fact that the Function pointer + // has been created from an integer and is most likely garbage anyway. + Function

[clang] [clang][Interp] Integral pointers (PR #84159)

2024-04-10 Thread Simon Pilgrim via cfe-commits
@@ -22,7 +22,11 @@ class FunctionPointer final { const Function *Func; public: - FunctionPointer() : Func(nullptr) {} + // FIXME: We might want to track the fact that the Function pointer + // has been created from an integer and is most likely garbage anyway. + Function

[clang] [clang][Interp] Integral pointers (PR #84159)

2024-04-10 Thread Timm Baeder via cfe-commits
https://github.com/tbaederr closed https://github.com/llvm/llvm-project/pull/84159 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][Interp] Integral pointers (PR #84159)

2024-04-09 Thread Timm Baeder via cfe-commits
https://github.com/tbaederr updated https://github.com/llvm/llvm-project/pull/84159 >From 3d6a09d1324dbd354668b0341644fb70fe09a47c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= Date: Wed, 6 Mar 2024 08:36:52 +0100 Subject: [PATCH] [clang][Interp] Integral pointers --- clang/lib

[clang] [clang][Interp] Integral pointers (PR #84159)

2024-04-09 Thread Timm Baeder via cfe-commits
Timm =?utf-8?q?B=C3=A4der?= , Timm =?utf-8?q?B=C3=A4der?= , Timm =?utf-8?q?B=C3=A4der?= , Timm =?utf-8?q?B=C3=A4der?= , Timm =?utf-8?q?B=C3=A4der?= Message-ID: In-Reply-To: @@ -1912,6 +1929,10 @@ inline bool NoRet(InterpState &S, CodePtr OpPC) { inline bool NarrowPtr(InterpS

[clang] [clang][Interp] Integral pointers (PR #84159)

2024-03-25 Thread Aaron Ballman via cfe-commits
Timm =?utf-8?q?Bäder?= , Timm =?utf-8?q?Bäder?= , Timm =?utf-8?q?Bäder?= , Timm =?utf-8?q?Bäder?= , Timm =?utf-8?q?Bäder?= Message-ID: In-Reply-To: @@ -2218,6 +2238,14 @@ inline bool GetFnPtr(InterpState &S, CodePtr OpPC, const Function *Func) { return true; } +template

[clang] [clang][Interp] Integral pointers (PR #84159)

2024-03-25 Thread Aaron Ballman via cfe-commits
Timm =?utf-8?q?Bäder?= , Timm =?utf-8?q?Bäder?= , Timm =?utf-8?q?Bäder?= , Timm =?utf-8?q?Bäder?= , Timm =?utf-8?q?Bäder?= Message-ID: In-Reply-To: @@ -199,6 +207,41 @@ bool ByteCodeExprGen::VisitCastExpr(const CastExpr *CE) { return true; } + case CK_IntegralToPoin

[clang] [clang][Interp] Integral pointers (PR #84159)

2024-03-25 Thread Aaron Ballman via cfe-commits
Timm =?utf-8?q?B=C3=A4der?= , Timm =?utf-8?q?B=C3=A4der?= , Timm =?utf-8?q?B=C3=A4der?= , Timm =?utf-8?q?B=C3=A4der?= , Timm =?utf-8?q?B=C3=A4der?= Message-ID: In-Reply-To: @@ -1912,6 +1929,10 @@ inline bool NoRet(InterpState &S, CodePtr OpPC) { inline bool NarrowPtr(InterpS

[clang] [clang][Interp] Integral pointers (PR #84159)

2024-03-25 Thread Aaron Ballman via cfe-commits
Timm =?utf-8?q?B=C3=A4der?= , Timm =?utf-8?q?B=C3=A4der?= , Timm =?utf-8?q?B=C3=A4der?= , Timm =?utf-8?q?B=C3=A4der?= , Timm =?utf-8?q?B=C3=A4der?= Message-ID: In-Reply-To: https://github.com/AaronBallman approved this pull request. Basically LGTM, just a few minor things. https://github.com/

[clang] [clang][Interp] Integral pointers (PR #84159)

2024-03-25 Thread Aaron Ballman via cfe-commits
Timm =?utf-8?q?Bäder?= , Timm =?utf-8?q?Bäder?= , Timm =?utf-8?q?Bäder?= , Timm =?utf-8?q?Bäder?= , Timm =?utf-8?q?Bäder?= Message-ID: In-Reply-To: https://github.com/AaronBallman edited https://github.com/llvm/llvm-project/pull/84159 ___ cfe-commits

[clang] [clang][Interp] Integral pointers (PR #84159)

2024-03-24 Thread Timm Baeder via cfe-commits
Timm =?utf-8?q?B=C3=A4der?= , Timm =?utf-8?q?B=C3=A4der?= , Timm =?utf-8?q?B=C3=A4der?= , Timm =?utf-8?q?B=C3=A4der?= , Timm =?utf-8?q?B=C3=A4der?= Message-ID: In-Reply-To: tbaederr wrote: Ping https://github.com/llvm/llvm-project/pull/84159 ___ cfe

[clang] [clang][Interp] Integral pointers (PR #84159)

2024-03-18 Thread Timm Baeder via cfe-commits
Timm =?utf-8?q?Bäder?= , Timm =?utf-8?q?Bäder?= , Timm =?utf-8?q?Bäder?= , Timm =?utf-8?q?Bäder?= , Timm =?utf-8?q?Bäder?= Message-ID: In-Reply-To: https://github.com/tbaederr updated https://github.com/llvm/llvm-project/pull/84159 >From 1c06781e92b8fec78ae82b0d6a85965524d223d6 Mon Sep 17 00:

[clang] [clang][Interp] Integral pointers (PR #84159)

2024-03-18 Thread via cfe-commits
Timm =?utf-8?q?Bäder?= , Timm =?utf-8?q?Bäder?= , Timm =?utf-8?q?Bäder?= , Timm =?utf-8?q?Bäder?= Message-ID: In-Reply-To: github-actions[bot] wrote: :warning: C/C++ code formatter, clang-format found issues in your code. :warning: You can test this locally with the following command:

[clang] [clang][Interp] Integral pointers (PR #84159)

2024-03-18 Thread Timm Baeder via cfe-commits
Timm =?utf-8?q?Bäder?= , Timm =?utf-8?q?Bäder?= , Timm =?utf-8?q?Bäder?= , Timm =?utf-8?q?Bäder?= Message-ID: In-Reply-To: https://github.com/tbaederr updated https://github.com/llvm/llvm-project/pull/84159 >From 7d49f0f7310c86fae986f0b84bfbf2bb6e79a745 Mon Sep 17 00:00:00 2001 From: =?UTF-8?

[clang] [clang][Interp] Integral pointers (PR #84159)

2024-03-15 Thread Aaron Ballman via cfe-commits
Timm =?utf-8?q?B=C3=A4der?= , Timm =?utf-8?q?B=C3=A4der?= Message-ID: In-Reply-To: @@ -53,6 +57,10 @@ class FunctionPointer final { return toAPValue().getAsString(Ctx, Func->getDecl()->getType()); } + uint32_t getIntegerRepresentation() const { +return static_cas

[clang] [clang][Interp] Integral pointers (PR #84159)

2024-03-15 Thread Aaron Ballman via cfe-commits
Timm =?utf-8?q?Bäder?= , Timm =?utf-8?q?Bäder?= Message-ID: In-Reply-To: @@ -28,11 +28,26 @@ class Block; class DeadBlock; class Pointer; class Context; +template class Integral; enum PrimType : unsigned; class Pointer; inline llvm::raw_ostream &operator<<(llvm::raw_os

[clang] [clang][Interp] Integral pointers (PR #84159)

2024-03-15 Thread Aaron Ballman via cfe-commits
Timm =?utf-8?q?Bäder?= , Timm =?utf-8?q?Bäder?= Message-ID: In-Reply-To: @@ -28,11 +28,26 @@ class Block; class DeadBlock; class Pointer; class Context; +template class Integral; enum PrimType : unsigned; class Pointer; inline llvm::raw_ostream &operator<<(llvm::raw_os

[clang] [clang][Interp] Integral pointers (PR #84159)

2024-03-13 Thread Timm Baeder via cfe-commits
Timm =?utf-8?q?Bäder?= , Timm =?utf-8?q?Bäder?= Message-ID: In-Reply-To: @@ -28,11 +28,26 @@ class Block; class DeadBlock; class Pointer; class Context; +template class Integral; enum PrimType : unsigned; class Pointer; inline llvm::raw_ostream &operator<<(llvm::raw_os

[clang] [clang][Interp] Integral pointers (PR #84159)

2024-03-13 Thread Timm Baeder via cfe-commits
Timm =?utf-8?q?B=C3=A4der?= , Timm =?utf-8?q?B=C3=A4der?= Message-ID: In-Reply-To: @@ -53,6 +57,10 @@ class FunctionPointer final { return toAPValue().getAsString(Ctx, Func->getDecl()->getType()); } + uint32_t getIntegerRepresentation() const { +return static_cas

[clang] [clang][Interp] Integral pointers (PR #84159)

2024-03-07 Thread Timm Baeder via cfe-commits
Timm =?utf-8?q?Bäder?= , Timm =?utf-8?q?Bäder?= Message-ID: In-Reply-To: https://github.com/tbaederr updated https://github.com/llvm/llvm-project/pull/84159 >From 5eacd7478d3db7472d5ab983468a441b1f61ad7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= Date: Wed, 6 Mar 2024 08:36

[clang] [clang][Interp] Integral pointers (PR #84159)

2024-03-07 Thread Timm Baeder via cfe-commits
Timm =?utf-8?q?Bäder?= Message-ID: In-Reply-To: @@ -28,11 +28,26 @@ class Block; class DeadBlock; class Pointer; class Context; +template class Integral; enum PrimType : unsigned; class Pointer; inline llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const Pointer

[clang] [clang][Interp] Integral pointers (PR #84159)

2024-03-07 Thread Timm Baeder via cfe-commits
Timm =?utf-8?q?B=C3=A4der?= Message-ID: In-Reply-To: @@ -123,8 +167,9 @@ APValue Pointer::toAPValue() const { Path.push_back(APValue::LValuePathEntry({BaseOrMember, IsVirtual})); Ptr = Ptr.getBase(); continue; + +llvm_unreachable("Invalid fiel

[clang] [clang][Interp] Integral pointers (PR #84159)

2024-03-06 Thread Timm Baeder via cfe-commits
Timm =?utf-8?q?Bäder?= Message-ID: In-Reply-To: https://github.com/tbaederr updated https://github.com/llvm/llvm-project/pull/84159 >From 5eacd7478d3db7472d5ab983468a441b1f61ad7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= Date: Wed, 6 Mar 2024 08:36:52 +0100 Subject: [PATCH

[clang] [clang][Interp] Integral pointers (PR #84159)

2024-03-06 Thread Timm Baeder via cfe-commits
tbaederr wrote: FWIW I've been tracking test failures by enabling the new interpreter by default and running `ninja check-clang-{ast,sema,semacxx,codegen}` at https://tbaederr.github.io/stats/. With this patch, we're down from 281 to 262 (with only one new failure, `Sema/callingconv-cast.c`).

[clang] [clang][Interp] Integral pointers (PR #84159)

2024-03-06 Thread Aaron Ballman via cfe-commits
@@ -26,60 +26,98 @@ Pointer::Pointer(Block *Pointee) Pointer::Pointer(Block *Pointee, unsigned BaseAndOffset) : Pointer(Pointee, BaseAndOffset, BaseAndOffset) {} -Pointer::Pointer(const Pointer &P) : Pointer(P.Pointee, P.Base, P.Offset) {} +Pointer::Pointer(const Pointer &

[clang] [clang][Interp] Integral pointers (PR #84159)

2024-03-06 Thread Aaron Ballman via cfe-commits
@@ -28,11 +28,26 @@ class Block; class DeadBlock; class Pointer; class Context; +template class Integral; enum PrimType : unsigned; class Pointer; inline llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const Pointer &P); +struct BlockPointer { Aaro

[clang] [clang][Interp] Integral pointers (PR #84159)

2024-03-06 Thread Aaron Ballman via cfe-commits
@@ -172,72 +217,107 @@ class Pointer { Adjust = sizeof(InitMapPtr); else Adjust = sizeof(InlineDescriptor); - return Pointer(Pointee, Base, Base + getSize() + Adjust); + return Pointer(asBlockPointer().Pointee, asBlockPointer().Base, +

[clang] [clang][Interp] Integral pointers (PR #84159)

2024-03-06 Thread Aaron Ballman via cfe-commits
@@ -26,60 +26,98 @@ Pointer::Pointer(Block *Pointee) Pointer::Pointer(Block *Pointee, unsigned BaseAndOffset) : Pointer(Pointee, BaseAndOffset, BaseAndOffset) {} -Pointer::Pointer(const Pointer &P) : Pointer(P.Pointee, P.Base, P.Offset) {} +Pointer::Pointer(const Pointer &

[clang] [clang][Interp] Integral pointers (PR #84159)

2024-03-06 Thread Aaron Ballman via cfe-commits
@@ -123,8 +167,9 @@ APValue Pointer::toAPValue() const { Path.push_back(APValue::LValuePathEntry({BaseOrMember, IsVirtual})); Ptr = Ptr.getBase(); continue; + +llvm_unreachable("Invalid field type"); AaronBallman wrote: Errr...

[clang] [clang][Interp] Integral pointers (PR #84159)

2024-03-06 Thread Aaron Ballman via cfe-commits
@@ -88,6 +126,12 @@ APValue Pointer::toAPValue() const { if (isZero()) return APValue(static_cast(nullptr), CharUnits::Zero(), Path, /*IsOnePastEnd=*/false, /*IsNullPtr=*/true); + if (isIntegralPointer()) { +return APValue(static_cast(nullptr), +

[clang] [clang][Interp] Integral pointers (PR #84159)

2024-03-06 Thread Aaron Ballman via cfe-commits
@@ -809,9 +809,9 @@ inline bool CmpHelperEQ(InterpState &S, CodePtr OpPC, CompareFn Fn) { // 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 pointers

[clang] [clang][Interp] Integral pointers (PR #84159)

2024-03-06 Thread Aaron Ballman via cfe-commits
@@ -2180,6 +2201,14 @@ inline bool GetFnPtr(InterpState &S, CodePtr OpPC, const Function *Func) { return true; } +template ::T> +inline bool GetIntPtr(InterpState &S, CodePtr OpPC, const Descriptor *Desc) { + const T &IntVal = S.Stk.pop(); + + S.Stk.push(static_cast(IntVa

[clang] [clang][Interp] Integral pointers (PR #84159)

2024-03-06 Thread Aaron Ballman via cfe-commits
@@ -187,6 +195,34 @@ bool ByteCodeExprGen::VisitCastExpr(const CastExpr *CE) { return true; } + case CK_IntegralToPointer: { +QualType IntType = SubExpr->getType(); +assert(IntType->isIntegralOrEnumerationType()); +if (!this->visit(SubExpr)) + return f

[clang] [clang][Interp] Integral pointers (PR #84159)

2024-03-06 Thread Aaron Ballman via cfe-commits
@@ -26,60 +26,98 @@ Pointer::Pointer(Block *Pointee) Pointer::Pointer(Block *Pointee, unsigned BaseAndOffset) : Pointer(Pointee, BaseAndOffset, BaseAndOffset) {} -Pointer::Pointer(const Pointer &P) : Pointer(P.Pointee, P.Base, P.Offset) {} +Pointer::Pointer(const Pointer &

[clang] [clang][Interp] Integral pointers (PR #84159)

2024-03-06 Thread Aaron Ballman via cfe-commits
@@ -1912,6 +1929,10 @@ inline bool NoRet(InterpState &S, CodePtr OpPC) { inline bool NarrowPtr(InterpState &S, CodePtr OpPC) { const Pointer &Ptr = S.Stk.pop(); + if (!S.getLangOpts().CPlusPlus) { +S.Stk.push(Ptr); AaronBallman wrote: Might be a good i

[clang] [clang][Interp] Integral pointers (PR #84159)

2024-03-06 Thread Aaron Ballman via cfe-commits
@@ -1505,12 +1509,17 @@ bool OffsetHelper(InterpState &S, CodePtr OpPC, const T &Offset, return true; } - if (!CheckNull(S, OpPC, Ptr, CSK_ArrayIndex)) -return false; + if (!CheckNull(S, OpPC, Ptr, CSK_ArrayIndex)) { +// The CheckNul will have emitted a note a

[clang] [clang][Interp] Integral pointers (PR #84159)

2024-03-06 Thread Aaron Ballman via cfe-commits
https://github.com/AaronBallman commented: I think the general direction is pretty reasonable. https://github.com/llvm/llvm-project/pull/84159 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-c

[clang] [clang][Interp] Integral pointers (PR #84159)

2024-03-06 Thread Aaron Ballman via cfe-commits
https://github.com/AaronBallman edited https://github.com/llvm/llvm-project/pull/84159 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][Interp] Integral pointers (PR #84159)

2024-03-06 Thread Aaron Ballman via cfe-commits
@@ -53,6 +57,10 @@ class FunctionPointer final { return toAPValue().getAsString(Ctx, Func->getDecl()->getType()); } + uint32_t getIntegerRepresentation() const { +return static_cast(reinterpret_cast(Func)); + } AaronBallman wrote: This seems dange

[clang] [clang][Interp] Integral pointers (PR #84159)

2024-03-06 Thread Aaron Ballman via cfe-commits
@@ -26,60 +26,98 @@ Pointer::Pointer(Block *Pointee) Pointer::Pointer(Block *Pointee, unsigned BaseAndOffset) : Pointer(Pointee, BaseAndOffset, BaseAndOffset) {} -Pointer::Pointer(const Pointer &P) : Pointer(P.Pointee, P.Base, P.Offset) {} +Pointer::Pointer(const Pointer &

[clang] [clang][Interp] Integral pointers (PR #84159)

2024-03-06 Thread via cfe-commits
llvmbot wrote: @llvm/pr-subscribers-clang Author: Timm Baeder (tbaederr) Changes This turns the current `Pointer` class into a discriminated union of `BlockPointer` and `IntPointer`. The former is what `Pointer` currently is while the latter is just an integer value and an optional `Desc

[clang] [clang][Interp] Integral pointers (PR #84159)

2024-03-06 Thread Timm Baeder via cfe-commits
https://github.com/tbaederr created https://github.com/llvm/llvm-project/pull/84159 This turns the current `Pointer` class into a discriminated union of `BlockPointer` and `IntPointer`. The former is what `Pointer` currently is while the latter is just an integer value and an optional `Descrip