[llvm] [LoopIdiom] Don't generate `wcslen` when the pointer passed is not known to be aligned (PR #229074)
Ömer Sinan Ağacan via llvm-commits
llvm-commits at lists.llvm.org
Sat Oct 10 14:43:32 PDT 2026
================
@@ -2114,10 +2114,18 @@ class StrlenVerifier {
return false;
if (StepSize != OpWidth / 8)
return false;
- if (OpWidth >= 16)
+ if (OpWidth >= 16) {
if (OpWidth != WcharSize * 8)
return false;
+ // Don't call `wcslen` if the base pointer isn't known to be aligned.
+ const DataLayout &DL = LoopLoad->getDataLayout();
+ Align WcharAlign = DL.getABITypeAlign(OperandType);
----------------
osa1 wrote:
It's good to be consistent. If I need alignment of a type, I do `getABITypeAlign` and it gives me the right answer regardless of whether the type is desuraged at the IR level or not. I don't need to special case anything and do different things for different types.
The renaming suggestion makes sense, I'll update.
https://github.com/llvm/llvm-project/pull/229074
More information about the llvm-commits
mailing list