[clang] [llvm] Global string alignment (PR #142346)

2025-06-06 Thread Eli Friedman via cfe-commits
https://github.com/efriedma-quic commented: I'm a little concerned we don't want to play whack-a-mole with this... but I guess optimizations generally won't explicitly request an alignment of "1", so this is probably good enough? Please write a test specifically for instcombine, not a clang te

[clang] [llvm] Global string alignment (PR #142346)

2025-06-06 Thread Ulrich Weigand via cfe-commits
uweigand wrote: > The clang patch was written the way it was because it was necessary to comply > with the ABI rules. Strings passed to printf don't have any sort of alignment > requirement, so you can't really appeal to the ABI rules here, I think? Just to be clear, the ABI requirement is tha

[clang] [llvm] Global string alignment (PR #142346)

2025-06-06 Thread Dominik Steenken via cfe-commits
dominik-steenken wrote: Ok. As far as i can tell, ```C++ M->getDataLayout().getPrefTypeAlign(getInt8Ty()) ``` should be functionally equivalent to ```C++ M->getDataLayout().getPreferredAlign(GV) ``` with the exception that the latter potentially preserves a preexisting alignment on the `GV`, wh

[clang] [llvm] Global string alignment (PR #142346)

2025-06-06 Thread Dominik Steenken via cfe-commits
https://github.com/dominik-steenken updated https://github.com/llvm/llvm-project/pull/142346 >From 318f0536ce71780f808ef70a1817af515f9861bd Mon Sep 17 00:00:00 2001 From: Dominik Steenken Date: Mon, 26 May 2025 14:53:41 +0200 Subject: [PATCH 1/2] Align global strings according to data layout W

[clang] [llvm] Global string alignment (PR #142346)

2025-06-05 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: The clang patch was written the way it was because it was necessary to comply with the ABI rules. Strings passed to printf don't have any sort of alignment requirement, so you can't really appeal to the ABI rules here, I think? The problem with copying the alignment is th

[clang] [llvm] Global string alignment (PR #142346)

2025-06-05 Thread Dominik Steenken via cfe-commits
dominik-steenken wrote: So i've been reading through the code and the history a bit, and there is [this commit](https://github.com/llvm/llvm-project/commit/fa806422050edba799bc4392125a0305a4bccf6b), which introduces the concept of a minimum alignment for globals to `clang`. The `clang` backend

[clang] [llvm] Global string alignment (PR #142346)

2025-06-05 Thread Dominik Steenken via cfe-commits
https://github.com/dominik-steenken updated https://github.com/llvm/llvm-project/pull/142346 >From 3b5ae726c3f3170b8a524007293934f2561ad572 Mon Sep 17 00:00:00 2001 From: Dominik Steenken Date: Mon, 26 May 2025 14:53:41 +0200 Subject: [PATCH 1/3] Align global strings according to data layout W

[clang] [llvm] Global string alignment (PR #142346)

2025-06-05 Thread Dominik Steenken via cfe-commits
https://github.com/dominik-steenken updated https://github.com/llvm/llvm-project/pull/142346 >From ff817c7a1b79596712d24b7cfac9212edcef9280 Mon Sep 17 00:00:00 2001 From: Dominik Steenken Date: Mon, 26 May 2025 14:53:41 +0200 Subject: [PATCH 1/3] Align global strings according to data layout W

[clang] [llvm] Global string alignment (PR #142346)

2025-06-02 Thread Eli Friedman via cfe-commits
efriedma-quic wrote: If there's some general rule that means we want to increase the alignment of globals, I think it makes sense to make CodeGenPrepare or some target-specific pass, instead of trying to fix every frontend and every optimization pass to use increased alignment. https://github

[clang] [llvm] Global string alignment (PR #142346)

2025-06-02 Thread Dominik Steenken via cfe-commits
dominik-steenken wrote: > I'm not sure this is the right fix for the issue. Just like for allocas, the > global variable alignment is a _minimum_ required alignment, which can and > should be raised by targets if it improves code generation. (The exception to > this is if the global has a sect

[clang] [llvm] Global string alignment (PR #142346)

2025-06-02 Thread Dominik Steenken via cfe-commits
@@ -52,7 +52,7 @@ GlobalVariable *IRBuilderBase::CreateGlobalString(StringRef Str, *M, StrConstant->getType(), true, GlobalValue::PrivateLinkage, StrConstant, Name, nullptr, GlobalVariable::NotThreadLocal, AddressSpace); GV->setUnnamedAddr(GlobalValue::UnnamedAd

[clang] [llvm] Global string alignment (PR #142346)

2025-06-02 Thread Nikita Popov via cfe-commits
https://github.com/nikic commented: I'm not sure this is the right fix for the issue. Just like for allocas, the global variable alignment is a *minimum* required alignment, which can and should be raised by targets if it improves code generation. (The exception to this is if the global has a

[clang] [llvm] Global string alignment (PR #142346)

2025-06-02 Thread Nikita Popov via cfe-commits
@@ -52,7 +52,7 @@ GlobalVariable *IRBuilderBase::CreateGlobalString(StringRef Str, *M, StrConstant->getType(), true, GlobalValue::PrivateLinkage, StrConstant, Name, nullptr, GlobalVariable::NotThreadLocal, AddressSpace); GV->setUnnamedAddr(GlobalValue::UnnamedAd

[clang] [llvm] Global string alignment (PR #142346)

2025-06-02 Thread Nikita Popov via cfe-commits
https://github.com/nikic edited https://github.com/llvm/llvm-project/pull/142346 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] Global string alignment (PR #142346)

2025-06-02 Thread Dominik Steenken via cfe-commits
dominik-steenken wrote: @uweigand FYI https://github.com/llvm/llvm-project/pull/142346 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] Global string alignment (PR #142346)

2025-06-02 Thread via cfe-commits
llvmbot wrote: @llvm/pr-subscribers-llvm-ir Author: Dominik Steenken (dominik-steenken) Changes When creating global strings, some targets have requirements that need to be taken into account. Previously, the global strings created by `IRBuilder::createGlobalString` had a hard-coded alig

[clang] [llvm] Global string alignment (PR #142346)

2025-06-02 Thread Dominik Steenken via cfe-commits
https://github.com/dominik-steenken created https://github.com/llvm/llvm-project/pull/142346 When creating global strings, some targets have requirements that need to be taken into account. Previously, the global strings created by `IRBuilder::createGlobalString` had a hard-coded alignment of