Skip to content

Commit 3afbf89

Browse files
committed
[clang][AArch64][SVE] Handle PRValue under VLAT <-> VLST cast
This change fixes the crash that PRValue cannot be handled by EmitLValue. Differential Revision: https://reviews.llvm.org/D105097
1 parent ae54339 commit 3afbf89

File tree

5 files changed

+172
-116
lines changed

5 files changed

+172
-116
lines changed

clang/lib/CodeGen/CGExprScalar.cpp

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2095,24 +2095,11 @@ Value *ScalarExprEmitter::VisitCastExpr(CastExpr *CE) {
20952095
isa<llvm::ScalableVectorType>(DstTy)) ||
20962096
(isa<llvm::ScalableVectorType>(SrcTy) &&
20972097
isa<llvm::FixedVectorType>(DstTy))) {
2098-
if (const CallExpr *CE = dyn_cast<CallExpr>(E)) {
2099-
// Call expressions can't have a scalar return unless the return type
2100-
// is a reference type so an lvalue can't be emitted. Create a temp
2101-
// alloca to store the call, bitcast the address then load.
2102-
QualType RetTy = CE->getCallReturnType(CGF.getContext());
2103-
Address Addr =
2104-
CGF.CreateDefaultAlignTempAlloca(SrcTy, "saved-call-rvalue");
2105-
LValue LV = CGF.MakeAddrLValue(Addr, RetTy);
2106-
CGF.EmitStoreOfScalar(Src, LV);
2107-
Addr = Builder.CreateElementBitCast(Addr, CGF.ConvertTypeForMem(DestTy),
2108-
"castFixedSve");
2109-
LValue DestLV = CGF.MakeAddrLValue(Addr, DestTy);
2110-
DestLV.setTBAAInfo(TBAAAccessInfo::getMayAliasInfo());
2111-
return EmitLoadOfLValue(DestLV, CE->getExprLoc());
2112-
}
2113-
2114-
Address Addr = EmitLValue(E).getAddress(CGF);
2115-
Addr = Builder.CreateElementBitCast(Addr, CGF.ConvertTypeForMem(DestTy));
2098+
Address Addr = CGF.CreateDefaultAlignTempAlloca(SrcTy, "saved-value");
2099+
LValue LV = CGF.MakeAddrLValue(Addr, E->getType());
2100+
CGF.EmitStoreOfScalar(Src, LV);
2101+
Addr = Builder.CreateElementBitCast(Addr, CGF.ConvertTypeForMem(DestTy),
2102+
"castFixedSve");
21162103
LValue DestLV = CGF.MakeAddrLValue(Addr, DestTy);
21172104
DestLV.setTBAAInfo(TBAAAccessInfo::getMayAliasInfo());
21182105
return EmitLoadOfLValue(DestLV, CE->getExprLoc());

0 commit comments

Comments
 (0)