268 Commits

Author SHA1 Message Date
Andrew Kelley
708894cf99 add a debug subcommand for printing LLVM integer type alignment
Useful when debugging why upgrading from LLVM 17 to 18 caused C ABI
regressions. Turns out LLVM 18 does the following insane thing:

```diff
-[nix-shell:~/dev/zig/build-llvm17]$ stage4/bin/zig llvm-ints i386-linux-musl
+[nix-shell:~/src/zig/build-llvm18]$ stage4/bin/zig llvm-ints i386-linux-musl
 LLVMABIAlignmentOfType(i1) == 1
 LLVMABIAlignmentOfType(i8) == 1
 LLVMABIAlignmentOfType(i16) == 2
 LLVMABIAlignmentOfType(i32) == 4
 LLVMABIAlignmentOfType(i64) == 4
-LLVMABIAlignmentOfType(i128) == 4
-LLVMABIAlignmentOfType(i256) == 4
+LLVMABIAlignmentOfType(i128) == 16
+LLVMABIAlignmentOfType(i256) == 16
```
2024-05-08 19:37:29 -07:00
Andrew Kelley
78002dbe47 add detect-cpu subcommand for debugging CPU features
This brings back `detectNativeCpuWithLLVM` so that we can troubleshoot
during LLVM upgrades.

closes #19793
2024-05-08 19:37:29 -07:00
Andrew Kelley
243ae3a6cb update for LLVM 18 new target data
New OSs:
* XROS
* Serenity
* Vulkan

Removed OSs:
* Ananas
* CloudABI
* Minix
* Contiki

New CPUs:
* spirv

The removed stuff is removed from LLVM but not Zig.
2024-05-08 19:37:28 -07:00
antlilja
c231d94960 LLVM: Remove deprecated or soon to be deprecated constant expressions 2024-04-25 22:58:47 -07:00
Jacob Young
4e85536604 Builder: fix encoding big integers in bitcode
Closes #19543
2024-04-06 12:53:09 -07:00
antlilja
637b1d606d LLVM Builder: Emit binary op optional flags for exact and no wrap 2024-04-06 14:57:46 -04:00
antlilja
79b868d504 LLVM: Use fast math when requested 2024-03-17 16:26:28 +01:00
antlilja
b20cee586c LLVM: Fix incorrect fast constant in FastMath packed struct 2024-03-17 16:25:59 +01:00
antlilja
37a4d9391f LLVM: Fix reaching unreachable code when emitting fast call 2024-03-17 16:23:14 +01:00
Tristan Ross
6067d39522
std.builtin: make atomic order fields lowercase 2024-03-11 07:09:10 -07:00
antlilja
e2345f006f LLVM: Add enableBrokenDebugInfoCheck and getBrokenDebugInfo
These functions allows the caller to find out wether the context
encounters broken debug info or not.
2024-03-02 20:53:06 +01:00
antlilja
147beec7da LLVM Builder: Fix emission of enum debug enumerator info bitcode 2024-02-29 12:02:13 -08:00
antlilja
40f99862e1 Builder: Implement StrtabString and use it for Global names 2024-02-28 14:46:43 +01:00
antlilja
826c6c0ec6 LLVM: Implement more efficient blob writing 2024-02-28 14:46:43 +01:00
Andrew Kelley
031f23117d
Merge pull request #19083 from antlilja/llvm-blockinfo
LLVM reduce size of emitted bitcode
2024-02-26 04:03:40 -08:00
antlilja
73a16d440b Builder: Reduce size of DebugLoc abbrev 2024-02-26 01:02:16 +01:00
antlilja
9754d6d0a0 Builder: Use BlockInfo block to reduce size of bitcode 2024-02-26 01:00:58 +01:00
Jacob Young
ed026b5dff llvm: free llvm data before running llvm optimizations
This reduces the max memory usage.
2024-02-25 17:37:27 +01:00
Jacob Young
1e1598950a llvm: implement per-module stripping
This avoids llvm module verification errors when the strip option
is different across modules.
2024-02-25 17:37:27 +01:00
Jacob Young
661137ac92
Merge pull request #19074 from antlilja/llvm-debug-loc
Rework LLVM debug locations to not emit them twice
2024-02-25 17:03:45 +01:00
Jacob Young
f6af773578 llvm: remork memory management in emit 2024-02-25 03:58:06 -08:00
antlilja
71d9f3a86b Builder: Fix llvm ir debug location output 2024-02-25 03:16:52 +01:00
antlilja
928914e25a Builder: Improve debug location system
Debug locations are no longer emitted twice every time
2024-02-25 03:16:52 +01:00
Jacob Young
edb6486b3b BitcodeWriter: cleanup type widths 2024-02-24 17:00:36 +01:00
Jacob Young
7e9f321f53 Builder: fix bitcode widths 2024-02-24 16:41:37 +01:00
antlilja
9b39e824cd Builder: Emit metadata attachment for globals 2024-02-24 02:28:00 +01:00
Jacob Young
a8708dbf3b Builder: fix inconsequential llvm ir flag syntax 2024-02-23 21:12:57 +01:00
Jacob Young
2c67a1ecd2 llvm: optimize i32 constants 2024-02-23 19:40:07 +01:00
Jacob Young
f644263a6c Builder: fix llvm ir/bc difference with allocas 2024-02-23 18:17:14 +01:00
Jacob Young
03eb332d3c Builder: fix aliases in bitcode 2024-02-23 18:17:14 +01:00
Jacob Young
7f3ade6dea Builder: fix x86_fp80 constants in bitcode 2024-02-23 09:15:58 +01:00
Jacob Young
800495afab Builder: fix minor llvm ir syntax errors 2024-02-23 07:51:38 +01:00
Jacob Young
6abb432598 Builder: implement opaque structs in bitcode 2024-02-23 07:51:38 +01:00
Jacob Young
43daed64fe Builder: change tuple metadata to not be inlined in llvm ir 2024-02-23 06:18:10 +01:00
Jacob Young
be4ad235a7 Builder: fix inconsequential llvm ir metadata syntax 2024-02-23 03:23:49 +01:00
Jacob Young
8d0f6605fe Builder: sync distinct bits with previous implementation 2024-02-23 03:23:49 +01:00
antlilja
dfde194287 LLVM Builder: Make some Metadata no longer be distinct 2024-02-23 03:12:54 +01:00
antlilja
0ba2185a42 LLVM Builder: Formatting 2024-02-23 03:12:35 +01:00
Jacob Young
c894df54f7 Builder: fix debug location of the first instruction in a block 2024-02-23 01:45:25 +01:00
Jacob Young
dbfa3238fe Builder: fix float constants in llvm ir 2024-02-22 23:51:53 +01:00
Jacob Young
83e66d301e Builder: fix bitcode strtab 2024-02-22 19:50:41 +01:00
Jacob Young
69a6f31596 Builder: fix llvm ir value names
Hello world now verifies when not stripped.
2024-02-22 19:10:52 +01:00
antlilja
de536e8473 LLVM Builder: Emit metadata kinds and function metadata attachments 2024-02-22 15:29:28 +01:00
antlilja
92eec8dfec LLVM Builder: Emit type for debug subprogram 2024-02-22 15:24:22 +01:00
Jacob Young
4b215e3a11 Builder: support printing metadata in llvm ir 2024-02-22 08:54:35 +01:00
antlilja
a907353ca4 LLVM Builder: Fix on 32-bit systems 2024-02-22 00:39:56 +01:00
antlilja
53f6071486 LLVM Builder: Emit debug vector types with DIVector flag 2024-02-21 23:33:25 +01:00
antlilja
5e9d0da43b LLVM Builder: Correctly emit debug subranges
The bitcode abbrev was missing the subrange code
2024-02-21 23:32:21 +01:00
antlilja
e57f553c07 LLVM Builder: Rework MetadataString to not rely on String
This fixes a problem where empty strings where not emitted as null.
This should also emit a smaller stringtab as all metadata strings were
emitted in both the strtab and in the strings block inside the metadata
block.
2024-02-21 21:46:04 +01:00
Jacob Young
48bd0ed7f3 llvm: fix builds that don't link with libllvm 2024-02-21 19:18:34 +01:00