[clang] [PowerPC] Fix incorrect store alignment for __builtin_vsx_build_pair() (PR #108606)

Lei Huang via cfe-commits cfe-commits at lists.llvm.org
Tue Sep 17 10:56:08 PDT 2024


================
@@ -18197,7 +18197,7 @@ Value *CodeGenFunction::EmitPPCBuiltinExpr(unsigned BuiltinID,
       CallOps.push_back(Ops[i]);
     llvm::Function *F = CGM.getIntrinsic(ID);
     Value *Call = Builder.CreateCall(F, CallOps);
-    return Builder.CreateAlignedStore(Call, Ops[0], MaybeAlign(64));
+    return Builder.CreateAlignedStore(Call, Ops[0], MaybeAlign());
----------------
lei137 wrote:

> I'd prefer to just explicitly write the expected alignment here,

@efriedma-quic  Do you mean like hard code the expected alignment?

Currently `CreateAlignedStore(Call, Ops[0], MaybeAlign());` calls:
```
StoreInst *CreateAlignedStore(Value *Val, Value *Ptr, MaybeAlign Align,
                                bool isVolatile = false) {
    if (!Align) {
      const DataLayout &DL = BB->getDataLayout();
      Align = DL.getABITypeAlign(Val->getType());
    }
    return Insert(new StoreInst(Val, Ptr, isVolatile, *Align));
  }
```
and get the proper ABI alignment for the type given.  Since this section of code process types that are either 32bit or 64bit aligned, we can't hard code any alignment here.

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


More information about the cfe-commits mailing list