================
@@ -426,28 +444,36 @@ emitStructFieldArgs(mlir::OpBuilder &builder,
mlir::Location loc,
mlir::Value structVal, cir::RecordType recTy,
SmallVectorImpl<mlir::Value> &newArgs,
SmallVectorImpl<cir::LoadOp> &replacedWholeLoads) {
- cir::LoadOp wholeLoad = structVal.getDefiningOp<cir::LoadOp>();
- cir::AllocaOp srcAlloca;
- if (wholeLoad && !wholeLoad.getIsVolatile() && !wholeLoad.getMemOrder())
- srcAlloca = wholeLoad.getAddr().getDefiningOp<cir::AllocaOp>();
+ WholeRecordSource src = getWholeRecordSource(structVal);
- if (srcAlloca) {
+ if (src.alloca) {
mlir::OpBuilder::InsertionGuard guard(builder);
- builder.setInsertionPoint(wholeLoad);
+ builder.setInsertionPoint(src.load);
for (auto [f, fieldTy] : llvm::enumerate(recTy.getMembers())) {
mlir::Type fieldPtrTy = cir::PointerType::get(fieldTy);
mlir::Value fieldPtr = cir::GetMemberOp::create(
- builder, loc, fieldPtrTy, srcAlloca, /*name=*/"", /*index=*/f);
+ builder, loc, fieldPtrTy, src.alloca, /*name=*/"", /*index=*/f);
newArgs.push_back(cir::LoadOp::create(builder, loc, fieldPtr));
}
- replacedWholeLoads.push_back(wholeLoad);
+ replacedWholeLoads.push_back(src.load);
} else {
for (unsigned f = 0; f < recTy.getNumElements(); ++f)
newArgs.push_back(
cir::ExtractMemberOp::create(builder, loc, structVal, f));
}
}
+/// Erase the whole-record loads a call-site rewrite read around, once the
----------------
adams381 wrote:
That sentence was bad. I renamed the function from `eraseDeadWholeRecordLoads`
to `eraseDeadRecordLoads` and tried to keep the "dead" phrasing everywhere to
try and keep it clear. I've rewritten the comment to be more clear. There is
a longer discussion below about the rename / clarification effort I made.
https://github.com/llvm/llvm-project/pull/216499
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits