Commit Graph

652 Commits

Author SHA1 Message Date
Jonas Maebe
c92a035614 agllvm: support nested constants in parameters
Needed for metadata support
2022-06-04 22:26:40 +02:00
Jonas Maebe
dc1e0a6bb3 tllvmcallpara: turned into object and added convenience methods 2022-06-04 22:26:40 +02:00
Jonas Maebe
fe0048bcec llvm: changed llvm_metadatatype from untyped pointer to undefineddef
That matches its meaning better, as it should not result in type conversions.
E.g. some kinds of metadata parameters expect a "type register" parameter such
as "metadata i32* %reg.3"
2022-06-04 22:26:40 +02:00
Jonas Maebe
aa43441ac9 llvm: replaced boolean fields in tllvmcallpara with a set 2022-06-04 22:26:40 +02:00
Jonas Maebe
573b2554f4 llvminfo: fix copy/paste error in llvm 14 comment
Spotted by @Alexey-T1
2022-06-04 22:26:40 +02:00
Jonas Maebe
a45e5e7ab6 llvm: version 14.0 support 2022-06-04 13:34:09 +02:00
Jonas Maebe
591c1b0177 llvm: added support for newer Xcode toolchains
Based on https://en.wikipedia.org/wiki/Xcode#Xcode_11.x_-_13.x_(since_SwiftUI_framework)_2
2022-06-04 09:43:39 +02:00
Jonas Maebe
dcf6063dc3 llvm: version 13.0 support 2022-06-03 21:46:23 +02:00
Jonas Maebe
1b06599e82 llvm: version 12.0 support 2022-06-03 21:46:23 +02:00
Jonas Maebe
a19deace45 llvmdbg: fix overflows for aggregates > 2^61 bytes
LLVM does not support aggregates larger than that at all, because internally
it stores all sizes in bits in an uint64. Their rationale for not having
special support for that is that there is no hardware with full 64 bit VM
address space anyway. So truncate our size emissions in debug info also to
that.
2022-05-29 13:33:27 +02:00
Jonas Maebe
70908b1449 llvm: support for adding/subtracting constants to pointers in typed constants
Fixes webtbs/tw34027 for llvm
2022-05-29 13:33:27 +02:00
Sven/Sarah Barth
088c746d45 * reset written source lines once a section is encountered 2022-05-26 21:43:35 +02:00
Jonas Maebe
ccc843f983 llvmdbg: emit uppercase symbol names unless C++-style debug info is selected
Otherwise gdb won't find the symbols unless you use the exact case
2022-05-21 22:32:35 +02:00
Jonas Maebe
9a7a97175e llvmdbg: emit debug information for global variables 2022-05-21 22:32:35 +02:00
Jonas Maebe
1b393c80aa llvmdbg: fix missing initialisation when there are no procedures 2022-05-21 22:32:35 +02:00
Jonas Maebe
d0bf7acc18 llvmdbg: build hashtable to lookup llvmdecl belonging to a global variable
We need to attach the debug info to it
2022-05-21 22:32:35 +02:00
Jonas Maebe
e865ab4c3a llvmdbg: handle nil in more places
"void" is represented as "null" in LLVM debug information, which we represent
by nil
2022-05-21 22:32:35 +02:00
Jonas Maebe
a33e6230a0 llvm metadata: add DIGlobalVariableExpression enum
Only documented as of LLVM 9.0, but existed already in 7.0.
Also fixed DIGlobalVariable not being marked as unique
2022-05-21 22:32:35 +02:00
Jonas Maebe
f896766837 agllvm: fix writing metadata operands for variable declarations 2022-05-21 22:32:35 +02:00
Jonas Maebe
16cb409fbf LLVM: separate as_clang_llvm_darwin
The Darwin local label prefix ('L') is different from that on most other
platforms ('.L). While LLVM generally handles that for us, for inline
assembly it's still FPC's job to adhere to the target conventions.
2022-05-14 22:38:49 +02:00
Jonas Maebe
481741c65b llvmdbg: remove some commented dbgdwarf code
Also adjusted some hashtable sizes
2022-05-14 22:38:49 +02:00
Pierre Muller
9b87fb4a34 Use '.L' as labelprefix for LLVM compiler variant 2022-05-14 21:26:13 +02:00
Pierre Muller
a0d4cccd87 Fix syntax error for isLocal field for function/procedure type LLVM debug information 2022-05-14 21:05:54 +02:00
Jonas Maebe
cddffbed58 llvmdbg: disable open array data location
Since we don't generate full debug info for parameters yet, this internalerrors
2022-05-14 08:34:38 +02:00
Jonas Maebe
fd125b506e LLVM debug info: LLVM 7.0 support
Also defined some llvm flags in a negative way so they can be removed from
later versions rather than added
2022-05-13 22:49:02 +02:00
Jonas Maebe
edbddec98a llvmdbg: diflags/dispflags fixes
Fix MainSubprogram flag for older LLVM versions, as it was a plain flag rather
than a subprogram flag there.

Added visibility flags for procdefs (public/private/protected)

Write flags as enum rather than integer to avoid issues with changing values
across different LLVM versions
2022-05-13 22:49:02 +02:00
Jonas Maebe
816ab7ffcc llvm metadata: counter per unit rather than globally
Results in less high numbers, and reproducible results when partially
rebuilding
2022-05-13 22:49:02 +02:00
Jonas Maebe
9b280db2b1 dbgllvm: add scopeLine attribute for function debug info
Ensures that breaking on the function correctly sets the breakpoint on the
first source line of the function (rather than potentially in the prologue
without line information)
2022-05-13 22:49:02 +02:00
Jonas Maebe
d1aaeff832 dbgllvm: fix crash for files without procedures/functions 2022-05-13 22:49:02 +02:00
Jonas Maebe
067d96242c dbgllvm: fix crash when generating debug info for procdef of imported struct 2022-05-13 22:49:02 +02:00
Jonas Maebe
cf6a97c8ed LLVM: fix fileinfo of temp allocations 2022-05-13 22:49:02 +02:00
Jonas Maebe
8d2d91d505 dbgllvm: fix infinite loop when writing multi-dimensional array info 2022-05-13 22:49:02 +02:00
Jonas Maebe
a7e19e9f06 llvm metadata: use cardinal instead of tsuperregister for unnamed metadata numbers
We're not putting these into registers, so no need to limit ourselves
2022-05-13 22:49:02 +02:00
Jonas Maebe
a75adf542d dbgllvm: handle empty spFlags 2022-05-13 22:49:02 +02:00
Jonas Maebe
91563115c4 dbgllvm: handle array of const (stub) 2022-05-13 22:49:02 +02:00
Jonas Maebe
aec7aefdd5 dbgllvm: create dummy line info for instructions that shouldn't have any
Use line 0 for that, like clang does
2022-05-13 22:49:02 +02:00
Jonas Maebe
20674089bd llvmdbg: add declaration for all DISPFlags 2022-05-13 22:49:02 +02:00
Jonas Maebe
13055bb58a llvmtype: ensure all processed defs get recorded
This is necessary so they get reset as well, as they may be reprocessed while
compiling other units (both by llvmtype and dbgllvm)
2022-05-13 22:49:02 +02:00
Jonas Maebe
f832444eaa LLVM lineinfo: fix nolineinfo generation
LLVM requires line info metadata for all call instructions that may potentially
be inlined. So attach one to all call instructions in nolineinfo regions, but
set their line number to 0 (same as what clang does)
2022-05-13 22:49:02 +02:00
Jonas Maebe
40418f5b3d dbgllvm: remove restriction to only write struct procdef in context of struct
Does not make a difference for LLVM since all debug info for procdefs is
assigned to the definition instructions for the procdef anyway, and avoids
issues when only generating line info (in that case the structs will never
be processed, but we still have to generate the basic debug info for their
procdefs to provide a scope for their line info)
2022-05-13 22:49:02 +02:00
Jonas Maebe
6cacd9c824 llvmdbg: initial version based on dbgdwarf
Line information is mostly functional, type information not yet (except
for basic procdef info, as that's required for line info)
2022-05-13 22:49:02 +02:00
Jonas Maebe
f1bcd02aaf Typed const builder: store tsym
Useful for LLVM debug info generation
2022-05-13 22:49:02 +02:00
Jonas Maebe
b7b495a679 LLVM: assign procdef.procstarttai, like in the regular code generator 2022-05-13 22:49:02 +02:00
Jonas Maebe
229eb93e72 tnodeuitls: merge GenerateObjCImageInfo into InsertObjectInfo
LLVM needs to insert the Objective-C image info into the general object info
metadata. This way we don't need to store a reference to that metadata so
as to add extra data to it later (tnodeutils is never instantiated, it only
contains class methods)
2022-05-13 22:49:02 +02:00
Jonas Maebe
78535bbcd8 agllvm: support for writing specialised metadata nodes 2022-05-13 22:49:02 +02:00
Jonas Maebe
d294731542 LLVM: enable DWARF debug info generation 2022-05-13 22:49:02 +02:00
Jonas Maebe
527c68b6c3 agllvm: remove useless code 2022-05-13 22:49:02 +02:00
Jonas Maebe
a8cb061a50 LLVM: support for attaching metadata to instructions 2022-05-13 22:49:02 +02:00
Jonas Maebe
4293d4455c LLVM: factor out writing operands in agllvm 2022-05-13 22:49:02 +02:00
Jonas Maebe
411fa298ae LLVM: data location debug info support
This was added to LLVM for Fortran arrays, but can also be used for Pascal
dynamic arrays
2022-05-13 22:49:02 +02:00