@@ -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