845 Commits

Author SHA1 Message Date
Andrew Kelley
90c1a2c41a
Merge pull request #19152 from antlilja/llvm-broken-debug
LLVM: Fail to emit if LLVM encounters broken debug info
2024-03-02 21:43:39 -08:00
Jacob Young
aa688567f5 Air: replace .dbg_inline_* with .dbg_inline_block
This prevents the possibility of not emitting a `.dbg_inline_end`
instruction and reduces the allocation requirements of the backends.

Closes #19093
2024-03-02 21:19:34 -08:00
antlilja
d345068ec2 LLVM: Fail to emit if LLVM encounters broken debug info 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
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
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
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
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
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
ceb2c030c4 llvm: revert debug file path resolution changes
Fixes test-stack-traces on windows.
2024-02-23 21:50:02 +01:00
Jacob Young
2c67a1ecd2 llvm: optimize i32 constants 2024-02-23 19:40:07 +01:00
Jacob Young
1d4a7e123c llvm: revert bad cleanup 2024-02-23 03:23:49 +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
Jacob Young
4b215e3a11 Builder: support printing metadata in llvm ir 2024-02-22 08:54:35 +01:00
antlilja
53f6071486 LLVM Builder: Emit debug vector types with DIVector flag 2024-02-21 23:33:25 +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
antlilja
f6d275b14e LLVM: Remove use of LLVM in Builder 2024-02-21 17:53:15 +01:00
antlilja
c11c7a28a3 codegen/llvm: Remove use of DIBuilder and output bin by parsing bitcode 2024-02-21 16:24:59 +01:00
antlilja
d3055480ec LLVM: Emit bitcode even if libllvm is not present 2024-02-21 16:24:59 +01:00
antlilja
1d94e9ef83 LLVM: Make sure child types get added first
The LLVM bitcode requires all type references in
structs to be to earlier defined types.

We make sure types are ordered in the builder
itself in order to avoid having to iterate the
types multiple times and changing the values
of type indicies.
2024-02-21 16:24:59 +01:00
Jacob Young
ec7293422d llvm: fix c abi for structs not passed in registers
Closes #18916
2024-02-20 23:36:47 +01:00
Jacob Young
6f08e17229 InternPool: make more use of NullTerminatedString.Slice
This should avoid the random pointer invalidation crashes.

Closes #18954
2024-02-16 00:27:25 -08:00
Jacob Young
6fe90a913a llvm: fix lowering of recursive debug info
This change allows recursing over types that are currently being
resolved fully with a second pass of forward resolution.

Closes #16414
2024-02-15 02:46:18 -08:00
Jacob Young
a9f738e56b x86_64: implement c abi for bool vectors 2024-02-12 05:25:07 +01:00
Andrew Kelley
78f15bc714 compiler: rename value.zig to Value.zig
This commit only does the file rename to be friendlier to version
control conflicts.
2024-02-05 18:13:07 -07:00
Ali Chraghi
afa7793351 spirv: basic shader support 2024-02-05 11:55:14 +03:30
mlugg
9eda6ccefc InternPool: use separate key for slices
This change eliminates some problematic recursive logic in InternPool,
and provides a safer API.
2024-02-02 11:02:03 +00:00
Veikka Tuominen
7d75c3d3b8 llvm: ensure returned undef is 0xaa bytes when runtime safety is enabled
Closes #13178
2024-01-29 17:35:07 -08:00
Andrew Kelley
f4f8036ec0
Merge pull request #18729 from Vexu/fixes
Fix some generic{Reader,Writer} related issues
2024-01-29 13:07:37 -08:00
Veikka Tuominen
f93a36c091 llvm: revert bad array access optimization
Closes #18723
2024-01-29 08:43:27 -08:00
Veikka Tuominen
78e982f7c3 llvm: fix alignment of array ptr when bitcasting vector
Closes #17996
2024-01-29 13:51:57 +02:00
ocrap7
1ce12db5c8 Skip all dbg instructions 2024-01-16 15:01:42 -08:00
Jacob Young
03ed3f56cf Sema: fix @extern decls
Closes #18550
2024-01-15 07:39:05 +01:00
Andrew Kelley
30688c341b LLVM: fix lowering of extern anyopaque
closes #18461
2024-01-11 01:00:49 -08:00
Veikka Tuominen
faeb0ef032 llvm: optional slices cannot be passed in parts when they allowzero
Closes #18428
2024-01-08 06:57:06 +02:00
Andrew Kelley
0be97b5ae3 fix population of builtin.zig not making the parent dir 2024-01-01 17:51:20 -07:00
Andrew Kelley
2047a6b82d fix remaining compile errors except one 2024-01-01 17:51:20 -07:00
Andrew Kelley
638db680f4 move dll_export_fns and rdynamic to Compilation.Config 2024-01-01 17:51:20 -07:00
Andrew Kelley
b54ad93175 update codegen.llvm references to bin_file.options 2024-01-01 17:51:19 -07:00