summaryrefslogtreecommitdiff
path: root/clang/lib/CIR/CodeGen/CIRGenFunction.cpp
AgeCommit message (Collapse)Author
2025-11-21Revert "Reland [MS][clang] Add support for vector deleting destructors" ↵Zequan Wu
(#169116) This reverts 4d10c1165442cbbbc0017b48fcdd7dae1ccf3678 and its two dependent commits: e6b9805b574bb5c90263ec7fbcb94df76d2807a4 and c243406a695ca056a07ef4064b0f9feee7685320, see discussion in https://github.com/llvm/llvm-project/pull/165598#issuecomment-3563825509.
2025-11-19[CIR] Add CxxCTorAttr, CxxDTorAttr, CxxAssignAttr, CxxSpecialMemberAttr to ↵Hendrik Hübner
cir::FuncOp (#167975) This PR adds a special member attribute to `cir::FuncOp`. This attribute is also present in the incubator repo. Additionally, I added a "is_trivial" flag, to mark trivial members. I think that might be useful when trying to replace calls to the copy constructor with memcpy for example, but please let me know your thoughts on this. [Here in the incubator repo](https://github.com/llvm/clangir/blob/823e943d1b9aaba0fc46f880c5a6ac8c29fc761d/clang/lib/CIR/Dialect/Transforms/LoweringPrepare.cpp#L1537-L1550) this function is called `LowerTrivialConstructorCall`, but I don't see a check that ensures the constructor is actually trivial.
2025-11-16[CIR] Upstream non-empty Try block with catch all (#165158)Amr Hesham
Upstream support for try block and catch all block with a function call that may throw an exception. Issue https://github.com/llvm/llvm-project/issues/154992
2025-11-14[CIR] Upstream handling for C++ default argument l-values (#167999)Andy Kaylor
This adds handling emitting C++ default arguments as l-values.
2025-11-13[CIR] Upstream l-value emission for ExprWithCleanups (#167938)Andy Kaylor
This adds the necessary handler for emitting an l-value for an ExprWithCleanups expression.
2025-11-13[CIR][NFC] Add missing code markers for Dtor_VectorDeleting (#167969)Andy Kaylor
This adds some minimal code to mark locations where handling is needed for Dtor_VectorDeleting type dtors, which were added in https://github.com/llvm/llvm-project/pull/165598 This is not a comprehensive mark-up of the missing code, as some code will be needed in places where the surrounding function has larger missing pieces in CIR currently. This fixes a warning for an uncovered switch case that was causing CI builds to fail.
2025-11-13[CIR] Upstream basic support for ExtVector element expr (#167570)Amr Hesham
Upstream the basic support for the ExtVectorType element expr
2025-11-12[CIR] Emit promise declaration in coroutine (#166683)Andres-Salamanca
This PR adds support for emitting the promise declaration in coroutines and obtaining the `get_return_object()`.
2025-10-31[CIR] Fix multiple returns in switch statements (#164468)Morris Hafner
Add support for multiple return statements in switch statements. Cases in switch statements don't have their own scopes but are distinct regions nonetheless. Insert multiple return blocks for each case and handle them in the cleanup code.
2025-10-28[CIR][NFC] Update TypeCache file to use MLIR-style camel case (#165060)Andres-Salamanca
This PR updates the file `CIRGenTypeCache` to use MLIR-style camel case naming.The change was inspired by the discussion here: https://github.com/llvm/llvm-project/pull/164180#discussion_r2461444730
2025-10-22[clang][CIR][mlir] Migrate to free create functions. NFC. (#164656)Jakub Kuderski
See https://discourse.llvm.org/t/psa-opty-create-now-with-100-more-tab-complete/87339. I plan to make these deprecated in https://github.com/llvm/llvm-project/pull/164649.
2025-10-22[CIR] Implement inline builtin functions (#163911)Morris Hafner
This patch implements the handling of inline builtin functions in CIR. There is a known limitation in CIR where direct calls to shadowed inline builtin functions are generated instead of the intrinsic. This is expected to be fixed by the introduction of the nobuiltin attribute in a future patch.
2025-10-21[CIR] Add support for ternary operator as lvalue (#163580)Morris Hafner
Added support for ConditionalOperator, BinaryConditionalOperator and OpaqueValueExpr as lvalue. Implemented support for ternary operators with one branch being a throw expression. This required weakening the requirement that the true and false regions of the ternary operator must terminate with a `YieldOp`. Instead the true and false regions are now allowed to terminate with an `UnreachableOp` and no `YieldOp` gets emitted when the block throws.
2025-10-15[CIR] Upstream support for variable length arrays (#163297)Andy Kaylor
This adds the code needed to emit alloca operations for variable length array local variables and the necessary calls to stacksave and stackrestore to adjust the local stack as the array variables go in an out of scope.
2025-10-13[CIR] Add support for virtual destructor calls (#162725)Andy Kaylor
This adds support for calling virtual destructors.
2025-10-08[CIR] Add support for destructing class members (#162196)Andy Kaylor
This adds the necessary cleanup handling to get class destructors to call the destructor for fields that require it.
2025-10-03[CIR] Initial support for emitting coroutine body (#161616)Andres-Salamanca
This PR adds new `FuncOp` attributes (`coroutine` and `builtin`) and begins the implementation of the `emitCoroutineBody` function. Feature markers were also added for guidance in future PRs.
2025-10-03[CIR] Add support for emitting predefined expressions (#161757)Andy Kaylor
This adds support for emitting pseudo-macro expressions that represent some form of the name of a function (such as `__func__` or `__PRETTY_FUNCTION__`) as l-values.
2025-10-01[CIR] Implement GenericSelectionExpr for AggregateExpr (#161003)Amr Hesham
Implement the GenericSelectionExpr for AggregateExpr
2025-09-30[CIR] Upstream support for generating global ctor regions (#161298)Andy Kaylor
This adds support for handling global variables with non-trivial constructors. The constructor call is emitted in CIR as a 'ctor' region associated with the global definition. This form of global definition cannot be lowered to LLVM IR yet. A later change will add support in LoweringPrepare to move the ctor code into a __cxx_global_var_init() function and add that function to the list of global global ctors, but for now we must stop at the initial CIR generation.
2025-09-30[CIR] Implement ChooseExpr for AggregateExpr (#160999)Amr Hesham
Implement the ChooseExpr for aggregate expr
2025-09-23[CIR] Implement static lambda invoker (#160137)Andy Kaylor
This adds support for handling static lambda invokers.
2025-09-22[CIR] Add support for lambda expressions (#157751)Andy Kaylor
This adds support for lambda operators and lambda calls. This does not include support for static lambda invoke, which will be added in a later change.
2025-09-09[CIR] Add support for copy elision (#157713)Andy Kaylor
This adds basic support for eliding copy constructors. In order to make this possible, it also adds support for returning structures. This support does not include setting an NRVO flag when the class whose copy is being elided has a non-trivial destructor.
2025-09-09[CIR][NFC] Fix build warnings after #154142 (#157724)Andy Kaylor
A recent change introduced a new dtor kind, which caused a build warning in the CIR code where this dtor kind wasn't handled in a switch. This fixes the problem.
2025-09-03[CIR] Add support for constructors with VTT parameters (#156521)Andy Kaylor
This adds the support for implicit VTT arguments in constructors.
2025-08-25[clang] NFC: change more places to use Type::getAsTagDecl and friends (#155313)Matheus Izvekov
This changes a bunch of places which use getAs<TagType>, including derived types, just to obtain the tag definition. This is preparation for #155028, offloading all the changes that PR used to introduce which don't depend on any new helpers.
2025-08-19[CIR] Implement Statement Expressions (#153677)Morris Hafner
Depends on #153625 This patch adds support for statement expressions. It also changes emitCompoundStmt and emitCompoundStmtWithoutScope to accept an Address that the optional result is written to. This allows the creation of the alloca ahead of the creation of the scope which saves us from hoisting the alloca to its parent scope.
2025-08-19[CIR] Upstream __builtin_va_start and __builtin_va_end (#153819)Morris Hafner
Part of #153286
2025-08-14[CIR][NFC] Add Symbol Table to CIRGenFunction (#153625)Morris Hafner
This patchs adds a symbol table to CIRGenFunction plus scopes and insertions to the table where we were missing them previously.
2025-08-11[CIR] Make ClangIR compatible with latest nested name specifier AST ↵Amr Hesham
representation (#152846) After AST representation, new modifications landed in (https://github.com/llvm/llvm-project/pull/147835). ClangIR requires some changes in how we use Clang AST to be compatible with the new changes
2025-08-10[CIR] Add support for __builtin_assume_aligned (#152152)Sirui Mu
This patch upstreams CIRGen and LLVM lowering support for the `__builtin_assume_aligned` builtin function.
2025-08-09[CIR] Fix build after the improved nested name specifier AST repr (91cdd35008e9)Michael Liao
2025-08-07[CIR] Upstream EHScopeStack memory allocator (#152215)Andy Kaylor
When the cleanup handling code was initially upstreamed, a SmallVector was used to simplify the handling of the stack of cleanup objects. However, that mechanism won't scale well enough for the rate at which cleanup handlers are going to be pushed and popped while compiling a large program. This change introduces the custom memory allocator which is used in classic codegen and the CIR incubator. Thiis does not otherwise change the cleanup handling implementation and many parts of the infrastructure are still missing. This is not intended to have any observable effect on the generated CIR, but it does change the internal implementation significantly, so it's not exactly an NFC change. The functionality is covered by existing tests.
2025-08-06[CIR] Plus & Minus CompoundAssignment support for ComplexType (#150759)Amr Hesham
This change adds support for Plus & Minus CompoundAssignment for ComplexType https://github.com/llvm/llvm-project/issues/141365
2025-08-05[CIR] Add CIRGen for cir.unreachable and cir.trap (#151363)Sirui Mu
2025-08-02[CIR] Use getDefiningOp<OpTy>() instead of dyn_cast<OpTy>(getDefiningOp()) ↵Henrich Lauko
(NFC) (#151217) This applies similar changes to llvm/llvm-project#150428
2025-08-01[CIR] Handle expression with cleanups (#151600)Andy Kaylor
This adds code to handle expressions with cleanup, including materializing a temporary object for the expression.
2025-07-31[CIR] Fix warnings related to unused variables in release builds (#151412)Andy Kaylor
This fixes a number of warnings in release builds due to variables that were only being used in asserts. Some of these variables will later be used in non-debug code, but for now they are unused in release builds.
2025-07-31[CIR] Fix fallthrough warning (#151418)Andy Kaylor
This fixes a warning about an unannotated fallthrough.
2025-07-28[CIR] Implement LValueBitcast for ComplexType (#150668)Amr Hesham
This change adds support for LValueBitcast for ComplexType https://github.com/llvm/llvm-project/issues/141365
2025-07-24[CIR] Add support for normal cleanups (#149948)Andy Kaylor
This change adds basic handling for normal cleanups. This is a very minimal implemention. In particular, it uses a naive substitute for the rich cleanup and EH stack handling that is present in classic codegen and the CIR incubator. This is intended as a temporary implementation to allow incremental progress. It is not expected to scale well enough to be used in a production environment. It will be replaced with the full EHScopeStack handling when such an implementation is needed.
2025-07-24[CIR] Add support for array constructors (#149142)Morris Hafner
This patch upstreams support for creating arrays of classes that require calling a constructor. * Adds the ArrayCtor operation * New lowering pass for lowering ArrayCtor to a loop --------- Co-authored-by: Andy Kaylor <akaylor@nvidia.com> Co-authored-by: Henrich Lauko <xlauko@mail.muni.cz>
2025-07-21[CIR] Add complete destructor handling (#149552)Andy Kaylor
The initial implementation for emitting destructors emitted the complete destructor body for both D1 and D2 destructors. This change updates the code to have the D1 destructor call the D2 destructor.
2025-07-19[CIR] Upstream CompoundLiteralExpr for Scalar (#148943)Amr Hesham
Upstream CompoundLiteralExpr for Scalar as a prerequisite for CompoundLiteralExpr for ComplexType
2025-07-14[CIR] Add Minimal Destructor Definition Support (#144719)Morris Hafner
This patch upstreams support for writing inline and out of line C++ destructor definitions. Calling a destructor implcitly or explicitly is left for a future patch. Because of that restriction complete destructors (D2 in Itanium mangling) do not call into the base (D1) destructors yet but simply behave like a base destructor. Deleting (D0) destructor support is not part of this patch. Destructor aliases aren't supported, either. Because of this compilation with -mno-constructor-aliases may be required to avoid running into NYI errors.
2025-06-27[CIR] Upstream support for operator assign (#145979)Andy Kaylor
This adds support for assignment operators, including implicit operator definitions.
2025-06-24[CIR] Add support for member initialization from constructors (#144583)Andy Kaylor
Upstream the code to handle member variable initialization in a constructor. At this point only simple scalar values (including members of anonymous unions) are handled.
2025-06-13[CIR] Function calls with aggregate arguments and return values (#143377)Sirui Mu
This patch updates cir.call operation and allows function calls with aggregate arguments and return values. It seems that C++ class support is still at a minimum now. I tried to make a call to a C++ function with an argument of aggregate type but it failed because the initialization of C++ class / struct is NYI. I also tried to inline this part of support into this patch, but the mixed patch quickly blows in size and becomes unsuitable for review. Thus, tests for calling functions with aggregate arguments are added only for C for now.
2025-06-12[CIR] Add support for delegating constructors (#143932)Andy Kaylor
This change adds the necessary support for handling delegating constructors in ClangIR. The implementation is kept as small as possible by not handling any other sort of initialization (members, base classes, etc.). That will be added in a future commit.