aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/CIR/CodeGen/CIRGenModule.cpp
AgeCommit message (Collapse)AuthorFilesLines
30 hours[CIR] Set the module name to the input filename (#160934)Andy Kaylor1-0/+13
This sets the MLIR module name to the main filename (according to the SourceManager), if one is available. The module name gets used when creating global init functions, so we will need it to be set.
2025-09-04[CIR] Add constant record ILE support (#155663)Morris Hafner1-0/+3
This patch adds basic support for constant record initializer list expressions. There's a couple of limitations: * No zero initialized padding bytes in C mode * No bitfields * No designated initializer lists * Record alignments are not calculated, yet * ILEs of derived records don't work, yet * The constant attribute is not propagated to the backend, resulting in non-constants being emitted in the LLVM IR
2025-09-03[CIR] Add support for constructors with VTT parameters (#156521)Andy Kaylor1-4/+11
This adds the support for implicit VTT arguments in constructors.
2025-08-26[clang] NFC: introduce Type::getAsEnumDecl, and cast variants for all ↵Matheus Izvekov1-4/+1
TagDecls (#155463) And make use of those. These changes are split from prior PR #155028, in order to decrease the size of that PR and facilitate review.
2025-08-25[clang] NFC: change more places to use Type::getAsTagDecl and friends (#155313)Matheus Izvekov1-2/+1
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-22[CIR][NFC] Fix build warning in getCIRSourceLanguage (#155029)Andy Kaylor1-4/+7
The getCIRSourceLanguage wasn't returning a value if the source language was anything other than C or C++. This change updates that function to return a std::optional value and only adds the source language attribute if one was returned.
2025-08-22[CIR] Add support for emitting vtables (#154808)Andy Kaylor1-1/+13
This adds a simplified version of the code to emit vtables. It does not yet handle RTTI or cases that require multiple vtables.
2025-08-21[CIR][Dialect] Add SourceLangAttr (#152511)7mile1-0/+20
This patch upstreams `SourceLangAttr` and its CodeGen logic in the CGM, which encodes the source language in CIR.
2025-08-20[CIR] Add support for string literal lvalues in ConstantLValueEmitter (#154514)Morris Hafner1-0/+13
2025-08-20[CIR] Add constant attribute to GlobalOp (#154359)Morris Hafner1-5/+5
This patch adds the constant attribute to cir.global, the appropriate lowering to LLVM constant and updates the tests. --------- Co-authored-by: Andy Kaylor <akaylor@nvidia.com>
2025-08-13[CIR} Add support for static member variable instantiation (#153200)Morris Hafner1-0/+14
This patch handles both implicit and explicit template instantiations of template class static member variables.
2025-08-12[CIR] Introduce the CIR global_view attribute (#153044)Andy Kaylor1-0/+10
This change introduces the #cir.global_view attribute and adds support for using that attribute to handle initializing a global variable with the address of another global variable. This does not yet include support for the optional list of indices to get an offset from the base address. Those will be added in a follow-up patch.
2025-08-12[CIR] Initialize vptr in dynamic classes (#152574)Andy Kaylor1-1/+44
This adds support for initializing the vptr member of a dynamic class in the constructor of that class. This does not include support for lowering the `cir.vtable.address_point` operation to the LLVM dialect. That handling will be added in a follow-up patch.
2025-08-09[CIR] Fix build after the improved nested name specifier AST repr (91cdd35008e9)Michael Liao1-3/+5
2025-08-07[CIR] add support for file scope assembly (#152093)gitoleg1-0/+18
This PR adds a support for file scope assembly in CIR.
2025-08-06[CIR] Upstream support for variable template specializations (#151069)Morris Hafner1-1/+4
2025-07-31[CIR] Fix warnings related to unused variables in release builds (#151412)Andy Kaylor1-3/+1
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] Upstream support for function-level variable decompositions (#151073)Morris Hafner1-1/+6
This implements support for structured bindings on a function scope level. It does not add support for global structured bindings.
2025-07-31[CIR] Support more declarations without any codegen (#151076)Morris Hafner1-1/+7
This patch adds or completes support for a couple of top level declaration types that don't emit any code: Most notably these include Concepts, static_assert and type aliases.
2025-07-30[CIR] Add support for C++ conversion operators (#151066)Morris Hafner1-0/+1
This fairly simple addition enables codegen for C++ conversion operators
2025-07-29[Clang][Cygwin] Enable few conditions that are shared with MinGW (#149637)jeremyd20191-4/+4
The Cygwin target is generally very similar to the MinGW target. The default auto-import behavior, the default calling convention, the `.dll.a` import library extension, the `__GXX_TYPEINFO_EQUALITY_INLINE` pre-define by `g++`, and the long double configuration. Co-authored-by: Mateusz Mikuła <oss@mateuszmikula.dev>
2025-07-29[CIR] Add proper handling for no prototype function calls (#150553)Andy Kaylor1-3/+82
This adds standard-comforming handling for calls to functions that were declared in C source in the no prototype form.
2025-07-28[CIR] Implement LValueBitcast for ComplexType (#150668)Amr Hesham1-0/+9
This change adds support for LValueBitcast for ComplexType https://github.com/llvm/llvm-project/issues/141365
2025-07-14[CIR] Add Minimal Destructor Definition Support (#144719)Morris Hafner1-6/+22
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-07-10[CIR] Add handlers for 'using enum' and namespace alias (#148011)Andy Kaylor1-0/+2
These decl types don't require any code generation, though when debug info is implemented, we will need to add handling for that. Until then, we just need to have a handler so they don't generate an NYI error.
2025-07-02[CIR] Add OptInfo attribute (#146261)Sirui Mu1-0/+6
This patch adds the `#cir.opt_info` attribute which holds module-level optimization information.
2025-06-27[CIR] Upstream support for operator assign (#145979)Andy Kaylor1-6/+0
This adds support for assignment operators, including implicit operator definitions.
2025-06-27[CIR] Add basic support for operator new (#145802)Andy Kaylor1-0/+1
This adds the code to handle operator new expressions in ClangIR.
2025-06-27[CIR] Add support for constructor aliases (#145792)Andy Kaylor1-0/+100
This change adds support for handling the -mconstructor-aliases option in CIR. Aliases are not yet correctly lowered to LLVM IR. That will be implemented in a future change.
2025-06-26[CIR][NFC] Fix an unused variable warning (#145922)Amr Hesham1-3/+3
This fixes a warning where a variable assigned in 'if' statement wasn't referenced again.
2025-06-25[CIR] Add support for function linkage and visibility (#145600)Andy Kaylor1-5/+77
This change adds support for function linkage and visibility and related attributes. Most of the test changes are generalizations to allow 'dso_local' to be accepted where we aren't specifically testing for it. Some tests based on CIR inputs have been updated to add 'private' to function declarations where required by newly supported interfaces. The dso-local.c test has been updated to add specific tests for dso_local being set correctly, and a new test, func-linkage.cpp tests other linkage settings. This change sets `comdat` correctly in CIR, but it is not yet applied to functions when lowering to LLVM IR. That will be handled in a later change.
2025-06-24[CIR] Add support for member initialization from constructors (#144583)Andy Kaylor1-0/+4
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-12[CIR] Upstream support for emitting constructors (#143639)Andy Kaylor1-6/+9
This change upstreams the code to emit simple constructor defintions.
2025-06-10[CIR] Upstream support for calling constructors (#143579)Andy Kaylor1-2/+52
This change adds support for calling C++ constructors. The support for actually defining a constructor is still missing and will be added in a later change.
2025-06-09[CIR] Add support for accessing members of base classes (#143195)Andy Kaylor1-0/+28
This change adds the support for accessing a member of a base class from a derived class object.
2025-06-06[CIR] Add support for completing forward-declared types (#143176)Andy Kaylor1-0/+6
This adds the needed handling for completing record types which were previously declared leading us to create an incomplete record type.
2025-06-05[CIR] Add decl case for template specialization (#143029)Andy Kaylor1-1/+6
This change adds the switch case to allow template specialization to pass through emitTopLevelDecl without issuing an error.
2025-06-05[CIR] Add empty handlers for Using and UsingShadow decls (#143032)Andy Kaylor1-0/+5
This adds emitTopLevelDecl "handlers" for Using and UsingShadow. These don't actually need any handling, but they need to be present in the switch to avoid hitting the default handler, which issues a diagnostic about the decl kind not being implemented. There are several other decl kinds that don't need any handling. Those will be added when I have test cases for them.
2025-06-05[CIR] Defer emitting function definitions (#142862)Andy Kaylor1-9/+59
This change implements deferring function definition emission until first use.
2025-06-04[CIR] Defer definitions of global variables until they are used. (#142496)Andy Kaylor1-3/+215
This change adds support for deferring global variable definitions until first use whenever it is possible to do so. Although deferring function definitions uses much of the same implementation, function deferral will be added in a follow-up change.
2025-06-02[CIR] Support inline C++ member function definitions (#142484)Andy Kaylor1-8/+0
This change upstreams the code to support emitting inline C++ function definitions, including the ASTConsumer handler for inline definitions and the code to load the 'this' pointer. This necessitates introducing the Itanium CXXABI class. No other CXXABI subclasses are supported at this time. The Itanium CXXABI is used for AppleARM64, which will require its own handler for a few special cases (such as array cookies) later.
2025-06-02[CIR] Fix dso_local and comdat handling for global vars (#142214)Andy Kaylor1-9/+55
This change adds extra processing of global variable definitions to correctly set the dso_local and comdat attributes.
2025-05-30[CIR] Add support for global linkage and visibility (#141973)Andy Kaylor1-13/+204
This change adds support for the CIRGlobalValueInterface and attributes for visibility and comdat to GlobalOp. The comdat attribute isn't correctly calculated yet, but it was required for the CIRGlobalValueInterface interface. There are also some cases where dso_local isn't set correctly, but it is better than it was before this change. Those issues will be addressed in a future patch.
2025-05-28[CIR] Defer declarations and tentative definitions (#141700)Andy Kaylor1-15/+46
This change adds code to defer emitting declarations and tentative definitions until they are referenced or trigger by a call to CompleteTentativeDefinition. This is needed to avoid premature handling of declarations and definitions that might not be referenced in the current translation unit. It also avoids incorrectly adding an initializer to external declarations. This change also updates the way the insertion location for globals is chosen so that all globals will be emitted together at the top of the module. This makes no functional difference, but it is very useful for writing sensible tests. Some tests are modified in this change to reorder global variables so that they can be checked in the order in which they will be emitted.
2025-05-23[CIR] Add alignment support for global, store, and load ops (#141163)Andy Kaylor1-5/+42
This adds alignment support for GlobalOp, LoadOp, and StoreOp. Tests which failed because cir.store/cir.load now print alignment were updated with wildcard matches, except where the alignment was relevant to the test. Tests which check for cir.store/cir.load in cases that don't have explicit alignment were not updated. New tests for alignment are alignment.c, align-load.c, and align-store.c.
2025-05-21[CIR] Upstream support for string literals (#140796)Andy Kaylor1-0/+102
This adds the minimal support needed to handle string literals.
2025-05-19[CIR] Upstream support for C++ member function calls (#140290)Andy Kaylor1-4/+11
This change adds the support needed to handle a C++ member function call, including arranging the function type with an argument added for the 'this' parameter. It was necessary to introduce the class to handle the CXXABI, but at this time no target-specific subclasses have been added.
2025-05-16[CIR][NFC] Use arrangeFunctionDeclaration to build function types (#139787)Andy Kaylor1-15/+2
This change replaces the simplified call that we were previously using to convert the function type provided by a global declaration to the CIR function type. We now go through 'arrangeGlobalDeclaration' which builds the function type in a more complicated manner. This change has no observable differences for the currently upstreamed CIR support, but it is necessary to prepare for C++ member function calls, which require the extra handling.
2025-05-13[CIR] Cleanup support for C functions (#136854)Iris Shi1-2/+17
This adds basic handling for non-prototype functions in C. Closes #130200.
2025-05-11[CIR] Upstream enum support (#136807)Ankur Ahir1-1/+1