llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clangir Author: Bruno Cardoso Lopes (bcardosolopes) <details> <summary>Changes</summary> CIR has no way to tell which alloca holds a return value other than its name: CIRGen calls the function's slot `__retval`, and CallConvLowering calls the slot it creates for an sret call `sret`. A user local can carry either name, so a pass that wants to rewire or elide the return slot cannot rely on it. Needless to say this is brittle and needed cleanup. - Add a `return_slot` unit attribute to `cir.alloca`. - CIRGen sets it on the slot the function builds its return value in (which is also an NRVO variable's storage), and CallConvLowering on the slot it allocates for an sret call result. Both slots are now unnamed. When CallConvLowering reuses a call result's store destination as the sret slot, that destination is left as it was. - CXXABILowering keeps the attribute when it retypes an alloca. - LoweringPrepare still names a constant initializer of the return slot `__const.<fn>.__retval`. --- Patch is 259.04 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/244192.diff 121 Files Affected: - (modified) clang/include/clang/CIR/Dialect/IR/CIROps.td (+6-1) - (modified) clang/lib/CIR/CodeGen/CIRGenFunction.cpp (+3-2) - (modified) clang/lib/CIR/CodeGen/CIRGenStmt.cpp (+2-2) - (modified) clang/lib/CIR/Dialect/Transforms/CXXABILowering.cpp (+1) - (modified) clang/lib/CIR/Dialect/Transforms/LoweringPrepare.cpp (+4-2) - (modified) clang/lib/CIR/Dialect/Transforms/TargetLowering/CIRABIRewriteContext.cpp (+16-13) - (modified) clang/test/CIR/CodeGen/agg-atomic-cast.c (+1-1) - (modified) clang/test/CIR/CodeGen/alloca-order.cpp (+4-4) - (modified) clang/test/CIR/CodeGen/assign-operator.cpp (+1-1) - (modified) clang/test/CIR/CodeGen/basic.c (+4-4) - (modified) clang/test/CIR/CodeGen/basic.cpp (+6-6) - (modified) clang/test/CIR/CodeGen/binassign.c (+1-1) - (modified) clang/test/CIR/CodeGen/bind-temporary-lvalue.cpp (+1-1) - (modified) clang/test/CIR/CodeGen/bitint-record-layout.c (+2-2) - (modified) clang/test/CIR/CodeGen/builtin-cpu-supports.c (+4-4) - (modified) clang/test/CIR/CodeGen/call-conv-lowering-amdgpu-one-field-struct.c (+1-1) - (modified) clang/test/CIR/CodeGen/call-conv-lowering-x86_64-union-copy.c (+8-8) - (modified) clang/test/CIR/CodeGen/call-conv-lowering-x86_64-x87-union.cpp (+5-5) - (modified) clang/test/CIR/CodeGen/call-conv-lowering-x86_64.c (+2-2) - (modified) clang/test/CIR/CodeGen/call.cpp (+1-1) - (modified) clang/test/CIR/CodeGen/cast.c (+1-1) - (modified) clang/test/CIR/CodeGen/cast.cpp (+1-1) - (modified) clang/test/CIR/CodeGen/cleanup-conditional.cpp (+2-2) - (modified) clang/test/CIR/CodeGen/complex.cpp (+8-8) - (modified) clang/test/CIR/CodeGen/compound_literal.cpp (+1-1) - (modified) clang/test/CIR/CodeGen/const-var-emit-as-constant.cpp (+2-2) - (modified) clang/test/CIR/CodeGen/constructor-destructor-return-this.cpp (+1-1) - (modified) clang/test/CIR/CodeGen/count-of.c (+2-2) - (modified) clang/test/CIR/CodeGen/cxx-construct-lvalue.cpp (+2-2) - (modified) clang/test/CIR/CodeGen/cxx-conversion-operators.cpp (+2-2) - (modified) clang/test/CIR/CodeGen/derived-to-base.cpp (+1-1) - (modified) clang/test/CIR/CodeGen/dtors.cpp (+3-3) - (modified) clang/test/CIR/CodeGen/ehspec.cpp (+1-1) - (modified) clang/test/CIR/CodeGen/fixed-point-arith.cpp (+33-33) - (modified) clang/test/CIR/CodeGen/gnu-ptr-math.c (+8-8) - (modified) clang/test/CIR/CodeGen/implicit-return-zero.c (+2-2) - (modified) clang/test/CIR/CodeGen/inline-cxx-func.cpp (+1-1) - (modified) clang/test/CIR/CodeGen/lambda-static-invoker.cpp (+5-5) - (modified) clang/test/CIR/CodeGen/lambda.cpp (+8-8) - (modified) clang/test/CIR/CodeGen/launder.cpp (+4-4) - (modified) clang/test/CIR/CodeGen/new-delete-deactivation.cpp (+1-1) - (modified) clang/test/CIR/CodeGen/new-delete.cpp (+3-3) - (modified) clang/test/CIR/CodeGen/nrvo.cpp (+2-2) - (modified) clang/test/CIR/CodeGen/openmp_default_simd_align.c (+1-1) - (modified) clang/test/CIR/CodeGen/pack-indexing.cpp (+5-5) - (modified) clang/test/CIR/CodeGen/paren-list-agg-init.cpp (+7-7) - (modified) clang/test/CIR/CodeGen/pointer-to-data-member-cast.cpp (+1-1) - (modified) clang/test/CIR/CodeGen/pointer-to-data-member.cpp (+16-16) - (modified) clang/test/CIR/CodeGen/pointer-to-member-func-cast.cpp (+2-2) - (modified) clang/test/CIR/CodeGen/pointer-to-member-func.cpp (+6-6) - (modified) clang/test/CIR/CodeGen/statement-exprs.c (+3-3) - (modified) clang/test/CIR/CodeGen/static-local-arm-guard.cpp (+1-1) - (modified) clang/test/CIR/CodeGen/static-local.cpp (+4-4) - (modified) clang/test/CIR/CodeGen/string-literals.cpp (+1-1) - (modified) clang/test/CIR/CodeGen/struct.c (+2-2) - (modified) clang/test/CIR/CodeGen/subscript-addrspace-cast.cpp (+1-1) - (modified) clang/test/CIR/CodeGen/target-lowering-dead-block.cpp (+2-2) - (modified) clang/test/CIR/CodeGen/temp-param-obj-decl.cpp (+2-2) - (modified) clang/test/CIR/CodeGen/temporary-materialization.cpp (+1-1) - (modified) clang/test/CIR/CodeGen/ternary-throw.cpp (+2-2) - (modified) clang/test/CIR/CodeGen/ternary.cpp (+1-1) - (modified) clang/test/CIR/CodeGen/three-way-cmp.cpp (+3-3) - (modified) clang/test/CIR/CodeGen/throws.cpp (+1-1) - (modified) clang/test/CIR/CodeGen/try-catch-non-trivial-copy.cpp (+1-1) - (modified) clang/test/CIR/CodeGen/try-catch.cpp (+3-3) - (modified) clang/test/CIR/CodeGen/unary.cpp (+44-44) - (modified) clang/test/CIR/CodeGen/union-agg-init.c (+1-1) - (modified) clang/test/CIR/CodeGen/union-agg-init.cpp (+1-1) - (modified) clang/test/CIR/CodeGen/union.c (+1-1) - (modified) clang/test/CIR/CodeGen/var-arg-aggregate.c (+1-1) - (modified) clang/test/CIR/CodeGen/var_arg.c (+3-3) - (modified) clang/test/CIR/CodeGen/variable-decomposition.cpp (+1-1) - (modified) clang/test/CIR/CodeGen/vector-ext.cpp (+1-1) - (modified) clang/test/CIR/CodeGen/vector.cpp (+1-1) - (modified) clang/test/CIR/CodeGen/vla.c (+1-1) - (modified) clang/test/CIR/CodeGenBuiltins/builtin-constant-p.c (+9-9) - (modified) clang/test/CIR/CodeGenBuiltins/builtin-fcmp-sse.c (+4-4) - (modified) clang/test/CIR/CodeGenCXX/sizeof-pack.cpp (+2-2) - (modified) clang/test/CIR/CodeGenCoroutines/coro-alloc.cpp (+1-1) - (modified) clang/test/CIR/CodeGenCoroutines/coro-task.cpp (+3-3) - (modified) clang/test/CIR/CodeGenHIP/cleanup-alloca-addrspace.hip (+1-1) - (modified) clang/test/CIR/CodeGenHIP/device-printf.hip (+1-1) - (modified) clang/test/CIR/CodeGenOpenCL/as_type.cl (+4-4) - (modified) clang/test/CIR/CodeGenOpenCL/vector.cl (+4-4) - (modified) clang/test/CIR/CodeGenOpenMP/omp-llvmir.c (+1-1) - (modified) clang/test/CIR/CodeGenSYCL/local-temporaries.cpp (+1-1) - (modified) clang/test/CIR/IR/alloca.cir (+8-4) - (modified) clang/test/CIR/IR/method-attr.cir (+6-6) - (modified) clang/test/CIR/IR/throw.cir (+2-2) - (modified) clang/test/CIR/Lowering/cast.cir (+1-1) - (modified) clang/test/CIR/Lowering/goto.cir (+1-1) - (modified) clang/test/CIR/Lowering/switch.cir (+1-1) - (modified) clang/test/CIR/Transforms/abi-lowering/amdgpu-flexible-array.cir (+1-1) - (modified) clang/test/CIR/Transforms/abi-lowering/amdgpu-indirect.cir (+2-2) - (modified) clang/test/CIR/Transforms/abi-lowering/amdgpu-one-field-struct.cir (+2-2) - (modified) clang/test/CIR/Transforms/abi-lowering/amdgpu-sret-nontrivial.cir (+5-5) - (modified) clang/test/CIR/Transforms/abi-lowering/amdgpu-union.cir (+2-2) - (modified) clang/test/CIR/Transforms/abi-lowering/coerce-record-return-from-memory.cir (+31-31) - (modified) clang/test/CIR/Transforms/abi-lowering/dropped-return-res-attrs.cir (+1-1) - (modified) clang/test/CIR/Transforms/abi-lowering/expand-struct-arg.cir (+1-1) - (modified) clang/test/CIR/Transforms/abi-lowering/indirect-byval.cir (+4-4) - (modified) clang/test/CIR/Transforms/abi-lowering/indirect-call.cir (+1-1) - (modified) clang/test/CIR/Transforms/abi-lowering/indirect-non-byval-forward-param.cir (+2-2) - (modified) clang/test/CIR/Transforms/abi-lowering/indirect-non-byval-nyi.cir (+1-1) - (modified) clang/test/CIR/Transforms/abi-lowering/indirect-return-sret.cir (+10-10) - (modified) clang/test/CIR/Transforms/abi-lowering/spirv-calling-conv.cir (+1-1) - (modified) clang/test/CIR/Transforms/abi-lowering/spirv-indirect.cir (+1-1) - (modified) clang/test/CIR/Transforms/abi-lowering/x86_64-bitint.cir (+3-3) - (modified) clang/test/CIR/Transforms/abi-lowering/x86_64-record-copy.cir (+7-7) - (modified) clang/test/CIR/Transforms/abi-lowering/x86_64-union.cir (+1-1) - (modified) clang/test/CIR/Transforms/complex-create-fold.cir (+2-2) - (modified) clang/test/CIR/Transforms/complex-imag-fold.cir (+2-2) - (modified) clang/test/CIR/Transforms/complex-real-fold.cir (+2-2) - (modified) clang/test/CIR/Transforms/flatten-cleanup-scope-eh.cir (+2-2) - (modified) clang/test/CIR/Transforms/flatten-cleanup-scope-musttail.cir (+2-2) - (modified) clang/test/CIR/Transforms/mem2reg.cir (+1-1) - (modified) clang/test/CIR/Transforms/scope.cir (+2-2) - (modified) clang/test/CIR/Transforms/switch-fold.cir (+1-1) - (modified) clang/test/CIR/Transforms/switch.cir (+2-2) - (modified) clang/test/CIR/Transforms/ternary.cir (+2-2) - (modified) clang/test/CIR/func-simple.cpp (+16-8) ``````````diff diff --git a/clang/include/clang/CIR/Dialect/IR/CIROps.td b/clang/include/clang/CIR/Dialect/IR/CIROps.td index 2a1600faaece8e..5f646be43646a9 100644 --- a/clang/include/clang/CIR/Dialect/IR/CIROps.td +++ b/clang/include/clang/CIR/Dialect/IR/CIROps.td @@ -797,6 +797,9 @@ def CIR_AllocaOp : CIR_Op<"alloca", [ The `cleanup_dest_slot` attribute indicates that this was a temporary alloca generated by the compiler to handle cleanup exit dispatching. + The `return_slot` attribute marks where a function builds its return value + (possibly an NRVO variable) and the temporaries made for sret call results. + The result type is a pointer to the input's type. Example: @@ -817,6 +820,7 @@ def CIR_AllocaOp : CIR_Op<"alloca", [ UnitAttr:$init, UnitAttr:$constant, UnitAttr:$cleanup_dest_slot, + UnitAttr:$return_slot, ConfinedAttr<I64Attr, [IntMinValue<1>]>:$alignment ); @@ -854,7 +858,8 @@ def CIR_AllocaOp : CIR_Op<"alloca", [ `align` `(` $alignment `)` oilist( `init` $init | `const` $constant - | `cleanup_dest_slot` $cleanup_dest_slot) + | `cleanup_dest_slot` $cleanup_dest_slot + | `return_slot` $return_slot) (`size` `(` $dynAllocSize^ `)`)? `:` qualified(type($addr)) attr-dict }]; diff --git a/clang/lib/CIR/CodeGen/CIRGenFunction.cpp b/clang/lib/CIR/CodeGen/CIRGenFunction.cpp index 23fbd963ef7864..c88a7b9523422a 100644 --- a/clang/lib/CIR/CodeGen/CIRGenFunction.cpp +++ b/clang/lib/CIR/CodeGen/CIRGenFunction.cpp @@ -264,7 +264,8 @@ void CIRGenFunction::emitAndUpdateRetAlloca(QualType type, mlir::Location loc, CharUnits alignment) { if (!type->isVoidType()) { Address allocaAddr = Address::invalid(); - returnValue = createMemTemp(type, alignment, loc, "__retval", &allocaAddr); + returnValue = createMemTemp(type, alignment, loc, "", &allocaAddr); + mlir::cast<cir::AllocaOp>(allocaAddr.getDefiningOp()).setReturnSlot(true); fnRetAlloca = allocaAddr.getPointer(); } } @@ -381,7 +382,7 @@ cir::ReturnOp CIRGenFunction::LexicalScope::emitReturn(mlir::Location loc) { assert(fn && "emitReturn from non-function"); if (!fn.getFunctionType().hasVoidReturn()) { - // Load the value from `__retval` and return it via the `cir.return` op. + // Load the value from the return slot and return it via `cir.return`. auto value = cir::LoadOp::create( builder, loc, fn.getFunctionType().getReturnType(), *cgf.fnRetAlloca); return cir::ReturnOp::create(builder, loc, diff --git a/clang/lib/CIR/CodeGen/CIRGenStmt.cpp b/clang/lib/CIR/CodeGen/CIRGenStmt.cpp index dc33685944600e..4efbad51e70f3f 100644 --- a/clang/lib/CIR/CodeGen/CIRGenStmt.cpp +++ b/clang/lib/CIR/CodeGen/CIRGenStmt.cpp @@ -757,7 +757,7 @@ mlir::LogicalResult CIRGenFunction::emitReturnStmt(const ReturnStmt &s) { // directly. // TODO(cir): Eliminate this redundant load and the store above when we can. if (fnRetAlloca) { - // Load the value from `__retval` and return it via the `cir.return` op. + // Load the value from the return slot and return it via `cir.return`. cir::AllocaOp retAlloca = mlir::cast<cir::AllocaOp>(fnRetAlloca->getDefiningOp()); auto value = cir::LoadOp::create(builder, loc, retAlloca.getAllocaType(), @@ -1550,7 +1550,7 @@ void CIRGenFunction::emitReturnOfRValue(mlir::Location loc, RValue rv, // during the CFG flattening phase, we can just emit the return statement // directly. // TODO(cir): Eliminate this redundant load and the store above when we can. - // Load the value from `__retval` and return it via the `cir.return` op. + // Load the value from the return slot and return it via `cir.return`. cir::AllocaOp retAlloca = mlir::cast<cir::AllocaOp>(fnRetAlloca->getDefiningOp()); auto value = cir::LoadOp::create(builder, loc, retAlloca.getAllocaType(), diff --git a/clang/lib/CIR/Dialect/Transforms/CXXABILowering.cpp b/clang/lib/CIR/Dialect/Transforms/CXXABILowering.cpp index 7208fee79fca66..8f276564d58206 100644 --- a/clang/lib/CIR/Dialect/Transforms/CXXABILowering.cpp +++ b/clang/lib/CIR/Dialect/Transforms/CXXABILowering.cpp @@ -363,6 +363,7 @@ mlir::LogicalResult CIRAllocaOpABILowering::matchAndRewrite( op.getAlignmentAttr(), /*dynAllocSize=*/adaptor.getDynAllocSize()); loweredOp.setInit(op.getInit()); loweredOp.setConstant(op.getConstant()); + loweredOp.setReturnSlot(op.getReturnSlot()); rewriter.replaceOp(op, loweredOp); return mlir::success(); diff --git a/clang/lib/CIR/Dialect/Transforms/LoweringPrepare.cpp b/clang/lib/CIR/Dialect/Transforms/LoweringPrepare.cpp index b30a20e9214216..753b712fc3c445 100644 --- a/clang/lib/CIR/Dialect/Transforms/LoweringPrepare.cpp +++ b/clang/lib/CIR/Dialect/Transforms/LoweringPrepare.cpp @@ -2743,8 +2743,10 @@ void LoweringPreparePass::lowerStoreOfConstAggregate(cir::StoreOp op) { return; llvm::StringRef funcName = func.getSymName(); - // Get variable name from the alloca. - llvm::StringRef varName = alloca.getName(); + // Get variable name from the alloca. The unnamed return slot keeps the + // `__retval` name it had before it was marked. + llvm::StringRef varName = + alloca.getReturnSlot() ? llvm::StringRef("__retval") : alloca.getName(); // Build base name: __const.<func>.<var> std::string baseName = ("__const." + funcName + "." + varName).str(); diff --git a/clang/lib/CIR/Dialect/Transforms/TargetLowering/CIRABIRewriteContext.cpp b/clang/lib/CIR/Dialect/Transforms/TargetLowering/CIRABIRewriteContext.cpp index f286fa85ec28eb..1d446ec145f613 100644 --- a/clang/lib/CIR/Dialect/Transforms/TargetLowering/CIRABIRewriteContext.cpp +++ b/clang/lib/CIR/Dialect/Transforms/TargetLowering/CIRABIRewriteContext.cpp @@ -1483,9 +1483,9 @@ void replaceAddrSpaceViews(cir::AllocaOp slot, mlir::Value ptr) { /// pointer (the prepended first block argument) and the function returns /// void. /// -/// CIRGen emits a local `__retval` alloca and emits `cir.return %loaded` -/// where `%loaded = cir.load __retval`. The naive lowering -- store the -/// loaded SSA value through the sret pointer -- byte-copies the record, +/// CIRGen emits a local return slot alloca and emits `cir.return %loaded` +/// where `%loaded = cir.load <slot>`. The naive lowering, storing the +/// loaded SSA value through the sret pointer, byte-copies the record, /// which is wrong for non-trivially-copyable types: e.g. libstdc++'s SSO /// `std::string` has a `_M_p` pointer that aliases the source's internal /// `_M_local_buf`, so a byte-copy leaves the destination pointing at the @@ -1493,14 +1493,14 @@ void replaceAddrSpaceViews(cir::AllocaOp slot, mlir::Value ptr) { /// later `free()`s a stack pointer. /// /// Instead, route construction directly into the sret slot: find the -/// `__retval` alloca, replace its uses with the sret pointer, and drop the -/// trailing `cir.load __retval` so the rewritten return has no operand. -/// The CIRGen-emitted constructor / store-into-`__retval` then targets the +/// return slot alloca, replace its uses with the sret pointer, and drop the +/// trailing `cir.load <slot>` so the rewritten return has no operand. +/// The CIRGen-emitted constructor / store-into-slot then targets the /// sret slot uniformly, matching classic CodeGen's "construct directly into /// `%agg.result`" pattern. /// -/// CIRGen emits one `%v = cir.load %__retval` / `cir.return %v` pair per -/// return statement, and every such load reads the single `__retval` +/// CIRGen emits one `%v = cir.load %slot` / `cir.return %v` pair per +/// return statement, and every such load reads the single return slot /// alloca (CIR does not merge returns into a shared epilogue block). The /// alloca is therefore rewired to the sret pointer once; each cir.return is /// then collapsed to a bare return and its now-dead load erased. This @@ -1508,7 +1508,7 @@ void replaceAddrSpaceViews(cir::AllocaOp slot, mlir::Value ptr) { /// CIRGen, so it is asserted via `cast<>` rather than guarded with a /// fallback. /// -/// A `__retval` outside the sret pointer's address space is not replaced +/// A return slot outside the sret pointer's address space is not replaced /// itself. Its address_space casts to the sret pointer's type are. void insertSRetStores(mlir::FunctionOpInterface funcOp, mlir::Type origRetTy, mlir::OpBuilder &builder) { @@ -1527,7 +1527,7 @@ void insertSRetStores(mlir::FunctionOpInterface funcOp, mlir::Type origRetTy, cir::LoadOp retLoad = mlir::cast<cir::LoadOp>(retOp.getInput()[0].getDefiningOp()); - // Rewire the shared `__retval` alloca to the sret pointer once. + // Rewire the shared return slot alloca to the sret pointer once. // replaceAllUsesWith updates every load of the alloca (including those // feeding the other cir.return ops) to read from sretPtr instead, so // all returns are covered by this single rewiring. @@ -1550,7 +1550,8 @@ void insertSRetStores(mlir::FunctionOpInterface funcOp, mlir::Type origRetTy, if (retAlloca) { assert(retAlloca->use_empty() && - "__retval used other than by its returns and address_space views"); + "return slot used other than by its returns and address_space " + "views"); retAlloca->erase(); } } @@ -1717,10 +1718,12 @@ rewriteIndirectReturnCall(cir::CallOp call, const FunctionClassification &fc, } if (!sretSlot) { cir::PointerType allocaPtrTy = getAllocaPtrTy(origRetTy, dl); - sretSlot = cir::AllocaOp::create( + auto slot = cir::AllocaOp::create( builder, call.getLoc(), allocaPtrTy, - /*name=*/builder.getStringAttr("sret"), + /*name=*/builder.getStringAttr(""), /*alignment=*/builder.getI64IntegerAttr(sretAlign)); + slot.setReturnSlot(true); + sretSlot = slot; // The sret pointer can be outside the alloca address space. if (allocaPtrTy != ptrTy) sretSlot = cir::CastOp::create(builder, call.getLoc(), ptrTy, diff --git a/clang/test/CIR/CodeGen/agg-atomic-cast.c b/clang/test/CIR/CodeGen/agg-atomic-cast.c index 5b2dc7cb218911..06704cb0fd47cc 100644 --- a/clang/test/CIR/CodeGen/agg-atomic-cast.c +++ b/clang/test/CIR/CodeGen/agg-atomic-cast.c @@ -60,7 +60,7 @@ struct T load_atomic_struct() { } // CIR: %[[RET_ADDR:.*]] = cir.alloca "coerce" {{.*}} : !cir.ptr<!rec_T> -// CIR: %[[RET_VAL_ADDR:.*]] = cir.alloca "__retval" {{.*}} : !cir.ptr<!rec_T> +// CIR: %[[RET_VAL_ADDR:.*]] = cir.alloca "" {{.*}} return_slot : !cir.ptr<!rec_T> // CIR: %[[A_ADDR:.*]] = cir.alloca "a" {{.*}} : !cir.ptr<!rec_anon_struct> // CIR: %[[NON_ATOMIC_TMP_ADDR:.*]] = cir.alloca "tmp" {{.*}} : !cir.ptr<!rec_anon_struct> // CIR: %[[A_U32:.*]] = cir.cast bitcast %[[A_ADDR]] : !cir.ptr<!rec_anon_struct> -> !cir.ptr<!u32i> diff --git a/clang/test/CIR/CodeGen/alloca-order.cpp b/clang/test/CIR/CodeGen/alloca-order.cpp index ec733a7dbb1235..7656f4009841c7 100644 --- a/clang/test/CIR/CodeGen/alloca-order.cpp +++ b/clang/test/CIR/CodeGen/alloca-order.cpp @@ -16,7 +16,7 @@ int main(int argc, char **argv) { } // CIR: cir.func {{.*}} @main( -// CIR-NEXT: %[[RETVAL:.*]] = cir.alloca "__retval" align(4) : !cir.ptr<!s32i> +// CIR-NEXT: %[[RETVAL:.*]] = cir.alloca "" align(4) return_slot : !cir.ptr<!s32i> // CIR-NEXT: %[[ARGC:.*]] = cir.alloca "argc" align(4) init : !cir.ptr<!s32i> // CIR-NEXT: %[[ARGV:.*]] = cir.alloca "argv" align(8) init : !cir.ptr<!cir.ptr<!cir.ptr<!s8i>>> // CIR-NEXT: %[[ZERO:.*]] = cir.const #cir.int<0> : !s32i @@ -47,7 +47,7 @@ int pick(int a, int b) { } // CIR: cir.func {{.*}} @_Z4pickii( -// CIR-NEXT: %[[RETVAL:.*]] = cir.alloca "__retval" align(4) : !cir.ptr<!s32i> +// CIR-NEXT: %[[RETVAL:.*]] = cir.alloca "" align(4) return_slot : !cir.ptr<!s32i> // CIR-NEXT: %[[A:.*]] = cir.alloca "a" align(4) init : !cir.ptr<!s32i> // CIR-NEXT: %[[B:.*]] = cir.alloca "b" align(4) init : !cir.ptr<!s32i> // CIR-NEXT: cir.store %{{.+}}, %[[A]] : !s32i, !cir.ptr<!s32i> @@ -78,7 +78,7 @@ int late(int a) { } // CIR: cir.func {{.*}} @_Z4latei( -// CIR-NEXT: %[[RETVAL:.*]] = cir.alloca "__retval" align(4) : !cir.ptr<!s32i> +// CIR-NEXT: %[[RETVAL:.*]] = cir.alloca "" align(4) return_slot : !cir.ptr<!s32i> // CIR-NEXT: %[[A:.*]] = cir.alloca "a" align(4) init : !cir.ptr<!s32i> // CIR-NEXT: %[[X:.*]] = cir.alloca "x" align(4) init : !cir.ptr<!s32i> // CIR-NEXT: %[[Z:.*]] = cir.alloca "z" align(4) init : !cir.ptr<!s32i> @@ -140,7 +140,7 @@ int S::pick(int k) { } // CIR: cir.func {{.*}} @_ZN1S4pickEi( -// CIR-NEXT: %[[RETVAL:.*]] = cir.alloca "__retval" align(4) : !cir.ptr<!s32i> +// CIR-NEXT: %[[RETVAL:.*]] = cir.alloca "" align(4) return_slot : !cir.ptr<!s32i> // CIR-NEXT: %[[THIS:.*]] = cir.alloca "this" align(8) init : !cir.ptr<!cir.ptr<!rec_S>> // CIR-NEXT: %[[K:.*]] = cir.alloca "k" align(4) init : !cir.ptr<!s32i> // CIR-NEXT: cir.store %{{.+}}, %[[THIS]] : !cir.ptr<!rec_S>, !cir.ptr<!cir.ptr<!rec_S>> diff --git a/clang/test/CIR/CodeGen/assign-operator.cpp b/clang/test/CIR/CodeGen/assign-operator.cpp index 991042e22d4d56..8919ff11e5e475 100644 --- a/clang/test/CIR/CodeGen/assign-operator.cpp +++ b/clang/test/CIR/CodeGen/assign-operator.cpp @@ -69,7 +69,7 @@ void copy_c(C &c1, C &c2) { // Implicit assignment operator for C. // CIR: cir.func {{.*}} @_ZN1CaSERKS_(%arg0: !cir.ptr<!rec_C> {{.*}}, %arg1: !cir.ptr<!rec_C> {{.*}}) -> (!cir.ptr<!rec_C>{{.*}}) -// CIR: %[[RET_ADDR:.*]] = cir.alloca "__retval" {{.*}} : !cir.ptr<!cir.ptr<!rec_C>> +// CIR: %[[RET_ADDR:.*]] = cir.alloca "" {{.*}} return_slot : !cir.ptr<!cir.ptr<!rec_C>> // CIR: %[[THIS_ADDR:.*]] = cir.alloca "this" {{.*}} init : !cir.ptr<!cir.ptr<!rec_C>> // CIR: %[[ARG1_ADDR:.*]] = cir.alloca "" {{.*}} init const : !cir.ptr<!cir.ptr<!rec_C>> // CIR: cir.store %arg0, %[[THIS_ADDR]] diff --git a/clang/test/CIR/CodeGen/basic.c b/clang/test/CIR/CodeGen/basic.c index e1c30578523304..902ae731d4bf29 100644 --- a/clang/test/CIR/CodeGen/basic.c +++ b/clang/test/CIR/CodeGen/basic.c @@ -35,7 +35,7 @@ int f1(int i) { } // CIR: cir.func{{.*}} @f1(%arg0: !s32i {llvm.noundef} loc({{.*}})) -> !s32i -// CIR-NEXT: %[[RV:.*]] = cir.alloca "__retval" align(4) : !cir.ptr<!s32i> +// CIR-NEXT: %[[RV:.*]] = cir.alloca "" align(4) return_slot : !cir.ptr<!s32i> // CIR-NEXT: %[[I_PTR:.*]] = cir.alloca "i" align(4) init : !cir.ptr<!s32i> // CIR-NEXT: cir.store{{.*}} %arg0, %[[I_PTR]] : !s32i, !cir.ptr<!s32i> // CIR-NEXT: %[[I_IGNORED:.*]] = cir.load{{.*}} %[[I_PTR]] : !cir.ptr<!s32i>, !s32i @@ -65,7 +65,7 @@ int f1(int i) { int f2(void) { return 3; } // CIR: cir.func{{.*}} @f2() -> !s32i -// CIR-NEXT: %[[RV:.*]] = cir.alloca "__retval" align(4) : !cir.ptr<!s32i> +// CIR-NEXT: %[[RV:.*]] = cir.alloca "" align(4) return_slot : !cir.ptr<!s32i> // CIR-NEXT: %[[THREE:.*]] = cir.const #cir.int<3> : !s32i // CIR-NEXT: cir.store{{.*}} %[[THREE]], %[[RV]] : !s32i, !cir.ptr<!s32i> // CIR-NEXT: %[[R:.*]] = cir.load{{.*}} %0 : !cir.ptr<!s32i>, !s32i @@ -87,7 +87,7 @@ int f3(void) { } // CIR: cir.func{{.*}} @f3() -> !s32i -// CIR-NEXT: %[[RV:.*]] = cir.alloca "__retval" align(4) : !cir.ptr<!s32i> +// CIR-NEXT: %[[RV:.*]] = cir.alloca "" align(4) return_slot : !cir.ptr<!s32i> // CIR-NEXT: %[[I_PTR:.*]] = cir.alloca "i" align(4) init : !cir.ptr<!s32i> // CIR-NEXT: %[[THREE:.*]] = cir.const #cir.int<3> : !s32i // CIR-NEXT: cir.store{{.*}} %[[THREE]], %[[I_PTR]] : !s32i, !cir.ptr<!s32i> @@ -170,7 +170,7 @@ int f6(void) { } // CIR: cir.func{{.*}} @f6() -> !s32i -// CIR-NEXT: %[[RV:.*]] = cir.alloca "__retval" align(4) : !cir.ptr<!s32i> +// CIR-NEXT: %[[RV:.*]] = cir.alloca "" align(4) return_slot : !cir.ptr<!s32i> // CIR-NEXT: %[[GV_PTR:.*]] = cir.get_global @gv : !cir.ptr<!s32i> // CIR-NEXT: %[[GV:.*]] = cir.load{{.*}} %[[GV_PTR]] : !cir.ptr<!s32i>, !s32i // CIR-NEXT: cir.store{{.*}} %[[GV]], %[[RV]] : !s32i, !cir.ptr<!s32i> diff --git a/clang/test/CIR/CodeGen/basic.cpp b/clang/test/CIR/CodeGen/basic.cpp index d69a018caee3b0..f41e143ea79595 100644 --- a/clang/test/CIR/CodeGen/basic.cpp +++ b/clang/test/CIR/CodeGen/basic.cpp @@ -32,7 +32,7 @@ int f1() { } // CHECK: cir.func{{.*}} @_Z2f1v() -> (!s32i {{.*}}) -// CHECK: %[[RV:.*]] = cir.alloca "__retval" align(4) : !cir.ptr<!s32i> +// CHECK: %[[RV:.*]] = cir.alloca "" align(4) return_slot : !cir.ptr<!s32i> // CHECK: %[[I_PTR:.*]] = cir.alloca "i" align(4) : !cir.ptr<!s32i> // CHECK: %[[I:.*]] = cir.load{{.*}} %[[I_PTR]] : !cir.ptr<!s32i>, !s32i // CHECK: cir.store{{.*}} %[[I]], %[[RV]] : !s32i, !cir.ptr<!s32i> @@ -45,7 +45,7 @@ int f2() { } // CHECK: cir.func{{.*}} @_Z2f2v() -> (!s32i {{.*}}) -// CHECK: %[[RV:.*]] = cir.alloca "__retval" align(4) : !cir.ptr<!s32i> +// CHECK: %[[RV:.*]] = cir.alloca "" align(4) return_slot : !cir.ptr<!s32i> // CHECK: %[[I_PTR:.*]] = cir.alloca "i" align(4) init const : !cir.ptr<!s32i> // CHECK: %[[TWO:.*]] = cir.const #cir.int<2> : !s32i // CHECK: cir.store{{.*}} %[[TWO]], %[[I_PTR]] : !s32i, !cir.ptr<!s32i> @@ -59,7 +59,7 @@ int f3(int i) { } // CHECK: cir.func{{.*}} @_Z2f3i(%[[ARG:.*]]: !s32i {{.*}} loc({{.*}})) -> (!s32i {{.*}}) -// CHECK: %[[RV:.*]] = cir.alloca "__retval" align(4) : !cir.ptr<!s32i> +// CHECK: %[[RV:.*]] = cir.alloca "" align(4) return_slot : !cir.ptr<!s32i> // CHECK: %[[ARG_ALLOCA:.*]] = cir.alloca "i" align(4) init : !cir.ptr<!s32i> // CHECK: cir.store{{.*}} %[[ARG]], %[[ARG_ALLOCA]] : !s32i, !cir.ptr<!s32i> // CHECK: %[[ARG_VAL:.*]] = cir.load{{.*}} %[[ARG_ALLOCA]] : !cir.ptr<!s32i>, !s32i @@ -72,7 +72,7 @@ int f4(const int i) { } // CHECK: cir.func{{.*}} @_Z2f4i(%[[ARG:.*]]: !s32i {{.*}} loc({{.*}})) -> (!s32i {{.*}}) -// CHECK: %[[RV:.*]] = cir.alloca "__retval" align(4) : !cir.ptr<!s32i> +// CHECK: %[[RV:.*]] = cir.alloca "" align(4) return_slot : !cir.ptr<!s32i> // CHECK: %[[ARG_ALLOCA:.*]] = cir.alloca "i" align(4) init const : !cir.ptr<!s32i> // CHECK: cir.store{{.*}} %[[ARG]], %[[ARG_ALLOCA]] : !s32i, !cir.ptr<!s32i> // CHECK: %[[ARG_VAL:.*]] = cir.load{{.*}} %[[ARG_ALLOCA]] : !cir.ptr<!s32i>, !s32i @@ -92,7 +92,7 @@ int *f5() { } // CHECK: cir.func{{.*}} @_Z2f5v() -> (!cir.ptr<!s32i> {{.*}}) -// CHECK-NEXT: %[[RET_ADDR:.*]] = cir.alloca "__retval" align(8) : !cir.ptr<!cir.ptr<!s32i>> +// CHECK-NEXT: %[[RET_ADDR:.*]] = cir.alloca "" align(8) return_slot : !cir.ptr<!cir.ptr<!s32i>> // CHECK-NEXT: %[[P_ADDR:.*]] = cir.alloca "p" align(8) init : !cir.ptr<!cir.ptr<!s32i>> // CHECK-NEXT: %[[NULLPTR:.*]] = cir.const #cir.ptr<null> : !cir.ptr<!s32i> // CHECK-NEXT: cir.store{{.*}} %[[NULLPTR]], %[[P_ADDR]] : !cir.ptr<!s32i>, !cir.ptr<!cir.ptr<!s32i>> @@ -148,7 +148,7 @@ short &return_ref() { } // CHECK: cir.func{{.*}} @_Z10return_refv() -> (!cir.ptr<!s16i> {{.*}}) -// CHECK: %[[RETVAL_ADDR:.*]] = cir.alloca "__retval" align(8) : !cir.ptr<!cir.ptr<!s16i>> +// CHECK: %[[RETVAL_ADDR:.*]] = cir.alloca "" align(8) return_slot : !cir.ptr<!cir.ptr<!s16i>> // CHECK: %[[GS_ADDR:.*]] = cir.get_global @gs : !cir.ptr<!s16i> // CHECK: cir.store{{.*}} %[[GS_ADDR]], %[[RETVAL_ADDR]] : !cir.ptr<!s16i>, !cir.ptr<!cir.ptr<!s16i>> // CHECK: %[[RETVAL:.*]] = cir.load{{.*}} %[[RETVAL_ADDR]] : !cir.ptr<!cir.ptr<!s16i>>, !cir.ptr<!s16i> diff --git a/clang/test/CIR/CodeGen/binassign.c b/clang/test/CIR/CodeGen/binassign.c index fdf2598f0b9fed..1bbe6b0b015efe 100644 --- a/clang/test/CIR/CodeGen/binassign.c +++ b/clang/test/CIR/CodeGen/binassign.c @@ -112,7 +112,7 @@ int ignore_result_assign() { } // CIR-LABEL: cir.func{{.*}} @ignore_result_assign() -> !s32i -// CIR: %[[RETVAL:.*]] = cir.alloca "__retval" {{.*}} : !cir.ptr<!s32i> +// CIR: %[[RETVAL:.*]] = cir.alloca "" {{.*}} return_slot : !cir.ptr<!s32i> // CIR: %[[ARR:.*]] = cir.alloca "arr" {{.*}} : !cir.ptr<!cir.array<!s32i x 10>> // CIR: %[[I:.*]] = cir.alloca "i" {{.*}} : !cir.ptr<!s32i> // CIR: %[[J:.*]] = cir.alloca "j" {{.*}} : !cir.ptr<!s32i> diff --git a/clang/test/CIR/CodeGen/bind-temporary-lvalue.cpp b/clang/test/CIR/CodeGen/bind-temporary-lvalue.cpp index 44893f3f9cab07..374c435e9b2d7f 100644 --- a/clang/test/CIR/CodeGen/bind-temporary-lvalue.cpp +++ b/clang/test/CIR/CodeGen/bind-temporary-lvalue.cpp @@ -15,7... [truncated] `````````` </details> https://github.com/llvm/llvm-project/pull/244192 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
