Skip to content

Commit

Permalink
Update dependency: llvm-backend/src/main/native/llvm-backend (#3938)
Browse files Browse the repository at this point in the history
Co-authored-by: devops <[email protected]>
Co-authored-by: Bruce Collie <[email protected]>
  • Loading branch information
3 people authored Jan 31, 2024
1 parent 50a2913 commit 1e26f72
Show file tree
Hide file tree
Showing 18 changed files with 160 additions and 34 deletions.
39 changes: 39 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,45 @@
copyright: Copyright (c) Runtime Verification, Inc. All Rights Reserved.
---

K Framework 6.2.0
=================

Major Changes
-------------

- The `Bytes` sort no longer represents mutable buffers of bytes by default.
Hooks that would previously have mutated a buffer when executing with the LLVM
backend will now perform a transparent copy of the underlying buffer. This
aligns the LLVM backend's behaviour with that of the Haskell backend and K. To
opt out of this change if performance when operating on large buffers is
important, semantics can pass the flag `--llvm-mutable-bytes` to `kompile`.

Minor Changes
-------------

- Removed the `#parseKORE` hook (which presented a hole in the K type system) in
favour of modern, Pyk-based solutions to deserializing intermediate K states.

- Added `k-which-python` tool to Nix builds of K, which helps to resolve
incompatibilities in Pyk-based applications that use K via `kup`.

- Strict casts now use the `::S` syntax everywhere; a legacy use case for the
syntax `{...}<:S` is no longer required.

- Improvements to the deterministic type inferencing algorithm; strict casts are
now handled and the new inferencer is enabled when typing proof claims.

- Better integration between the Booster and LLVM backend in the presence of
partial functions and run-time errors.

- The PL tutorial that was previously bundled with K will now be developed and
tested in its own repository.

- Substantial improvements to K developer experience (code cleanup, auditing and
automatic tooling).

- Bug fixes and feature requests supporting RV-internal projects.

K Framework 6.1.0
=================

Expand Down
6 changes: 3 additions & 3 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion install-k
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/sh -e

K_VERSION=6.1.87
K_VERSION=6.2.0

if [ `id -u` -ne 0 ]; then
echo "$0: error: This script must be run as root."
Expand Down
53 changes: 27 additions & 26 deletions k-distribution/include/kframework/builtin/domains.md
Original file line number Diff line number Diff line change
Expand Up @@ -1961,12 +1961,13 @@ Byte Arrays
-----------

Provided here is the syntax of an implementation of fixed-width arrays of Bytes
in K. This type is hooked to an implementation of bytes provided by the
backend. In concrete backends, this representation is mutable and thus multiple
references can occur to the same `Bytes` object and when one is modified, the
others are also modified. Care should be taken not to rely on this fact however
as this is not the case in symbolic backends and thus you will experience
divergent behavior unless the `Bytes` type is used in a manner that preserves
in K. This type is hooked to an implementation of bytes provided by the backend.
On the LLVM backend, it is possible to opt in to a faster, mutable
representation (using the `--llvm-mutable-bytes` flag to `kompile`) where
multiple references can occur to the same `Bytes` object and when one is
modified, the others are also modified. Care should be taken when using this
feature, however, as it is possible to experience divergent behavior with
symbolic backends unless the `Bytes` type is used in a manner that preserves
consistency.

```k
Expand Down Expand Up @@ -2103,39 +2104,38 @@ The result is `#False` if `startIndex` or `endIndex` are not valid.

### Multiple bytes update

You can modify a `Bytes` to return a `Bytes` which is equal to `dest` except
the `N` elements starting at `index` are replaced with the contents of `src` in
O(N) time. This does not create a new `Bytes` object and will instead modify
the original on concrete backends. The result is `#False` if `index` + `N`
is not a valid index.
You can modify a `Bytes` to return a `Bytes` which is equal to `dest` except the
`N` elements starting at `index` are replaced with the contents of `src` in O(N)
time. If `--llvm-mutable-bytes` is active, this will not create a new `Bytes`
object and will instead modify the original on concrete backends. The result is
`#False` if `index` + `N` is not a valid index.

```k
syntax Bytes ::= replaceAtBytes(dest: Bytes, index: Int, src: Bytes) [function, hook(BYTES.replaceAt)]
```

### Multiple bytes update

You can modify a `Bytes` to return a `Bytes` which is equal to `dest` except
the `count` bytes starting at `index` are replaced with `count` bytes of value
You can modify a `Bytes` to return a `Bytes` which is equal to `dest` except the
`count` bytes starting at `index` are replaced with `count` bytes of value
`Int2Bytes(1, v, LE/BE)` in O(count) time. This does not create a new `Bytes`
object and will instead modify the original on concrete backends.
This will throw an exception if `index` + `count` is not a valid index.
The acceptable range of values for `v` is -128 to 127. This will throw an
exception if `v` is outside of this range.
This is implemented only for the LLVM backend.
object and will instead modify the original if `--llvm-mutable-bytes` is active.
This will throw an exception if `index` + `count` is not a valid index. The
acceptable range of values for `v` is -128 to 127. This will throw an exception
if `v` is outside of this range. This is implemented only for the LLVM backend.

```k
syntax Bytes ::= memsetBytes(dest: Bytes, index: Int, count: Int, v: Int) [function, hook(BYTES.memset)]
```

### Bytes padding

You can create a new `Bytes` object which is at least `length` bytes long
by taking the input sequence and padding it on the right (respectively, on the
left) with the specified `value`. This does not create a new `Bytes` object
if the input is already at least `length` bytes long, and will instead
return the input unchanged. The result is `#False` if `value` is not in the
range `[0..255]`, or if the length is negative.
You can create a new `Bytes` object which is at least `length` bytes long by
taking the input sequence and padding it on the right (respectively, on the
left) with the specified `value`. If `--llvm-mutable-bytes` is active, this does
not create a new `Bytes` object if the input is already at least `length` bytes
long, and will instead return the input unchanged. The result is `#False` if
`value` is not in the range `[0..255]`, or if the length is negative.

```k
syntax Bytes ::= padRightBytes(Bytes, length: Int, value: Int) [function, hook(BYTES.padRight)]
Expand All @@ -2144,8 +2144,9 @@ range `[0..255]`, or if the length is negative.

### Bytes reverse

You can reverse a `Bytes` object in O(N) time. This does not create a new
`Bytes` object and will instead modify the original on concrete backends.
You can reverse a `Bytes` object in O(N) time. If `--llvm-mutable-bytes` is
active, this will not create a new `Bytes` object and will instead modify the
original.

```k
syntax Bytes ::= reverseBytes(Bytes) [function, total, hook(BYTES.reverse)]
Expand Down
2 changes: 2 additions & 0 deletions k-distribution/tests/regression-new/mutable-bytes/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
SUBDIRS=default mutable
include ../../../include/kframework/ktest-group.mak
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
DEF=test
EXT=test
TESTDIR=.
KOMPILE_BACKEND=llvm
KOMPILE_FLAGS=--syntax-module TEST

include ../../../../include/kframework/ktest.mak
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
a
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<test>
<k>
d ~> .
</k>
<mem>
b"bob__"
</mem>
<stuff>
b"alice"
</stuff>
</test>
21 changes: 21 additions & 0 deletions k-distribution/tests/regression-new/mutable-bytes/default/test.k
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
module TEST
imports BYTES
imports INT-SYNTAX

configuration
<test>
<k> $PGM </k>
<mem> .Bytes </mem>
<stuff> .Bytes </stuff>
</test>

syntax KItem ::= "a" | "b" | "c" | "d" | "e"

rule <k> a => b </k>
<mem> _ => b"alice" </mem>
rule <k> b => c </k>
<mem> B </mem>
<stuff> _ => B </stuff>
rule <k> c => d </k>
<mem> B => replaceAtBytes(B, 0:Int, b"bob__") </mem>
endmodule
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
DEF=test
EXT=test
TESTDIR=.
KOMPILE_BACKEND=llvm
KOMPILE_FLAGS=--syntax-module TEST --llvm-mutable-bytes

include ../../../../include/kframework/ktest.mak
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
a
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<test>
<k>
d ~> .
</k>
<mem>
b"bob__"
</mem>
<stuff>
b"bob__"
</stuff>
</test>
21 changes: 21 additions & 0 deletions k-distribution/tests/regression-new/mutable-bytes/mutable/test.k
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
module TEST
imports BYTES
imports INT-SYNTAX

configuration
<test>
<k> $PGM </k>
<mem> .Bytes </mem>
<stuff> .Bytes </stuff>
</test>

syntax KItem ::= "a" | "b" | "c" | "d" | "e"

rule <k> a => b </k>
<mem> _ => b"alice" </mem>
rule <k> b => c </k>
<mem> B </mem>
<stuff> _ => B </stuff>
rule <k> c => d </k>
<mem> B => replaceAtBytes(B, 0:Int, b"bob__") </mem>
endmodule
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,10 @@ private void llvmKompile(String type, String executable) {
args.add("--proof-hint-instrumentation");
}

if (options.llvmMutableBytes) {
args.add("--mutable-bytes");
}

// Arguments after this point are passed on to Clang.
args.add("--");

Expand Down
2 changes: 1 addition & 1 deletion llvm-backend/src/main/native/llvm-backend
Submodule llvm-backend updated 37 files
+7 −0 bin/llvm-kompile
+4 −0 bindings/c/include/kllvm-c/kllvm-c.h
+7 −2 bindings/c/lib.cpp
+0 −3 include/kllvm/codegen/CreateTerm.h
+18 −0 include/kllvm/codegen/Metadata.h
+1 −0 lib/codegen/CMakeLists.txt
+0 −17 lib/codegen/CreateTerm.cpp
+50 −0 lib/codegen/Metadata.cpp
+1 −0 runtime/strings/CMakeLists.txt
+10 −0 runtime/strings/bytes.cpp
+25 −0 runtime/strings/copy_on_write.cpp
+1 −0 test/c/Inputs/api.c
+1 −0 test/c/Inputs/api.h
+3,220 −0 test/defn/bytes-cow/bytes-cow-1.kore
+3,033 −0 test/defn/bytes-cow/bytes-cow-2.kore
+3,043 −0 test/defn/bytes-cow/bytes-cow-3.kore
+3,301 −0 test/defn/bytes-cow/bytes-cow-4.kore
+3,272 −0 test/defn/bytes-cow/bytes-cow-5.kore
+26 −0 test/defn/k-files/bytes-cow/bytes-cow-1.k
+26 −0 test/defn/k-files/bytes-cow/bytes-cow-2.k
+24 −0 test/defn/k-files/bytes-cow/bytes-cow-3.k
+28 −0 test/defn/k-files/bytes-cow/bytes-cow-4.k
+32 −0 test/defn/k-files/bytes-cow/bytes-cow-5.k
+1 −0 test/input/bytes-cow-1.in
+1 −0 test/input/bytes-cow-2.in
+1 −0 test/input/bytes-cow-3.in
+1 −0 test/input/bytes-cow-4.in
+1 −0 test/input/bytes-cow-5.in
+1 −0 test/output/bytes-cow-1.out.diff
+1 −0 test/output/bytes-cow-2.out.diff
+1 −0 test/output/bytes-cow-3.out.diff
+1 −0 test/output/bytes-cow-4.out.diff
+1 −0 test/output/bytes-cow-5.out.diff
+14 −3 tools/llvm-kompile-codegen/main.cpp
+2 −0 unittests/runtime-ffi/ffi.cpp
+1 −0 unittests/runtime-io/io.cpp
+3 −0 unittests/runtime-strings/stringtest.cpp
2 changes: 1 addition & 1 deletion package/arch/PKGBUILD
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Maintainer: Dwight Guth <[email protected]>
pkgname=kframework-git
pkgver=6.1.0
pkgver=6.2.0
pkgrel=1
epoch=
pkgdesc="K framework toolchain. Includes K Framework compiler for K language definitions, and K interpreter and prover for programs written in languages defined in K."
Expand Down
2 changes: 1 addition & 1 deletion package/debian/changelog
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
kframework (6.1.87) unstable; urgency=medium
kframework (6.2.0) unstable; urgency=medium

* Initial Release.

Expand Down
2 changes: 1 addition & 1 deletion package/version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6.1.87
6.2.0

0 comments on commit 1e26f72

Please sign in to comment.