[llvm] [Inliner] Fix Issue #45778: Inliner now respects the alignment of parameters passed by value (PR #137455)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Sat Apr 26 07:44:16 PDT 2025


================
@@ -1703,19 +1703,21 @@ static void AddAlignmentAssumptions(CallBase &CB, InlineFunctionInfo &IFI) {
 }
 
 static void HandleByValArgumentInit(Type *ByValType, Value *Dst, Value *Src,
-                                    Module *M, BasicBlock *InsertBlock,
+                                    MaybeAlign SrcAlign, Module *M,
+                                    BasicBlock *InsertBlock,
                                     InlineFunctionInfo &IFI,
                                     Function *CalledFunc) {
   IRBuilder<> Builder(InsertBlock, InsertBlock->begin());
 
   Value *Size =
       Builder.getInt64(M->getDataLayout().getTypeStoreSize(ByValType));
 
-  // Always generate a memcpy of alignment 1 here because we don't know
-  // the alignment of the src pointer.  Other optimizations can infer
-  // better alignment.
-  CallInst *CI = Builder.CreateMemCpy(Dst, /*DstAlign*/ Align(1), Src,
-                                      /*SrcAlign*/ Align(1), Size);
+  Align DstAlign = Dst->getPointerAlignment(M->getDataLayout());
+
+  // Generate a mempcpy with the correct alignments. At this point, the
----------------
nikic wrote:

```suggestion
  // Generate a memcpy with the correct alignments. At this point, the
```

https://github.com/llvm/llvm-project/pull/137455


More information about the llvm-commits mailing list