[clang] [clang] LazyOffsetPtr: Use native pointer width (PR #111995)

2024-10-18 Thread Jessica Clarke via cfe-commits
jrtc27 wrote: > > But yes, the short answer is that the code as written should work on > > Morello and CHERI-RISC-V. > > Great, thanks. > > > > > The std::launder may be unnecessary > > > > > > > > > Formally I think it's correct and necessary for the pointer and integer > > > case because

[clang] [clang] LazyOffsetPtr: Use native pointer width (PR #111995)

2024-10-18 Thread Richard Smith via cfe-commits
zygoloid wrote: > But yes, the short answer is that the code as written should work on Morello > and CHERI-RISC-V. Great, thanks. > > > The std::launder may be unnecessary > > > > > > Formally I think it's correct and necessary for the pointer and integer > > case because an array element a

[clang] [clang] LazyOffsetPtr: Use native pointer width (PR #111995)

2024-10-18 Thread Jessica Clarke via cfe-commits
jrtc27 wrote: > > How about: > > [...] > > Yeah, I think that fixes it. For me that looks a lot less simple than using a > union, but it is nice to have only a single implementation. I'd be fine with > going in that direction. > > For CHERI, can we assume that the least-significant byte of th

[clang] [clang] LazyOffsetPtr: Use native pointer width (PR #111995)

2024-10-18 Thread Richard Smith via cfe-commits
zygoloid wrote: > How about: > [...] Yeah, I think that fixes it. For me that looks a lot less simple than using a union, but it is nice to have only a single implementation. I'd be fine with going in that direction. For CHERI, can we assume that the least-significant byte of the pointer rep

[clang] [clang] LazyOffsetPtr: Use native pointer width (PR #111995)

2024-10-18 Thread Jessica Clarke via cfe-commits
jrtc27 wrote: > > > > #112806 should address this without narrowing the field to 32 bits. > > > > > > > > > As does [#111995 > > > (comment)](https://github.com/llvm/llvm-project/pull/111995#discussion_r1805329590), > > > with less code and more generality > > > > > > I prefer this solution

[clang] [clang] LazyOffsetPtr: Use native pointer width (PR #111995)

2024-10-18 Thread Richard Smith via cfe-commits
zygoloid wrote: > > > #112806 should address this without narrowing the field to 32 bits. > > > > > > As does [#111995 > > (comment)](https://github.com/llvm/llvm-project/pull/111995#discussion_r1805329590), > > with less code and more generality > > I prefer this solution too. That solutio

[clang] [clang] LazyOffsetPtr: Use native pointer width (PR #111995)

2024-10-17 Thread Chuanqi Xu via cfe-commits
ChuanqiXu9 wrote: > > #112806 should address this without narrowing the field to 32 bits. > > As does [#111995 > (comment)](https://github.com/llvm/llvm-project/pull/111995#discussion_r1805329590), > with less code and more generality I prefer this solution too. https://github.com/llvm/llvm-

[clang] [clang] LazyOffsetPtr: Use native pointer width (PR #111995)

2024-10-17 Thread Chuanqi Xu via cfe-commits
@@ -326,25 +326,25 @@ struct LazyOffsetPtr { /// /// If the low bit is clear, a pointer to the AST node. If the low /// bit is set, the upper 63 bits are the offset. - mutable uint64_t Ptr = 0; + mutable uintptr_t Ptr = 0; public: LazyOffsetPtr() = default; - exp

[clang] [clang] LazyOffsetPtr: Use native pointer width (PR #111995)

2024-10-17 Thread Jessica Clarke via cfe-commits
jrtc27 wrote: > #112806 should address this without narrowing the field to 32 bits. As does https://github.com/llvm/llvm-project/pull/111995#discussion_r1805329590, with less code and more generality https://github.com/llvm/llvm-project/pull/111995

[clang] [clang] LazyOffsetPtr: Use native pointer width (PR #111995)

2024-10-17 Thread Richard Smith via cfe-commits
zygoloid wrote: #112806 should address this without narrowing the field to 32 bits. https://github.com/llvm/llvm-project/pull/111995 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] LazyOffsetPtr: Use native pointer width (PR #111995)

2024-10-17 Thread via cfe-commits
ernsteiswuerfel wrote: This also fixes issue [#86460](https://github.com/llvm/llvm-project/issues/86460)! The patch applies cleanly on top of 19.1.2 (tested on ppc32-musl). https://github.com/llvm/llvm-project/pull/111995 ___ cfe-commits mailing list

[clang] [clang] LazyOffsetPtr: Use native pointer width (PR #111995)

2024-10-17 Thread Jessica Clarke via cfe-commits
@@ -326,25 +326,25 @@ struct LazyOffsetPtr { /// /// If the low bit is clear, a pointer to the AST node. If the low /// bit is set, the upper 63 bits are the offset. - mutable uint64_t Ptr = 0; + mutable uintptr_t Ptr = 0; public: LazyOffsetPtr() = default; - exp

[clang] [clang] LazyOffsetPtr: Use native pointer width (PR #111995)

2024-10-17 Thread Jessica Clarke via cfe-commits
https://github.com/jrtc27 edited https://github.com/llvm/llvm-project/pull/111995 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] LazyOffsetPtr: Use native pointer width (PR #111995)

2024-10-17 Thread John McCall via cfe-commits
@@ -326,25 +326,25 @@ struct LazyOffsetPtr { /// /// If the low bit is clear, a pointer to the AST node. If the low /// bit is set, the upper 63 bits are the offset. - mutable uint64_t Ptr = 0; + mutable uintptr_t Ptr = 0; public: LazyOffsetPtr() = default; - exp

[clang] [clang] LazyOffsetPtr: Use native pointer width (PR #111995)

2024-10-17 Thread Jessica Clarke via cfe-commits
@@ -326,25 +326,25 @@ struct LazyOffsetPtr { /// /// If the low bit is clear, a pointer to the AST node. If the low /// bit is set, the upper 63 bits are the offset. - mutable uint64_t Ptr = 0; + mutable uintptr_t Ptr = 0; public: LazyOffsetPtr() = default; - exp

[clang] [clang] LazyOffsetPtr: Use native pointer width (PR #111995)

2024-10-17 Thread John McCall via cfe-commits
@@ -326,25 +326,25 @@ struct LazyOffsetPtr { /// /// If the low bit is clear, a pointer to the AST node. If the low /// bit is set, the upper 63 bits are the offset. - mutable uint64_t Ptr = 0; + mutable uintptr_t Ptr = 0; public: LazyOffsetPtr() = default; - exp

[clang] [clang] LazyOffsetPtr: Use native pointer width (PR #111995)

2024-10-17 Thread Jessica Clarke via cfe-commits
@@ -326,25 +326,25 @@ struct LazyOffsetPtr { /// /// If the low bit is clear, a pointer to the AST node. If the low /// bit is set, the upper 63 bits are the offset. - mutable uint64_t Ptr = 0; + mutable uintptr_t Ptr = 0; public: LazyOffsetPtr() = default; - exp

[clang] [clang] LazyOffsetPtr: Use native pointer width (PR #111995)

2024-10-17 Thread Jessica Clarke via cfe-commits
https://github.com/jrtc27 edited https://github.com/llvm/llvm-project/pull/111995 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] LazyOffsetPtr: Use native pointer width (PR #111995)

2024-10-17 Thread Jessica Clarke via cfe-commits
@@ -326,25 +326,25 @@ struct LazyOffsetPtr { /// /// If the low bit is clear, a pointer to the AST node. If the low /// bit is set, the upper 63 bits are the offset. - mutable uint64_t Ptr = 0; + mutable uintptr_t Ptr = 0; public: LazyOffsetPtr() = default; - exp

[clang] [clang] LazyOffsetPtr: Use native pointer width (PR #111995)

2024-10-17 Thread John McCall via cfe-commits
@@ -326,25 +326,25 @@ struct LazyOffsetPtr { /// /// If the low bit is clear, a pointer to the AST node. If the low /// bit is set, the upper 63 bits are the offset. - mutable uint64_t Ptr = 0; + mutable uintptr_t Ptr = 0; public: LazyOffsetPtr() = default; - exp

[clang] [clang] LazyOffsetPtr: Use native pointer width (PR #111995)

2024-10-17 Thread Jessica Clarke via cfe-commits
@@ -326,25 +326,25 @@ struct LazyOffsetPtr { /// /// If the low bit is clear, a pointer to the AST node. If the low /// bit is set, the upper 63 bits are the offset. - mutable uint64_t Ptr = 0; + mutable uintptr_t Ptr = 0; public: LazyOffsetPtr() = default; - exp

[clang] [clang] LazyOffsetPtr: Use native pointer width (PR #111995)

2024-10-17 Thread John McCall via cfe-commits
@@ -326,25 +326,25 @@ struct LazyOffsetPtr { /// /// If the low bit is clear, a pointer to the AST node. If the low /// bit is set, the upper 63 bits are the offset. - mutable uint64_t Ptr = 0; + mutable uintptr_t Ptr = 0; public: LazyOffsetPtr() = default; - exp

[clang] [clang] LazyOffsetPtr: Use native pointer width (PR #111995)

2024-10-16 Thread Jessica Clarke via cfe-commits
@@ -326,25 +326,25 @@ struct LazyOffsetPtr { /// /// If the low bit is clear, a pointer to the AST node. If the low /// bit is set, the upper 63 bits are the offset. - mutable uint64_t Ptr = 0; + mutable uintptr_t Ptr = 0; public: LazyOffsetPtr() = default; - exp

[clang] [clang] LazyOffsetPtr: Use native pointer width (PR #111995)

2024-10-16 Thread Chuanqi Xu via cfe-commits
@@ -326,25 +326,25 @@ struct LazyOffsetPtr { /// /// If the low bit is clear, a pointer to the AST node. If the low /// bit is set, the upper 63 bits are the offset. - mutable uint64_t Ptr = 0; + mutable uintptr_t Ptr = 0; public: LazyOffsetPtr() = default; - exp

[clang] [clang] LazyOffsetPtr: Use native pointer width (PR #111995)

2024-10-16 Thread Chuanqi Xu via cfe-commits
@@ -326,25 +326,25 @@ struct LazyOffsetPtr { /// /// If the low bit is clear, a pointer to the AST node. If the low /// bit is set, the upper 63 bits are the offset. - mutable uint64_t Ptr = 0; + mutable uintptr_t Ptr = 0; public: LazyOffsetPtr() = default; - exp

[clang] [clang] LazyOffsetPtr: Use native pointer width (PR #111995)

2024-10-16 Thread John McCall via cfe-commits
https://github.com/rjmccall edited https://github.com/llvm/llvm-project/pull/111995 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] LazyOffsetPtr: Use native pointer width (PR #111995)

2024-10-16 Thread John McCall via cfe-commits
https://github.com/rjmccall edited https://github.com/llvm/llvm-project/pull/111995 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] LazyOffsetPtr: Use native pointer width (PR #111995)

2024-10-16 Thread John McCall via cfe-commits
https://github.com/rjmccall edited https://github.com/llvm/llvm-project/pull/111995 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] LazyOffsetPtr: Use native pointer width (PR #111995)

2024-10-16 Thread John McCall via cfe-commits
@@ -326,25 +326,25 @@ struct LazyOffsetPtr { /// /// If the low bit is clear, a pointer to the AST node. If the low /// bit is set, the upper 63 bits are the offset. - mutable uint64_t Ptr = 0; + mutable uintptr_t Ptr = 0; public: LazyOffsetPtr() = default; - exp

[clang] [clang] LazyOffsetPtr: Use native pointer width (PR #111995)

2024-10-16 Thread Chuanqi Xu via cfe-commits
ChuanqiXu9 wrote: > > > Can we remove `getAddressOfPointer` instead?. Where is it being used? > > > > > > It is used in `VarDecl::getInitAddress()` in Decl.cpp. It looks like it is > > used indirectly by the StmtIterator > > And that in turn is used in `StmtIterator`, and indeed we can end up

[clang] [clang] LazyOffsetPtr: Use native pointer width (PR #111995)

2024-10-16 Thread Richard Smith via cfe-commits
zygoloid wrote: > > Can we remove `getAddressOfPointer` instead?. Where is it being used? > > It is used in `VarDecl::getInitAddress()` in Decl.cpp. It looks like it is > used indirectly by the StmtIterator And that in turn is used in `StmtIterator`, and indeed we can end up *storing through*

[clang] [clang] LazyOffsetPtr: Use native pointer width (PR #111995)

2024-10-16 Thread Chuanqi Xu via cfe-commits
@@ -326,25 +326,25 @@ struct LazyOffsetPtr { /// /// If the low bit is clear, a pointer to the AST node. If the low /// bit is set, the upper 63 bits are the offset. - mutable uint64_t Ptr = 0; + mutable uintptr_t Ptr = 0; public: LazyOffsetPtr() = default; - exp

[clang] [clang] LazyOffsetPtr: Use native pointer width (PR #111995)

2024-10-16 Thread Jessica Clarke via cfe-commits
@@ -326,25 +326,25 @@ struct LazyOffsetPtr { /// /// If the low bit is clear, a pointer to the AST node. If the low /// bit is set, the upper 63 bits are the offset. - mutable uint64_t Ptr = 0; + mutable uintptr_t Ptr = 0; public: LazyOffsetPtr() = default; - exp

[clang] [clang] LazyOffsetPtr: Use native pointer width (PR #111995)

2024-10-16 Thread A. Wilcox via cfe-commits
@@ -326,25 +326,25 @@ struct LazyOffsetPtr { /// /// If the low bit is clear, a pointer to the AST node. If the low /// bit is set, the upper 63 bits are the offset. - mutable uint64_t Ptr = 0; + mutable uintptr_t Ptr = 0; public: LazyOffsetPtr() = default; - exp

[clang] [clang] LazyOffsetPtr: Use native pointer width (PR #111995)

2024-10-16 Thread Richard Smith via cfe-commits
@@ -326,25 +326,25 @@ struct LazyOffsetPtr { /// /// If the low bit is clear, a pointer to the AST node. If the low /// bit is set, the upper 63 bits are the offset. - mutable uint64_t Ptr = 0; + mutable uintptr_t Ptr = 0; public: LazyOffsetPtr() = default; - exp

[clang] [clang] LazyOffsetPtr: Use native pointer width (PR #111995)

2024-10-16 Thread Jessica Clarke via cfe-commits
@@ -326,25 +326,25 @@ struct LazyOffsetPtr { /// /// If the low bit is clear, a pointer to the AST node. If the low /// bit is set, the upper 63 bits are the offset. - mutable uint64_t Ptr = 0; + mutable uintptr_t Ptr = 0; public: LazyOffsetPtr() = default; - exp

[clang] [clang] LazyOffsetPtr: Use native pointer width (PR #111995)

2024-10-16 Thread A. Wilcox via cfe-commits
awilfox wrote: > Btw, if you submit a fix, it would be great if it could be backported to the > 18 and 19 branches. I think the 18 branch may already be closed. This is what we are shipping in Adélie for 18: [big-endian-32.patch](https://github.com/user-attachments/files/17404400/big-endian-

[clang] [clang] LazyOffsetPtr: Use native pointer width (PR #111995)

2024-10-16 Thread A. Wilcox via cfe-commits
@@ -326,25 +326,25 @@ struct LazyOffsetPtr { /// /// If the low bit is clear, a pointer to the AST node. If the low /// bit is set, the upper 63 bits are the offset. - mutable uint64_t Ptr = 0; + mutable uintptr_t Ptr = 0; public: LazyOffsetPtr() = default; - exp

[clang] [clang] LazyOffsetPtr: Use native pointer width (PR #111995)

2024-10-16 Thread John Paul Adrian Glaubitz via cfe-commits
glaubitz wrote: Btw, if you submit a fix, it would be great if it could be backported to the 18 and 19 branches. https://github.com/llvm/llvm-project/pull/111995 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/ma

[clang] [clang] LazyOffsetPtr: Use native pointer width (PR #111995)

2024-10-15 Thread John Paul Adrian Glaubitz via cfe-commits
glaubitz wrote: > cc @glaubitz (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113341) I can confirm that the patch from this PR fixes the GCC bootstrap on 32-bit PowerPC on Linux for me (GCC pr/target 113341). https://github.com/llvm/llvm-project/pull/111995

[clang] [clang] LazyOffsetPtr: Use native pointer width (PR #111995)

2024-10-15 Thread Chuanqi Xu via cfe-commits
ChuanqiXu9 wrote: > Can we remove `getAddressOfPointer` instead?. Where is it being used? It is used in `VarDecl::getInitAddress()` in Decl.cpp. It looks like it is used indirectly by the StmtIterator https://github.com/llvm/llvm-project/pull/111995

[clang] [clang] LazyOffsetPtr: Use native pointer width (PR #111995)

2024-10-15 Thread Richard Smith via cfe-commits
https://github.com/zygoloid commented: Can we remove `getAddressOfPointer` instead?. Where is it being used? https://github.com/llvm/llvm-project/pull/111995 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman

[clang] [clang] LazyOffsetPtr: Use native pointer width (PR #111995)

2024-10-14 Thread Sam James via cfe-commits
thesamesam wrote: cc @glaubitz (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113341) https://github.com/llvm/llvm-project/pull/111995 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] LazyOffsetPtr: Use native pointer width (PR #111995)

2024-10-13 Thread Chuanqi Xu via cfe-commits
@@ -326,25 +326,25 @@ struct LazyOffsetPtr { /// /// If the low bit is clear, a pointer to the AST node. If the low /// bit is set, the upper 63 bits are the offset. - mutable uint64_t Ptr = 0; + mutable uintptr_t Ptr = 0; public: LazyOffsetPtr() = default; - exp

[clang] [clang] LazyOffsetPtr: Use native pointer width (PR #111995)

2024-10-11 Thread A. Wilcox via cfe-commits
awilfox wrote: I feel like the messages being highlighted in the CI formatter need work anyway. I was hoping the community would have a suggestion on better wording. However, I will be glad to reformat those lines in that manner if this wording should stay. https://github.com/llvm/llvm-proj

[clang] [clang] LazyOffsetPtr: Use native pointer width (PR #111995)

2024-10-11 Thread A. Wilcox via cfe-commits
awilfox wrote: This patch has been tested on 32-bit PowerPC, 64-bit PowerPC, and 64-bit x86_64 (ensuring it doesn't change any behaviour on LE systems) - the entire Clang test suite passed on all three platforms. https://github.com/llvm/llvm-project/pull/111995

[clang] [clang] LazyOffsetPtr: Use native pointer width (PR #111995)

2024-10-11 Thread via cfe-commits
llvmbot wrote: @llvm/pr-subscribers-clang Author: A. Wilcox (awilfox) Changes On big-endian systems, narrow casting will read the higher bits of the value. LazyOffsetPtr's `getAddressOfPointer` returns the address-of `Ptr` which was unconditionally a 64-bit value. On 32-bit big endian

[clang] [clang] LazyOffsetPtr: Use native pointer width (PR #111995)

2024-10-11 Thread via cfe-commits
github-actions[bot] wrote: Thank you for submitting a Pull Request (PR) to the LLVM Project! This PR will be automatically labeled and the relevant teams will be notified. If you wish to, you can add reviewers by using the "Reviewers" section on this page. If this is not working for you, it

[clang] [clang] LazyOffsetPtr: Use native pointer width (PR #111995)

2024-10-11 Thread A. Wilcox via cfe-commits
https://github.com/awilfox created https://github.com/llvm/llvm-project/pull/111995 On big-endian systems, narrow casting will read the higher bits of the value. LazyOffsetPtr's `getAddressOfPointer` returns the address-of `Ptr` which was unconditionally a 64-bit value. On 32-bit big endian