13 Commits

Author SHA1 Message Date
Sirui Mu
7b8189aab8
[CIR] Add CIRGen for pseudo destructor calls (#153014) 2025-08-13 09:21:40 +08:00
Sirui Mu
23104a74e7
[CIR] Add nothrow attribute to the call operation (#145178)
This patch adds extra function attributes to the `cir.call` operation.
The extra attributes now may contain a single `cir.nothrow` attribute
that indicates whether the callee throws.
2025-07-03 22:54:15 +08:00
Andy Kaylor
1e45ea12db
[CIR] Add support for function linkage and visibility (#145600)
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-25 10:59:30 -07:00
Sirui Mu
8ba62fdb3d
[CIR] Function calls with aggregate arguments and return values (#143377)
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-13 16:47:56 +08:00
Sirui Mu
628a3f0a48
[CIR] Call to variadic functions (#141942) 2025-05-31 09:59:41 +08:00
Andy Kaylor
ea3c225786
[CIR] Add alignment support for global, store, and load ops (#141163)
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-23 15:34:59 -07:00
Sirui Mu
838ddc28f2
[CIR] Add support for indirect calls (#139748)
This PR adds support for indirect calls to the `cir.call` operation.
2025-05-20 18:11:19 +08:00
Sirui Mu
806b491401
[CIR] LLVMIR lowering for cir.call (#138873) 2025-05-09 21:16:29 +08:00
Sirui Mu
44c4b4cef9
[CIR] Upstream cir.call with scalar arguments (#136810)
This PR upstreams support for scalar arguments in `cir.call` operation.

Related to #132487 .
2025-05-02 10:04:48 +08:00
Andy Kaylor
8b98612910
[CIR] Fix calling defined functions (#137271)
Until now our function symbol lookup has been assuming that the function
did not exist and creating a definition for it. This caused us to create
a duplicate definition if we ever tried to call a function that was
already defined.

This change fixes that by adding handling for trying to look up existing
global definitions before creating a new one.
2025-04-25 12:08:52 -07:00
Andy Kaylor
7d71164855
[CIR] Upstream support for name mangling (#137094)
We have been using the default names for global symbols to this point.
This change introduces proper name mangling for functions.

This requires introducing a CXXABI class in the CIRGenModule. Because
only target independent name mangling is handled in this patch, the
CXXABI class does not require a target-specific implementation. The
general mechanism for selecting an implementation is introduced here,
but the actual target-specific subclasses are deferred until needed.
2025-04-24 14:24:19 -07:00
Sirui Mu
78857e7263
[CIR] cir.call with scalar return type (#135552)
This PR introduces support for calling functions with a scalar return
type to the upstream. This PR also includes an initial version of
`CIRGenTargetInfo` and related definitions which are essential for the
CIRGen of call ops.

Related to #132487 .
2025-04-17 22:38:37 +08:00
Sirui Mu
85614e160b
[CIR] Upstream initial function call support (#134673)
This patch upstreams initial support for making function calls in CIR.
Function arguments and return values are not included to keep the patch
small for review.

Related to #132487
2025-04-10 22:41:00 +08:00