1710 Commits

Author SHA1 Message Date
antlilja
d345068ec2 LLVM: Fail to emit if LLVM encounters broken debug info 2024-03-02 20:53:06 +01: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
mlugg
321045cf33
codegen: handle dbg_var scoping correctly after eliding more ZIR blocks
Since we now elide more ZIR blocks in AstGen, care must be taken in
codegen to introduce lexical scopes for every body, not just `block`s.

Also, elide a few unnecessary AIR blocks in Sema.
2024-02-29 23:38:18 +00:00
antlilja
147beec7da LLVM Builder: Fix emission of enum debug enumerator info bitcode 2024-02-29 12:02:13 -08:00
antlilja
5c2e463ecd LLVM: Don't create a debug lexical block when inlining 2024-02-28 14:46:43 +01: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
7b37bc771b move Zir to std.zig.Zir
Part of an effort to ship more of the compiler in source form.
2024-02-26 21:35:30 -07:00
Andrew Kelley
f7143e18e3 move Zcu.LazySrcLoc to std.zig.LazySrcLoc
Part of an effort to ship more of the compiler in source form.
2024-02-26 21:35:30 -07:00
mlugg
59447e5305
compiler: decide dbg_var scoping based on AIR blocks
This commit eliminates the `dbg_block_{begin,end}` instructions from
both ZIR and AIR. Instead, lexical scoping of `dbg_var_{ptr,val}`
instructions is decided based on the AIR block they exist within. This
is a much more robust system, and also results in a huge drop in ZIR
bytes - around 7% for Sema.zig.

This required some enhancements to Sema to prevent elision of blocks
when they are required for debug variable scoping. This can be observed
by looking at the AIR for the following simple test program with and
without `-fstrip`:

```zig
export fn f() void {
    {
        var a: u32 = 0;
        _ = &a;
    }
    {
        var a: u32 = 0;
        _ = &a;
    }
}
```

When `-fstrip` is passed, no AIR blocks are generated. When `-fno-strip`
is passed, the ZIR blocks are lowered to true AIR blocks to give correct
lexical scoping to the debug vars.

The changes here incidentally reolve #19060. A corresponding behavior
test has been added.

Resolves: #19060
2024-02-26 13:20:45 +00: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
Andrew Kelley
9dda2eb1ab
Merge pull request #19080 from jacobly0/llvm-per-mod-strip
llvm: implement per-module stripping
2024-02-25 21:44:10 -08:00
Andrew Kelley
91fb211faa
Merge pull request #18906 from jacobly0/x86_64-tests
x86_64: pass more tests
2024-02-25 21:43:20 -08:00
Jacob Young
d656c2a7ab test: rework how filtering works
* make test names contain the fully qualified name
 * make test filters match the fully qualified name
 * allow multiple test filters, where a test is skipped if it does not
   match any of the specified filters
2024-02-25 19:12:08 -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
Jacob Young
e5c439a16d x86_64: implement optional comparisons
Closes #18959
2024-02-25 11:22:10 +01:00
Jacob Young
2fcb2f5975 Sema: implement vector coercions
These used to be lowered elementwise in air, and now are a single air
instruction that can be lowered elementwise in the backend if necessary.
2024-02-25 11:22:10 +01: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
ceb2c030c4 llvm: revert debug file path resolution changes
Fixes test-stack-traces on windows.
2024-02-23 21:50:02 +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
1d4a7e123c llvm: revert bad cleanup 2024-02-23 03:23:49 +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
6cc51d3c33 LLVM: Set new debug location after inlining 2024-02-22 16:07:25 +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