980 Commits

Author SHA1 Message Date
Alan
7833107993
[OCaml] Make OCaml MetadataKind type consistent with C API (#134507)
Fixes breakage of OCaml API introduced by commit 6894734.
2025-04-05 18:21:38 -04:00
Tom Tromey
68947342b7
Add support for fixed-point types (#129596)
This adds DWARF generation for fixed-point types. This feature is needed
by Ada.

Note that a pre-existing GNU extension is used in one case. This has
been emitted by GCC for years, and is needed because standard DWARF is
otherwise incapable of representing these types.
2025-03-31 07:42:21 -07:00
Alan
b32cf75699
[LLVM-C][OCaml] Make LLVMMetadataKind consistent between C and OCaml (#132268)
- Move LLVMDISubrangeTypeMetadataKind to end of LLVMMetadataKind enum.
Inserting a new enum constant in the middle of the enum breaks the ABI for
that enum. Commit e298fc2 introduced this issue, which was revealed because
the OCaml binding tests failed.
- Bring OCaml bindings up to date with LLVMMetadataKind enum.
2025-03-23 21:20:56 -04:00
Mike Aizatsky
750e716ef0
[capi][nfc] Reference Function::getFunctionType in LLVMGlobalGetValueType (#132102) 2025-03-20 11:19:19 +01:00
Tom Tromey
e298fc2da9
Add DISubrangeType (#126772)
An Ada program can have types that are subranges of other types. This
patch adds a new DIType node, DISubrangeType, to represent this concept.
    
I considered extending the existing DISubrange to do this, but as
DISubrange does not derive from DIType, that approach seemed more
disruptive.
    
A DISubrangeType can be used both as an ordinary type, but also as the
type of an array index. This is also important for Ada.

Ada subrange types can also be stored using a bias. Representing this in
the DWARF required the use of an extension. GCC has been emitting this
extension for years, so I've reused it here.
2025-02-24 10:11:53 -08:00
Nikita Popov
d8b2e432d6
[IR] Remove mul constant expression (#127046)
Remove support for the mul constant expression, which has previously
already been marked as undesirable. This removes the APIs to create mul
expressions and updates tests to stop using mul expressions.

Part of:
https://discourse.llvm.org/t/rfc-remove-most-constant-expressions/63179
2025-02-14 09:28:57 +01:00
Vladimir Kozelkov
2cac0bf8fe
Remove unused LLVMLandingPadClauseTy from Core.h (#124472)
enum LLVMLandingPadClauseTy has never been used and exists by mistake.

[This](772fe17a6d (diff-9e2da57026497163c9f7396a48567626a0b94828a5757436ef20a4e67522525d)) commit added a LLVMAddClause function that took it as a parameter. 

[Here](10c6d12a9f (diff-6e588c82c378e251a7d265b08973d4a7312a592756f88023cd317f109083de10)) the enum was removed.

And [here](e6e8826870 (diff-9e2da57026497163c9f7396a48567626a0b94828a5757436ef20a4e67522525d)) it is added again by mistake, although the LLVMAddClause function no longer accepts it
2025-02-02 17:18:07 +00:00
Michael Buch
a5fb2bbb2a Reapply "[clang][DebugInfo] Emit DW_AT_object_pointer on function declarations with explicit this" (#123455)
This reverts commit c3a935e3f967f8f22f5db240d145459ee621c1e0.

The only change to the reverted commit is that this also updates
the OCaml bindings according to the C debug-info API changes.

The build failure originally introduced was:
```
FAILED: bindings/ocaml/debuginfo/debuginfo_ocaml.o /b/1/llvm-clang-x86_64-expensive-checks-debian/build/bindings/ocaml/debuginfo/debuginfo_ocaml.o
cd /b/1/llvm-clang-x86_64-expensive-checks-debian/build/bindings/ocaml/debuginfo && /usr/bin/ocamlfind ocamlc -c /b/1/llvm-clang-x86_64-expensive-checks-debian/build/bindings/ocaml/debuginfo/debuginfo_ocaml.c -ccopt "-I/b/1/llvm-clang-x86_64-expensive-checks-debian/llvm-project/llvm/bindings/ocaml/debuginfo/../llvm -D_GNU_SOURCE -D_DEBUG -D_GLIBCXX_ASSERTIONS -DEXPENSIVE_CHECKS -D_GLIBCXX_DEBUG -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/b/1/llvm-clang-x86_64-expensive-checks-debian/build/include -I/b/1/llvm-clang-x86_64-expensive-checks-debian/llvm-project/llvm/include  -DNDEBUG "
/b/1/llvm-clang-x86_64-expensive-checks-debian/build/bindings/ocaml/debuginfo/debuginfo_ocaml.c: In function ‘llvm_dibuild_create_object_pointer_type’:
/b/1/llvm-clang-x86_64-expensive-checks-debian/build/bindings/ocaml/debuginfo/debuginfo_ocaml.c:620:30: error: too few arguments to function ‘LLVMDIBuilderCreateObjectPointerType’
  620 |   LLVMMetadataRef Metadata = LLVMDIBuilderCreateObjectPointerType(
      |                              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /b/1/llvm-clang-x86_64-expensive-checks-debian/build/bindings/ocaml/debuginfo/debuginfo_ocaml.c:23:
/b/1/llvm-clang-x86_64-expensive-checks-debian/llvm-project/llvm/include/llvm-c/DebugInfo.h:880:17: note: declared here
  880 | LLVMMetadataRef LLVMDIBuilderCreateObjectPointerType(LLVMDIBuilderRef Builder,
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
```
2025-01-18 18:03:41 +00:00
Michał Górny
c3a935e3f9
Revert "[clang][DebugInfo] Emit DW_AT_object_pointer on function declarations with explicit this" (#123455)
Reverts llvm/llvm-project#122928
2025-01-18 07:59:30 +00:00
Michael Buch
10fdd09c3b
[clang][DebugInfo] Emit DW_AT_object_pointer on function declarations with explicit this (#122928)
In https://github.com/llvm/llvm-project/pull/122897 we started attaching
`DW_AT_object_pointer` to function definitions. This patch does the same
but for function declarations (which we do for implicit object pointers
already).

Fixes https://github.com/llvm/llvm-project/issues/120974
2025-01-17 19:51:14 +00:00
Daniel Sanders
5d9aabbab3
[dwarf] Add language id for Metal Shading Language (#117215)
Unfortunately there's no upstream frontend for Metal but since the id's
are now assigned by the DWARF standard I think it makes sense to have
the enums upstream to enable tools like llvm-dwarfdump. This patch
therefore uses an AArch64 test with artificially modified debug info to
verify that the Metal language id can be used.

https://dwarfstd.org/issues/241111.1.html
2024-11-22 13:49:42 -08:00
Rahul Joshi
b5dc7b8fc2
[LLVM] Change LLVMIntrinsicCopyOverloadedName API return type (#114334)
Change the return type of `LLVMIntrinsicCopyOverloadedName` and
`LLVMIntrinsicCopyOverloadedName2` to `char *` instead of `const char *`
since the returned memory is owned by the caller and we expect that the
returned pointer is passed to free to deallocate it (without casting it
back to non-const pointer).
2024-11-04 08:21:01 -08:00
tf2spi
f23bdbbaff
Add DILabel functions for LLVM-C (#112840)
Addresses #112799
2024-10-28 10:59:53 -07:00
Jon Roelofs
709116cb76
[llvm-c][MC] Expose color printing via LLVMSetDisasmOptions (#112980) 2024-10-18 15:30:57 -07:00
Rahul Joshi
fa789dffb1
[NFC] Rename Intrinsic::getDeclaration to getOrInsertDeclaration (#111752)
Rename the function to reflect its correct behavior and to be consistent
with `Module::getOrInsertFunction`. This is also in preparation of
adding a new `Intrinsic::getDeclaration` that will have behavior similar
to `Module::getFunction` (i.e, just lookup, no creation).
2024-10-11 05:26:03 -07:00
Rahul Joshi
1b7b3b8d35
[NFC] Move intrinsic related functions to Intrinsic namespace (#110125)
Move static functions `Function::lookupIntrinsicID` and
`Function::isTargetIntrinsic` to Intrinsic namespace.
2024-09-30 07:42:53 -07:00
Nikita Popov
ecb98f9fed [IRBuilder] Remove uses of CreateGlobalStringPtr() (NFC)
Since the migration to opaque pointers, CreateGlobalStringPtr()
is the same as CreateGlobalString(). Normalize to the latter.
2024-09-23 16:30:50 +02:00
Benji Smith
df6855ba57
[C API] Add usub_cond and usub_sat atomic ops to C API (#109532)
These were added in the C++ API in
https://github.com/llvm/llvm-project/pull/105568 but were not exposed
via the C API previously
2024-09-23 09:54:02 +02:00
Michal Rostecki
c320df4a2c
[LLVM-C] Add bindings to Instruction::getDbgRecordRange() (#107802)
Since the migration from `@llvm.dbg.value` intrinsic to `#dbg_value`
records, there is no way to retrieve the debug records for an
`Instruction` in LLVM-C API.

Previously, with debug info intrinsics, retrieving debug info for an
`Instruction` could be done with `LLVMGetNextInstructions`, because the
intrinsic call was also an instruction.

However, to be able to retrieve debug info with the current LLVM, where
debug records are used, the `getDbgRecordRange()` iterator needs to be
exposed.

Add new functions for DbgRecord sequence traversal:
  LLVMGetFirstDbgRecord
  LLVMGetLastDbgRecord
  LLVMGetNextDbgRecord
  LLVMGetPreviousDbgRecord

See llvm/docs/RemoveDIsDebugInfo.md and release notes.
2024-09-20 14:34:42 +01:00
Tim Besard
eb7d535199
[LLVM] Add a C API for creating instructions with custom syncscopes. (#104775)
Another upstreaming of C API extensions we have in Julia/LLVM.jl.
Although [we went](https://github.com/maleadt/LLVM.jl/pull/431) with a
string-based API there, here I'm proposing something that's similar to
existing metadata/attribute APIs:
- explicit functions to map syncscope names to IDs, and back
- `LLVM*SyncScope` versions of builder APIs that already take a
`SingleThread` argument: atomic rmw, atomic xchg, fence
- `LLVMGetAtomicSyncScopeID` and `LLVMSetAtomicSyncScopeID` for other
atomic instructions
- testing through `llvm-c-test`'s `--echo` functionality
2024-08-20 14:12:35 +02:00
Bogdan-Alexandru Geană
7cfc9a3a3d
[llvm-c] Add getters for LLVMContextRef for various types (#99087)
Small PR to add additional getters for LLVMContextRef in the C API.
2024-08-20 14:10:12 +02:00
Tim Besard
00def06c6e
[LLVM][NewPM] Add C API for running the pipeline on a single function. (#103773)
By adding a new entrypoint, `LLVMRunPassesOnFunction`, as suggested in
https://discourse.llvm.org/t/newpm-c-api-questions/80598.

Also removes erroneous `LLVMConsumeError`s from the pass builder unit
tests as the string conversion already consumes the error, causing an
abort when the test would fail.
2024-08-19 12:34:23 +02:00
wr7
e8e88873ab
[llvm-c] Add non-cstring versions of LLVMGetNamedFunction and LLVMGetNamedGlobal (#103396)
Add `LLVMGetNamedFunctionWithLength` and `LLVMGetNamedGlobalWithLength`

As far as i know, it isn't currently possible to use
`LLVMGetNamedFunction` and `LLVMGetNamedGlobal` with non-null-terminated
strings.

These new functions are more convenient for C programs that use
non-null-terminated strings or for languages like Rust that primarily
use non-null-terminated strings.
2024-08-16 14:44:25 +02:00
Tim Besard
241f9e7492
[LLVM][NewPM] Add a C API for setting the PassBuilder AA pipeline. (#102482)
This PR adds a field to the pass builder options struct, `AAPipeline`,
exposed through a C API `LLVMPassBuilderOptionsSetAAPipeline`, that is
used to set an alias analysis pipeline to be used in stead of the
default one.

x-ref https://discourse.llvm.org/t/newpm-c-api-questions/80598
2024-08-14 09:36:06 +02:00
David Blaikie
45ef0d492f Add llvm::Error C API, LLVMCantFail
It's barely testable - the test does exercise the code, but wouldn't
fail on an empty implementation. It would cause a memory leak though
(because the error handle wouldn't be unwrapped/reowned) which could be
detected by asan and other leak detectors.
2024-07-31 16:40:26 +00:00
wr7
299c700a22
[llvm-c][documentation] fix typo in LLVMSizeOfTypeInBits (#100839)
`LLVMSizeOfTypeInBits`:
- `Computes the size of a type in bytes for a target` -> `Computes the
size of a type in bits for a target`
2024-07-27 09:45:15 +03:00
James Y Knight
dfeb3991fb
Remove the x86_mmx IR type. (#98505)
It is now translated to `<1 x i64>`, which allows the removal of a bunch
of special casing.

This _incompatibly_ changes the ABI of any LLVM IR function with
`x86_mmx` arguments or returns: instead of passing in mmx registers,
they will now be passed via integer registers. However, the real-world
incompatibility caused by this is expected to be minimal, because Clang
never uses the x86_mmx type -- it lowers `__m64` to either `<1 x i64>`
or `double`, depending on ABI.

This change does _not_ eliminate the SelectionDAG `MVT::x86mmx` type.
That type simply no longer corresponds to an IR type, and is used only
by MMX intrinsics and inline-asm operands.

Because SelectionDAGBuilder only knows how to generate the
operands/results of intrinsics based on the IR type, it thus now
generates the intrinsics with the type MVT::v1i64, instead of
MVT::x86mmx. We need to fix this before the DAG LegalizeTypes, and thus
have the X86 backend fix them up in DAGCombine. (This may be a
short-lived hack, if all the MMX intrinsics can be removed in upcoming
changes.)

Works towards issue #98272.
2024-07-25 09:19:22 -04:00
Benji Smith
f56db7860b
[C API] Support new ptrauth constant type (#93909)
This is a new constant type that was added to the C++ API in
0edc97f119f3ac3ff96b11183fe5c001a48a9a8d. This adds the ability to
create instances of this constant and get its values to the C API.
2024-07-17 11:35:25 +02:00
Benji Smith
c8783991c7
[C API] Add accessors for new no-wrap flags on GEP instructions (#97970)
Previously, only the inbounds flag was accessible via the C API. This
adds support for any no-wrap related flags (currently nuw and nusw).
2024-07-16 13:21:07 +02:00
Benji Smith
f782ff8fc6
[C API] Add getters for Target Extension Types to C API (#96447)
Accessors for the name, type parameters, and integer parameters are
added. A test is added to echo.ll

This was originally done in
https://github.com/llvm/llvm-project/pull/71291 but that has been stale
for several months. This re-applies the changes, but with some tweaks.
e.g. removing the bulk getters in favour of a simple get-by-index
approach for the type/integer parameters. The latter is more in line
with the rest of the API
2024-06-26 12:10:06 +02:00
Nikita Popov
76d3ab2cc3
[IR] Remove support for shl constant expressions (#96037)
Remove support for shl constant expressions, as part of:
https://discourse.llvm.org/t/rfc-remove-most-constant-expressions/63179
2024-06-20 08:59:29 +02:00
Carlos Alberto Enciso
db394edf95
[RemoveDIs] Update DIBuilder C API with DbgRecord functions. (#95535)
The DIBuilder C API was changed to deal with DbgRecord functions:

https://github.com/llvm/llvm-project/pull/84915
https://github.com/llvm/llvm-project/pull/85657
https://github.com/llvm/llvm-project/pull/92417#issuecomment-2120078326

As discussed by @nikic and @OCHyams:

https://github.com/llvm/llvm-project/pull/92417#issuecomment-2144505440

> For the intrinsic-inserting functions, do you think we should:
>
> a) mark as deprecated but otherwise leave them alone for now.
> b) mark as deprecated and change their behaviour so that they
>    do nothing and return nullptr.
> c) outright delete them (it sounds like you're voting this one,
>    but just wanted to double check).

This patch implements option (c).
2024-06-18 08:39:36 +01:00
Amaury Séchet
86dc758623 [llvm-c] Move LLVMAttributeIndex to a more apropriate place. NFC. 2024-06-14 12:22:17 +00:00
Orlando Cazalet-Hyams
38c01c3d91 NFC fix typos from #92417 2024-06-10 09:25:26 +01:00
Orlando Cazalet-Hyams
d732a3298a
[RemoveDIs] C API: Add before-dbg-record versions of IRBuilder position funcs (#92417)
Add `LLVMPositionBuilderBeforeDbgRecords` and
`LLVMPositionBuilderBeforeInstrAndDbgRecords` to `llvm/include/llvm-c/Core.h`
which behave the same as `LLVMPositionBuilder` and `LVMPositionBuilderBefore`
except that the position is set before debug records attached to the target
instruction (the existing functions set the insertion point to after any
attached debug records).

More info on debug records and the migration towards using them can be found
here: https://llvm.org/docs/RemoveDIsDebugInfo.html

The distinction is important in some situations. An important example is when
inserting a phi before another instruction which has debug records attached to
it (these come "before" the instruction). Inserting before the instruction but
after the debug records would result in having debug records before a phi, which
is illegal. That results in an assertion failure:

`llvm/lib/IR/Instruction.cpp:166: Assertion '!isa<PHINode>(this) && "Inserting
PHI after debug-records!"' failed.`

In llvm (C++) we've added bit to instruction iterators that carries around the
extra information. Adding dedicated functions seemed like the least invasive and
least suprising way to update the C API.

Update llvm/tools/llvm-c-test/debuginfo.c to test this functionality.

Update the OCaml bindings, the migration docs and release notes.
2024-06-10 09:21:40 +01:00
Nikita Popov
deab451e7a
[IR] Remove support for icmp and fcmp constant expressions (#93038)
Remove support for the icmp and fcmp constant expressions.

This is part of:
https://discourse.llvm.org/t/rfc-remove-most-constant-expressions/63179

As usual, many of the updated tests will no longer test what they were
originally intended to -- this is hard to preserve when constant
expressions get removed, and in many cases just impossible as the
existence of a specific kind of constant expression was the cause of the
issue in the first place.
2024-06-04 08:31:03 +02:00
Benji Smith
584253c4e2
[C API] Add getters and build function for CallBr (#91154)
This adds LLVMBuildCallBr to create CallBr instructions, and getters for
the CallBr-specific data. The remainder of its data, e.g.
arguments/function, can be accessed using existing getters.
2024-05-08 10:59:53 +09:00
Andreas Jonson
1343e68862
[C API] Add function to create ConstantRange attributes to C API (#90505) 2024-05-04 16:01:59 +09:00
Adrian Prantl
300340f656
Implement the DWARF 6 language and version attributes. (#89980)
This patch adds DWARF constants for DW_AT_language_name and
DW_AT_language_version to Dwarf.def and Dwarf.h.

While the DWARF 6 spec is not finalized, the constants are published on
the DWARF website and considered stable, with idea being that the list
published on dwarfstd.org is the authoritative source that is being
continuously updated between DWARF revisions, as new languages are being
developed.

https://dwarfstd.org/languages-v6.html

My main motivation for adding this is to use in
https://github.com/llvm/llvm-project/pull/89981
2024-04-26 12:25:39 -07:00
Benji Smith
dfe12b3fd1
[C API] Support uinc_wrap/udec_wrap in atomicrmw when accessing the bin op (#87163)
These previously were added in the C++ API in
778cf5431cafc243f81dd5c8cbd27701ff7f9120, but without updating the enum
in the C API or mapping functions.

Corresponding tests for all current atomicrmw bin ops have been added as
well.
2024-04-16 10:37:55 +09:00
Orlando Cazalet-Hyams
2a2fd488b6
[RemoveDIs] Update DIBuilder C API and OCaml bindings [2/2] (#86529)
Follow on from #84915 which adds the DbgRecord function variants. The C API
changes were reviewed in #85657.

# C API

Update the LLVMDIBuilderInsert... functions to insert DbgRecords instead
of debug intrinsics.

    LLVMDIBuilderInsertDeclareBefore
    LLVMDIBuilderInsertDeclareAtEnd
    LLVMDIBuilderInsertDbgValueBefore
    LLVMDIBuilderInsertDbgValueAtEnd

Calling these functions will now cause an assertion if the module is in the
wrong debug info format. They should only be used when the module is in "new
debug format".

Use LLVMIsNewDbgInfoFormat to query and LLVMSetIsNewDbgInfoFormat to change the
debug info format of a module.

Please see https://llvm.org/docs/RemoveDIsDebugInfo.html#c-api-change
(RemoveDIsDebugInfo.md) for more info.

# OCaml bindings

Add set_is_new_dbg_info_format and is_new_dbg_info_format to the OCaml bindings.
These can be used to set and query the current debug info mode. These will
eventually be removed, but are useful while we're transitioning between old and
new debug info formats.

Add string_of_lldbgrecord, like string_of_llvalue but prints DbgRecords.

In test dbginfo.ml, unconditionally set the module debug info to the new mode
and update CHECK lines to check for DbgRecords. Without this change the test
crashes because it attempts to insert DbgRecords (new default behaviour of
llvm_dibuild_insert_declare_...) into a module that is in the old debug info
mode.
2024-03-28 08:54:27 +00:00
Yingwei Zheng
caa2258250
[LLVM] Remove nuw neg (#86295)
This patch removes APIs that creating NUW neg. It is a trivial case
because `sub nuw 0, X` always gets simplified into zero.
I believe there is no optimization opportunities in the real-world
applications that we can take advantage of the nuw flag.

Motivated by
https://github.com/llvm/llvm-project/pull/84792#discussion_r1524891134.

Compile-time improvement:
https://llvm-compile-time-tracker.com/compare.php?from=d1f182c895728d89c5c3d198b133e212a5d9d4a3&to=da7b7478b7cbb32c09d760f6b8d0e67901e0d533&stat=instructions:u
2024-03-26 20:56:16 +08:00
Orlando Cazalet-Hyams
26857582e5 Revert "[RemoveDIs] Update DIBuilder C API with DbgRecord functions [2/2] (#85657)"
This reverts commit 2091c74796b1dac68e622284c63a870b88b7554f.

Builtbot failure: https://lab.llvm.org/buildbot/#/builders/16/builds/63080
2024-03-22 16:21:50 +00:00
Orlando Cazalet-Hyams
2091c74796
[RemoveDIs] Update DIBuilder C API with DbgRecord functions [2/2] (#85657)
Follow on from #84915 which adds the DbgRecord function variants.

Update the LLVMDIBuilderInsert... functions to insert DbgRecords instead
of debug intrinsics.

    LLVMDIBuilderInsertDeclareBefore
    LLVMDIBuilderInsertDeclareAtEnd
    LLVMDIBuilderInsertDbgValueBefore
    LLVMDIBuilderInsertDbgValueAtEnd

Calling these functions will now cause an assertion if the module is in the
wrong debug info format. They should only be used when the module is in "new
debug format".

Use LLVMIsNewDbgInfoFormat to query and LLVMSetIsNewDbgInfoFormat to change the
debug info format of a module.

Please see https://llvm.org/docs/RemoveDIsDebugInfo.html#c-api-change
(RemoveDIsDebugInfo.md) for more info.
2024-03-22 15:47:40 +00:00
Benji Smith
a8bda0b4a6
[C API] Add accessors for function prefix and prologue data (#82193)
A test is added to echo.ll, and the echo.cpp part of llvm-c-test is
updated to clone a function's prefix and prologue.
2024-03-18 14:58:22 +01:00
Orlando Cazalet-Hyams
f0dbcfe352
[RemoveDIs] Update DIBuilder C API with DbgRecord functions [1/2] (#84915)
Follow on from #84739, which updates the DIBuilder class.

All the functions that have been added are temporary and will be
deprecated in the future. The intention is that they'll help downstream
projects adapt during the transition period.

```
New functions (all to be deprecated)
------------------------------------
LLVMIsNewDbgInfoFormat                      # Returns true if the module is in the new non-instruction mode.
LLVMSetIsNewDbgInfoFormat                   # Convert to the requested debug info format.

LLVMDIBuilderInsertDeclareIntrinsicBefore   # Insert a debug intrinsic (old debug info format). 
LLVMDIBuilderInsertDeclareIntrinsicAtEnd    # Same as above.
LLVMDIBuilderInsertDbgValueIntrinsicBefore  # Same as above.
LLVMDIBuilderInsertDbgValueIntrinsicAtEnd   # Same as above.

LLVMDIBuilderInsertDeclareRecordBefore      # Insert a debug record (new debug info format). 
LLVMDIBuilderInsertDeclareRecordAtEnd       # Same as above.
LLVMDIBuilderInsertDbgValueRecordBefore     # Same as above.
LLVMDIBuilderInsertDbgValueRecordAtEnd      # Same as above.
```

The existing `LLVMDIBuilderInsert...` functions call through to the
intrinsic versions (old debug info format) currently.

In the next patch, I'll swap them to call the debug records versions
(new debug info format). Downstream users of this API can query and
change the current format using the first two functions above, or can
instead opt to temporarily use intrinsics or records explicitly.
2024-03-18 11:45:14 +00:00
erer1243
e1405e4f71
[llvm-c] Add C API methods to match size_t ConstantDataArray C++ API signatures (#84433)
Adds `LLVMConstStringInContext2` and `LLVMConstString2`, which are
identical to originals except that they use `size_t` for length. This is
a clone of
35276f16e5
and is needed for https://github.com/rust-lang/rust/pull/122000.

As an aside, the issue of 32 bit overflow on constants is present in the
C++ APIs as well. A few classes, e.g. `ConstantDataArray` and
`ConstantAggregateZero`, can hold 64-bit ArrayTypes but their length
accessors return 32-bit values. This means the same issue from the
original Rust report is also present in LLVM itself. Would it be a
reasonable goal to update all of these length methods & types to be
uint64_t, or would that be too breaking? Alternatively, we could use
safe fallible casts instead of implicit ones inside the accessors (if an
overflow does happen, the solution would be to use
`MyValue->getType()->getArrayNumElements()` instead).
2024-03-09 10:29:33 +08:00
Benji Smith
b726a81947
[C API] Add blockaddress getters to C API (#81382)
This allows for accessing the function/basic block that a blockaddress
constant refers to

Due to the difficulties of fully supporting cloning BlockAddress values
in echo.cpp, tests are instead done using a unit test.

This previously was up for review at
https://github.com/llvm/llvm-project/pull/77390.
2024-02-12 10:59:00 +01:00
lhames
ebe8733a11
[ORC] Merge MaterializationResponsibility notifyEmitted and addDependencies
Removes the MaterializationResponsibility::addDependencies and
addDependenciesForAll methods, and transfers dependency registration to
the notifyEmitted operation. The new dependency registration allows
dependencies to be specified for arbitrary subsets of the
MaterializationResponsibility's symbols (rather than just single symbols
or all symbols) via an array of SymbolDependenceGroups (pairs of symbol
sets and corresponding dependencies for that set).

This patch aims to both improve emission performance and simplify
dependence tracking. By eliminating some states (e.g. symbols having
registered dependencies but not yet being resolved or emitted) we make
some errors impossible by construction, and reduce the number of error
cases that we need to check. NonOwningSymbolStringPtrs are used for
dependence tracking under the session lock, which should reduce
ref-counting operations, and intra-emit dependencies are resolved
outside the session lock, which should provide better performance when
JITing concurrently (since some dependence tracking can happen in
parallel).

The Orc C API is updated to account for this change, with the
LLVMOrcMaterializationResponsibilityNotifyEmitted API being modified and
the LLVMOrcMaterializationResponsibilityAddDependencies and
LLVMOrcMaterializationResponsibilityAddDependenciesForAll operations
being removed.
2024-01-31 13:06:09 -08:00
Benji Smith
d5c95302b9
[C API] Add getters and setters for fast-math flags on relevant instructions (#75123)
These flags are usable on floating point arithmetic, as well as call,
select, and phi instructions whose resulting type is floating point, or
a vector of, or an array of, a valid type. Whether or not the flags are
valid for a given instruction can be checked with the new
LLVMCanValueUseFastMathFlags function.

These are exposed using a new LLVMFastMathFlags type, which is an alias
for unsigned. An anonymous enum defines the bit values for it.

Tests are added in echo.ll for select/phil/call, and the floating point
types in the new float_ops.ll bindings test.

Select and the floating point arithmetic instructions were not
implemented in llvm-c-test/echo.cpp, so they were added as well.
2023-12-12 17:15:05 +01:00