diff --git a/.github/workflows/rust.yml b/.github/workflows/linux.yml similarity index 100% rename from .github/workflows/rust.yml rename to .github/workflows/linux.yml diff --git a/.github/workflows/lit.yml b/.github/workflows/lit.yml new file mode 100644 index 00000000000..4858e5864b4 --- /dev/null +++ b/.github/workflows/lit.yml @@ -0,0 +1,35 @@ +name: Build + +on: + # Triggers the workflow on push or pull request events but only for the master branch + push: + pull_request: + branches: [ master ] + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +jobs: + lit-linux-debug: + name: lit tests (Linux, debug build) + runs-on: ubuntu-latest + container: ghcr.io/plc-lang/rust-llvm:latest + steps: + - uses: actions/checkout@v3 + + - name: Run `build.sh --lit` + shell: bash + run: | + ./scripts/build.sh --lit + + lit-linux-release: + name: lit tests (Linux, release build) + runs-on: ubuntu-latest + container: ghcr.io/plc-lang/rust-llvm:latest + steps: + - uses: actions/checkout@v3 + + - name: Run `build.sh --lit --release` + shell: bash + run: | + ./scripts/build.sh --lit --release \ No newline at end of file diff --git a/.gitignore b/.gitignore index cb17664f457..3d60db547f6 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,7 @@ *.a *.elf *.out + +# Garbage generated by llvm-lit +tests/lit/**/*.txt +tests/lit/**/Output/ \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json index 21eab6ec81d..8241a1f9ec9 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -20,9 +20,13 @@ } }, "args": [ - "target/demo.st", + "target/demo.st" ], - "cwd": "${workspaceFolder}" + "cwd": "${workspaceFolder}", + "env": { + "RUST_LOG": "rusty" + }, + "terminal": "integrated" }, { "type": "lldb", @@ -43,7 +47,11 @@ "args": [ "demo" ], - "cwd": "${workspaceFolder}" + "cwd": "${workspaceFolder}", + "env": { + "RUST_LOG": "rusty" + }, + "terminal": "integrated" }, ] } \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock index 2dea6b2af6f..e206b259bb0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2221,9 +2221,9 @@ dependencies = [ [[package]] name = "openssl" -version = "0.10.64" +version = "0.10.66" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95a0481286a310808298130d22dd1fef0fa571e05a8f44ec801801e84b216b1f" +checksum = "9529f4786b70a3e8c61e11179af17ab6188ad8d0ded78c5529441ed39d4bd9c1" dependencies = [ "bitflags 2.4.2", "cfg-if", @@ -2253,9 +2253,9 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" [[package]] name = "openssl-sys" -version = "0.9.101" +version = "0.9.103" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dda2b0f344e78efc2facf7d195d098df0dd72151b26ab98da807afc26c198dff" +checksum = "7f9e8deee91df40a943c71b917e5874b951d32a802526c85721ce3b776c929d6" dependencies = [ "cc", "libc", @@ -2537,6 +2537,7 @@ dependencies = [ "serde", "serde_json", "tempfile", + "toml", ] [[package]] @@ -3023,6 +3024,9 @@ checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] name = "section_mangler" version = "0.0.1" +dependencies = [ + "nom", +] [[package]] name = "security-framework" diff --git a/README.md b/README.md index e52386e6b00..f209f5bc755 100644 --- a/README.md +++ b/README.md @@ -1,40 +1,34 @@ -# RuSTy -[![Rust Build](https://github.com/PLC-lang/rusty/actions/workflows/rust.yml/badge.svg)](https://github.com/PLC-lang/ruSTy/actions) -[![codecov](https://codecov.io/gh/PLC-lang/rusty/branch/master/graph/badge.svg?token=7ZZ5XZYE9V)](https://codecov.io/gh/PLC-lang/rusty) -[![Lines of Code](https://tokei.rs/b1/github/PLC-lang/rusty)](https://github.com/XAMPPRocky/tokei) +
+ +

RuSTy

+

A structured text compiler written in Rust, utilizing the LLVM framework for native code compilation.

-[Structured text](https://en.wikipedia.org/wiki/Structured_text) compiler written in Rust + + + + + -## About RuSTy +

+ Examples | + Documentation | + Contributing +

-RuSTy is a structured text (ST) compiler written in Rust. RuSTy utilizes the -LLVM framework to compile eventually to native code. +
-## Getting started - -The easiest way to compile this project is to use the provided `Dockerfile`. The project offers a `.devcontainer` when using [VSCode](https://code.visualstudio.com/docs/remote/containers). The Dockerfile offers a linux-image which contains everything you need to run `cargo build` / `cargo test` in the project's root directory. - -If you want to build the project without docker, start [here](https://plc-lang.github.io/rusty/build_and_install.html). - -### Documentation - -The compiler's documentation can be found here: [documentation](https://plc-lang.github.io/rusty/). -### Contributing - -If you want to contribute to the project you should look for some [beginner-friendly issues](https://github.com/PLC-lang/rusty/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22) and reach out to project's maintainers. - -## Why RuSTy +## Why RuSTy? Structured Text is a popular language in the domain of automation. A standardized specification of the language ([IEC 61131](https://en.wikipedia.org/wiki/IEC_61131)) was published in the 90s. It was updated several times in the meantime, while its initial spirit - being built for cyclic, robust and deterministic automation applications - still applies. Several automation platform suppliers built proprietary compilers and runtime libraries, native to the vendor's hard- and software platform. -RuSTy is aiming towards a _fast_, _modern_ and _open-source_ industry-grade ST compiler for a wide range of platforms, sticking close to the standard. +RuSTy is aiming towards a **fast**, **modern** and **open-source** industry-grade ST compiler for a wide range of platforms, sticking close to the standard. -## Dependencies +## Getting started + +The easiest way to compile this project is to use the provided `Dockerfile`. The project offers a `.devcontainer` when using [VSCode](https://code.visualstudio.com/docs/remote/containers). The Dockerfile offers a linux-image which contains everything you need to run `cargo build` / `cargo test` in the project's root directory. -We use the [_logos_](https://crates.io/crates/logos/) -crate library to perform lexical analysis before a handwritten recursive decent parser creates the AST. -Generating LLVM IR is accomplished with the help of [_inkwell_](https://github.com/TheDan64/inkwell), a Rust-wrapper around the native LLVM C-API. +If you want to build the project without docker, start [here](https://plc-lang.github.io/rusty/build_and_install.html). \ No newline at end of file diff --git a/compiler/plc_ast/src/ast.rs b/compiler/plc_ast/src/ast.rs index 83a218d5ecd..f851a8fd31f 100644 --- a/compiler/plc_ast/src/ast.rs +++ b/compiler/plc_ast/src/ast.rs @@ -487,6 +487,7 @@ pub enum DataType { PointerType { name: Option, referenced_type: Box, + auto_deref: Option, }, StringType { name: Option, @@ -504,6 +505,18 @@ pub enum DataType { }, } +#[derive(Debug, Clone, Copy, PartialEq)] +pub enum AutoDerefType { + /// A plain pointer variable with the auto-deref trait, e.g. VAR_IN_OUT or VAR_INPUT{ref} variables + Default, + + /// An alias pointer variable, e.g. `foo AT bar : DINT` + Alias, + + /// A reference pointer variable, e.g. `foo : REFERENCE TO DINT;` + Reference, +} + impl DataType { pub fn set_name(&mut self, new_name: String) { match self { @@ -596,12 +609,14 @@ pub struct AstNode { #[derive(Debug, Clone, PartialEq)] pub enum AstStatement { EmptyStatement(EmptyStatement), - // a placeholder that indicates a default value of a datatype + + // A placeholder which indicates a default value of a datatype DefaultValue(DefaultValue), + // Literals Literal(AstLiteral), - CastStatement(CastStatement), MultipliedStatement(MultipliedStatement), + // Expressions ReferenceExpr(ReferenceExpr), Identifier(String), @@ -613,15 +628,17 @@ pub enum AstStatement { ParenExpression(Box), RangeStatement(RangeStatement), VlaRangeStatement, - // Assignment + + // TODO: Merge these variants with a `kind` field? + // Assignments Assignment(Assignment), - // OutputAssignment OutputAssignment(Assignment), - //Call Statement + RefAssignment(Assignment), + CallStatement(CallStatement), + // Control Statements ControlStatement(AstControlStatement), - CaseCondition(Box), ExitStatement(()), ContinueStatement(()), @@ -662,6 +679,9 @@ impl Debug for AstNode { AstStatement::OutputAssignment(Assignment { left, right }) => { f.debug_struct("OutputAssignment").field("left", left).field("right", right).finish() } + AstStatement::RefAssignment(Assignment { left, right }) => { + f.debug_struct("ReferenceAssignment").field("left", left).field("right", right).finish() + } AstStatement::CallStatement(CallStatement { operator, parameters }) => f .debug_struct("CallStatement") .field("operator", operator) @@ -735,9 +755,6 @@ impl Debug for AstNode { } AstStatement::ContinueStatement(..) => f.debug_struct("ContinueStatement").finish(), AstStatement::ExitStatement(..) => f.debug_struct("ExitStatement").finish(), - AstStatement::CastStatement(CastStatement { target, type_name }) => { - f.debug_struct("CastStatement").field("type_name", type_name).field("target", target).finish() - } AstStatement::ReferenceExpr(ReferenceExpr { access, base }) => { f.debug_struct("ReferenceExpr").field("kind", access).field("base", base).finish() } @@ -855,6 +872,14 @@ impl AstNode { matches!(self.stmt, AstStatement::EmptyStatement(..)) } + pub fn is_assignment(&self) -> bool { + matches!(self.stmt, AstStatement::Assignment(..)) + } + + pub fn is_output_assignment(&self) -> bool { + matches!(self.stmt, AstStatement::OutputAssignment(..)) + } + pub fn is_reference(&self) -> bool { matches!(self.stmt, AstStatement::ReferenceExpr(..)) } @@ -1280,8 +1305,11 @@ impl AstFactory { } /// creates a new Identifier - pub fn create_identifier(name: &str, location: &SourceLocation, id: AstId) -> AstNode { - AstNode::new(AstStatement::Identifier(name.to_string()), id, location.clone()) + pub fn create_identifier(name: &str, location: T, id: AstId) -> AstNode + where + T: Into, + { + AstNode::new(AstStatement::Identifier(name.to_string()), id, location.into()) } pub fn create_unary_expression( @@ -1315,6 +1343,19 @@ impl AstFactory { ) } + // TODO: Merge `create_assignment`, `create_output_assignment` and `create_ref_assignment` + // once the the Assignment AstStatements have been merged and a `kind` field is available + // I.e. something like `AstStatement::Assignment { data, kind: AssignmentKind { Normal, Output, Reference } } + // and then fn create_assignment(kind: AssignmentKind, ...) + pub fn create_ref_assignment(left: AstNode, right: AstNode, id: AstId) -> AstNode { + let location = left.location.span(&right.location); + AstNode::new( + AstStatement::RefAssignment(Assignment { left: Box::new(left), right: Box::new(right) }), + id, + location, + ) + } + pub fn create_member_reference(member: AstNode, base: Option, id: AstId) -> AstNode { let location = base .as_ref() @@ -1413,18 +1454,21 @@ impl AstFactory { } } - pub fn create_call_statement( + pub fn create_call_statement( operator: AstNode, parameters: Option, id: usize, - location: SourceLocation, - ) -> AstNode { + location: T, + ) -> AstNode + where + T: Into, + { AstNode { stmt: AstStatement::CallStatement(CallStatement { operator: Box::new(operator), parameters: parameters.map(Box::new), }), - location, + location: location.into(), id, } } diff --git a/compiler/plc_ast/src/lib.rs b/compiler/plc_ast/src/lib.rs index 7e7d78a7dee..33febadee02 100644 --- a/compiler/plc_ast/src/lib.rs +++ b/compiler/plc_ast/src/lib.rs @@ -7,3 +7,4 @@ pub mod control_statements; pub mod literals; mod pre_processor; pub mod provider; +pub mod visitor; diff --git a/compiler/plc_ast/src/visitor.rs b/compiler/plc_ast/src/visitor.rs new file mode 100644 index 00000000000..c50b7c3c1bc --- /dev/null +++ b/compiler/plc_ast/src/visitor.rs @@ -0,0 +1,724 @@ +//! This module defines the `AstVisitor` trait and its associated macros. +//! The `AstVisitor` trait provides a set of methods for traversing and visiting ASTs + +use crate::ast::AstNode; +use crate::ast::*; +use crate::control_statements::{AstControlStatement, ConditionalBlock, ReturnStatement}; +use crate::literals::AstLiteral; + +/// Macro that calls the visitor's `visit` method for every AstNode in the passed iterator `iter`. +macro_rules! visit_all_nodes { + ($visitor:expr, $iter:expr) => { + for node in $iter { + $visitor.visit(node); + } + }; +} + +/// Macro that calls the visitor's `visit` method for every AstNode in the passed sequence of nodes. +macro_rules! visit_nodes { + ($visitor:expr, $($node:expr),*) => { + $( + $visitor.visit($node); + )* + }; +} + +/// The `Walker` implements the traversal of the AST nodes and Ast-related objects (e.g. CompilationUnit). +/// The `walk` method is called on the object to visit its children. +/// If the object passed to a `AstVisitor`'s `visit` method implements the `Walker` trait, +/// a call to the it's walk function continues the visiting process on its children. +/// +/// Spliting the traversal logic into a separate trait allows to call the default traversal logic +/// from the visitor while overriding the visitor's `visit` method for specific nodes. +/// +/// # Example +/// ``` +/// use plc_ast::ast::AstNode; +/// use plc_ast::visitor::Walker; +/// use plc_ast::visitor::AstVisitor; +/// +/// struct MyAssignment { +/// left: AstNode, +/// right: AstNode, +/// } +/// +/// impl Walker for MyAssignment { +/// fn walk(&self, visitor: &mut V) +/// where +/// V: AstVisitor, +/// { +/// visitor.visit(&self.right); +/// visitor.visit(&self.left); +/// } +/// } +/// ``` +/// +pub trait Walker { + fn walk(&self, visitor: &mut V) + where + V: AstVisitor; +} + +/// The `AstVisitor` trait provides a set of methods for visiting different types of AST nodes. +/// Implementors can individually override the methods they are interested in. When overriding a method, +/// make sure to call `walk` on the visited statement to visit its children. DO NOT call walk on +/// the node itself to avoid a recursion (last parameter). Implementors may also decide to not call +/// the statement's `walk` method to avoid visiting the children of the statement. +/// +/// The visitor offers strongly typed `visit_X` functions for every node type. The function's signature +/// is `fn visit_X(&mut self, stmt: &X, node: &AstNode)`. The `stmt` parameter is the unwrapped, typed +/// node and the `node` parameter is the `AstNode` wrapping the stmt. The `AstNode` node offers access to location +/// information and the AstId. Note that some nodes are not wrapped in an `AstNode` node (e.g. `CompilationUnit`) +/// and therefore only the strongly typed node is passed to the `visit_X` function. +/// +/// # Example +/// ``` +/// use plc_ast::{ +/// ast::{Assignment, AstNode}, +/// visitor::{AstVisitor, Walker}, +/// }; +/// +/// struct AssignmentCounter { +/// count: usize, +/// } +/// +/// impl AstVisitor for AssignmentCounter { +/// fn visit_assignment(&mut self, stmt: &Assignment, _node: &AstNode) { +/// self.count += 1; +/// // visit child nodes +/// stmt.walk(self); +/// } +/// +/// fn visit_output_assignment(&mut self, stmt: &Assignment, _node: &AstNode) { +/// self.count += 1; +/// // visit child nodes +/// stmt.walk(self); +/// } +/// } +/// ``` +pub trait AstVisitor: Sized { + /// Visits this `AstNode`. The default implementation calls the `walk` method on the node + /// and will eventually call the strongly typed `visit` method for the node (e.g. visit_assignment + /// if the node is an `AstStatement::Assignment`). + /// # Arguments + /// * `node` - The `AstNode` node to visit. + fn visit(&mut self, node: &AstNode) { + node.walk(self) + } + + /// Visits a `CompilationUnit` node. + /// Make sure to call `walk` on the `CompilationUnit` node to visit its children. + /// # Arguments + /// * `unit` - The unwraped, typed `CompilationUnit` node to visit. + /// * `node` - The wrapped `AstNode` node to visit. Offers access to location information and AstId + fn visit_compilation_unit(&mut self, unit: &CompilationUnit) { + unit.walk(self) + } + + /// Visits an `Implementation` node. + /// Make sure to call `walk` on the `Implementation` node to visit its children. + /// # Arguments + /// * `implementation` - The unwraped, typed `Implementation` node to visit. + fn visit_implementation(&mut self, implementation: &Implementation) { + implementation.walk(self); + } + + /// Visits a `DataTypeDeclaration` node. + /// Make sure to call `walk` on the `VariableBlock` node to visit its children. + /// # Arguments + /// * `block` - The unwraped, typed `VariableBlock` node to visit. + fn visit_variable_block(&mut self, block: &VariableBlock) { + block.walk(self) + } + + /// Visits a `Variable` node. + /// Make sure to call `walk` on the `Variable` node to visit its children. + /// # Arguments + /// * `variable` - The unwraped, typed `Variable` node to visit. + fn visit_variable(&mut self, variable: &Variable) { + variable.walk(self); + } + + /// Visits an enum element `AstNode` node. + /// Make sure to call `walk` on the `AstNode` node to visit its children. + /// # Arguments + /// * `element` - The unwraped, typed `AstNode` node to visit. + fn visit_enum_element(&mut self, element: &AstNode) { + element.walk(self); + } + + /// Visits a `DataTypeDeclaration` node. + /// Make sure to call `walk` on the `DataTypeDeclaration` node to visit its children. + /// # Arguments + /// * `data_type_declaration` - The unwraped, typed `DataTypeDeclaration` node to visit. + fn visit_data_type_declaration(&mut self, data_type_declaration: &DataTypeDeclaration) { + data_type_declaration.walk(self); + } + + /// Visits a `UserTypeDeclaration` node. + /// Make sure to call `walk` on the `UserTypeDeclaration` node to visit its children. + /// # Arguments + /// * `user_type` - The unwraped, typed `UserTypeDeclaration` node to visit. + fn visit_user_type_declaration(&mut self, user_type: &UserTypeDeclaration) { + user_type.walk(self); + } + + /// Visits a `UserTypeDeclaration` node. + /// Make sure to call `walk` on the `DataType` node to visit its children. + /// # Arguments + /// * `data_type` - The unwraped, typed `DataType` node to visit. + fn visit_data_type(&mut self, data_type: &DataType) { + data_type.walk(self); + } + + /// Visits a `Pou` node. + /// Make sure to call `walk` on the `Pou` node to visit its children. + /// # Arguments + /// * `pou` - The unwraped, typed `Pou` node to visit. + fn visit_pou(&mut self, pou: &Pou) { + pou.walk(self); + } + + /// Visits an `EmptyStatement` node. + /// # Arguments + /// * `stmt` - The unwraped, typed `EmptyStatement` node to visit. + /// * `node` - The wrapped `AstNode` node to visit. Offers access to location information and AstId + fn visit_empty_statement(&mut self, _stmt: &EmptyStatement, _node: &AstNode) {} + + /// Visits a `DefaultValue` node. + /// # Arguments + /// * `stmt` - The unwraped, typed `DefaultValue` node to visit. + /// * `node` - The wrapped `AstNode` node to visit. Offers access to location information and AstId + fn visit_default_value(&mut self, _stmt: &DefaultValue, _node: &AstNode) {} + + /// Visits an `AstLiteral` node. + /// Make sure to call `walk` on the `AstLiteral` node to visit its children. + /// # Arguments + /// * `stmt` - The unwraped, typed `AstLiteral` node to visit. + /// * `node` - The wrapped `AstNode` node to visit. Offers access to location information and AstId + fn visit_literal(&mut self, stmt: &AstLiteral, _node: &AstNode) { + stmt.walk(self) + } + + /// Visits a `MultipliedStatement` node. + /// Make sure to call `walk` on the `MultipliedStatement` node to visit its children. + /// # Arguments + /// * `stmt` - The unwraped, typed `MultipliedStatement` node to visit. + /// * `node` - The wrapped `AstNode` node to visit. Offers access to location information and AstId + fn visit_multiplied_statement(&mut self, stmt: &MultipliedStatement, _node: &AstNode) { + stmt.walk(self) + } + + /// Visits a `ReferenceExpr` node. + /// Make sure to call `walk` on the `ReferenceExpr` node to visit its children. + /// # Arguments + /// * `stmt` - The unwraped, typed `ReferenceExpr` node to visit. + /// * `node` - The wrapped `AstNode` node to visit. Offers access to location information and AstId + fn visit_reference_expr(&mut self, stmt: &ReferenceExpr, _node: &AstNode) { + stmt.walk(self) + } + + /// Visits an `Identifier` node. + /// Make sure to call `walk` on the `Identifier` node to visit its children. + /// # Arguments + /// * `stmt` - The unwraped, typed `Identifier` node to visit. + /// * `node` - The wrapped `AstNode` node to visit. Offers access to location information and AstId + fn visit_identifier(&mut self, _stmt: &str, _node: &AstNode) {} + + /// Visits a `DirectAccess` node. + /// Make sure to call `walk` on the `DirectAccess` node to visit its children. + /// # Arguments + /// * `stmt` - The unwraped, typed `DirectAccess` node to visit. + /// * `node` - The wrapped `AstNode` node to visit. Offers access to location information and AstId + fn visit_direct_access(&mut self, stmt: &DirectAccess, _node: &AstNode) { + stmt.walk(self) + } + + /// Visits a `HardwareAccess` node. + /// Make sure to call `walk` on the `HardwareAccess` node to visit its children. + /// # Arguments + /// * `stmt` - The unwraped, typed `HardwareAccess` node to visit. + /// * `node` - The wrapped `AstNode` node to visit. Offers access to location information and AstId + fn visit_hardware_access(&mut self, stmt: &HardwareAccess, _node: &AstNode) { + stmt.walk(self) + } + + /// Visits a `BinaryExpression` node. + /// Make sure to call `walk` on the `BinaryExpression` node to visit its children. + /// # Arguments + /// * `stmt` - The unwraped, typed `BinaryExpression` node to visit. + /// * `node` - The wrapped `AstNode` node to visit. Offers access to location information and AstId + fn visit_binary_expression(&mut self, stmt: &BinaryExpression, _node: &AstNode) { + stmt.walk(self) + } + + /// Visits a `UnaryExpression` node. + /// Make sure to call `walk` on the `UnaryExpression` node to visit its children. + /// # Arguments + /// * `stmt` - The unwraped, typed `UnaryExpression` node to visit. + /// * `node` - The wrapped `AstNode` node to visit. Offers access to location information and AstId + fn visit_unary_expression(&mut self, stmt: &UnaryExpression, _node: &AstNode) { + stmt.walk(self) + } + + /// Visits an `ExpressionList` node. + /// Make sure to call `walk` on the `Vec` node to visit its children. + /// # Arguments + /// * `stmt` - The unwraped, typed `ExpressionList` node to visit. + /// * `node` - The wrapped `AstNode` node to visit. Offers access to location information and AstId + fn visit_expression_list(&mut self, stmt: &Vec, _node: &AstNode) { + visit_all_nodes!(self, stmt); + } + + /// Visits a `ParenExpression` node. + /// Make sure to call `walk` on the inner `AstNode` node to visit its children. + /// # Arguments + /// * `inner` - The unwraped, typed inner `AstNode` node to visit. + /// * `node` - The wrapped `AstNode` node to visit. Offers access to location information and AstId + fn visit_paren_expression(&mut self, inner: &AstNode, _node: &AstNode) { + inner.walk(self) + } + + /// Visits a `RangeStatement` node. + /// Make sure to call `walk` on the `RangeStatement` node to visit its children. + /// # Arguments + /// * `stmt` - The unwraped, typed `RangeStatement` node to visit. + /// * `node` - The wrapped `AstNode` node to visit. Offers access to location information and AstId + fn visit_range_statement(&mut self, stmt: &RangeStatement, _node: &AstNode) { + stmt.walk(self) + } + + /// Visits a `VlaRangeStatement` node. + /// # Arguments + /// * `node` - The wrapped `AstNode` node to visit. Offers access to location information and AstId + fn visit_vla_range_statement(&mut self, _node: &AstNode) {} + + /// Visits an `Assignment` node. + /// Make sure to call `walk` on the `Assignment` node to visit its children. + /// # Arguments + /// * `stmt` - The unwraped, typed `Assignment` node to visit. + /// * `node` - The wrapped `AstNode` node to visit. Offers access to location information and AstId + fn visit_assignment(&mut self, stmt: &Assignment, _node: &AstNode) { + stmt.walk(self) + } + + /// Visits an `OutputAssignment` node. + /// Make sure to call `walk` on the `Assignment` node to visit its children. + /// # Arguments + /// * `stmt` - The unwraped, typed `Assignment` node to visit. + /// * `node` - The wrapped `AstNode` node to visit. Offers access to location information and AstId + fn visit_output_assignment(&mut self, stmt: &Assignment, _node: &AstNode) { + stmt.walk(self) + } + + /// Visits an `RefAssignment` node. + /// Make sure to call `walk` on the `Assignment` node to visit its children. + /// # Arguments + /// * `stmt` - The unwraped, typed `Assignment` node to visit. + /// * `node` - The wrapped `AstNode` node to visit. Offers access to location information and AstId + fn visit_ref_assignment(&mut self, stmt: &Assignment, _node: &AstNode) { + stmt.walk(self) + } + + /// Visits a `CallStatement` node. + /// Make sure to call `walk` on the `CallStatement` node to visit its children. + /// # Arguments + /// * `stmt` - The unwraped, typed `CallStatement` node to visit. + /// * `node` - The wrapped `AstNode` node to visit. Offers access to location information and AstId + fn visit_call_statement(&mut self, stmt: &CallStatement, _node: &AstNode) { + stmt.walk(self) + } + + /// Visits an `AstControlStatement` node. + /// Make sure to call `walk` on the `AstControlStatement` node to visit its children. + /// # Arguments + /// * `stmt` - The unwraped, typed `AstControlStatement` node to visit. + /// * `node` - The wrapped `AstNode` node to visit. Offers access to location information and AstId + fn visit_control_statement(&mut self, stmt: &AstControlStatement, _node: &AstNode) { + stmt.walk(self) + } + + /// Visits a `CaseCondition` node. + /// Make sure to call `walk` on the child-`AstNode` node to visit its children. + /// # Arguments + /// * `stmt` - The unwraped, typed `CaseCondition` node to visit. + /// * `node` - The wrapped `AstNode` node to visit. Offers access to location information and AstId + fn visit_case_condition(&mut self, child: &AstNode, _node: &AstNode) { + child.walk(self) + } + + /// Visits an `ExitStatement` node. + /// # Arguments + /// * `node` - The wrapped `AstNode` node to visit. Offers access to location information and AstId + fn visit_exit_statement(&mut self, _node: &AstNode) {} + + /// Visits a `ContinueStatement` node. + /// # Arguments + /// * `node` - The wrapped `AstNode` node to visit. Offers access to location information and AstId + fn visit_continue_statement(&mut self, _node: &AstNode) {} + + /// Visits a `ReturnStatement` node. + /// Make sure to call `walk` on the `ReturnStatement` node to visit its children. + /// # Arguments + /// * `stmt` - The unwraped, typed `ReturnStatement` node to visit. + /// * `node` - The wrapped `AstNode` node to visit. Offers access to location information and AstId + fn visit_return_statement(&mut self, stmt: &ReturnStatement, _node: &AstNode) { + stmt.walk(self) + } + + /// Visits a `JumpStatement` node. + /// Make sure to call `walk` on the `JumpStatement` node to visit its children. + /// # Arguments + /// * `stmt` - The unwraped, typed `JumpStatement` node to visit. + /// * `node` - The wrapped `AstNode` node to visit. Offers access to location information and AstId + fn visit_jump_statement(&mut self, stmt: &JumpStatement, _node: &AstNode) { + stmt.walk(self) + } + + /// Visits a `LabelStatement` node. + /// # Arguments + /// * `stmt` - The unwraped, typed `LabelStatement` node to visit. + /// * `node` - The wrapped `AstNode` node to visit. Offers access to location information and AstId + fn visit_label_statement(&mut self, _stmt: &LabelStatement, _node: &AstNode) {} +} + +/// Helper method that walks through a slice of `ConditionalBlock` and applies the visitor's `walk` method to each node. +fn walk_conditional_blocks(visitor: &mut V, blocks: &[ConditionalBlock]) +where + V: AstVisitor, +{ + for b in blocks { + visit_nodes!(visitor, &b.condition); + visit_all_nodes!(visitor, &b.body); + } +} + +impl Walker for AstLiteral { + fn walk(&self, _visitor: &mut V) + where + V: AstVisitor, + { + // do nothing + } +} + +impl Walker for MultipliedStatement { + fn walk(&self, visitor: &mut V) + where + V: AstVisitor, + { + visitor.visit(&self.element) + } +} + +impl Walker for ReferenceExpr { + fn walk(&self, visitor: &mut V) + where + V: AstVisitor, + { + if let Some(base) = &self.base { + visitor.visit(base); + } + + match &self.access { + ReferenceAccess::Member(t) | ReferenceAccess::Index(t) | ReferenceAccess::Cast(t) => { + visitor.visit(t) + } + _ => {} + } + } +} + +impl Walker for DirectAccess { + fn walk(&self, visitor: &mut V) + where + V: AstVisitor, + { + visit_nodes!(visitor, &self.index); + } +} + +impl Walker for HardwareAccess { + fn walk(&self, visitor: &mut V) + where + V: AstVisitor, + { + visit_all_nodes!(visitor, &self.address); + } +} + +impl Walker for BinaryExpression { + fn walk(&self, visitor: &mut V) + where + V: AstVisitor, + { + visit_nodes!(visitor, &self.left, &self.right); + } +} + +impl Walker for UnaryExpression { + fn walk(&self, visitor: &mut V) + where + V: AstVisitor, + { + visit_nodes!(visitor, &self.value); + } +} + +impl Walker for Assignment { + fn walk(&self, visitor: &mut V) + where + V: AstVisitor, + { + visit_nodes!(visitor, &self.left, &self.right); + } +} + +impl Walker for RangeStatement { + fn walk(&self, visitor: &mut V) + where + V: AstVisitor, + { + visit_nodes!(visitor, &self.start, &self.end); + } +} + +impl Walker for CallStatement { + fn walk(&self, visitor: &mut V) + where + V: AstVisitor, + { + visit_nodes!(visitor, &self.operator); + if let Some(params) = &self.parameters { + visit_nodes!(visitor, params); + } + } +} + +impl Walker for AstControlStatement { + fn walk(&self, visitor: &mut V) + where + V: AstVisitor, + { + match self { + AstControlStatement::If(stmt) => { + walk_conditional_blocks(visitor, &stmt.blocks); + visit_all_nodes!(visitor, &stmt.else_block); + } + AstControlStatement::WhileLoop(stmt) | AstControlStatement::RepeatLoop(stmt) => { + visit_nodes!(visitor, &stmt.condition); + visit_all_nodes!(visitor, &stmt.body); + } + AstControlStatement::ForLoop(stmt) => { + visit_nodes!(visitor, &stmt.counter, &stmt.start, &stmt.end); + visit_all_nodes!(visitor, &stmt.by_step); + visit_all_nodes!(visitor, &stmt.body); + } + AstControlStatement::Case(stmt) => { + visit_nodes!(visitor, &stmt.selector); + walk_conditional_blocks(visitor, &stmt.case_blocks); + visit_all_nodes!(visitor, &stmt.else_block); + } + } + } +} + +impl Walker for ReturnStatement { + fn walk(&self, visitor: &mut V) + where + V: AstVisitor, + { + visit_all_nodes!(visitor, &self.condition); + } +} + +impl Walker for JumpStatement { + fn walk(&self, visitor: &mut V) + where + V: AstVisitor, + { + visit_nodes!(visitor, &self.condition, &self.target); + } +} + +impl Walker for AstNode { + fn walk(&self, visitor: &mut V) + where + V: AstVisitor, + { + let node = self; + match &self.stmt { + AstStatement::EmptyStatement(stmt) => visitor.visit_empty_statement(stmt, node), + AstStatement::DefaultValue(stmt) => visitor.visit_default_value(stmt, node), + AstStatement::Literal(stmt) => visitor.visit_literal(stmt, node), + AstStatement::MultipliedStatement(stmt) => visitor.visit_multiplied_statement(stmt, node), + AstStatement::ReferenceExpr(stmt) => visitor.visit_reference_expr(stmt, node), + AstStatement::Identifier(stmt) => visitor.visit_identifier(stmt, node), + AstStatement::DirectAccess(stmt) => visitor.visit_direct_access(stmt, node), + AstStatement::HardwareAccess(stmt) => visitor.visit_hardware_access(stmt, node), + AstStatement::BinaryExpression(stmt) => visitor.visit_binary_expression(stmt, node), + AstStatement::UnaryExpression(stmt) => visitor.visit_unary_expression(stmt, node), + AstStatement::ExpressionList(stmt) => visitor.visit_expression_list(stmt, node), + AstStatement::ParenExpression(stmt) => visitor.visit_paren_expression(stmt, node), + AstStatement::RangeStatement(stmt) => visitor.visit_range_statement(stmt, node), + AstStatement::VlaRangeStatement => visitor.visit_vla_range_statement(node), + AstStatement::Assignment(stmt) => visitor.visit_assignment(stmt, node), + AstStatement::OutputAssignment(stmt) => visitor.visit_output_assignment(stmt, node), + AstStatement::RefAssignment(stmt) => visitor.visit_ref_assignment(stmt, node), + AstStatement::CallStatement(stmt) => visitor.visit_call_statement(stmt, node), + AstStatement::ControlStatement(stmt) => visitor.visit_control_statement(stmt, node), + AstStatement::CaseCondition(stmt) => visitor.visit_case_condition(stmt, node), + AstStatement::ExitStatement(_stmt) => visitor.visit_exit_statement(node), + AstStatement::ContinueStatement(_stmt) => visitor.visit_continue_statement(node), + AstStatement::ReturnStatement(stmt) => visitor.visit_return_statement(stmt, node), + AstStatement::JumpStatement(stmt) => visitor.visit_jump_statement(stmt, node), + AstStatement::LabelStatement(stmt) => visitor.visit_label_statement(stmt, node), + } + } +} + +impl Walker for CompilationUnit { + fn walk(&self, visitor: &mut V) + where + V: AstVisitor, + { + for block in &self.global_vars { + visitor.visit_variable_block(block); + } + + for user_type in &self.user_types { + visitor.visit_user_type_declaration(user_type); + } + + for pou in &self.units { + visitor.visit_pou(pou); + } + + for i in &self.implementations { + visitor.visit_implementation(i); + } + } +} + +impl Walker for UserTypeDeclaration { + fn walk(&self, visitor: &mut V) + where + V: AstVisitor, + { + visitor.visit_data_type(&self.data_type); + visit_all_nodes!(visitor, &self.initializer); + } +} + +impl Walker for VariableBlock { + fn walk(&self, visitor: &mut V) + where + V: AstVisitor, + { + for v in self.variables.iter() { + visitor.visit_variable(v); + } + } +} + +impl Walker for Variable { + fn walk(&self, visitor: &mut V) + where + V: AstVisitor, + { + visit_all_nodes!(visitor, &self.address); + visitor.visit_data_type_declaration(&self.data_type_declaration); + visit_all_nodes!(visitor, &self.initializer); + } +} + +impl Walker for DataType { + fn walk(&self, visitor: &mut V) + where + V: AstVisitor, + { + match self { + DataType::StructType { variables, .. } => { + for v in variables.iter() { + visitor.visit_variable(v); + } + } + DataType::EnumType { elements, .. } => { + for ele in flatten_expression_list(elements) { + visitor.visit_enum_element(ele); + } + } + DataType::SubRangeType { bounds, .. } => { + visit_all_nodes!(visitor, bounds); + } + DataType::ArrayType { bounds, referenced_type, .. } => { + visitor.visit(bounds); + visitor.visit_data_type_declaration(referenced_type); + } + DataType::PointerType { referenced_type, .. } => { + visitor.visit_data_type_declaration(referenced_type); + } + DataType::StringType { size, .. } => { + visit_all_nodes!(visitor, size); + } + DataType::VarArgs { referenced_type, .. } => { + if let Some(data_type_declaration) = referenced_type { + visitor.visit_data_type_declaration(data_type_declaration); + } + } + DataType::GenericType { .. } => { + //no further visits + } + } + } +} + +impl Walker for DataTypeDeclaration { + fn walk(&self, visitor: &mut V) + where + V: AstVisitor, + { + if let DataTypeDeclaration::DataTypeDefinition { data_type, .. } = self { + visitor.visit_data_type(data_type); + } + } +} + +impl Walker for Option +where + T: Walker, +{ + fn walk(&self, visitor: &mut V) + where + V: AstVisitor, + { + if let Some(node) = self { + node.walk(visitor); + } + } +} + +impl Walker for Pou { + fn walk(&self, visitor: &mut V) + where + V: AstVisitor, + { + for block in &self.variable_blocks { + visitor.visit_variable_block(block); + } + + self.return_type.as_ref().inspect(|rt| visitor.visit_data_type_declaration(rt)); + } +} + +impl Walker for Implementation { + fn walk(&self, visitor: &mut V) + where + V: AstVisitor, + { + for n in &self.statements { + visitor.visit(n); + } + } +} diff --git a/compiler/plc_diagnostics/src/diagnostics.rs b/compiler/plc_diagnostics/src/diagnostics.rs index d45546a92dc..1aa1441df2d 100644 --- a/compiler/plc_diagnostics/src/diagnostics.rs +++ b/compiler/plc_diagnostics/src/diagnostics.rs @@ -2,6 +2,7 @@ use std::fmt::Display; use serde::{Deserialize, Serialize}; +use crate::diagnostics::diagnostics_registry::DIAGNOSTICS; use plc_ast::ast::AstNode; use plc_source::{ source_location::{SourceLocation, SourceLocationFactory}, @@ -88,8 +89,10 @@ impl Diagnostic { self } - pub fn with_error_code(mut self, error_code: &'static str) -> Self { - self.error_code = error_code; + pub fn with_error_code(mut self, code: &'static str) -> Self { + debug_assert!(DIAGNOSTICS.get(code).is_some(), "Error {code} does not exist"); + + self.error_code = code; self } @@ -199,12 +202,26 @@ impl Diagnostic { .with_error_code("E006") } - pub fn invalid_parameter_count(expected: usize, received: usize, location: SourceLocation) -> Diagnostic { - Diagnostic::new( - format!( - "Invalid parameter count. Received {received} parameters while {expected} parameters were expected.", - )).with_error_code("E032") - .with_location(location) + pub fn invalid_argument_count(expected: usize, actual: usize, location: T) -> Diagnostic + where + T: Into, + { + // Let's be extra fancy here 🕺 + fn message(value: usize) -> String { + match value { + 1 => format!("{value} argument"), + _ => format!("{value} arguments"), + } + } + + Diagnostic::new(format!( + "this POU takes {expected} but {actual} {was_or_were} supplied", + expected = message(expected), + actual = message(actual), + was_or_were = if actual == 1 { "was" } else { "were" } + )) + .with_error_code("E032") + .with_location(location.into()) } pub fn unknown_type(type_name: &str, location: SourceLocation) -> Diagnostic { @@ -217,7 +234,10 @@ impl Diagnostic { .with_location(location) } - pub fn invalid_assignment(right_type: &str, left_type: &str, location: SourceLocation) -> Diagnostic { + pub fn invalid_assignment(right_type: &str, left_type: &str, location: T) -> Diagnostic + where + T: Into, + { Diagnostic::new(format!("Invalid assignment: cannot assign '{right_type}' to '{left_type}'")) .with_error_code("E037") .with_location(location) diff --git a/compiler/plc_diagnostics/src/diagnostics/diagnostics_registry.rs b/compiler/plc_diagnostics/src/diagnostics/diagnostics_registry.rs index b9999558bc0..f3db285d771 100644 --- a/compiler/plc_diagnostics/src/diagnostics/diagnostics_registry.rs +++ b/compiler/plc_diagnostics/src/diagnostics/diagnostics_registry.rs @@ -99,296 +99,110 @@ impl From<&DiagnosticsRegistry> for DiagnosticsConfiguration { } } +#[rustfmt::skip] lazy_static! { - static ref DIAGNOSTICS: FxHashMap<&'static str, DiagnosticEntry> = add_diagnostic!( - E001, - Error, - include_str!("./error_codes/E001.md"), //General Error - E002, - Error, - include_str!("./error_codes/E002.md"), //General IO Error - E003, - Error, - include_str!("./error_codes/E003.md"), //Parameter Error - E004, - Error, - include_str!("./error_codes/E004.md"), //Duplicate Symbol - E005, - Error, - include_str!("./error_codes/E005.md"), //Generic LLVM Error - E006, - Error, - include_str!("./error_codes/E006.md"), //Missing Token - E007, - Error, - include_str!("./error_codes/E007.md"), //Unexpected Token - E008, - Error, - include_str!("./error_codes/E008.md"), //Invalid Range - E009, - Error, - include_str!("./error_codes/E009.md"), //Mismatched Parantheses - E010, - Error, - include_str!("./error_codes/E010.md"), //Invalid Time Literal - E011, - Error, - include_str!("./error_codes/E011.md"), //Invalid Number - E012, - Error, - include_str!("./error_codes/E012.md"), //Missing Case Condition - E013, - Warning, - include_str!("./error_codes/E013.md"), //Keywords shoud contain underscores - E014, - Warning, - include_str!("./error_codes/E014.md"), //Wrong parantheses type - E015, - Warning, - include_str!("./error_codes/E015.md"), //Pointer is not standard - E016, - Warning, - include_str!("./error_codes/E016.md"), //Return types cannot have a default value - E017, - Error, - include_str!("./error_codes/E017.md"), //Classes cannot contain implementations - E018, - Error, - include_str!("./error_codes/E018.md"), //Duplicate Label - E019, - Error, - include_str!("./error_codes/E019.md"), //Classes cannot contain IN_OUT variables - E020, - Error, - include_str!("./error_codes/E020.md"), //Classes cannot contain a return type - E021, - Error, - include_str!("./error_codes/E021.md"), //POUs cannot be extended - E022, - Warning, - include_str!("./error_codes/E022.md"), //Missing action container - E023, - Warning, - include_str!("./error_codes/E023.md"), //Statement with no effect - E024, - Warning, - include_str!("./error_codes/E024.md"), //Invalid pragma location - E025, - Error, - include_str!("./error_codes/E025.md"), // Missing return type - E026, - Error, - include_str!("./error_codes/E026.md"), - E027, - Error, - include_str!("./error_codes/E027.md"), - E028, - Error, - include_str!("./error_codes/E028.md"), - E029, - Error, - include_str!("./error_codes/E029.md"), - E030, - Error, - include_str!("./error_codes/E030.md"), - E031, - Error, - include_str!("./error_codes/E031.md"), - E032, - Error, - include_str!("./error_codes/E032.md"), - E033, - Error, - include_str!("./error_codes/E033.md"), - E034, - Error, - include_str!("./error_codes/E034.md"), - E035, - Error, - include_str!("./error_codes/E035.md"), - E036, - Error, - include_str!("./error_codes/E036.md"), - E037, - Error, - include_str!("./error_codes/E037.md"), - E038, - Error, - include_str!("./error_codes/E038.md"), //Missing type - E039, - Warning, - include_str!("./error_codes/E039.md"), - E040, - Error, - include_str!("./error_codes/E040.md"), - E041, - Error, - include_str!("./error_codes/E041.md"), - E042, - Warning, - include_str!("./error_codes/E042.md"), //Assignment to reference - E043, - Error, - include_str!("./error_codes/E043.md"), - E044, - Error, - include_str!("./error_codes/E044.md"), - E045, - Error, - include_str!("./error_codes/E045.md"), - E046, - Error, - include_str!("./error_codes/E046.md"), - E047, - Warning, - include_str!("./error_codes/E047.md"), //VLAs are always by reference - E048, - Error, - include_str!("./error_codes/E048.md"), - E049, - Error, - include_str!("./error_codes/E049.md"), - E050, - Error, - include_str!("./error_codes/E050.md"), - E051, - Error, - include_str!("./error_codes/E051.md"), - E052, - Error, - include_str!("./error_codes/E052.md"), - E053, - Error, - include_str!("./error_codes/E053.md"), - E054, - Error, - include_str!("./error_codes/E054.md"), - E055, - Error, - include_str!("./error_codes/E055.md"), - E056, - Error, - include_str!("./error_codes/E056.md"), - E057, - Error, - include_str!("./error_codes/E057.md"), - E058, - Error, - include_str!("./error_codes/E058.md"), - E059, - Error, - include_str!("./error_codes/E059.md"), - E060, - Info, - include_str!("./error_codes/E060.md"), //Variable direct access with % - E061, - Error, - include_str!("./error_codes/E061.md"), - E062, - Error, - include_str!("./error_codes/E062.md"), - E063, - Error, - include_str!("./error_codes/E063.md"), - E064, - Error, - include_str!("./error_codes/E064.md"), - E065, - Error, - include_str!("./error_codes/E065.md"), - E066, - Error, - include_str!("./error_codes/E066.md"), - E067, - Warning, - include_str!("./error_codes/E067.md"), //Implicit typecast - E068, - Error, - include_str!("./error_codes/E068.md"), - E069, - Error, - include_str!("./error_codes/E069.md"), - E070, - Error, - include_str!("./error_codes/E070.md"), - E071, - Error, - include_str!("./error_codes/E071.md"), - E072, - Error, - include_str!("./error_codes/E072.md"), - E073, - Error, - include_str!("./error_codes/E073.md"), - E074, - Error, - include_str!("./error_codes/E074.md"), - E075, - Error, - include_str!("./error_codes/E075.md"), - E076, - Error, - include_str!("./error_codes/E076.md"), - E077, - Error, - include_str!("./error_codes/E077.md"), - E078, - Error, - include_str!("./error_codes/E078.md"), - E079, - Error, - include_str!("./error_codes/E079.md"), - E080, - Error, - include_str!("./error_codes/E080.md"), - E081, - Error, - include_str!("./error_codes/E081.md"), - E082, - Error, - include_str!("./error_codes/E082.md"), - E083, - Error, - include_str!("./error_codes/E083.md"), - E084, - Error, - include_str!("./error_codes/E084.md"), - E085, - Error, - include_str!("./error_codes/E085.md"), - E086, - Error, - include_str!("./error_codes/E086.md"), - E087, - Error, - include_str!("./error_codes/E087.md"), - E088, - Error, - include_str!("./error_codes/E088.md"), - E089, - Error, - include_str!("./error_codes/E089.md"), - E090, - Warning, - include_str!("./error_codes/E090.md"), //Incompatible reference Assignment - E091, - Warning, - include_str!("./error_codes/E091.md"), - E092, - Info, - include_str!("./error_codes/E092.md"), - E093, - Warning, - include_str!("./error_codes/E093.md"), - E094, - Error, - include_str!("./error_codes/E094.md"), - E095, - Error, - include_str!("./error_codes/E095.md"), // Action call without `()` - E096, Warning, include_str!("./error_codes/E096.md"), // Integer Condition - E097, Error, include_str!("./error_codes/E097.md"), // Invalid Array Range -); + pub static ref DIAGNOSTICS: FxHashMap<&'static str, DiagnosticEntry> = add_diagnostic!( + E001, Error, include_str!("./error_codes/E001.md"), //General Error + E002, Error, include_str!("./error_codes/E002.md"), //General IO Error + E003, Error, include_str!("./error_codes/E003.md"), //Parameter Error + E004, Error, include_str!("./error_codes/E004.md"), //Duplicate Symbol + E005, Error, include_str!("./error_codes/E005.md"), //Generic LLVM Error + E006, Error, include_str!("./error_codes/E006.md"), //Missing Token + E007, Error, include_str!("./error_codes/E007.md"), //Unexpected Token + E008, Error, include_str!("./error_codes/E008.md"), //Invalid Range + E009, Error, include_str!("./error_codes/E009.md"), //Mismatched Parantheses + E010, Error, include_str!("./error_codes/E010.md"), //Invalid Time Literal + E011, Error, include_str!("./error_codes/E011.md"), //Invalid Number + E012, Error, include_str!("./error_codes/E012.md"), //Missing Case Condition + E013, Warning, include_str!("./error_codes/E013.md"), //Keywords shoud contain underscores + E014, Warning, include_str!("./error_codes/E014.md"), //Wrong parantheses type + E015, Warning, include_str!("./error_codes/E015.md"), //Pointer is not standard + E016, Warning, include_str!("./error_codes/E016.md"), //Return types cannot have a default value + E017, Error, include_str!("./error_codes/E017.md"), //Classes cannot contain implementations + E018, Error, include_str!("./error_codes/E018.md"), //Duplicate Label + E019, Error, include_str!("./error_codes/E019.md"), //Classes cannot contain IN_OUT variables + E020, Error, include_str!("./error_codes/E020.md"), //Classes cannot contain a return type + E021, Error, include_str!("./error_codes/E021.md"), //POUs cannot be extended + E022, Warning, include_str!("./error_codes/E022.md"), //Missing action container + E023, Warning, include_str!("./error_codes/E023.md"), //Statement with no effect + E024, Warning, include_str!("./error_codes/E024.md"), //Invalid pragma location + E025, Error, include_str!("./error_codes/E025.md"), // Missing return type + E026, Error, include_str!("./error_codes/E026.md"), + E027, Error, include_str!("./error_codes/E027.md"), + E028, Error, include_str!("./error_codes/E028.md"), + E029, Error, include_str!("./error_codes/E029.md"), + E030, Error, include_str!("./error_codes/E030.md"), + E031, Error, include_str!("./error_codes/E031.md"), + E032, Error, include_str!("./error_codes/E032.md"), + E033, Error, include_str!("./error_codes/E033.md"), + E034, Error, include_str!("./error_codes/E034.md"), + E035, Error, include_str!("./error_codes/E035.md"), + E036, Error, include_str!("./error_codes/E036.md"), + E037, Error, include_str!("./error_codes/E037.md"), + E038, Error, include_str!("./error_codes/E038.md"), //Missing type + E039, Warning, include_str!("./error_codes/E039.md"), + E040, Error, include_str!("./error_codes/E040.md"), + E041, Error, include_str!("./error_codes/E041.md"), + E042, Warning, include_str!("./error_codes/E042.md"), //Assignment to reference + E043, Error, include_str!("./error_codes/E043.md"), + E044, Error, include_str!("./error_codes/E044.md"), + E045, Error, include_str!("./error_codes/E045.md"), + E046, Error, include_str!("./error_codes/E046.md"), + E047, Warning, include_str!("./error_codes/E047.md"), //VLAs are always by reference + E048, Error, include_str!("./error_codes/E048.md"), + E049, Error, include_str!("./error_codes/E049.md"), + E050, Error, include_str!("./error_codes/E050.md"), + E051, Error, include_str!("./error_codes/E051.md"), + E052, Error, include_str!("./error_codes/E052.md"), + E053, Error, include_str!("./error_codes/E053.md"), + E054, Error, include_str!("./error_codes/E054.md"), + E055, Error, include_str!("./error_codes/E055.md"), + E056, Error, include_str!("./error_codes/E056.md"), + E057, Error, include_str!("./error_codes/E057.md"), + E058, Error, include_str!("./error_codes/E058.md"), + E059, Error, include_str!("./error_codes/E059.md"), + E060, Info, include_str!("./error_codes/E060.md"), //Variable direct access with % + E061, Error, include_str!("./error_codes/E061.md"), + E062, Error, include_str!("./error_codes/E062.md"), + E063, Error, include_str!("./error_codes/E063.md"), + E064, Error, include_str!("./error_codes/E064.md"), + E065, Error, include_str!("./error_codes/E065.md"), + E066, Error, include_str!("./error_codes/E066.md"), + E067, Warning, include_str!("./error_codes/E067.md"), //Implicit typecast + E068, Error, include_str!("./error_codes/E068.md"), + E069, Error, include_str!("./error_codes/E069.md"), + E070, Error, include_str!("./error_codes/E070.md"), + E071, Error, include_str!("./error_codes/E071.md"), + E072, Error, include_str!("./error_codes/E072.md"), + E073, Error, include_str!("./error_codes/E073.md"), + E074, Error, include_str!("./error_codes/E074.md"), + E075, Error, include_str!("./error_codes/E075.md"), + E076, Error, include_str!("./error_codes/E076.md"), + E077, Error, include_str!("./error_codes/E077.md"), + E078, Error, include_str!("./error_codes/E078.md"), + E079, Error, include_str!("./error_codes/E079.md"), + E080, Error, include_str!("./error_codes/E080.md"), + E081, Error, include_str!("./error_codes/E081.md"), + E082, Error, include_str!("./error_codes/E082.md"), + E083, Error, include_str!("./error_codes/E083.md"), + E084, Error, include_str!("./error_codes/E084.md"), + E085, Error, include_str!("./error_codes/E085.md"), + E086, Error, include_str!("./error_codes/E086.md"), + E087, Error, include_str!("./error_codes/E087.md"), + E088, Error, include_str!("./error_codes/E088.md"), + E089, Error, include_str!("./error_codes/E089.md"), + E090, Warning, include_str!("./error_codes/E090.md"), //Incompatible reference Assignment + E091, Warning, include_str!("./error_codes/E091.md"), + E092, Info, include_str!("./error_codes/E092.md"), + E093, Warning, include_str!("./error_codes/E093.md"), + E094, Error, include_str!("./error_codes/E094.md"), + E095, Error, include_str!("./error_codes/E095.md"), // Action call without `()` + E096, Warning, include_str!("./error_codes/E096.md"), // Integer Condition + E097, Error, include_str!("./error_codes/E097.md"), // Invalid Array Range + E098, Error, include_str!("./error_codes/E098.md"), // Invalid `REF=` assignment + E099, Error, include_str!("./error_codes/E099.md"), // Invalid `REFERENCE TO` declaration + E100, Error, include_str!("./error_codes/E100.md"), // Immutable variable address + ); } #[cfg(test)] diff --git a/compiler/plc_diagnostics/src/diagnostics/error_codes/E032.md b/compiler/plc_diagnostics/src/diagnostics/error_codes/E032.md index 53e170129cb..cb2b5ed0200 100644 --- a/compiler/plc_diagnostics/src/diagnostics/error_codes/E032.md +++ b/compiler/plc_diagnostics/src/diagnostics/error_codes/E032.md @@ -1 +1,18 @@ -# Invalid number of parameters +# Invalid number of arguments + +An invalid number of arguments was passed to a POU. For example + +``` +FUNCTION foo + (* ... *) +END_FUNCTION + +FUNCTION main : DINT + foo('bar'); // Error, foo isn't expecting any arguments +END_FUNCTION +``` + +Note that for `FUNCTION`s the argument count must match with the parameter list and can be bigger if a variadic +parameter is present. For stateful POUs variadic parameters are not supported, thus the argument count must be equal +or less than the parameter list depending on whether optional arguments such as `VAR_INPUT` or `VAR_OUTPUT` were +passed or not. diff --git a/compiler/plc_diagnostics/src/diagnostics/error_codes/E098.md b/compiler/plc_diagnostics/src/diagnostics/error_codes/E098.md new file mode 100644 index 00000000000..f5502719471 --- /dev/null +++ b/compiler/plc_diagnostics/src/diagnostics/error_codes/E098.md @@ -0,0 +1,19 @@ +# Invalid REF= assignment + +`REF=` assignments are considered valid if the left-hand side of the assignment is a pointer variable +and the right-hand side is a variable of the type that is being referenced. + +For example assignments such as the following are invalid + +```smalltalk +VAR + foo : DINT; + bar : DINT; + qux : SINT; + refFoo : REFERENCE TO DINT; +END_VAR + +refFoo REF= 5; // `5` is not a variable +foo REF= bar; // `foo` is not a pointer +refFoo REF= qux; // `refFoo` and `qux` have different types, DINT vs SINT +``` \ No newline at end of file diff --git a/compiler/plc_diagnostics/src/diagnostics/error_codes/E099.md b/compiler/plc_diagnostics/src/diagnostics/error_codes/E099.md new file mode 100644 index 00000000000..f78cc784484 --- /dev/null +++ b/compiler/plc_diagnostics/src/diagnostics/error_codes/E099.md @@ -0,0 +1,6 @@ +# Invalid `REFERENCE TO` declaration + +`REFERENCE TO` variable declarations are considered valid if the referenced type is not of the following form +* `foo : REFERENCE TO REFERENCE TO (* ... *)` +* `foo : ARRAY[...] OF REFERENCE TO (* ... *)` +* `foo : REF_TO REFERENCE TO (* ... *)` \ No newline at end of file diff --git a/compiler/plc_diagnostics/src/diagnostics/error_codes/E100.md b/compiler/plc_diagnostics/src/diagnostics/error_codes/E100.md new file mode 100644 index 00000000000..5d9e852ac4c --- /dev/null +++ b/compiler/plc_diagnostics/src/diagnostics/error_codes/E100.md @@ -0,0 +1,15 @@ +# Immutable Variable Address + +Alias variables are immutable with regards to their pointer address, thus re-assigning an address will return an error. For example the following code will not compile +```ST +FUNCTION main + VAR + foo AT bar : DINT; + bar : DINT; + baz : DINT; + END_VAR + + foo := baz; // Valid, because we are changing the pointers dereferenced value + foo REF= baz; // Invalid, `foo` is immutable with regards to it's pointer address +END_FUNCTION +``` \ No newline at end of file diff --git a/compiler/plc_driver/Cargo.toml b/compiler/plc_driver/Cargo.toml index 743087961a4..8eccbdd01ab 100644 --- a/compiler/plc_driver/Cargo.toml +++ b/compiler/plc_driver/Cargo.toml @@ -16,6 +16,7 @@ plc_index = { path = "../plc_index" } serde = { version = "1.0", features = ["derive"] } serde_json = "1" +toml = "0.5" clap = { version = "3.0", features = ["derive"] } rayon = "1.6.1" tempfile = "3" diff --git a/compiler/plc_driver/src/cli.rs b/compiler/plc_driver/src/cli.rs index b086c79cfdc..46f0dc2bae8 100644 --- a/compiler/plc_driver/src/cli.rs +++ b/compiler/plc_driver/src/cli.rs @@ -22,6 +22,14 @@ pub struct CompileParameters { #[clap(short, long, global = true, name = "output-file", help = "Write output to ")] pub output: Option, + #[clap( + long = "ast", + group = "format", + global = true, + help = "Emit AST (Abstract Syntax Tree) as output" + )] + pub output_ast: bool, + #[clap( long = "ir", group = "format", @@ -100,6 +108,18 @@ pub struct CompileParameters { ) ] pub hardware_config: Option, + #[clap( + name = "got-layout-file", + long, + global = true, + help = "Obtain information about the current custom GOT layout from the given file if it exists. + Save information about the generated custom GOT layout to the given file. + Format is detected by extension. + Supported formats : json, toml", + parse(try_from_str = validate_config) + ) ] + pub got_layout_file: Option, + #[clap( name = "optimization", long, @@ -308,7 +328,9 @@ pub fn get_config_format(name: &str) -> Option { impl CompileParameters { pub fn parse + AsRef>(args: &[T]) -> Result { - CompileParameters::try_parse_from(args).and_then(|result| { + CompileParameters::try_parse_from(args).and_then(|mut result| { + result.got_layout_file = Some(String::from("tmp.json")); + if result.sysroot.len() > result.target.len() { let mut cmd = CompileParameters::command(); Err(cmd.error( @@ -379,6 +401,10 @@ impl CompileParameters { self.hardware_config.as_deref().and_then(get_config_format) } + pub fn got_layout_format(&self) -> Option { + self.got_layout_file.as_deref().and_then(get_config_format) + } + /// Returns the location where the build artifacts should be stored / output pub fn get_build_location(&self) -> Option { match &self.commands { @@ -637,6 +663,16 @@ mod cli_tests { fn valid_output_formats() { let parameters = CompileParameters::parse(vec_of_strings!("input.st", "--ir")).unwrap(); assert!(parameters.output_ir); + assert!(!parameters.output_ast); + assert!(!parameters.output_bit_code); + assert!(!parameters.output_obj_code); + assert!(!parameters.output_pic_obj); + assert!(!parameters.output_shared_obj); + assert!(!parameters.output_reloc_code); + + let parameters = CompileParameters::parse(vec_of_strings!("input.st", "--ast")).unwrap(); + assert!(!parameters.output_ir); + assert!(parameters.output_ast); assert!(!parameters.output_bit_code); assert!(!parameters.output_obj_code); assert!(!parameters.output_pic_obj); @@ -645,6 +681,7 @@ mod cli_tests { let parameters = CompileParameters::parse(vec_of_strings!("input.st", "--bc")).unwrap(); assert!(!parameters.output_ir); + assert!(!parameters.output_ast); assert!(parameters.output_bit_code); assert!(!parameters.output_obj_code); assert!(!parameters.output_pic_obj); @@ -653,6 +690,7 @@ mod cli_tests { let parameters = CompileParameters::parse(vec_of_strings!("input.st", "--static")).unwrap(); assert!(!parameters.output_ir); + assert!(!parameters.output_ast); assert!(!parameters.output_bit_code); assert!(parameters.output_obj_code); assert!(!parameters.output_pic_obj); @@ -661,6 +699,7 @@ mod cli_tests { let parameters = CompileParameters::parse(vec_of_strings!("input.st", "--pic")).unwrap(); assert!(!parameters.output_ir); + assert!(!parameters.output_ast); assert!(!parameters.output_bit_code); assert!(!parameters.output_obj_code); assert!(parameters.output_pic_obj); @@ -669,6 +708,7 @@ mod cli_tests { let parameters = CompileParameters::parse(vec_of_strings!("input.st", "--shared")).unwrap(); assert!(!parameters.output_ir); + assert!(!parameters.output_ast); assert!(!parameters.output_bit_code); assert!(!parameters.output_obj_code); assert!(!parameters.output_pic_obj); @@ -677,6 +717,7 @@ mod cli_tests { let parameters = CompileParameters::parse(vec_of_strings!("input.st", "--relocatable")).unwrap(); assert!(!parameters.output_ir); + assert!(!parameters.output_ast); assert!(!parameters.output_bit_code); assert!(!parameters.output_obj_code); assert!(!parameters.output_pic_obj); @@ -685,6 +726,7 @@ mod cli_tests { let parameters = CompileParameters::parse(vec_of_strings!("input.st")).unwrap(); assert!(!parameters.output_ir); + assert!(!parameters.output_ast); assert!(!parameters.output_bit_code); assert!(!parameters.output_obj_code); assert!(!parameters.output_pic_obj); diff --git a/compiler/plc_driver/src/lib.rs b/compiler/plc_driver/src/lib.rs index 750095032c2..9564b9e449d 100644 --- a/compiler/plc_driver/src/lib.rs +++ b/compiler/plc_driver/src/lib.rs @@ -19,8 +19,8 @@ use std::{ use cli::{CompileParameters, ParameterError, SubCommands}; use pipelines::AnnotatedProject; use plc::{ - codegen::CodegenContext, linker::LinkerType, output::FormatOption, DebugLevel, ErrorFormat, - OptimizationLevel, Target, Threads, + codegen::CodegenContext, linker::LinkerType, output::FormatOption, ConfigFormat, DebugLevel, + ErrorFormat, OptimizationLevel, Target, Threads, }; use plc_diagnostics::{diagnostician::Diagnostician, diagnostics::Diagnostic}; @@ -50,6 +50,8 @@ pub struct CompileOptions { /// The name of the resulting compiled file pub output: String, pub output_format: FormatOption, + pub got_layout_file: Option, + pub got_layout_format: Option, pub optimization: OptimizationLevel, pub error_format: ErrorFormat, pub debug_level: DebugLevel, @@ -63,6 +65,8 @@ impl Default for CompileOptions { build_location: None, output: String::new(), output_format: Default::default(), + got_layout_file: None, + got_layout_format: None, optimization: OptimizationLevel::None, error_format: ErrorFormat::None, debug_level: DebugLevel::None, @@ -172,6 +176,8 @@ pub fn get_compilation_context + AsRef + Debug>( build_location: compile_parameters.get_build_location(), output: project.get_output_name(), output_format, + got_layout_file: compile_parameters.got_layout_file.clone(), + got_layout_format: compile_parameters.got_layout_format(), optimization: compile_parameters.optimization, error_format: compile_parameters.error_format, debug_level: compile_parameters.debug_level(), @@ -247,6 +253,11 @@ pub fn compile_with_options(compile_options: CompilationContext) -> Result<()> { .index(ctxt.provider()) .annotate(ctxt.provider()); + if compile_parameters.output_ast { + println!("{:#?}", annotated_project.units); + return Ok(()); + } + // 4 : Validate annotated_project.validate(&ctxt, &mut diagnostician)?; diff --git a/compiler/plc_driver/src/pipelines.rs b/compiler/plc_driver/src/pipelines.rs index 67d89913116..72d86b0ff82 100644 --- a/compiler/plc_driver/src/pipelines.rs +++ b/compiler/plc_driver/src/pipelines.rs @@ -1,8 +1,10 @@ use std::{ + collections::HashMap, env, fs::{self, File}, io::Write, path::{Path, PathBuf}, + sync::Mutex, }; use crate::{CompileOptions, LinkOptions}; @@ -33,6 +35,42 @@ use project::{ use rayon::prelude::*; use source_code::{source_location::SourceLocation, SourceContainer}; +use serde_json; +use toml; + +pub fn read_got_layout(location: &str, format: ConfigFormat) -> Result, Diagnostic> { + if !Path::new(location).is_file() { + // Assume if the file doesn't exist that there is no existing GOT layout yet. write_got_layout will handle + // creating our file when we want to. + return Ok(HashMap::new()); + } + + let s = fs::read_to_string(location) + .map_err(|_| Diagnostic::new("GOT layout could not be read from file"))?; + match format { + ConfigFormat::JSON => serde_json::from_str(&s) + .map_err(|_| Diagnostic::new("Could not deserialize GOT layout from JSON")), + ConfigFormat::TOML => { + toml::de::from_str(&s).map_err(|_| Diagnostic::new("Could not deserialize GOT layout from TOML")) + } + } +} + +fn write_got_layout( + got_entries: HashMap, + location: &str, + format: ConfigFormat, +) -> Result<(), Diagnostic> { + let s = match format { + ConfigFormat::JSON => serde_json::to_string(&got_entries) + .map_err(|_| Diagnostic::new("Could not serialize GOT layout to JSON"))?, + ConfigFormat::TOML => toml::ser::to_string(&got_entries) + .map_err(|_| Diagnostic::new("Could not serialize GOT layout to TOML"))?, + }; + + fs::write(location, s).map_err(|_| Diagnostic::new("GOT layout could not be written to file")) +} + ///Represents a parsed project ///For this struct to be built, the project would have been parsed correctly and an AST would have ///been generated @@ -234,8 +272,15 @@ impl AnnotatedProject { .iter() .map(|(unit, dependencies, literals)| { let context = CodegenContext::create(); - self.generate_module(&context, compile_options, unit, dependencies, literals) - .map(|it| it.persist_to_string()) + self.generate_module( + &context, + compile_options, + unit, + dependencies, + literals, + todo!("GOT layout for codegen_to_string?"), + ) + .map(|it| it.persist_to_string()) }) .collect() } @@ -249,7 +294,14 @@ impl AnnotatedProject { .units .iter() .map(|(unit, dependencies, literals)| { - self.generate_module(context, compile_options, unit, dependencies, literals) + self.generate_module( + context, + compile_options, + unit, + dependencies, + literals, + todo!("give GOT layout for single modules?"), + ) }) .reduce(|a, b| { let a = a?; @@ -269,11 +321,13 @@ impl AnnotatedProject { unit: &CompilationUnit, dependencies: &FxIndexSet, literals: &StringLiterals, + got_layout: &Mutex>>, ) -> Result, Diagnostic> { let mut code_generator = plc::codegen::CodeGen::new( context, compile_options.root.as_deref(), &unit.file_name, + compile_options.got_layout_file.clone().zip(compile_options.got_layout_format), compile_options.optimization, compile_options.debug_level, ); @@ -285,8 +339,9 @@ impl AnnotatedProject { literals, dependencies, &self.index, + got_layout, )?; - code_generator.generate(context, unit, &self.annotations, &self.index, &llvm_index) + code_generator.generate(context, unit, &self.annotations, &self.index, llvm_index) } pub fn codegen_single_module<'ctx>( @@ -331,6 +386,15 @@ impl AnnotatedProject { }); ensure_compile_dirs(targets, &compile_directory)?; let targets = if targets.is_empty() { &[Target::System] } else { targets }; + + let got_layout = compile_options + .got_layout_file + .as_ref() + .map(|path| read_got_layout(path, ConfigFormat::JSON)) + .transpose()?; + + let got_layout = Mutex::new(got_layout); + let res = targets .par_iter() .map(|target| { @@ -364,8 +428,15 @@ impl AnnotatedProject { }; let context = CodegenContext::create(); //Create a build location for the generated object files - let module = - self.generate_module(&context, compile_options, unit, dependencies, literals)?; + let module = self.generate_module( + &context, + compile_options, + unit, + dependencies, + literals, + &got_layout, + )?; + module .persist( Some(&compile_directory), @@ -384,6 +455,10 @@ impl AnnotatedProject { }) .collect::, Diagnostic>>()?; + compile_options.got_layout_file.as_ref().map(|path| { + write_got_layout(got_layout.into_inner().unwrap().unwrap(), path, ConfigFormat::JSON) + }); + Ok(res) } diff --git a/compiler/plc_driver/src/tests/snapshots/plc_driver__tests__external_files__external_file_function_call.snap b/compiler/plc_driver/src/tests/snapshots/plc_driver__tests__external_files__external_file_function_call.snap index 3436f9b653a..4574b771023 100644 --- a/compiler/plc_driver/src/tests/snapshots/plc_driver__tests__external_files__external_file_function_call.snap +++ b/compiler/plc_driver/src/tests/snapshots/plc_driver__tests__external_files__external_file_function_call.snap @@ -5,7 +5,7 @@ expression: "results.join(\"\\n\")" ; ModuleID = 'main.st' source_filename = "main.st" -define i16 @main() section "fn-main:i16" { +define i16 @main() section "fn-$RUSTY$main:i16" { entry: %main = alloca i16, align 2 store i16 0, i16* %main, align 2 @@ -14,9 +14,9 @@ entry: ret i16 %main_ret } -declare i16 @external() section "fn-external:i16" +declare i16 @external() section "fn-$RUSTY$external:i16" ; ModuleID = 'external.st' source_filename = "external.st" -declare i16 @external() section "fn-external:i16" +declare i16 @external() section "fn-$RUSTY$external:i16" diff --git a/compiler/plc_driver/src/tests/snapshots/plc_driver__tests__external_files__external_file_global_var.snap b/compiler/plc_driver/src/tests/snapshots/plc_driver__tests__external_files__external_file_global_var.snap index 275c650b64f..cc8effcdc07 100644 --- a/compiler/plc_driver/src/tests/snapshots/plc_driver__tests__external_files__external_file_global_var.snap +++ b/compiler/plc_driver/src/tests/snapshots/plc_driver__tests__external_files__external_file_global_var.snap @@ -5,10 +5,10 @@ expression: "results.join(\"\\n\")" ; ModuleID = 'main.st' source_filename = "main.st" -@x = external global i16 -@y = external global i16 +@x = external global i16, section "var-$RUSTY$x:i16" +@y = external global i16, section "var-$RUSTY$y:i16" -define i16 @main() section "fn-main:i16" { +define i16 @main() section "fn-$RUSTY$main:i16" { entry: %main = alloca i16, align 2 store i16 0, i16* %main, align 2 @@ -19,12 +19,12 @@ entry: ret i16 %main_ret } -declare i16 @external() section "fn-external:i16" +declare i16 @external() section "fn-$RUSTY$external:i16" ; ModuleID = 'external.st' source_filename = "external.st" -@x = external global i16 -@y = external global i16 +@x = external global i16, section "var-$RUSTY$x:i16" +@y = external global i16, section "var-$RUSTY$y:i16" -declare i16 @external() section "fn-external:i16" +declare i16 @external() section "fn-$RUSTY$external:i16" diff --git a/compiler/plc_driver/src/tests/snapshots/plc_driver__tests__multi_files__multiple_files_in_different_locations_with_debug_info.snap b/compiler/plc_driver/src/tests/snapshots/plc_driver__tests__multi_files__multiple_files_in_different_locations_with_debug_info.snap index d66f8c80d55..4deafcb8310 100644 --- a/compiler/plc_driver/src/tests/snapshots/plc_driver__tests__multi_files__multiple_files_in_different_locations_with_debug_info.snap +++ b/compiler/plc_driver/src/tests/snapshots/plc_driver__tests__multi_files__multiple_files_in_different_locations_with_debug_info.snap @@ -7,9 +7,9 @@ source_filename = "app/file1.st" %mainProg = type {} -@mainProg_instance = external global %mainProg, !dbg !0 +@mainProg_instance = external global %mainProg, section "var-$RUSTY$mainProg_instance:r0", !dbg !0 -define i16 @main() section "fn-main:i16" !dbg !10 { +define i16 @main() section "fn-$RUSTY$main:i16" !dbg !10 { entry: %main = alloca i16, align 2, !dbg !14 call void @llvm.dbg.declare(metadata i16* %main, metadata !15, metadata !DIExpression()), !dbg !17 @@ -19,7 +19,7 @@ entry: ret i16 %main_ret, !dbg !14 } -declare !dbg !18 void @mainProg(%mainProg*) section "fn-mainProg:v" +declare !dbg !18 void @mainProg(%mainProg*) section "fn-$RUSTY$mainProg:v" ; Function Attrs: nofree nosync nounwind readnone speculatable willreturn declare void @llvm.dbg.declare(metadata, metadata, metadata) #0 @@ -54,9 +54,9 @@ source_filename = "lib/file2.st" %mainProg = type {} -@mainProg_instance = global %mainProg zeroinitializer, !dbg !0 +@mainProg_instance = global %mainProg zeroinitializer, section "var-$RUSTY$mainProg_instance:r0", !dbg !0 -define void @mainProg(%mainProg* %0) section "fn-mainProg:v" !dbg !10 { +define void @mainProg(%mainProg* %0) section "fn-$RUSTY$mainProg:v" !dbg !10 { entry: call void @llvm.dbg.declare(metadata %mainProg* %0, metadata !13, metadata !DIExpression()), !dbg !14 ret void, !dbg !14 diff --git a/compiler/plc_driver/src/tests/snapshots/plc_driver__tests__multi_files__multiple_files_with_debug_info.snap b/compiler/plc_driver/src/tests/snapshots/plc_driver__tests__multi_files__multiple_files_with_debug_info.snap index 10ea84d0cd1..a8623288bf2 100644 --- a/compiler/plc_driver/src/tests/snapshots/plc_driver__tests__multi_files__multiple_files_with_debug_info.snap +++ b/compiler/plc_driver/src/tests/snapshots/plc_driver__tests__multi_files__multiple_files_with_debug_info.snap @@ -7,9 +7,9 @@ source_filename = "file1.st" %mainProg = type {} -@mainProg_instance = external global %mainProg, !dbg !0 +@mainProg_instance = external global %mainProg, section "var-$RUSTY$mainProg_instance:r0", !dbg !0 -define i16 @main() section "fn-main:i16" !dbg !10 { +define i16 @main() section "fn-$RUSTY$main:i16" !dbg !10 { entry: %main = alloca i16, align 2, !dbg !14 call void @llvm.dbg.declare(metadata i16* %main, metadata !15, metadata !DIExpression()), !dbg !17 @@ -19,7 +19,7 @@ entry: ret i16 %main_ret, !dbg !14 } -declare !dbg !18 void @mainProg(%mainProg*) section "fn-mainProg:v" +declare !dbg !18 void @mainProg(%mainProg*) section "fn-$RUSTY$mainProg:v" ; Function Attrs: nofree nosync nounwind readnone speculatable willreturn declare void @llvm.dbg.declare(metadata, metadata, metadata) #0 @@ -54,9 +54,9 @@ source_filename = "file2.st" %mainProg = type {} -@mainProg_instance = global %mainProg zeroinitializer, !dbg !0 +@mainProg_instance = global %mainProg zeroinitializer, section "var-$RUSTY$mainProg_instance:r0", !dbg !0 -define void @mainProg(%mainProg* %0) section "fn-mainProg:v" !dbg !10 { +define void @mainProg(%mainProg* %0) section "fn-$RUSTY$mainProg:v" !dbg !10 { entry: call void @llvm.dbg.declare(metadata %mainProg* %0, metadata !13, metadata !DIExpression()), !dbg !14 ret void, !dbg !14 diff --git a/compiler/plc_driver/src/tests/snapshots/plc_driver__tests__multi_files__multiple_source_files_generated.snap b/compiler/plc_driver/src/tests/snapshots/plc_driver__tests__multi_files__multiple_source_files_generated.snap index 9d922834778..e2f0569d084 100644 --- a/compiler/plc_driver/src/tests/snapshots/plc_driver__tests__multi_files__multiple_source_files_generated.snap +++ b/compiler/plc_driver/src/tests/snapshots/plc_driver__tests__multi_files__multiple_source_files_generated.snap @@ -7,9 +7,9 @@ source_filename = "external_file1.st" %mainProg = type {} -@mainProg_instance = external global %mainProg +@mainProg_instance = external global %mainProg, section "var-$RUSTY$mainProg_instance:r0" -define i16 @main() section "fn-main:i16" { +define i16 @main() section "fn-$RUSTY$main:i16" { entry: %main = alloca i16, align 2 store i16 0, i16* %main, align 2 @@ -18,16 +18,16 @@ entry: ret i16 %main_ret } -declare void @mainProg(%mainProg*) section "fn-mainProg:v" +declare void @mainProg(%mainProg*) section "fn-$RUSTY$mainProg:v" ; ModuleID = 'external_file2.st' source_filename = "external_file2.st" %mainProg = type {} -@mainProg_instance = global %mainProg zeroinitializer +@mainProg_instance = global %mainProg zeroinitializer, section "var-$RUSTY$mainProg_instance:r0" -define void @mainProg(%mainProg* %0) section "fn-mainProg:v" { +define void @mainProg(%mainProg* %0) section "fn-$RUSTY$mainProg:v" { entry: ret void } diff --git a/compiler/section_mangler/Cargo.toml b/compiler/section_mangler/Cargo.toml index f3386a21e01..f0cfaf92a4a 100644 --- a/compiler/section_mangler/Cargo.toml +++ b/compiler/section_mangler/Cargo.toml @@ -4,3 +4,4 @@ version = "0.0.1" edition = "2021" [dependencies] +nom = "7.1" diff --git a/compiler/section_mangler/src/lib.rs b/compiler/section_mangler/src/lib.rs index 4e00658c692..759c5cdbf63 100644 --- a/compiler/section_mangler/src/lib.rs +++ b/compiler/section_mangler/src/lib.rs @@ -44,25 +44,51 @@ use std::fmt; +mod parser; + /// The main builder type of this crate. Use it to create mangling contexts, in /// order to encode and decode binary type information. // TODO: Add example code for using this builder +#[derive(Debug, PartialEq, Clone)] pub enum SectionMangler { Function(FunctionMangler), Variable(VariableMangler), } +#[derive(Debug, PartialEq, Clone)] pub struct FunctionMangler { name: String, parameters: Vec, return_type: Option, } +#[derive(Debug, PartialEq, Clone)] pub struct VariableMangler { name: String, ty: Type, } +pub const RUSTY_PREFIX: &str = "$RUSTY$"; + +// TODO: How to encode variadics? +fn mangle_function(FunctionMangler { name, parameters, return_type }: FunctionMangler) -> String { + /* FIXME: Is that correct? */ + let return_type = return_type.unwrap_or(Type::Void); + + let mangled = match parameters.as_slice() { + [] => format!("{return_type}[]"), + parameters => { + parameters.iter().fold(return_type.to_string(), |mangled, arg| format!("{mangled}[{arg}]")) + } + }; + + format!("{name}:{mangled}") +} + +fn mangle_variable(VariableMangler { name, ty }: VariableMangler) -> String { + format!("{name}:{ty}") +} + impl SectionMangler { pub fn function>(name: S) -> SectionMangler { SectionMangler::Function(FunctionMangler { name: name.into(), parameters: vec![], return_type: None }) @@ -72,6 +98,13 @@ impl SectionMangler { SectionMangler::Variable(VariableMangler { name: name.into(), ty }) } + pub fn name(&self) -> &str { + match self { + SectionMangler::Function(FunctionMangler { name, .. }) + | SectionMangler::Variable(VariableMangler { name, .. }) => name, + } + } + pub fn with_parameter(self, param: FunctionArgument) -> SectionMangler { match self { SectionMangler::Function(f) => { @@ -84,9 +117,11 @@ impl SectionMangler { } } - pub fn with_return_type(self, return_type: Option) -> SectionMangler { + pub fn with_return_type(self, return_type: Type) -> SectionMangler { match self { - SectionMangler::Function(f) => SectionMangler::Function(FunctionMangler { return_type, ..f }), + SectionMangler::Function(f) => { + SectionMangler::Function(FunctionMangler { return_type: Some(return_type), ..f }) + } SectionMangler::Variable(_) => unreachable!("global variables do not have a return type."), } } @@ -97,7 +132,7 @@ impl SectionMangler { SectionMangler::Variable(v) => ("var", mangle_variable(v)), }; - format!("{prefix}-{content}") + format!("{RUSTY_PREFIX}{prefix}-{content}") } } @@ -111,6 +146,7 @@ impl SectionMangler { // NOTE: This is called `variable_linkage` in the `MemberInfo` struct. /// We have to encode this because if it changes, the function needs to be reloaded - this is an ABI breakage +#[derive(Debug, PartialEq, Clone)] pub enum FunctionArgument { ByValue(Type), ByRef(Type), @@ -127,6 +163,7 @@ impl fmt::Display for FunctionArgument { } // TODO: Do we have to encode this? Does that affect ABI? Probably +#[derive(Debug, PartialEq, Clone)] pub enum StringEncoding { // TODO: Should we encode this differently? this could cause problems compared to encoding unsigned types /// Encoded as `8u` @@ -146,6 +183,7 @@ impl fmt::Display for StringEncoding { // This maps directly to the [`DataTypeInformation`] enum in RuSTy - we simply remove some fields and add the ability to encode/decode serialize/deserialize // TODO: Do we have to handle Generic? +#[derive(Debug, PartialEq, Clone)] pub enum Type { /// Encoded as `v` Void, @@ -158,7 +196,9 @@ pub enum Type { semantic_size: Option, }, /// Encoded as `f` - Float { size: u32 }, + Float { + size: u32, + }, /// Encoded as `s` String { size: usize, // FIXME: Is that okay? will all the constant expressions be folded at that point? Can we have TypeSize::Undetermined still? @@ -170,23 +210,12 @@ pub enum Type { // TODO: Is changing the `auto_deref` mode an ABI break? // auto_deref: bool, }, - - // --- UNIMPLEMENTED - - // FIXME: Do we need any info here? How are structs codegened? Struct { - // name: TypeId, - // members: Vec, - // source: StructSource, + members: Vec, }, - - // FIXME: Same here Enum { - // name: TypeId, - // referenced_type: TypeId, - // // TODO: Would it make sense to store `VariableIndexEntry`s similar to how the `Struct` variant does? - // // This would allow us to pattern match in the index `find_member` method - // elements: Vec, + referenced_type: Box, + elements: usize, }, Array { inner: Box, @@ -224,27 +253,20 @@ impl fmt::Display for Type { Type::Float { size } => write!(f, "f{size}"), Type::String { size, encoding } => write!(f, "s{encoding}{size}",), Type::Pointer { inner } => write!(f, "p{}", inner), + Type::Struct { members } => { + write!( + f, + "r{}{}", + members.len(), + members.iter().fold(String::new(), |acc, m| format!("{acc}{m}")) + ) + } + Type::Enum { referenced_type, elements } => write!(f, "e{elements}{referenced_type}"), + Type::Array { inner } => write!(f, "a{inner}"), // -- Unimplemented - Type::Struct {} => todo!(), - Type::Enum {} => todo!(), - Type::Array { .. } => todo!(), Type::SubRange {} => todo!(), Type::Alias {} => todo!(), Type::Generic {} => todo!(), } } } - -// TODO: How to encode variadics? -fn mangle_function(FunctionMangler { name, parameters, return_type }: FunctionMangler) -> String { - let mangled = parameters - .into_iter() - /* FIXME: Is that correct? */ - .fold(return_type.unwrap_or(Type::Void).to_string(), |mangled, arg| format!("{mangled}[{arg}]")); - - format!("{name}:{mangled}") -} - -fn mangle_variable(VariableMangler { name, ty }: VariableMangler) -> String { - format!("{name}:{ty}") -} diff --git a/compiler/section_mangler/src/parser.rs b/compiler/section_mangler/src/parser.rs new file mode 100644 index 00000000000..7379ca03030 --- /dev/null +++ b/compiler/section_mangler/src/parser.rs @@ -0,0 +1,323 @@ +use crate::{FunctionArgument, SectionMangler, StringEncoding, Type}; + +use std::str; + +use nom::branch::alt; +use nom::bytes::complete::{tag, take_until1}; +use nom::character::complete::{char, digit1}; +use nom::combinator::map_res; +use nom::multi::{many0, many_m_n}; +use nom::sequence::delimited; +use nom::{IResult, Parser}; + +type ParseResult<'i, O> = IResult<&'i str, O>; + +enum Prefix { + Fn, + Var, +} + +fn parse_prefix(input: &str) -> ParseResult { + let fn_prefix = tag("fn").map(|_| Prefix::Fn); + let var_prefix = tag("var").map(|_| Prefix::Var); + + let (input, _) = tag(crate::RUSTY_PREFIX)(input)?; + let (input, prefix) = alt((fn_prefix, var_prefix))(input)?; + + Ok((input, prefix)) +} + +fn parse_entity_name(input: &str) -> ParseResult<&str> { + delimited(char('-'), take_until1(":"), char(':'))(input) +} + +fn type_void(input: &str) -> ParseResult { + char('v').map(|_| Type::Void).parse(input) +} + +fn number(input: &str) -> ParseResult { + map_res(digit1, str::parse)(input) +} + +fn type_integer(input: &str) -> ParseResult { + fn parse_signedness(input: &str) -> ParseResult { + let signed = char('i').map(|_| true); + let unsigned = char('u').map(|_| false); + + alt((signed, unsigned))(input) + } + + parse_signedness + .and(number::) + .map(|(signed, size)| Type::Integer { signed, size, semantic_size: None }) + .parse(input) +} + +fn type_float(input: &str) -> ParseResult { + char('f').and(number::).map(|(_, size)| Type::Float { size }).parse(input) +} + +fn type_pointer(input: &str) -> ParseResult { + char('p').and(parse_type).map(|(_, inner)| Type::Pointer { inner: Box::new(inner) }).parse(input) +} + +fn type_struct(input: &str) -> ParseResult { + let (input, (_, n)) = char('r').and(number::).parse(input)?; + + many_m_n(n, n, parse_type).map(|members| Type::Struct { members }).parse(input) +} + +fn type_enum(input: &str) -> ParseResult { + char('e') + .and(number::) + .and(parse_type) + .map(|((_, elements), ty)| Type::Enum { referenced_type: Box::new(ty), elements }) + .parse(input) +} + +fn string_encoding(input: &str) -> ParseResult { + let utf8 = tag("8u").map(|_| StringEncoding::Utf8); + let utf16 = tag("16u").map(|_| StringEncoding::Utf16); + + alt((utf8, utf16))(input) +} + +fn type_string(input: &str) -> ParseResult { + char('s') + .and(string_encoding) + .and(number::) + .map(|((_, encoding), size)| Type::String { size, encoding }) + .parse(input) +} + +fn type_array(input: &str) -> ParseResult { + char('a').and(parse_type).map(|(_, inner_ty)| Type::Array { inner: Box::new(inner_ty) }).parse(input) +} + +fn parse_type(input: &str) -> ParseResult { + alt((type_void, type_integer, type_float, type_pointer, type_struct, type_enum, type_string, type_array))( + input, + ) +} + +fn parse_var_content<'i>(input: &'i str, name: &str) -> ParseResult<'i, SectionMangler> { + let (input, ty) = parse_type(input)?; + + Ok((input, SectionMangler::variable(name, ty))) +} + +fn parse_fn_content<'i>(input: &'i str, name: &str) -> ParseResult<'i, SectionMangler> { + let (input, return_type) = parse_type(input)?; + let (input, parameters) = delimited(char('['), many0(parse_type), char(']'))(input)?; + + // TODO: Do not always encode parameters as ByValue + let mangler = parameters + .into_iter() + .fold(SectionMangler::function(name).with_return_type(return_type), |mangler, param| { + mangler.with_parameter(FunctionArgument::ByValue(param)) + }); + + // TODO: Would it be better for the function to encode the number of arguments it has? + // or just parse what is in between `[]` like we do currently? + + Ok((input, mangler)) +} + +// We don't need to handle any kind of errors, because an invalid mangled string can only be +// caused by a programming error or a mismatch in versions +impl From<&str> for SectionMangler { + fn from(input: &str) -> SectionMangler { + let (input, prefix) = parse_prefix(input).unwrap(); + let (input, name) = parse_entity_name(input).unwrap(); + + match prefix { + Prefix::Var => parse_var_content(input, name).unwrap().1, + Prefix::Fn => parse_fn_content(input, name).unwrap().1, + } + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn parse_prefix_valid() { + assert!(parse_prefix("$RUSTY$fn").is_ok()); + assert!(parse_prefix("$RUSTY$var").is_ok()); + + assert!(parse_prefix("$RUSTY$random").is_err()); + assert!(parse_prefix("fn").is_err()); + assert!(parse_prefix("var").is_err()); + + assert!(parse_prefix("").is_err()); + assert!(parse_prefix("a random prefix").is_err()); + } + + #[test] + fn parse_name_valid() { + assert_eq!(parse_entity_name("-foo:").unwrap().1, "foo"); + + // empty name + assert!(parse_entity_name("-:").is_err()); + } + + #[test] + fn parse_integer() { + assert!(type_integer("i15").is_ok()); + assert!(type_integer("u49").is_ok()); + assert!(type_integer("i0").is_ok()); + + assert!(type_integer("i").is_err()); + assert!(type_integer("b49").is_err()); + } + + #[test] + fn parse_void() { + assert!(type_void("v").is_ok()); + + assert!(type_void("i15").is_err()); + } + + #[test] + fn parse_float() { + assert!(type_float("f15").is_ok()); + assert!(type_float("f2560").is_ok()); + + assert!(type_float("f").is_err()); + assert!(type_float("i0").is_err()); + } + + #[test] + fn parse_ptr() { + assert!(type_pointer("pf15").is_ok()); + assert!(type_pointer("pv").is_ok()); + assert!(type_pointer("pi45").is_ok()); + assert!(type_pointer("pppppppi45").is_ok()); + + assert!(type_pointer("p").is_err()); + assert!(type_pointer("i0").is_err()); + } + + #[test] + fn parse_struct() { + assert!(type_struct("r1u8").is_ok()); + assert!(type_struct("r1r2u8u49").is_ok()); + assert!(type_struct("r5pu8r1u8u32u32pv").is_ok()); + + // these are fine - we parse a struct which is valid, but we have remaining input. + // this needs to be handled by the toplevel parse function + assert!(type_struct("r0u8u8").is_ok()); + assert!(type_struct("r1u8u8").is_ok()); + assert!(type_struct("r5s8u1025s8u2049s8u3u64s8u3").is_ok()); + + // invalid number of elements + assert!(type_struct("r15u8").is_err()); + assert!(type_struct("r1").is_err()); + assert!(type_struct("r2r1u8").is_err()); + } + + #[test] + fn parse_enum() { + assert!(type_enum("e15u8").is_ok()); + assert!(type_enum("e12pv").is_ok()); + + assert!(type_enum("e1").is_err()); + assert!(type_enum("eu8").is_err()); + } + + #[test] + fn parse_variable() { + let _ = SectionMangler::from("$RUSTY$var-name:u8"); + } + + #[test] + fn parse_function() { + let _ = SectionMangler::from("$RUSTY$fn-foo:u8[]"); + let _ = SectionMangler::from("$RUSTY$fn-foo:v[]"); + let _ = SectionMangler::from("$RUSTY$fn-foo:v[pvu8]"); + let _ = SectionMangler::from("$RUSTY$fn-foo:e156u394[pvu8r1e12u8]"); + } + + #[test] + #[should_panic] + fn parse_function_invalid_no_return_type() { + let _ = SectionMangler::from("$RUSTY$fn-no_return_type:[]"); + } + + #[test] + #[should_panic] + fn parse_function_invalid_no_arguments() { + let _ = SectionMangler::from("$RUSTY$fn-no_arguments:u16u8"); + } + + #[test] + fn parse_qualified_var_name() { + let mangled = SectionMangler::from("$RUSTY$var-Color.red:e4i32"); + + assert_eq!(mangled.name(), "Color.red"); + } + + #[test] + fn parse_complex1() { + let mangled = SectionMangler::from("$RUSTY$var-__File__init:r5s8u1025s8u2049s8u3u64s8u3"); + + assert_eq!(mangled.name(), "__File__init"); + } + + #[test] + fn parse_complex2() { + let inputs = [ + "$RUSTY$var-__CosineSignal__init:r4f64i32f64f64", + "$RUSTY$var-__File__init:r5s8u1025s8u2049s8u3u64s8u3", + "$RUSTY$var-__SineSignal__init:r4f64i32f64f64", + "$RUSTY$var-__mainProg_state.Init:e3i32", + "$RUSTY$var-__mainProg_state.Running:e3i32", + "$RUSTY$var-__mainProg_state.Stopped:e3i32", + "$RUSTY$var-__SR__init:r3u8u8u8", + "$RUSTY$var-__RS__init:r3u8u8u8", + "$RUSTY$var-__CTU__init:r6u8u8i16u8i16u8", + "$RUSTY$var-__CTU_INT__init:r6u8u8i16u8i16u8", + "$RUSTY$var-__CTU_DINT__init:r6u8u8i32u8i32u8", + "$RUSTY$var-__CTU_UDINT__init:r6u8u8u32u8u32u8", + "$RUSTY$var-__CTU_LINT__init:r6u8u8i64u8i64u8", + "$RUSTY$var-__CTU_ULINT__init:r6u8u8u64u8u64u8", + "$RUSTY$var-__CTD__init:r6u8u8i16u8i16u8", + "$RUSTY$var-__CTD_INT__init:r6u8u8i16u8i16u8", + "$RUSTY$var-__CTD_DINT__init:r6u8u8i32u8i32u8", + "$RUSTY$var-__CTD_UDINT__init:r6u8u8u32u8u32u8", + "$RUSTY$var-__CTD_LINT__init:r6u8u8i64u8i64u8", + "$RUSTY$var-__CTD_ULINT__init:r6u8u8u64u8u64u8", + "$RUSTY$var-__CTUD__init:r10u8u8u8u8i16u8u8i16u8u8", + "$RUSTY$var-__CTUD_INT__init:r10u8u8u8u8i16u8u8i16u8u8", + "$RUSTY$var-__CTUD_DINT__init:r10u8u8u8u8i32u8u8i32u8u8", + "$RUSTY$var-__CTUD_UDINT__init:r10u8u8u8u8u32u8u8u32u8u8", + "$RUSTY$var-__CTUD_LINT__init:r10u8u8u8u8i64u8u8i64u8u8", + "$RUSTY$var-__CTUD_ULINT__init:r10u8u8u8u8u64u8u8u64u8u8", + "$RUSTY$var-__R_TRIG__init:r3u8u8u8", + "$RUSTY$var-__F_TRIG__init:r3u8u8u8", + "$RUSTY$var-__TP__init:r7u8i64u8i64u8u8au8", + "$RUSTY$var-__TP_TIME__init:r7u8i64u8i64u8u8au8", + "$RUSTY$var-__TP_LTIME__init:r7u8i64u8i64u8u8au8", + "$RUSTY$var-__TON__init:r7u8i64u8i64u8u8au8", + "$RUSTY$var-__TON_TIME__init:r7u8i64u8i64u8u8au8", + "$RUSTY$var-__TON_LTIME__init:r7u8i64u8i64u8u8au8", + "$RUSTY$var-__TOF__init:r7u8i64u8i64u8u8au8", + "$RUSTY$var-__TOF_TIME__init:r7u8i64u8i64u8u8au8", + "$RUSTY$var-__TOF_LTIME__init:r7u8i64u8i64u8u8au8", + "$RUSTY$fn-CosineSignal:v[f64][i32][f64]", + "$RUSTY$fn-File:v[s8u1025][s8u2049][s8u3]", + "$RUSTY$fn-File.Open:v", + "$RUSTY$fn-File.Write:v", + "$RUSTY$fn-File.Close:v", + "$RUSTY$fn-File.Clear:v", + "$RUSTY$fn-SineSignal:v[f64][i32][f64]", + "$RUSTY$fn-mainProg:v", + "$RUSTY$var-mainProg:r7i32r4f64i32f64f64r4f64i32f64f64e3i32r5s8u1025s8u2049s8u3u64s8u3r5s8u1025s8u2049s8u3u64s8u3r5s8u1025s8u2049s8u3u64s8u3" + ]; + + inputs.into_iter().for_each(|input| { + let _ = SectionMangler::from(dbg!(input)); + }); + } +} diff --git a/libs/stdlib/tests/counters_tests.rs b/libs/stdlib/tests/counters_tests.rs index d9793768b78..431f6ac253d 100644 --- a/libs/stdlib/tests/counters_tests.rs +++ b/libs/stdlib/tests/counters_tests.rs @@ -28,11 +28,11 @@ fn ctu() { END_VAR // count up until Q_res true and then reset CV_res IF Q_res THEN - ctu_inst(CU:= TRUE, R:= TRUE, PV:= INT#3, Q:= Q_res, CV:= CV_res); + ctu_inst(CU:= TRUE, R:= TRUE, PV:= INT#3, Q => Q_res, CV => CV_res); ELSE - ctu_inst(CU:= TRUE, R:= FALSE, PV:= INT#3, Q:= Q_res, CV:= CV_res); + ctu_inst(CU:= TRUE, R:= FALSE, PV:= INT#3, Q => Q_res, CV => CV_res); // input CU evaluated by R_EDGE, this call will enable to count up again - ctu_inst(CU:= FALSE, R:= FALSE, PV:= INT#3, Q:= Q_res, CV:= CV_res); + ctu_inst(CU:= FALSE, R:= FALSE, PV:= INT#3, Q => Q_res, CV => CV_res); END_IF END_PROGRAM "#; @@ -70,11 +70,11 @@ fn ctu_int() { END_VAR // count up until Q_res true and then reset CV_res IF Q_res THEN - ctu_inst(CU:= TRUE, R:= TRUE, PV:= INT#3, Q:= Q_res, CV:= CV_res); + ctu_inst(CU:= TRUE, R:= TRUE, PV:= INT#3, Q => Q_res, CV => CV_res); ELSE - ctu_inst(CU:= TRUE, R:= FALSE, PV:= INT#3, Q:= Q_res, CV:= CV_res); + ctu_inst(CU:= TRUE, R:= FALSE, PV:= INT#3, Q => Q_res, CV => CV_res); // input CU evaluated by R_EDGE, this call will enable to count up again - ctu_inst(CU:= FALSE, R:= FALSE, PV:= INT#3, Q:= Q_res, CV:= CV_res); + ctu_inst(CU:= FALSE, R:= FALSE, PV:= INT#3, Q => Q_res, CV => CV_res); END_IF END_PROGRAM "#; @@ -112,11 +112,11 @@ fn ctu_dint() { END_VAR // count up until Q_res true and then reset CV_res IF Q_res THEN - ctu_inst(CU:= TRUE, R:= TRUE, PV:= DINT#3, Q:= Q_res, CV:= CV_res); + ctu_inst(CU:= TRUE, R:= TRUE, PV:= DINT#3, Q => Q_res, CV => CV_res); ELSE - ctu_inst(CU:= TRUE, R:= FALSE, PV:= DINT#3, Q:= Q_res, CV:= CV_res); + ctu_inst(CU:= TRUE, R:= FALSE, PV:= DINT#3, Q => Q_res, CV => CV_res); // input CU evaluated by R_EDGE, this call will enable to count up again - ctu_inst(CU:= FALSE, R:= FALSE, PV:= DINT#3, Q:= Q_res, CV:= CV_res); + ctu_inst(CU:= FALSE, R:= FALSE, PV:= DINT#3, Q => Q_res, CV => CV_res); END_IF END_PROGRAM "#; @@ -154,11 +154,11 @@ fn ctu_udint() { END_VAR // count up until Q_res true and then reset CV_res IF Q_res THEN - ctu_inst(CU:= TRUE, R:= TRUE, PV:= UDINT#3, Q:= Q_res, CV:= CV_res); + ctu_inst(CU:= TRUE, R:= TRUE, PV:= UDINT#3, Q => Q_res, CV => CV_res); ELSE - ctu_inst(CU:= TRUE, R:= FALSE, PV:= UDINT#3, Q:= Q_res, CV:= CV_res); + ctu_inst(CU:= TRUE, R:= FALSE, PV:= UDINT#3, Q => Q_res, CV => CV_res); // input CU evaluated by R_EDGE, this call will enable to count up again - ctu_inst(CU:= FALSE, R:= FALSE, PV:= UDINT#3, Q:= Q_res, CV:= CV_res); + ctu_inst(CU:= FALSE, R:= FALSE, PV:= UDINT#3, Q => Q_res, CV => CV_res); END_IF END_PROGRAM "#; @@ -196,11 +196,11 @@ fn ctu_lint() { END_VAR // count up until Q_res true and then reset CV_res IF Q_res THEN - ctu_inst(CU:= TRUE, R:= TRUE, PV:= LINT#3, Q:= Q_res, CV:= CV_res); + ctu_inst(CU:= TRUE, R:= TRUE, PV:= LINT#3, Q => Q_res, CV => CV_res); ELSE - ctu_inst(CU:= TRUE, R:= FALSE, PV:= LINT#3, Q:= Q_res, CV:= CV_res); + ctu_inst(CU:= TRUE, R:= FALSE, PV:= LINT#3, Q => Q_res, CV => CV_res); // input CU evaluated by R_EDGE, this call will enable to count up again - ctu_inst(CU:= FALSE, R:= FALSE, PV:= LINT#3, Q:= Q_res, CV:= CV_res); + ctu_inst(CU:= FALSE, R:= FALSE, PV:= LINT#3, Q => Q_res, CV => CV_res); END_IF END_PROGRAM "#; @@ -238,11 +238,11 @@ fn ctu_ulint() { END_VAR // count up until Q_res true and then reset CV_res IF Q_res THEN - ctu_inst(CU:= TRUE, R:= TRUE, PV:= ULINT#3, Q:= Q_res, CV:= CV_res); + ctu_inst(CU:= TRUE, R:= TRUE, PV:= ULINT#3, Q => Q_res, CV => CV_res); ELSE - ctu_inst(CU:= TRUE, R:= FALSE, PV:= ULINT#3, Q:= Q_res, CV:= CV_res); + ctu_inst(CU:= TRUE, R:= FALSE, PV:= ULINT#3, Q => Q_res, CV => CV_res); // input CU evaluated by R_EDGE, this call will enable to count up again - ctu_inst(CU:= FALSE, R:= FALSE, PV:= ULINT#3, Q:= Q_res, CV:= CV_res); + ctu_inst(CU:= FALSE, R:= FALSE, PV:= ULINT#3, Q => Q_res, CV => CV_res); END_IF END_PROGRAM "#; @@ -290,12 +290,12 @@ fn ctd() { END_VAR // load PV value IF load THEN - ctd_inst(CD:= TRUE, LD:= load, PV:= INT#3, Q:= Q_res, CV:= CV_res); + ctd_inst(CD:= TRUE, LD:= load, PV:= INT#3, Q => Q_res, CV => CV_res); load := FALSE; END_IF - ctd_inst(CD:= TRUE, LD:= load, PV:= INT#3, Q:= Q_res, CV:= CV_res); + ctd_inst(CD:= TRUE, LD:= load, PV:= INT#3, Q => Q_res, CV => CV_res); // input CD evaluated by R_EDGE, this call will enable to count down again - ctd_inst(CD:= FALSE, LD:= load, PV:= INT#3, Q:= Q_res, CV:= CV_res); + ctd_inst(CD:= FALSE, LD:= load, PV:= INT#3, Q => Q_res, CV => CV_res); END_PROGRAM "#; @@ -333,12 +333,12 @@ fn ctd_int() { END_VAR // load PV value IF load THEN - ctd_inst(CD:= TRUE, LD:= load, PV:= INT#3, Q:= Q_res, CV:= CV_res); + ctd_inst(CD:= TRUE, LD:= load, PV:= INT#3, Q => Q_res, CV => CV_res); load := FALSE; END_IF - ctd_inst(CD:= TRUE, LD:= load, PV:= INT#3, Q:= Q_res, CV:= CV_res); + ctd_inst(CD:= TRUE, LD:= load, PV:= INT#3, Q => Q_res, CV => CV_res); // input CD evaluated by R_EDGE, this call will enable to count down again - ctd_inst(CD:= FALSE, LD:= load, PV:= INT#3, Q:= Q_res, CV:= CV_res); + ctd_inst(CD:= FALSE, LD:= load, PV:= INT#3, Q => Q_res, CV => CV_res); END_PROGRAM "#; @@ -376,12 +376,12 @@ fn ctd_dint() { END_VAR // load PV value IF load THEN - ctd_inst(CD:= TRUE, LD:= load, PV:= DINT#3, Q:= Q_res, CV:= CV_res); + ctd_inst(CD:= TRUE, LD:= load, PV:= DINT#3, Q => Q_res, CV => CV_res); load := FALSE; END_IF - ctd_inst(CD:= TRUE, LD:= load, PV:= DINT#3, Q:= Q_res, CV:= CV_res); + ctd_inst(CD:= TRUE, LD:= load, PV:= DINT#3, Q => Q_res, CV => CV_res); // input CD evaluated by R_EDGE, this call will enable to count down again - ctd_inst(CD:= FALSE, LD:= load, PV:= DINT#3, Q:= Q_res, CV:= CV_res); + ctd_inst(CD:= FALSE, LD:= load, PV:= DINT#3, Q => Q_res, CV => CV_res); END_PROGRAM "#; @@ -419,12 +419,12 @@ fn ctd_udint() { END_VAR // load PV value IF load THEN - ctd_inst(CD:= TRUE, LD:= load, PV:= UDINT#3, Q:= Q_res, CV:= CV_res); + ctd_inst(CD:= TRUE, LD:= load, PV:= UDINT#3, Q => Q_res, CV => CV_res); load := FALSE; END_IF - ctd_inst(CD:= TRUE, LD:= load, PV:= UDINT#3, Q:= Q_res, CV:= CV_res); + ctd_inst(CD:= TRUE, LD:= load, PV:= UDINT#3, Q => Q_res, CV => CV_res); // input CD evaluated by R_EDGE, this call will enable to count down again - ctd_inst(CD:= FALSE, LD:= load, PV:= UDINT#3, Q:= Q_res, CV:= CV_res); + ctd_inst(CD:= FALSE, LD:= load, PV:= UDINT#3, Q => Q_res, CV => CV_res); END_PROGRAM "#; @@ -462,12 +462,12 @@ fn ctd_lint() { END_VAR // load PV value IF load THEN - ctd_inst(CD:= TRUE, LD:= load, PV:= LINT#3, Q:= Q_res, CV:= CV_res); + ctd_inst(CD:= TRUE, LD:= load, PV:= LINT#3, Q => Q_res, CV => CV_res); load := FALSE; END_IF - ctd_inst(CD:= TRUE, LD:= load, PV:= LINT#3, Q:= Q_res, CV:= CV_res); + ctd_inst(CD:= TRUE, LD:= load, PV:= LINT#3, Q => Q_res, CV => CV_res); // input CD evaluated by R_EDGE, this call will enable to count down again - ctd_inst(CD:= FALSE, LD:= load, PV:= LINT#3, Q:= Q_res, CV:= CV_res); + ctd_inst(CD:= FALSE, LD:= load, PV:= LINT#3, Q => Q_res, CV => CV_res); END_PROGRAM "#; @@ -505,12 +505,12 @@ fn ctd_ulint() { END_VAR // load PV value IF load THEN - ctd_inst(CD:= TRUE, LD:= load, PV:= ULINT#3, Q:= Q_res, CV:= CV_res); + ctd_inst(CD:= TRUE, LD:= load, PV:= ULINT#3, Q => Q_res, CV => CV_res); load := FALSE; END_IF - ctd_inst(CD:= TRUE, LD:= load, PV:= ULINT#3, Q:= Q_res, CV:= CV_res); + ctd_inst(CD:= TRUE, LD:= load, PV:= ULINT#3, Q => Q_res, CV => CV_res); // input CD evaluated by R_EDGE, this call will enable to count down again - ctd_inst(CD:= FALSE, LD:= load, PV:= ULINT#3, Q:= Q_res, CV:= CV_res); + ctd_inst(CD:= FALSE, LD:= load, PV:= ULINT#3, Q => Q_res, CV => CV_res); END_PROGRAM "#; @@ -561,31 +561,31 @@ fn ctud() { END_VAR // 1st call, load PV value IF load THEN - ctud_inst(CU:= FALSE, CD:= FALSE, R:= FALSE, LD:= TRUE, PV:= INT#1, QU:= QU_res, QD:= QD_res, CV:= CV_res); + ctud_inst(CU:= FALSE, CD:= FALSE, R:= FALSE, LD:= TRUE, PV:= INT#1, QU => QU_res, QD => QD_res, CV => CV_res); load := FALSE; END_IF // 2nd call, CU/CD both true, nothing should happen IF i = 1 THEN - ctud_inst(CU:= TRUE, CD:= TRUE, R:= FALSE, LD:= FALSE, PV:= INT#1, QU:= QU_res, QD:= QD_res, CV:= CV_res); + ctud_inst(CU:= TRUE, CD:= TRUE, R:= FALSE, LD:= FALSE, PV:= INT#1, QU => QU_res, QD => QD_res, CV => CV_res); END_IF // 3rd call, count down IF i = 2 THEN // input CD evaluated by R_EDGE, this call will enable count down again - ctud_inst(CU:= FALSE, CD:= FALSE, R:= FALSE, LD:= FALSE, PV:= INT#1, QU:= QU_res, QD:= QD_res, CV:= CV_res); - ctud_inst(CU:= FALSE, CD:= TRUE, R:= FALSE, LD:= FALSE, PV:= INT#1, QU:= QU_res, QD:= QD_res, CV:= CV_res); + ctud_inst(CU:= FALSE, CD:= FALSE, R:= FALSE, LD:= FALSE, PV:= INT#1, QU => QU_res, QD => QD_res, CV => CV_res); + ctud_inst(CU:= FALSE, CD:= TRUE, R:= FALSE, LD:= FALSE, PV:= INT#1, QU => QU_res, QD => QD_res, CV => CV_res); END_IF // 4th call, count up IF i = 3 THEN // input CU evaluated by R_EDGE, third call enabled count up again - ctud_inst(CU:= TRUE, CD:= FALSE, R:= FALSE, LD:= FALSE, PV:= INT#1, QU:= QU_res, QD:= QD_res, CV:= CV_res); + ctud_inst(CU:= TRUE, CD:= FALSE, R:= FALSE, LD:= FALSE, PV:= INT#1, QU => QU_res, QD => QD_res, CV => CV_res); END_IF // 5th call, reset IF i = 4 THEN - ctud_inst(CU:= FALSE, CD:= FALSE, R:= TRUE, LD:= FALSE, PV:= INT#1, QU:= QU_res, QD:= QD_res, CV:= CV_res); + ctud_inst(CU:= FALSE, CD:= FALSE, R:= TRUE, LD:= FALSE, PV:= INT#1, QU => QU_res, QD => QD_res, CV => CV_res); END_IF i := i + 1; END_PROGRAM @@ -636,31 +636,31 @@ fn ctud_int() { END_VAR // 1st call, load PV value IF load THEN - ctud_inst(CU:= FALSE, CD:= FALSE, R:= FALSE, LD:= TRUE, PV:= INT#1, QU:= QU_res, QD:= QD_res, CV:= CV_res); + ctud_inst(CU:= FALSE, CD:= FALSE, R:= FALSE, LD:= TRUE, PV:= INT#1, QU => QU_res, QD => QD_res, CV => CV_res); load := FALSE; END_IF // 2nd call, CU/CD both true, nothing should happen IF i = 1 THEN - ctud_inst(CU:= TRUE, CD:= TRUE, R:= FALSE, LD:= FALSE, PV:= INT#1, QU:= QU_res, QD:= QD_res, CV:= CV_res); + ctud_inst(CU:= TRUE, CD:= TRUE, R:= FALSE, LD:= FALSE, PV:= INT#1, QU => QU_res, QD => QD_res, CV => CV_res); END_IF // 3rd call, count down IF i = 2 THEN // input CD evaluated by R_EDGE, this call will enable count down again - ctud_inst(CU:= FALSE, CD:= FALSE, R:= FALSE, LD:= FALSE, PV:= INT#1, QU:= QU_res, QD:= QD_res, CV:= CV_res); - ctud_inst(CU:= FALSE, CD:= TRUE, R:= FALSE, LD:= FALSE, PV:= INT#1, QU:= QU_res, QD:= QD_res, CV:= CV_res); + ctud_inst(CU:= FALSE, CD:= FALSE, R:= FALSE, LD:= FALSE, PV:= INT#1, QU => QU_res, QD => QD_res, CV => CV_res); + ctud_inst(CU:= FALSE, CD:= TRUE, R:= FALSE, LD:= FALSE, PV:= INT#1, QU => QU_res, QD => QD_res, CV => CV_res); END_IF // 4th call, count up IF i = 3 THEN // input CU evaluated by R_EDGE, third call enabled count up again - ctud_inst(CU:= TRUE, CD:= FALSE, R:= FALSE, LD:= FALSE, PV:= INT#1, QU:= QU_res, QD:= QD_res, CV:= CV_res); + ctud_inst(CU:= TRUE, CD:= FALSE, R:= FALSE, LD:= FALSE, PV:= INT#1, QU => QU_res, QD => QD_res, CV => CV_res); END_IF // 5th call, reset IF i = 4 THEN - ctud_inst(CU:= FALSE, CD:= FALSE, R:= TRUE, LD:= FALSE, PV:= INT#1, QU:= QU_res, QD:= QD_res, CV:= CV_res); + ctud_inst(CU:= FALSE, CD:= FALSE, R:= TRUE, LD:= FALSE, PV:= INT#1, QU => QU_res, QD => QD_res, CV => CV_res); END_IF i := i + 1; END_PROGRAM @@ -711,31 +711,31 @@ fn ctud_dint() { END_VAR // 1st call, load PV value IF load THEN - ctud_inst(CU:= FALSE, CD:= FALSE, R:= FALSE, LD:= TRUE, PV:= DINT#1, QU:= QU_res, QD:= QD_res, CV:= CV_res); + ctud_inst(CU:= FALSE, CD:= FALSE, R:= FALSE, LD:= TRUE, PV:= DINT#1, QU => QU_res, QD => QD_res, CV => CV_res); load := FALSE; END_IF // 2nd call, CU/CD both true, nothing should happen IF i = 1 THEN - ctud_inst(CU:= TRUE, CD:= TRUE, R:= FALSE, LD:= FALSE, PV:= DINT#1, QU:= QU_res, QD:= QD_res, CV:= CV_res); + ctud_inst(CU:= TRUE, CD:= TRUE, R:= FALSE, LD:= FALSE, PV:= DINT#1, QU => QU_res, QD => QD_res, CV => CV_res); END_IF // 3rd call, count down IF i = 2 THEN // input CD evaluated by R_EDGE, this call will enable count down again - ctud_inst(CU:= FALSE, CD:= FALSE, R:= FALSE, LD:= FALSE, PV:= DINT#1, QU:= QU_res, QD:= QD_res, CV:= CV_res); - ctud_inst(CU:= FALSE, CD:= TRUE, R:= FALSE, LD:= FALSE, PV:= DINT#1, QU:= QU_res, QD:= QD_res, CV:= CV_res); + ctud_inst(CU:= FALSE, CD:= FALSE, R:= FALSE, LD:= FALSE, PV:= DINT#1, QU => QU_res, QD => QD_res, CV => CV_res); + ctud_inst(CU:= FALSE, CD:= TRUE, R:= FALSE, LD:= FALSE, PV:= DINT#1, QU => QU_res, QD => QD_res, CV => CV_res); END_IF // 4th call, count up IF i = 3 THEN // input CU evaluated by R_EDGE, third call enabled count up again - ctud_inst(CU:= TRUE, CD:= FALSE, R:= FALSE, LD:= FALSE, PV:= DINT#1, QU:= QU_res, QD:= QD_res, CV:= CV_res); + ctud_inst(CU:= TRUE, CD:= FALSE, R:= FALSE, LD:= FALSE, PV:= DINT#1, QU => QU_res, QD => QD_res, CV => CV_res); END_IF // 5th call, reset IF i = 4 THEN - ctud_inst(CU:= FALSE, CD:= FALSE, R:= TRUE, LD:= FALSE, PV:= DINT#1, QU:= QU_res, QD:= QD_res, CV:= CV_res); + ctud_inst(CU:= FALSE, CD:= FALSE, R:= TRUE, LD:= FALSE, PV:= DINT#1, QU => QU_res, QD => QD_res, CV => CV_res); END_IF i := i + 1; END_PROGRAM @@ -786,31 +786,31 @@ fn ctud_udint() { END_VAR // 1st call, load PV value IF load THEN - ctud_inst(CU:= FALSE, CD:= FALSE, R:= FALSE, LD:= TRUE, PV:= UDINT#1, QU:= QU_res, QD:= QD_res, CV:= CV_res); + ctud_inst(CU:= FALSE, CD:= FALSE, R:= FALSE, LD:= TRUE, PV:= UDINT#1, QU => QU_res, QD => QD_res, CV => CV_res); load := FALSE; END_IF // 2nd call, CU/CD both true, nothing should happen IF i = 1 THEN - ctud_inst(CU:= TRUE, CD:= TRUE, R:= FALSE, LD:= FALSE, PV:= UDINT#1, QU:= QU_res, QD:= QD_res, CV:= CV_res); + ctud_inst(CU:= TRUE, CD:= TRUE, R:= FALSE, LD:= FALSE, PV:= UDINT#1, QU => QU_res, QD => QD_res, CV => CV_res); END_IF // 3rd call, count down IF i = 2 THEN // input CD evaluated by R_EDGE, this call will enable count down again - ctud_inst(CU:= FALSE, CD:= FALSE, R:= FALSE, LD:= FALSE, PV:= UDINT#1, QU:= QU_res, QD:= QD_res, CV:= CV_res); - ctud_inst(CU:= FALSE, CD:= TRUE, R:= FALSE, LD:= FALSE, PV:= UDINT#1, QU:= QU_res, QD:= QD_res, CV:= CV_res); + ctud_inst(CU:= FALSE, CD:= FALSE, R:= FALSE, LD:= FALSE, PV:= UDINT#1, QU => QU_res, QD => QD_res, CV => CV_res); + ctud_inst(CU:= FALSE, CD:= TRUE, R:= FALSE, LD:= FALSE, PV:= UDINT#1, QU => QU_res, QD => QD_res, CV => CV_res); END_IF // 4th call, count up IF i = 3 THEN // input CU evaluated by R_EDGE, third call enabled count up again - ctud_inst(CU:= TRUE, CD:= FALSE, R:= FALSE, LD:= FALSE, PV:= UDINT#1, QU:= QU_res, QD:= QD_res, CV:= CV_res); + ctud_inst(CU:= TRUE, CD:= FALSE, R:= FALSE, LD:= FALSE, PV:= UDINT#1, QU => QU_res, QD => QD_res, CV => CV_res); END_IF // 5th call, reset IF i = 4 THEN - ctud_inst(CU:= FALSE, CD:= FALSE, R:= TRUE, LD:= FALSE, PV:= UDINT#1, QU:= QU_res, QD:= QD_res, CV:= CV_res); + ctud_inst(CU:= FALSE, CD:= FALSE, R:= TRUE, LD:= FALSE, PV:= UDINT#1, QU => QU_res, QD => QD_res, CV => CV_res); END_IF i := i + 1; END_PROGRAM @@ -861,31 +861,31 @@ fn ctud_lint() { END_VAR // 1st call, load PV value IF load THEN - ctud_inst(CU:= FALSE, CD:= FALSE, R:= FALSE, LD:= TRUE, PV:= LINT#1, QU:= QU_res, QD:= QD_res, CV:= CV_res); + ctud_inst(CU:= FALSE, CD:= FALSE, R:= FALSE, LD:= TRUE, PV:= LINT#1, QU => QU_res, QD => QD_res, CV => CV_res); load := FALSE; END_IF // 2nd call, CU/CD both true, nothing should happen IF i = 1 THEN - ctud_inst(CU:= TRUE, CD:= TRUE, R:= FALSE, LD:= FALSE, PV:= LINT#1, QU:= QU_res, QD:= QD_res, CV:= CV_res); + ctud_inst(CU:= TRUE, CD:= TRUE, R:= FALSE, LD:= FALSE, PV:= LINT#1, QU => QU_res, QD => QD_res, CV => CV_res); END_IF // 3rd call, count down IF i = 2 THEN // input CD evaluated by R_EDGE, this call will enable count down again - ctud_inst(CU:= FALSE, CD:= FALSE, R:= FALSE, LD:= FALSE, PV:= LINT#1, QU:= QU_res, QD:= QD_res, CV:= CV_res); - ctud_inst(CU:= FALSE, CD:= TRUE, R:= FALSE, LD:= FALSE, PV:= LINT#1, QU:= QU_res, QD:= QD_res, CV:= CV_res); + ctud_inst(CU:= FALSE, CD:= FALSE, R:= FALSE, LD:= FALSE, PV:= LINT#1, QU => QU_res, QD => QD_res, CV => CV_res); + ctud_inst(CU:= FALSE, CD:= TRUE, R:= FALSE, LD:= FALSE, PV:= LINT#1, QU => QU_res, QD => QD_res, CV => CV_res); END_IF // 4th call, count up IF i = 3 THEN // input CU evaluated by R_EDGE, third call enabled count up again - ctud_inst(CU:= TRUE, CD:= FALSE, R:= FALSE, LD:= FALSE, PV:= LINT#1, QU:= QU_res, QD:= QD_res, CV:= CV_res); + ctud_inst(CU:= TRUE, CD:= FALSE, R:= FALSE, LD:= FALSE, PV:= LINT#1, QU => QU_res, QD => QD_res, CV => CV_res); END_IF // 5th call, reset IF i = 4 THEN - ctud_inst(CU:= FALSE, CD:= FALSE, R:= TRUE, LD:= FALSE, PV:= LINT#1, QU:= QU_res, QD:= QD_res, CV:= CV_res); + ctud_inst(CU:= FALSE, CD:= FALSE, R:= TRUE, LD:= FALSE, PV:= LINT#1, QU => QU_res, QD => QD_res, CV => CV_res); END_IF i := i + 1; END_PROGRAM @@ -936,31 +936,31 @@ fn ctud_ulint() { END_VAR // 1st call, load PV value IF load THEN - ctud_inst(CU:= FALSE, CD:= FALSE, R:= FALSE, LD:= TRUE, PV:= ULINT#1, QU:= QU_res, QD:= QD_res, CV:= CV_res); + ctud_inst(CU:= FALSE, CD:= FALSE, R:= FALSE, LD:= TRUE, PV:= ULINT#1, QU => QU_res, QD => QD_res, CV => CV_res); load := FALSE; END_IF // 2nd call, CU/CD both true, nothing should happen IF i = 1 THEN - ctud_inst(CU:= TRUE, CD:= TRUE, R:= FALSE, LD:= FALSE, PV:= ULINT#1, QU:= QU_res, QD:= QD_res, CV:= CV_res); + ctud_inst(CU:= TRUE, CD:= TRUE, R:= FALSE, LD:= FALSE, PV:= ULINT#1, QU => QU_res, QD => QD_res, CV => CV_res); END_IF // 3rd call, count down IF i = 2 THEN // input CD evaluated by R_EDGE, this call will enable count down again - ctud_inst(CU:= FALSE, CD:= FALSE, R:= FALSE, LD:= FALSE, PV:= ULINT#1, QU:= QU_res, QD:= QD_res, CV:= CV_res); - ctud_inst(CU:= FALSE, CD:= TRUE, R:= FALSE, LD:= FALSE, PV:= ULINT#1, QU:= QU_res, QD:= QD_res, CV:= CV_res); + ctud_inst(CU:= FALSE, CD:= FALSE, R:= FALSE, LD:= FALSE, PV:= ULINT#1, QU => QU_res, QD => QD_res, CV => CV_res); + ctud_inst(CU:= FALSE, CD:= TRUE, R:= FALSE, LD:= FALSE, PV:= ULINT#1, QU => QU_res, QD => QD_res, CV => CV_res); END_IF // 4th call, count up IF i = 3 THEN // input CU evaluated by R_EDGE, third call enabled count up again - ctud_inst(CU:= TRUE, CD:= FALSE, R:= FALSE, LD:= FALSE, PV:= ULINT#1, QU:= QU_res, QD:= QD_res, CV:= CV_res); + ctud_inst(CU:= TRUE, CD:= FALSE, R:= FALSE, LD:= FALSE, PV:= ULINT#1, QU => QU_res, QD => QD_res, CV => CV_res); END_IF // 5th call, reset IF i = 4 THEN - ctud_inst(CU:= FALSE, CD:= FALSE, R:= TRUE, LD:= FALSE, PV:= ULINT#1, QU:= QU_res, QD:= QD_res, CV:= CV_res); + ctud_inst(CU:= FALSE, CD:= FALSE, R:= TRUE, LD:= FALSE, PV:= ULINT#1, QU => QU_res, QD => QD_res, CV => CV_res); END_IF i := i + 1; END_PROGRAM diff --git a/scripts/build.sh b/scripts/build.sh index 14ece3a9106..ab431fc90f8 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -8,6 +8,7 @@ check_style=0 build=0 doc=0 test=0 +lit=0 coverage=0 release=0 debug=0 @@ -140,6 +141,19 @@ function run_check_style() { cargo fmt -- --check } +function run_lit_test() { + # We need a binary as well as the stdlib and its *.so file before running lit tests + run_build + run_std_build + run_package_std + + if [[ $release -eq 0 ]]; then + lit -v -DLIB=$project_location/output -DCOMPILER=$project_location/target/debug/plc tests/lit/ + else + lit -v -DLIB=$project_location/output -DCOMPILER=$project_location/target/release/plc tests/lit/ + fi +} + function run_test() { CARGO_OPTIONS=$(set_cargo_options) log "Running cargo test" @@ -191,6 +205,8 @@ function set_offline() { function run_package_std() { cc=$(get_compiler) + OUTPUT_DIR=$project_location/output + make_dir "$OUTPUT_DIR" log "Packaging Standard functions" log "Removing previous output folder" rm -rf $OUTPUT_DIR @@ -291,6 +307,9 @@ function run_in_container() { if [[ $test -ne 0 ]]; then params="$params --test" fi + if [[ $lit -ne 0 ]]; then + params="$params --lit" + fi if [[ $junit -ne 0 ]]; then params="$params --junit" fi @@ -330,7 +349,7 @@ function run_in_container() { set -o errexit -o pipefail -o noclobber -o nounset OPTIONS=sorbvc -LONGOPTS=sources,offline,release,check,check-style,build,doc,test,junit,verbose,container,linux,container-name:,coverage,package,target: +LONGOPTS=sources,offline,release,check,check-style,build,doc,lit,test,junit,verbose,container,linux,container-name:,coverage,package,target: check_env # -activate quoting/enhanced mode (e.g. by writing out “--options”) @@ -382,6 +401,9 @@ while true; do --test) test=1 ;; + --lit) + lit=1 + ;; --junit) junit=1 ;; @@ -417,11 +439,6 @@ if [[ $container -ne 0 ]]; then exit 0 fi -if [[ $package -ne 0 ]]; then - OUTPUT_DIR=$project_location/output - make_dir "$OUTPUT_DIR" -fi - if [[ $vendor -ne 0 ]]; then generate_sources exit 0 @@ -457,6 +474,10 @@ if [[ $test -ne 0 ]]; then run_test fi +if [[ $lit -ne 0 ]]; then + run_lit_test +fi + if [[ $doc -ne 0 ]]; then run_doc fi diff --git a/src/builtins.rs b/src/builtins.rs index 4deca18bb17..9f5da9f6f93 100644 --- a/src/builtins.rs +++ b/src/builtins.rs @@ -92,14 +92,14 @@ lazy_static! { }), validation: Some(|validator, operator, parameters, _, _| { let Some(params) = parameters else { - validator.push_diagnostic(Diagnostic::invalid_parameter_count(1, 0, operator.get_location())); + validator.push_diagnostic(Diagnostic::invalid_argument_count(1, 0, operator.get_location())); return; }; let params = flatten_expression_list(params); if params.len() > 1 { - validator.push_diagnostic(Diagnostic::invalid_parameter_count(1, params.len(), operator.get_location())); + validator.push_diagnostic(Diagnostic::invalid_argument_count(1, params.len(), operator.get_location())); } }), generic_name_resolver: no_generic_name_resolver, @@ -579,7 +579,7 @@ fn validate_builtin_symbol_parameter_count( operation: Operator, ) { let Some(params) = parameters else { - validator.push_diagnostic(Diagnostic::invalid_parameter_count(2, 0, operator.get_location())); + validator.push_diagnostic(Diagnostic::invalid_argument_count(2, 0, operator.get_location())); return; }; @@ -588,7 +588,7 @@ fn validate_builtin_symbol_parameter_count( // non-extensible operators Operator::Minus | Operator::Division | Operator::NotEqual => { if count != 2 { - validator.push_diagnostic(Diagnostic::invalid_parameter_count( + validator.push_diagnostic(Diagnostic::invalid_argument_count( 2, count, operator.get_location(), @@ -597,7 +597,7 @@ fn validate_builtin_symbol_parameter_count( } _ => { if count < 2 { - validator.push_diagnostic(Diagnostic::invalid_parameter_count( + validator.push_diagnostic(Diagnostic::invalid_argument_count( 2, count, operator.get_location(), @@ -746,7 +746,7 @@ fn validate_variable_length_array_bound_function( index: &Index, ) { let Some(parameters) = parameters else { - validator.push_diagnostic(Diagnostic::invalid_parameter_count(2, 0, operator.get_location())); + validator.push_diagnostic(Diagnostic::invalid_argument_count(2, 0, operator.get_location())); // no params, nothing to validate return; }; @@ -754,7 +754,7 @@ fn validate_variable_length_array_bound_function( let params = ast::flatten_expression_list(parameters); if params.len() > 2 { - validator.push_diagnostic(Diagnostic::invalid_parameter_count( + validator.push_diagnostic(Diagnostic::invalid_argument_count( 2, params.len(), operator.get_location(), @@ -798,7 +798,7 @@ fn validate_variable_length_array_bound_function( }; } (Some(_), None) => { - validator.push_diagnostic(Diagnostic::invalid_parameter_count(2, 1, operator.get_location())) + validator.push_diagnostic(Diagnostic::invalid_argument_count(2, 1, operator.get_location())) } _ => unreachable!(), } @@ -846,20 +846,6 @@ fn generate_variable_length_array_bound_function<'ink>( let offset = if is_lower { (value - 1) as u64 * 2 } else { (value - 1) as u64 * 2 + 1 }; llvm.i32_type().const_int(offset, false) } - AstStatement::CastStatement(data) => { - let ExpressionValue::RValue(value) = generator.generate_expression_value(&data.target)? else { - unreachable!() - }; - - if !value.is_int_value() { - return Err(Diagnostic::codegen_error( - format!("Expected INT value, found {}", value.get_type()), - location, - )); - }; - - value.into_int_value() - } // e.g. LOWER_BOUND(arr, idx + 3) _ => { let expression_value = generator.generate_expression(params[1])?; diff --git a/src/codegen.rs b/src/codegen.rs index b141c368ef8..8bf1eb116f5 100644 --- a/src/codegen.rs +++ b/src/codegen.rs @@ -1,8 +1,10 @@ // Copyright (c) 2020 Ghaith Hachem and Mathias Rieder use std::{ cell::RefCell, + collections::HashMap, ops::Deref, path::{Path, PathBuf}, + sync::Mutex, }; /// module to generate llvm intermediate representation for a CompilationUnit @@ -19,7 +21,7 @@ use self::{ use crate::{ output::FormatOption, resolver::{AstAnnotations, Dependency, StringLiterals}, - DebugLevel, OptimizationLevel, Target, + ConfigFormat, DebugLevel, OptimizationLevel, Target, }; use super::index::*; @@ -29,11 +31,14 @@ use inkwell::{ execution_engine::{ExecutionEngine, JitFunction}, memory_buffer::MemoryBuffer, types::BasicType, + values::BasicValue, + AddressSpace, }; use inkwell::{ module::Module, passes::PassBuilderOptions, targets::{CodeModel, FileType, InitializationConfig, RelocMode}, + types::BasicTypeEnum, }; use plc_ast::ast::{CompilationUnit, LinkageType}; use plc_diagnostics::diagnostics::Diagnostic; @@ -71,6 +76,8 @@ pub struct CodeGen<'ink> { /// the debugging module creates debug information at appropriate locations pub debug: DebugBuilderEnum<'ink>, + pub got_layout_file: Option<(String, ConfigFormat)>, + pub module_location: String, } @@ -88,13 +95,14 @@ impl<'ink> CodeGen<'ink> { context: &'ink CodegenContext, root: Option<&Path>, module_location: &str, + got_layout_file: Option<(String, ConfigFormat)>, optimization_level: OptimizationLevel, debug_level: DebugLevel, ) -> CodeGen<'ink> { let module = context.create_module(module_location); module.set_source_file_name(module_location); let debug = debug::DebugBuilderEnum::new(context, &module, root, optimization_level, debug_level); - CodeGen { module, debug, module_location: module_location.to_string() } + CodeGen { module, debug, got_layout_file, module_location: module_location.to_string() } } pub fn generate_llvm_index( @@ -104,6 +112,7 @@ impl<'ink> CodeGen<'ink> { literals: &StringLiterals, dependencies: &FxIndexSet, global_index: &Index, + got_layout: &Mutex>>, ) -> Result, Diagnostic> { let llvm = Llvm::new(context, context.create_builder()); let mut index = LlvmTypedIndex::default(); @@ -125,6 +134,86 @@ impl<'ink> CodeGen<'ink> { variable_generator.generate_global_variables(dependencies, &self.module_location)?; index.merge(llvm_gv_index); + // Build our GOT layout here. We need to find all the names for globals, programs, and + // functions and assign them indices in the GOT, taking into account prior indices. + let program_globals = + global_index.get_program_instances().into_iter().fold(Vec::new(), |mut acc, p| { + acc.push(p.get_name().to_owned()); + acc.push(p.get_qualified_name().to_owned()); + acc.push(format!("{}_instance", p.get_name())); + acc + }); + + let functions = global_index.get_pous().values().filter_map(|p| match p { + PouIndexEntry::Function { name, linkage: LinkageType::Internal, is_generated: false, .. } + | PouIndexEntry::FunctionBlock { name, linkage: LinkageType::Internal, .. } => { + Some(String::from(name)) + } + _ => None, + }); + let all_names = global_index + .get_globals() + .values() + .map(VariableIndexEntry::get_qualified_name) + .map(String::from) + .chain(program_globals) + .chain(functions) + .map(|s| s.to_lowercase()) + .map(|s| (crate::index::get_initializer_name(&s), s)) + .fold(Vec::new(), |mut acc, (s, s1)| { + acc.push(s); + acc.push(s1); + acc + }); + + if let Some(got_entries) = &mut *got_layout.lock().unwrap() { + let mut new_symbols = Vec::new(); + let mut new_got_entries = HashMap::new(); + let mut new_got = HashMap::new(); + + for name in all_names { + if let Some(idx) = got_entries.get(&name.to_string()) { + new_got_entries.insert(name.to_string(), *idx); + index.associate_got_index(&name, *idx)?; + new_got.insert(*idx, name.to_string()); + } else { + new_symbols.push(name.to_string()); + } + } + + // Put any names that weren't there last time in any free space in the GOT. + let mut idx: u64 = 0; + for name in &new_symbols { + while new_got.contains_key(&idx) { + idx += 1; + } + new_got_entries.insert(name.to_string(), idx); + index.associate_got_index(name, idx)?; + new_got.insert(idx, name.to_string()); + } + + // Construct our GOT as a new global array. We initialise this array in the loader code. + let got_size: u32 = new_got + .keys() + .max() + .map_or(0, |m| *m + 1) + .try_into() + .expect("the computed custom GOT size is too large"); + + let ptr_ty = llvm.context.i8_type().ptr_type(AddressSpace::default()); + let empty_got = ptr_ty + .const_array(vec![ptr_ty.const_null(); got_size as usize].as_slice()) + .as_basic_value_enum(); + let custom_got_ty = + BasicTypeEnum::ArrayType(Llvm::get_array_type(BasicTypeEnum::PointerType(ptr_ty), got_size)); + + let custom_got = llvm.create_global_variable(&self.module, "__custom_got", custom_got_ty); + custom_got.set_linkage(inkwell::module::Linkage::WeakODR); + custom_got.set_initial_value(Some(empty_got), custom_got_ty); + + *got_entries = new_got_entries; + } + //Generate opaque functions for implementations and associate them with their types let llvm = Llvm::new(context, context.create_builder()); let llvm_impl_index = pou_generator::generate_implementation_stubs( @@ -193,11 +282,11 @@ impl<'ink> CodeGen<'ink> { unit: &CompilationUnit, annotations: &AstAnnotations, global_index: &Index, - llvm_index: &LlvmTypedIndex, + llvm_index: LlvmTypedIndex, ) -> Result, Diagnostic> { //generate all pous let llvm = Llvm::new(context, context.create_builder()); - let pou_generator = PouGenerator::new(llvm, global_index, annotations, llvm_index); + let pou_generator = PouGenerator::new(llvm, global_index, annotations, &llvm_index); //Generate the POU stubs in the first go to make sure they can be referenced. for implementation in &unit.implementations { diff --git a/src/codegen/generators/expression_generator.rs b/src/codegen/generators/expression_generator.rs index 404526afd6e..6e88c4e83b5 100644 --- a/src/codegen/generators/expression_generator.rs +++ b/src/codegen/generators/expression_generator.rs @@ -1,29 +1,17 @@ // Copyright (c) 2020 Ghaith Hachem and Mathias Rieder -use crate::{ - codegen::{ - debug::{Debug, DebugBuilderEnum}, - llvm_index::LlvmTypedIndex, - llvm_typesystem::{cast_if_needed, get_llvm_int_type}, - }, - index::{ - const_expressions::ConstId, ArgumentType, ImplementationIndexEntry, Index, PouIndexEntry, - VariableIndexEntry, VariableType, - }, - resolver::{AnnotationMap, AstAnnotations, StatementAnnotation}, - typesystem::{ - is_same_type_class, DataType, DataTypeInformation, DataTypeInformationProvider, Dimension, - StringEncoding, VarArgs, DINT_TYPE, INT_SIZE, INT_TYPE, LINT_TYPE, - }, -}; + use inkwell::{ builder::Builder, - types::{BasicType, BasicTypeEnum}, + types::{BasicType, BasicTypeEnum, FunctionType}, values::{ - ArrayValue, BasicMetadataValueEnum, BasicValue, BasicValueEnum, FloatValue, IntValue, PointerValue, - StructValue, VectorValue, + ArrayValue, BasicMetadataValueEnum, BasicValue, BasicValueEnum, CallSiteValue, CallableValue, + FloatValue, IntValue, PointerValue, StructValue, VectorValue, }, AddressSpace, FloatPredicate, IntPredicate, }; +use rustc_hash::FxHashSet; + +use plc_ast::ast::Assignment; use plc_ast::{ ast::{ flatten_expression_list, AstFactory, AstNode, AstStatement, DirectAccessType, Operator, @@ -34,10 +22,27 @@ use plc_ast::{ use plc_diagnostics::diagnostics::{Diagnostic, INTERNAL_LLVM_ERROR}; use plc_source::source_location::SourceLocation; use plc_util::convention::qualified_name; -use rustc_hash::FxHashSet; -use std::vec; + +use crate::{ + codegen::{ + debug::{Debug, DebugBuilderEnum}, + llvm_index::LlvmTypedIndex, + llvm_typesystem::{cast_if_needed, get_llvm_int_type}, + }, + index::{ + const_expressions::ConstId, ArgumentType, ImplementationIndexEntry, Index, PouIndexEntry, + VariableIndexEntry, VariableType, + }, + resolver::{AnnotationMap, AstAnnotations, StatementAnnotation}, + typesystem, + typesystem::{ + is_same_type_class, DataType, DataTypeInformation, DataTypeInformationProvider, Dimension, + StringEncoding, VarArgs, DINT_TYPE, INT_SIZE, INT_TYPE, LINT_TYPE, + }, +}; use super::{llvm::Llvm, statement_generator::FunctionContext, ADDRESS_SPACE_CONST, ADDRESS_SPACE_GENERIC}; + /// the generator for expressions pub struct ExpressionCodeGenerator<'a, 'b> { pub llvm: &'b Llvm<'a>, @@ -62,7 +67,7 @@ pub struct ExpressionCodeGenerator<'a, 'b> { #[derive(Debug)] struct CallParameterAssignment<'a, 'b> { /// the assignmentstatement in the call-argument list (a:=3) - assignment_statement: &'b AstNode, + assignment: &'b AstNode, /// the name of the function we're calling function_name: &'b str, /// the position of the argument in the POU's argument's list @@ -282,6 +287,68 @@ impl<'ink, 'b> ExpressionCodeGenerator<'ink, 'b> { self.generate_expression_value(const_expression) } + /// Generate an access to the appropriate GOT entry to achieve an access to the given base + /// lvalue. + pub fn generate_got_access( + &self, + context: &AstNode, + llvm_type: &BasicTypeEnum<'ink>, + ) -> Result>, Diagnostic> { + match self.annotations.get(context) { + Some(StatementAnnotation::Variable { qualified_name, .. }) => { + // We will generate a GEP, which has as its base address the magic constant which + // will eventually be replaced by the location of the GOT. + let base = + self.llvm.context.i64_type().const_int(0xdeadbeef00000000, false).const_to_pointer( + llvm_type.ptr_type(AddressSpace::default()).ptr_type(AddressSpace::default()), + ); + + self.llvm_index + .find_got_index(qualified_name) + .map(|idx| { + let ptr = self.llvm.load_array_element( + base, + &[self.llvm.context.i32_type().const_int(idx, false)], + "", + )?; + Ok(self.llvm.load_pointer(&ptr, "").into_pointer_value()) + }) + .transpose() + } + _ => Ok(None), + } + } + + /// Generate an access to the appropriate GOT entry to achieve a call to the given function. + pub fn generate_got_call( + &self, + qualified_name: &str, + function_type: &FunctionType<'ink>, + args: &[BasicMetadataValueEnum<'ink>], + ) -> Result>, Diagnostic> { + // We will generate a GEP, which has as its base address the magic constant which + // will eventually be replaced by the location of the GOT. + let base = self.llvm.context.i64_type().const_int(0xdeadbeef00000000, false).const_to_pointer( + function_type.ptr_type(AddressSpace::default()).ptr_type(AddressSpace::default()), + ); + + self.llvm_index + .find_got_index(qualified_name) + .map(|idx| { + let mut ptr = self.llvm.load_array_element( + base, + &[self.llvm.context.i32_type().const_int(idx, false)], + "", + )?; + ptr = self.llvm.load_pointer(&ptr, "").into_pointer_value(); + let callable = CallableValue::try_from(ptr) + .map_err(|_| Diagnostic::new("Pointer was not a function pointer"))?; + + Ok(self.llvm.builder.build_call(callable, args, "call")) + }) + .transpose() + } + /// generates a binary expression (e.g. a + b, x AND y, etc.) and returns the resulting `BasicValueEnum` /// - `left` the AstStatement left of the operator /// - `right` the AstStatement right of the operator @@ -424,7 +491,8 @@ impl<'ink, 'b> ExpressionCodeGenerator<'ink, 'b> { self.index.find_pou(name) } else { None - }) + } + ) .ok_or_else(|| Diagnostic::cannot_generate_call_statement(operator))?; // find corresponding implementation @@ -478,9 +546,20 @@ impl<'ink, 'b> ExpressionCodeGenerator<'ink, 'b> { None }; + // Check for the function within the GOT. If it's there, we need to generate an indirect + // call to its location within the GOT, which should contain a function pointer. + // First get the function type so our function pointer can have the correct type. + let qualified_name = self + .annotations + .get_qualified_name(operator) + .expect("Shouldn't have got this far without a name for the function"); + let function_type = function.get_type(); + let call = self + .generate_got_call(qualified_name, &function_type, &arguments_list)? + .unwrap_or_else(|| self.llvm.builder.build_call(function, &arguments_list, "call")); + // if the target is a function, declare the struct locally // assign all parameters into the struct values - let call = &self.llvm.builder.build_call(function, &arguments_list, "call"); // so grab either: // - the out-pointer if we generated one in by_ref_func_out @@ -500,12 +579,13 @@ impl<'ink, 'b> ExpressionCodeGenerator<'ink, 'b> { // after the call we need to copy the values for assigned outputs // this is only necessary for outputs defined as `rusty::index::ArgumentType::ByVal` (PROGRAM, FUNCTION_BLOCK) - // FUNCTION outputs are defined as `rusty::index::ArgumentType::ByRef` + // FUNCTION outputs are defined as `rusty::index::ArgumentType::ByRef` // FIXME(mhasel): for standard-compliance functions also need to support VAR_OUTPUT if !pou.is_function() { let parameter_struct = match arguments_list.first() { Some(v) => v.into_pointer_value(), None => self.generate_lvalue(operator)?, }; + self.assign_output_values(parameter_struct, implementation_name, parameters_list)? } @@ -522,72 +602,220 @@ impl<'ink, 'b> ExpressionCodeGenerator<'ink, 'b> { function_name: &str, parameters: Vec<&AstNode>, ) -> Result<(), Diagnostic> { + let pou_info = self.index.get_declared_parameters(function_name); + let implicit = arguments_are_implicit(¶meters); + for (index, assignment_statement) in parameters.into_iter().enumerate() { - self.assign_output_value(&CallParameterAssignment { - assignment_statement, - function_name, - index: index as u32, - parameter_struct, - })? + let is_output = pou_info.get(index).is_some_and(|param| param.get_variable_type().is_output()); + + if assignment_statement.is_output_assignment() || (implicit && is_output) { + self.assign_output_value(&CallParameterAssignment { + assignment: assignment_statement, + function_name, + index: index as u32, + parameter_struct, + })? + } } + Ok(()) } fn assign_output_value(&self, param_context: &CallParameterAssignment) -> Result<(), Diagnostic> { - match param_context.assignment_statement.get_stmt() { - AstStatement::OutputAssignment(data) | AstStatement::Assignment(data) => self - .generate_explicit_output_assignment( - param_context.parameter_struct, - param_context.function_name, - &data.left, - &data.right, - ), + match ¶m_context.assignment.stmt { + AstStatement::OutputAssignment(assignment) => self.generate_explicit_output_assignment( + param_context.parameter_struct, + param_context.function_name, + assignment, + ), + _ => self.generate_output_assignment(param_context), } } - fn generate_output_assignment(&self, param_context: &CallParameterAssignment) -> Result<(), Diagnostic> { - let builder = &self.llvm.builder; - let expression = param_context.assignment_statement; - let parameter_struct = param_context.parameter_struct; - let function_name = param_context.function_name; - let index = param_context.index; - if let Some(parameter) = self.index.get_declared_parameter(function_name, index) { - if matches!(parameter.get_variable_type(), VariableType::Output) - && !matches!(expression.get_stmt(), AstStatement::EmptyStatement { .. }) + pub fn generate_assignment_with_direct_access( + &self, + left_statement: &AstNode, + left_value: IntValue, + left_pointer: PointerValue, + right_type: &DataType, + right_expr: BasicValueEnum, + ) -> Result<(), Diagnostic> { + let Some((target, access_sequence)) = collect_base_and_direct_access_for_assignment(left_statement) + else { + unreachable!("Invalid direct-access expression: {left_statement:#?}") + }; + + let type_left = self.get_type_hint_for(target)?; + let type_right = + if let DataTypeInformation::Integer { semantic_size: Some(typesystem::U1_SIZE), .. } = + *right_type.get_type_information() { - { - let assigned_output = self.generate_lvalue(expression)?; + // we need to switch to a faked u1 type, when dealing with a single bit + self.index.get_type_or_panic(typesystem::U1_TYPE) + } else { + right_type + }; - let assigned_output_type = - self.annotations.get_type_or_void(expression, self.index).get_type_information(); + let Some((element, direct_access)) = access_sequence.split_first() else { unreachable!("") }; - let output = builder.build_struct_gep(parameter_struct, index, "").map_err(|_| { - Diagnostic::codegen_error( - format!("Cannot build generate parameter: {parameter:#?}"), - parameter.source_location.clone(), - ) - })?; + // Build index + let mut index = if let AstStatement::DirectAccess(data, ..) = element.get_stmt() { + self.generate_direct_access_index( + &data.access, + &data.index, + type_right.get_type_information(), + type_left, + ) + } else { + // TODO: using the global context we could get a slice here; currently not possible because the + // global context isn't passed into codegen + Err(Diagnostic::new(format!("{element:?} not a direct access")) + .with_error_code("E055") + .with_location(element.get_location())) + }?; + for element in direct_access { + let rhs_next = if let AstStatement::DirectAccess(data, ..) = element.get_stmt() { + self.generate_direct_access_index( + &data.access, + &data.index, + type_right.get_type_information(), + type_left, + ) + } else { + // TODO: using the global context we could get a slice here; currently not possible because the + // global context isn't passed into codegen + Err(Diagnostic::new(&format!("{element:?} not a direct access")) + .with_error_code("E055") + .with_location(element.get_location())) + }?; + index = self.llvm.builder.build_int_add(index, rhs_next, ""); + } - let output_value_type = - self.index.get_type_information_or_void(parameter.get_type_name()); - - if assigned_output_type.is_aggregate() && output_value_type.is_aggregate() { - self.build_memcpy( - assigned_output, - assigned_output_type, - expression.get_location(), - output, - output_value_type, - parameter.source_location.clone(), - )?; - } else { - let output_value = builder.build_load(output, ""); - builder.build_store(assigned_output, output_value); - } + //Build mask for the index + //Get the target bit type as all ones + let rhs_type = self.llvm_index.get_associated_type(type_right.get_name())?.into_int_type(); + let ones = rhs_type.const_all_ones(); + + //Extend the mask to the target type + let extended_mask = self.llvm.builder.build_int_z_extend(ones, left_value.get_type(), "ext"); + //Position the ones in their correct locations + let shifted_mask = self.llvm.builder.build_left_shift(extended_mask, index, "shift"); + //Invert the mask + let mask = self.llvm.builder.build_not(shifted_mask, "invert"); + //And the result with the mask to erase the set bits at the target location + let and_value = self.llvm.builder.build_and(left_value, mask, "erase"); + + //Cast the right side to the left side type + let lhs = cast_if_needed!(self, type_left, type_right, right_expr, None).into_int_value(); + //Shift left by the direct access + let value = self.llvm.builder.build_left_shift(lhs, index, "value"); + + //OR the result and store it in the left side + let or_value = self.llvm.builder.build_or(and_value, value, "or"); + self.llvm.builder.build_store(left_pointer, or_value); + + Ok(()) + } + + fn generate_output_assignment_with_direct_access( + &self, + left_statement: &AstNode, + left_pointer: PointerValue, + right_pointer: PointerValue, + right_type: &DataType, + ) -> Result<(), Diagnostic> { + let left_value = self.llvm.builder.build_load(left_pointer, "").into_int_value(); + + //Generate an expression for the right size + let right = self.llvm.builder.build_load(right_pointer, ""); + self.generate_assignment_with_direct_access( + left_statement, + left_value, + left_pointer, + right_type, + right, + )?; + + Ok(()) + } + + fn generate_output_assignment(&self, context: &CallParameterAssignment) -> Result<(), Diagnostic> { + let &CallParameterAssignment { assignment: expr, function_name, index, parameter_struct } = context; + let builder = &self.llvm.builder; + + // We don't want to generate any code if the right side of an assignment is empty, e.g. `foo(out =>)` + if expr.is_empty_statement() { + return Ok(()); + } + + let parameter = self.index.get_declared_parameter(function_name, index).expect("must exist"); + + match expr.get_stmt() { + AstStatement::ReferenceExpr(_) if expr.has_direct_access() => { + let rhs_type = { + let pou = self.index.find_pou(function_name).unwrap(); + let pou_struct = &pou.find_instance_struct_type(self.index).unwrap().information; + let DataTypeInformation::Struct { members, .. } = pou_struct else { unreachable!() }; + + self.index.find_effective_type_by_name(&members[index as usize].data_type_name).unwrap() + }; + + let AstStatement::ReferenceExpr(ReferenceExpr { + access: ReferenceAccess::Member(member), + base, + }) = &expr.get_stmt() + else { + unreachable!("must be a bitaccess, will return early for all other cases") + }; + + if let AstStatement::DirectAccess(_) = member.as_ref().get_stmt() { + // Given `foo.bar.baz.%W1.%B1.%X3`, we want to grab the base i.e. `foo.bar.baz` + let (Some(base), _) = (base, ..) else { panic!() }; + let (base, _) = collect_base_and_direct_access_for_assignment(base).unwrap(); + + let lhs = self.generate_expression_value(base)?.get_basic_value_enum(); + let rhs = self.llvm.builder.build_struct_gep(parameter_struct, index, "").unwrap(); + + self.generate_output_assignment_with_direct_access( + expr, + lhs.into_pointer_value(), + rhs, + rhs_type, + )?; + }; + } + + _ => { + let assigned_output = self.generate_lvalue(expr)?; + let assigned_output_type = + self.annotations.get_type_or_void(expr, self.index).get_type_information(); + + let output = builder.build_struct_gep(parameter_struct, index, "").map_err(|_| { + Diagnostic::codegen_error( + format!("Cannot build generate parameter: {parameter:#?}"), + parameter.source_location.clone(), + ) + })?; + + let output_value_type = self.index.get_type_information_or_void(parameter.get_type_name()); + + if assigned_output_type.is_aggregate() && output_value_type.is_aggregate() { + self.build_memcpy( + assigned_output, + assigned_output_type, + expr.get_location(), + output, + output_value_type, + parameter.source_location.clone(), + )?; + } else { + let output_value = builder.build_load(output, ""); + builder.build_store(assigned_output, output_value); } } - } + }; + Ok(()) } @@ -595,22 +823,25 @@ impl<'ink, 'b> ExpressionCodeGenerator<'ink, 'b> { &self, parameter_struct: PointerValue<'ink>, function_name: &str, - left: &AstNode, - right: &AstNode, + assignment: &Assignment, ) -> Result<(), Diagnostic> { + let Assignment { left, right } = assignment; + if let Some(StatementAnnotation::Variable { qualified_name, .. }) = self.annotations.get(left) { let parameter = self .index .find_fully_qualified_variable(qualified_name) .ok_or_else(|| Diagnostic::unresolved_reference(qualified_name, left.get_location()))?; let index = parameter.get_location_in_parent(); - self.assign_output_value(&CallParameterAssignment { - assignment_statement: right, + + self.generate_output_assignment(&CallParameterAssignment { + assignment: right, function_name, index, parameter_struct, })? }; + Ok(()) } @@ -686,8 +917,9 @@ impl<'ink, 'b> ExpressionCodeGenerator<'ink, 'b> { .get(i) .map(|it| { let name = it.get_type_name(); - if let Some(DataTypeInformation::Pointer { inner_type_name, auto_deref: true, .. }) = - self.index.find_effective_type_info(name) + if let Some(DataTypeInformation::Pointer { + inner_type_name, auto_deref: Some(_), .. + }) = self.index.find_effective_type_info(name) { // for auto_deref pointers (VAR_INPUT {ref}, VAR_IN_OUT) we call generate_argument_by_ref() // we need the inner_type and not pointer to type otherwise we would generate a double pointer @@ -973,7 +1205,7 @@ impl<'ink, 'b> ExpressionCodeGenerator<'ink, 'b> { .unwrap_or_else(|| vec![parameter_struct.as_basic_value_enum().into()]); for (i, stmt) in passed_parameters.iter().enumerate() { let parameter = self.generate_call_struct_argument_assignment(&CallParameterAssignment { - assignment_statement: stmt, + assignment: stmt, function_name: pou_name, index: i as u32, parameter_struct, @@ -987,7 +1219,7 @@ impl<'ink, 'b> ExpressionCodeGenerator<'ink, 'b> { } fn get_parameter_type(&self, parameter: &VariableIndexEntry) -> String { - if let Some(DataTypeInformation::Pointer { inner_type_name, auto_deref: true, .. }) = + if let Some(DataTypeInformation::Pointer { inner_type_name, auto_deref: Some(_), .. }) = self.index.find_effective_type_info(parameter.get_type_name()) { inner_type_name.into() @@ -1049,7 +1281,7 @@ impl<'ink, 'b> ExpressionCodeGenerator<'ink, 'b> { &self, param_context: &CallParameterAssignment, ) -> Result>, Diagnostic> { - let parameter_value = match param_context.assignment_statement.get_stmt() { + let parameter_value = match param_context.assignment.get_stmt() { // explicit call parameter: foo(param := value) AstStatement::OutputAssignment(data) | AstStatement::Assignment(data) => { self.generate_formal_parameter(param_context, &data.left, &data.right)?; @@ -1072,7 +1304,7 @@ impl<'ink, 'b> ExpressionCodeGenerator<'ink, 'b> { let function_name = param_context.function_name; let index = param_context.index; let parameter_struct = param_context.parameter_struct; - let expression = param_context.assignment_statement; + let expression = param_context.assignment; if let Some(parameter) = self.index.get_declared_parameter(function_name, index) { // this happens before the pou call // before the call statement we may only consider inputs and inouts @@ -1095,7 +1327,7 @@ impl<'ink, 'b> ExpressionCodeGenerator<'ink, 'b> { .map(|var| var.get_type_information()) .unwrap_or_else(|| self.index.get_void_type().get_type_information()); - if let DataTypeInformation::Pointer { auto_deref: true, inner_type_name, .. } = parameter { + if let DataTypeInformation::Pointer { auto_deref: Some(_), inner_type_name, .. } = parameter { //this is a VAR_IN_OUT assignment, so don't load the value, assign the pointer //expression may be empty -> generate a local variable for it let generated_exp = if expression.is_empty_statement() { @@ -1139,16 +1371,15 @@ impl<'ink, 'b> ExpressionCodeGenerator<'ink, 'b> { // don't generate param assignments for empty statements, with the exception // of VAR_IN_OUT params - they need an address to point to - let is_auto_deref = matches!( - self.index - .find_effective_type_by_name(parameter.get_type_name()) - .map(|var| var.get_type_information()) - .unwrap_or_else(|| self.index.get_void_type().get_type_information()), - DataTypeInformation::Pointer { auto_deref: true, .. } - ); + let is_auto_deref = self + .index + .find_effective_type_by_name(parameter.get_type_name()) + .map(|var| var.get_type_information()) + .unwrap_or(self.index.get_void_type().get_type_information()) + .is_auto_deref(); if !right.is_empty_statement() || is_auto_deref { self.generate_call_struct_argument_assignment(&CallParameterAssignment { - assignment_statement: right, + assignment: right, function_name, index, parameter_struct, @@ -1218,13 +1449,19 @@ impl<'ink, 'b> ExpressionCodeGenerator<'ink, 'b> { } } + let ctx_type = self.annotations.get_type_or_void(context, self.index).get_type_information(); + // no context ... so just something like 'x' match self.annotations.get(context) { Some(StatementAnnotation::Variable { qualified_name, .. }) | Some(StatementAnnotation::Program { qualified_name, .. }) => self - .llvm_index - .find_loaded_associated_variable_value(qualified_name) - .ok_or_else(|| Diagnostic::unresolved_reference(name, offset.clone())), + .generate_got_access(context, &self.llvm_index.get_associated_type(ctx_type.get_name())?)? + .map_or( + self.llvm_index + .find_loaded_associated_variable_value(qualified_name) + .ok_or_else(|| Diagnostic::unresolved_reference(name, offset.clone())), + Ok, + ), _ => Err(Diagnostic::unresolved_reference(name, offset.clone())), } } @@ -1261,9 +1498,7 @@ impl<'ink, 'b> ExpressionCodeGenerator<'ink, 'b> { accessor_ptr: PointerValue<'ink>, statement: &AstNode, ) -> PointerValue<'ink> { - if let Some(StatementAnnotation::Variable { is_auto_deref: true, .. }) = - self.annotations.get(statement) - { + if self.annotations.get(statement).is_some_and(|opt| opt.is_auto_deref()) { self.deref(accessor_ptr) } else { accessor_ptr @@ -1751,7 +1986,6 @@ impl<'ink, 'b> ExpressionCodeGenerator<'ink, 'b> { } // if there is just one assignment, this may be an struct-initialization (TODO this is not very elegant :-/ ) AstStatement::Assignment { .. } => self.generate_literal_struct(literal_statement), - AstStatement::CastStatement(data) => self.generate_expression_value(&data.target), _ => Err(cannot_generate_literal()), } } @@ -1819,7 +2053,7 @@ impl<'ink, 'b> ExpressionCodeGenerator<'ink, 'b> { } } } - DataTypeInformation::Pointer { inner_type_name, auto_deref: true, .. } => { + DataTypeInformation::Pointer { inner_type_name, auto_deref: Some(_), .. } => { let inner_type = self.index.get_type_information_or_void(inner_type_name); self.generate_string_literal_for_type(inner_type, value, location) } @@ -2116,7 +2350,7 @@ impl<'ink, 'b> ExpressionCodeGenerator<'ink, 'b> { return Err(Diagnostic::codegen_error( format!("Cannot generate phi-expression for operator {operator:}"), left.get_location(), - )) + )); } }; @@ -2350,19 +2584,18 @@ impl<'ink, 'b> ExpressionCodeGenerator<'ink, 'b> { /// - `access` the ReferenceAccess of the reference to generate /// - `base` the "previous" segment of an optional qualified reference-access /// - `original_expression` the original ast-statement used to report Diagnostics - fn generate_reference_expression( + pub(crate) fn generate_reference_expression( &self, access: &ReferenceAccess, base: Option<&AstNode>, original_expression: &AstNode, ) -> Result, Diagnostic> { match (access, base) { - // expressions like `base.member`, or just `member` (ReferenceAccess::Member(member), base) => { let base_value = base.map(|it| self.generate_expression_value(it)).transpose()?; - if let AstStatement::DirectAccess (data) = member.as_ref().get_stmt() { + if let AstStatement::DirectAccess(data) = member.as_ref().get_stmt() { let (Some(base), Some(base_value)) = (base, base_value) else { return Err(Diagnostic::codegen_error("Cannot generate DirectAccess without base value.", original_expression.get_location())); }; @@ -2374,7 +2607,7 @@ impl<'ink, 'b> ExpressionCodeGenerator<'ink, 'b> { self.get_load_name(member).as_deref().unwrap_or(member_name), original_expression, ) - .map(ExpressionValue::LValue) + .map(ExpressionValue::LValue) } } @@ -2387,8 +2620,8 @@ impl<'ink, 'b> ExpressionCodeGenerator<'ink, 'b> { self.annotations.get(base).expect(""), array_idx.as_ref(), ) - .map_err(|_| unreachable!("invalid access statement")) - .map(ExpressionValue::LValue) + .map_err(|_| unreachable!("invalid access statement")) + .map(ExpressionValue::LValue) } else { // normal array expression self.generate_element_pointer_for_array(base, array_idx).map(ExpressionValue::LValue) @@ -2426,7 +2659,7 @@ impl<'ink, 'b> ExpressionCodeGenerator<'ink, 'b> { | (ReferenceAccess::Cast(_), None) // INT#; | (ReferenceAccess::Deref, None) // ^; | (ReferenceAccess::Address, None) // &; - => Err(Diagnostic::codegen_error( + => Err(Diagnostic::codegen_error( "Expected a base-expressions, but found none.", original_expression.get_location(), )), @@ -2647,3 +2880,32 @@ fn int_value_multiply_accumulate<'ink>( } llvm.builder.build_load(accum, "accessor").into_int_value() } + +// XXX: Could be problematic with https://github.com/PLC-lang/rusty/issues/668 +/// Returns false if any argument in the given list is an (output-)assignment and true otherwise +fn arguments_are_implicit(arguments: &[&AstNode]) -> bool { + !arguments.iter().any(|argument| argument.is_assignment() || argument.is_output_assignment()) +} + +/// when generating an assignment to a direct-access (e.g. a.b.c.%W3.%X2 := 2;) +/// we want to deconstruct the sequence into the base-statement (a.b.c) and the sequence +/// of direct-access commands (vec![%W3, %X2]) +fn collect_base_and_direct_access_for_assignment( + left_statement: &AstNode, +) -> Option<(&AstNode, Vec<&AstNode>)> { + let mut current = Some(left_statement); + let mut access_sequence = Vec::new(); + + while let Some(AstStatement::ReferenceExpr(ReferenceExpr { access: ReferenceAccess::Member(m), base })) = + current.map(|it| it.get_stmt()) + { + if matches!(m.get_stmt(), AstStatement::DirectAccess { .. }) { + access_sequence.insert(0, m.as_ref()); + current = base.as_deref(); + } else { + break; + } + } + + current.zip(Some(access_sequence)) +} diff --git a/src/codegen/generators/pou_generator.rs b/src/codegen/generators/pou_generator.rs index e23af09f0e6..cada91f3b13 100644 --- a/src/codegen/generators/pou_generator.rs +++ b/src/codegen/generators/pou_generator.rs @@ -133,6 +133,7 @@ pub fn generate_global_constants_for_pou_members<'ink>( .make_constant() .set_initial_value(Some(value), variable_type); local_llvm_index.associate_global(&name, global_value)?; + local_llvm_index.insert_new_got_index(&name)?; } } } @@ -153,17 +154,16 @@ impl<'ink, 'cg> PouGenerator<'ink, 'cg> { PouGenerator { llvm, index, annotations, llvm_index } } - fn mangle_function(&self, implementation: &ImplementationIndexEntry) -> String { - let ctx = SectionMangler::function(implementation.get_call_name()); + fn mangle_function(&self, implementation: &ImplementationIndexEntry) -> Result { + let ctx = SectionMangler::function(implementation.get_call_name().to_lowercase()); let params = self.index.get_declared_parameters(implementation.get_call_name()); - let ctx = params.into_iter().fold(ctx, |ctx, param| { - // FIXME: Can we unwrap here? + let ctx = params.into_iter().try_fold(ctx, |ctx, param| -> Result { let ty = section_names::mangle_type( self.index, - self.index.get_effective_type_by_name(¶m.data_type_name).unwrap(), - ); + self.index.get_effective_type_by_name(¶m.data_type_name)?, + )?; let parameter = match param.argument_type { // TODO: We need to handle the `VariableType` enum as well - this describes the mode of // argument passing, e.g. inout @@ -171,15 +171,20 @@ impl<'ink, 'cg> PouGenerator<'ink, 'cg> { index::ArgumentType::ByRef(_) => FunctionArgument::ByRef(ty), }; - ctx.with_parameter(parameter) - }); + Ok(ctx.with_parameter(parameter)) + })?; let return_ty = self .index .find_return_type(implementation.get_type_name()) .map(|ty| section_names::mangle_type(self.index, ty)); - ctx.with_return_type(return_ty).mangle() + let ctx = match return_ty { + Some(rty) => ctx.with_return_type(rty?), + None => ctx, + }; + + Ok(ctx.mangle()) } /// generates an empty llvm function for the given implementation, including all parameters and the return type @@ -281,7 +286,7 @@ impl<'ink, 'cg> PouGenerator<'ink, 'cg> { let curr_f = module.add_function(implementation.get_call_name(), function_declaration, None); - let section_name = self.mangle_function(implementation); + let section_name = self.mangle_function(implementation)?; curr_f.set_section(Some(§ion_name)); let pou_name = implementation.get_call_name(); diff --git a/src/codegen/generators/section_names.rs b/src/codegen/generators/section_names.rs index a6a03c83802..15e4b480643 100644 --- a/src/codegen/generators/section_names.rs +++ b/src/codegen/generators/section_names.rs @@ -1,14 +1,17 @@ use crate::index::Index; use crate::typesystem::{self, DataTypeInformation, StringEncoding, TypeSize}; +use plc_diagnostics::diagnostics::Diagnostic; use section_mangler::{StringEncoding as SectionStringEncoding, Type}; -pub fn mangle_type(index: &Index, ty: &typesystem::DataType) -> section_mangler::Type { +pub fn mangle_type(index: &Index, ty: &typesystem::DataType) -> Result { + let access_inner = |ty_name| mangle_type(index, index.get_effective_type_by_name(ty_name)?); + // TODO: This is a bit ugly because we keep dereferencing references to Copy types like // bool, u32, etc, because `DataTypeInformation::Pointer` keeps a `String` which is not // Copy. the alternative is for section_mangle::Type to keep references everywhere, and // have a lifetime generic parameter, e.g. `section_mangler::Type<'a>` - which is also // annoying. - match ty.get_type_information() { + let mangled = match ty.get_type_information() { DataTypeInformation::Void => Type::Void, DataTypeInformation::Integer { signed, size, semantic_size, .. } => { Type::Integer { signed: *signed, size: *size, semantic_size: *semantic_size } @@ -22,12 +25,40 @@ pub fn mangle_type(index: &Index, ty: &typesystem::DataType) -> section_mangler: Type::String { size: *size as usize, encoding } } - DataTypeInformation::Pointer { inner_type_name, .. } => Type::Pointer { - inner: Box::new(mangle_type(index, index.get_effective_type_by_name(inner_type_name).unwrap())), + DataTypeInformation::Pointer { inner_type_name, .. } => { + Type::Pointer { inner: Box::new(access_inner(inner_type_name)?) } + } + DataTypeInformation::Enum { referenced_type, variants, .. } => { + Type::Enum { referenced_type: Box::new(access_inner(referenced_type)?), elements: variants.len() } + } + DataTypeInformation::Struct { members, .. } => Type::Struct { + members: members.iter().try_fold(Vec::new(), |mut acc, m| -> Result, Diagnostic> { + let inner = access_inner(m.get_type_name())?; + + acc.push(inner); + + Ok(acc) + })?, }, - // FIXME: For now, encode all unknown types as "void" since this is not required for + DataTypeInformation::Array { inner_type_name, .. } => { + Type::Array { inner: Box::new(access_inner(inner_type_name)?) } + } + // FIXME: Is that correct? + // For code generation, the actual range does not matter - it is not a breaking change + // if a variable's range changes, at least not for codegen, since the underlying type will stay + // the same. Therefore, only encode it as its underlying type. + DataTypeInformation::SubRange { referenced_type, .. } + // Similarly, we do not care about the alias - only the type which is being codegen'd + | DataTypeInformation::Alias { referenced_type, .. } => access_inner(referenced_type)?, + DataTypeInformation::Generic { .. } => { + // FIXME: Is that correct? + unreachable!("generic types should not exist at codegen") + } + // FIXME: For now, encode all unknown types as "void" since this is not required for // execution. Not doing so (and doing an `unreachable!()` for example) obviously causes // failures, because complex types are already implemented in the compiler. _ => Type::Void, - } + }; + + Ok(mangled) } diff --git a/src/codegen/generators/statement_generator.rs b/src/codegen/generators/statement_generator.rs index 40b36c193f5..7c053ddf936 100644 --- a/src/codegen/generators/statement_generator.rs +++ b/src/codegen/generators/statement_generator.rs @@ -1,20 +1,23 @@ // Copyright (c) 2020 Ghaith Hachem and Mathias Rieder use super::{ - expression_generator::{to_i1, ExpressionCodeGenerator}, + expression_generator::{to_i1, ExpressionCodeGenerator, ExpressionValue}, llvm::Llvm, }; use crate::{ - codegen::{debug::Debug, llvm_typesystem::cast_if_needed}, - codegen::{debug::DebugBuilderEnum, LlvmTypedIndex}, + codegen::{ + debug::{Debug, DebugBuilderEnum}, + llvm_typesystem::cast_if_needed, + LlvmTypedIndex, + }, index::{ImplementationIndexEntry, Index}, resolver::{AnnotationMap, AstAnnotations, StatementAnnotation}, - typesystem::{self, DataTypeInformation}, + typesystem::{get_bigger_type, DataTypeInformation, DINT_TYPE}, }; use inkwell::{ basic_block::BasicBlock, builder::Builder, context::Context, - values::{BasicValueEnum, FunctionValue, PointerValue}, + values::{FunctionValue, PointerValue}, }; use plc_ast::{ ast::{ @@ -122,7 +125,9 @@ impl<'a, 'b> StatementCodeGenerator<'a, 'b> { AstStatement::Assignment(data, ..) => { self.generate_assignment_statement(&data.left, &data.right)?; } - + AstStatement::RefAssignment(data, ..) => { + self.generate_ref_assignment(&data.left, &data.right)?; + } AstStatement::ControlStatement(ctl_statement, ..) => { self.generate_control_statement(ctl_statement)? } @@ -231,6 +236,31 @@ impl<'a, 'b> StatementCodeGenerator<'a, 'b> { } } + /// Generates IR for a `REF=` assignment, which is syntactic sugar for an assignment where the + /// right-hand side is wrapped in a `REF(...)` call. Specifically `foo REF= bar` and + /// `foo := REF(bar)` are the same. + /// + /// Note: Although somewhat similar to the [`generate_assignment_statement`] function, we can't + /// apply the code here because the left side of a `REF=` assignment is flagged as auto-deref. + /// For `REF=` assignments we don't want (and can't) deref without generating incorrect IR. + pub fn generate_ref_assignment(&self, left: &AstNode, right: &AstNode) -> Result<(), Diagnostic> { + let exp = self.create_expr_generator(); + let ref_builtin = self.index.get_builtin_function("REF").expect("REF must exist"); + + let AstStatement::ReferenceExpr(data) = &left.stmt else { + unreachable!("should be covered by a validation") + }; + + let left_ptr_val = { + let expr = exp.generate_reference_expression(&data.access, data.base.as_deref(), left)?; + expr.get_basic_value_enum().into_pointer_value() + }; + let right_expr_val = ref_builtin.codegen(&exp, &[&right], right.get_location())?; + + self.llvm.builder.build_store(left_ptr_val, right_expr_val.get_basic_value_enum()); + Ok(()) + } + /// generates an assignment statement _left_ := _right_ /// /// `left_statement` the left side of the assignment @@ -244,7 +274,7 @@ impl<'a, 'b> StatementCodeGenerator<'a, 'b> { self.register_debug_location(left_statement); //TODO: Looks hacky, the strings will be similar so we should look into making the assignment a bit nicer. if left_statement.has_direct_access() { - return self.generate_direct_access_assignment(left_statement, right_statement); + return self.generate_assignment_statement_direct_access(left_statement, right_statement); } //TODO: Also hacky but for now we cannot generate assignments for hardware access if matches!(left_statement.get_stmt(), AstStatement::HardwareAccess { .. }) { @@ -279,96 +309,32 @@ impl<'a, 'b> StatementCodeGenerator<'a, 'b> { self.debug.set_debug_location(self.llvm, &self.function_context.function, line, column); } - fn generate_direct_access_assignment( + fn generate_assignment_statement_direct_access( &self, left_statement: &AstNode, right_statement: &AstNode, ) -> Result<(), Diagnostic> { - //TODO : Validation let exp_gen = self.create_expr_generator(); - // given a complex direct-access assignemnt: a.b.c.%W3,%X1 - // we want to deconstruct the targe-part (a.b.c) and the direct-access sequence (%W3.%X1) - let Some((target, access_sequence)) = collect_base_and_direct_access_for_assignment(left_statement) - else { + // Left pointer + let Some((base, _)) = collect_base_and_direct_access_for_assignment(left_statement) else { unreachable!("Invalid direct-access expression: {left_statement:#?}") }; + let left_expr_value = exp_gen.generate_expression_value(base)?; + let left_value = left_expr_value.as_r_value(self.llvm, None).into_int_value(); + let left_pointer = left_expr_value.get_basic_value_enum().into_pointer_value(); - let left_type = exp_gen.get_type_hint_for(target)?; + // Generate an expression for the right size let right_type = exp_gen.get_type_hint_for(right_statement)?; - - //special case if we deal with a single bit, then we need to switch to a faked u1 type - let right_type = - if let DataTypeInformation::Integer { semantic_size: Some(typesystem::U1_SIZE), .. } = - *right_type.get_type_information() - { - self.index.get_type_or_panic(typesystem::U1_TYPE) - } else { - right_type - }; - - //Left pointer - let left_expression_value = exp_gen.generate_expression_value(target)?; - let left_value = left_expression_value.as_r_value(self.llvm, None).into_int_value(); - let left = left_expression_value.get_basic_value_enum().into_pointer_value(); - //Build index - if let Some((element, direct_access)) = access_sequence.split_first() { - let mut rhs = if let AstStatement::DirectAccess(data, ..) = element.get_stmt() { - exp_gen.generate_direct_access_index( - &data.access, - &data.index, - right_type.get_type_information(), - left_type, - ) - } else { - //TODO: using the global context we could get a slice here - Err(Diagnostic::new(format!("{element:?} not a direct access")) - .with_error_code("E055") - .with_location(element.get_location())) - }?; - for element in direct_access { - let rhs_next = if let AstStatement::DirectAccess(data, ..) = element.get_stmt() { - exp_gen.generate_direct_access_index( - &data.access, - &data.index, - right_type.get_type_information(), - left_type, - ) - } else { - //TODO: using the global context we could get a slice here - Err(Diagnostic::new(&format!("{element:?} not a direct access")) - .with_error_code("E055") - .with_location(element.get_location())) - }?; - rhs = self.llvm.builder.build_int_add(rhs, rhs_next, ""); - } - //Build mask for the index - //Get the target bit type as all ones - let rhs_type = self.llvm_index.get_associated_type(right_type.get_name())?.into_int_type(); - let ones = rhs_type.const_all_ones(); - //Extend the mask to the target type - let extended_mask = self.llvm.builder.build_int_z_extend(ones, left_value.get_type(), "ext"); - //Position the ones in their correct locations - let shifted_mask = self.llvm.builder.build_left_shift(extended_mask, rhs, "shift"); - //Invert the mask - let mask = self.llvm.builder.build_not(shifted_mask, "invert"); - //And the result with the mask to erase the set bits at the target location - let and_value = self.llvm.builder.build_and(left_value, mask, "erase"); - - //Generate an expression for the right size - let right = exp_gen.generate_expression(right_statement)?; - //Cast the right side to the left side type - let lhs = cast_if_needed!(self, left_type, right_type, right, None).into_int_value(); - //Shift left by the direct access - let value = self.llvm.builder.build_left_shift(lhs, rhs, "value"); - - //OR the result and store it in the left side - let or_value = self.llvm.builder.build_or(and_value, value, "or"); - self.llvm.builder.build_store(left, or_value); - } else { - unreachable!(); - } - Ok(()) + let right_expr = exp_gen.generate_expression(right_statement)?; + + exp_gen.generate_assignment_with_direct_access( + left_statement, + left_value, + left_pointer, + right_type, + right_expr, + ) } /// generates a for-loop statement @@ -389,117 +355,107 @@ impl<'a, 'b> StatementCodeGenerator<'a, 'b> { body: &[AstNode], ) -> Result<(), Diagnostic> { let (builder, current_function, context) = self.get_llvm_deps(); - self.generate_assignment_statement(counter, start)?; - let condition_check = context.append_basic_block(current_function, "condition_check"); - let for_body = context.append_basic_block(current_function, "for_body"); - let increment_block = context.append_basic_block(current_function, "increment"); - let continue_block = context.append_basic_block(current_function, "continue"); - - //Generate an initial jump to the for condition - builder.build_unconditional_branch(condition_check); - - //Check loop condition - builder.position_at_end(condition_check); let exp_gen = self.create_expr_generator(); - let counter_statement = exp_gen.generate_expression(counter)?; - //. / and_2 \ - //. / and 1 \ - //. (counter_end_le && counter_start_ge) || (counter_end_ge && counter_start_le) - let or_eval = self.generate_compare_expression(counter, end, start, &exp_gen)?; + let end_ty = self.annotations.get_type_or_void(end, self.index); + let counter_ty = self.annotations.get_type_or_void(counter, self.index); + let cast_target_ty = get_bigger_type(self.index.get_type_or_panic(DINT_TYPE), counter_ty, self.index); + let cast_target_llty = self.llvm_index.find_associated_type(cast_target_ty.get_name()).unwrap(); + + let step_ty = by_step.as_ref().map(|it| { + self.register_debug_location(it); + self.annotations.get_type_or_void(it, self.index) + }); + + let eval_step = || { + step_ty.map_or_else( + || self.llvm.create_const_numeric(&cast_target_llty, "1", SourceLocation::undefined()), + |step_ty| { + let step = exp_gen.generate_expression(by_step.as_ref().unwrap())?; + Ok(cast_if_needed!(exp_gen, cast_target_ty, step_ty, step, None)) + }, + ) + }; - builder.build_conditional_branch(to_i1(or_eval.into_int_value(), builder), for_body, continue_block); + let predicate_incrementing = context.append_basic_block(current_function, "predicate_sle"); + let predicate_decrementing = context.append_basic_block(current_function, "predicate_sge"); + let loop_body = context.append_basic_block(current_function, "loop"); + let increment = context.append_basic_block(current_function, "increment"); + let afterloop = context.append_basic_block(current_function, "continue"); - //Enter the for loop - builder.position_at_end(for_body); - let body_generator = StatementCodeGenerator { - current_loop_exit: Some(continue_block), - current_loop_continue: Some(increment_block), + self.generate_assignment_statement(counter, start)?; + let counter = exp_gen.generate_lvalue(counter)?; + + // generate loop predicate selector. since `STEP` can be a reference, this needs to be a runtime eval + // XXX(mhasel): IR could possibly be improved by generating phi instructions. + // Candidate for frontend optimization for builds without optimization when `STEP` + // is a compile-time constant + let is_incrementing = builder.build_int_compare( + inkwell::IntPredicate::SGT, + eval_step()?.into_int_value(), + self.llvm + .create_const_numeric(&cast_target_llty, "0", SourceLocation::undefined())? + .into_int_value(), + "is_incrementing", + ); + builder.build_conditional_branch(is_incrementing, predicate_incrementing, predicate_decrementing); + // generate predicates for incrementing and decrementing counters + let generate_predicate = |predicate| { + builder.position_at_end(match predicate { + inkwell::IntPredicate::SLE => predicate_incrementing, + inkwell::IntPredicate::SGE => predicate_decrementing, + _ => unreachable!(), + }); + + let end = exp_gen.generate_expression_value(end).unwrap(); + let end_value = match end { + ExpressionValue::LValue(ptr) => builder.build_load(ptr, ""), + ExpressionValue::RValue(val) => val, + }; + let counter_value = builder.build_load(counter, ""); + let cmp = builder.build_int_compare( + predicate, + cast_if_needed!(exp_gen, cast_target_ty, counter_ty, counter_value, None).into_int_value(), + cast_if_needed!(exp_gen, cast_target_ty, end_ty, end_value, None).into_int_value(), + "condition", + ); + builder.build_conditional_branch(cmp, loop_body, afterloop); + }; + generate_predicate(inkwell::IntPredicate::SLE); + generate_predicate(inkwell::IntPredicate::SGE); + + // generate loop body + builder.position_at_end(loop_body); + let body_builder = StatementCodeGenerator { + current_loop_continue: Some(increment), + current_loop_exit: Some(afterloop), load_prefix: self.load_prefix.clone(), load_suffix: self.load_suffix.clone(), ..*self }; - body_generator.generate_body(body)?; - builder.build_unconditional_branch(increment_block); - - //Increment - builder.position_at_end(increment_block); - let expression_generator = self.create_expr_generator(); - let step_by_value = by_step.as_ref().map_or_else( - || { - self.llvm.create_const_numeric( - &counter_statement.get_type(), - "1", - SourceLocation::undefined(), - ) - }, - |step| { - self.register_debug_location(step); - expression_generator.generate_expression(step) - }, - )?; - - let next = builder.build_int_add( - counter_statement.into_int_value(), - step_by_value.into_int_value(), - "tmpVar", + body_builder.generate_body(body)?; + + // increment counter + builder.build_unconditional_branch(increment); + builder.position_at_end(increment); + let counter_value = builder.build_load(counter, ""); + let inc = inkwell::values::BasicValue::as_basic_value_enum(&builder.build_int_add( + eval_step()?.into_int_value(), + cast_if_needed!(exp_gen, cast_target_ty, counter_ty, counter_value, None).into_int_value(), + "next", + )); + builder.build_store( + counter, + cast_if_needed!(exp_gen, counter_ty, cast_target_ty, inc, None).into_int_value(), ); - let ptr = expression_generator.generate_lvalue(counter)?; - builder.build_store(ptr, next); - - //Loop back - builder.build_unconditional_branch(condition_check); - - //Continue - builder.position_at_end(continue_block); - + // check condition + builder.build_conditional_branch(is_incrementing, predicate_incrementing, predicate_decrementing); + // continue + builder.position_at_end(afterloop); Ok(()) } - fn generate_compare_expression( - &'a self, - counter: &AstNode, - end: &AstNode, - start: &AstNode, - exp_gen: &'a ExpressionCodeGenerator, - ) -> Result, Diagnostic> { - let bool_id = self.annotations.get_bool_id(); - let counter_end_ge = AstFactory::create_binary_expression( - counter.clone(), - Operator::GreaterOrEqual, - end.clone(), - bool_id, - ); - let counter_start_ge = AstFactory::create_binary_expression( - counter.clone(), - Operator::GreaterOrEqual, - start.clone(), - bool_id, - ); - let counter_end_le = AstFactory::create_binary_expression( - counter.clone(), - Operator::LessOrEqual, - end.clone(), - bool_id, - ); - let counter_start_le = AstFactory::create_binary_expression( - counter.clone(), - Operator::LessOrEqual, - start.clone(), - bool_id, - ); - let and_1 = - AstFactory::create_binary_expression(counter_end_le, Operator::And, counter_start_ge, bool_id); - let and_2 = - AstFactory::create_binary_expression(counter_end_ge, Operator::And, counter_start_le, bool_id); - let or = AstFactory::create_binary_expression(and_1, Operator::Or, and_2, bool_id); - - self.register_debug_location(&or); - let or_eval = exp_gen.generate_expression(&or)?; - Ok(or_eval) - } - /// genertes a case statement /// /// CASE selector OF @@ -842,9 +798,8 @@ impl<'a, 'b> StatementCodeGenerator<'a, 'b> { } } -/// when generating an assignment to a direct-access (e.g. a.b.c.%W3.%X2 := 2;) -/// we want to deconstruct the sequence into the base-statement (a.b.c) and the sequence -/// of direct-access commands (vec![%W3, %X2]) +/// Deconstructs assignments such as `a.b.c.%W3.%X2 := 2` into a base statement and its direct-access sequences. +/// For the given example this function would return `(Node(a.b.c), vec![Node(%W3), Node(%X2)])` fn collect_base_and_direct_access_for_assignment( left_statement: &AstNode, ) -> Option<(&AstNode, Vec<&AstNode>)> { diff --git a/src/codegen/generators/variable_generator.rs b/src/codegen/generators/variable_generator.rs index 55a8194b056..f963689de8e 100644 --- a/src/codegen/generators/variable_generator.rs +++ b/src/codegen/generators/variable_generator.rs @@ -6,15 +6,16 @@ use crate::{ index::{get_initializer_name, Index, PouIndexEntry, VariableIndexEntry}, resolver::{AnnotationMap, AstAnnotations, Dependency}, }; - use inkwell::{module::Module, values::GlobalValue}; use plc_ast::ast::LinkageType; use plc_diagnostics::diagnostics::Diagnostic; +use section_mangler::SectionMangler; use super::{ data_type_generator::get_default_for, expression_generator::ExpressionCodeGenerator, llvm::{GlobalValueExt, Llvm}, + section_names, }; use crate::codegen::debug::DebugBuilderEnum; use crate::index::FxIndexSet; @@ -75,7 +76,7 @@ impl<'ctx, 'b> VariableGenerator<'ctx, 'b> { } }); - for (name, variable) in globals { + for (name, variable) in &globals { let linkage = if !variable.is_in_unit(location) { LinkageType::External } else { variable.get_linkage() }; let global_variable = self.generate_global_variable(variable, linkage).map_err(|err| { @@ -170,6 +171,24 @@ impl<'ctx, 'b> VariableGenerator<'ctx, 'b> { } } + let global_name = if global_variable.get_name().ends_with("instance") { + global_variable.get_name() + } else { + global_variable.get_qualified_name() + }; + let global_name = global_name.to_lowercase(); + + let section = SectionMangler::variable( + global_name, + section_names::mangle_type( + self.global_index, + self.global_index.get_effective_type_by_name(global_variable.get_type_name())?, + )?, + ) + .mangle(); + + global_ir_variable.set_section(Some(§ion)); + Ok(global_ir_variable) } } diff --git a/src/codegen/llvm_index.rs b/src/codegen/llvm_index.rs index b30d428c23d..4c1490a96eb 100644 --- a/src/codegen/llvm_index.rs +++ b/src/codegen/llvm_index.rs @@ -14,6 +14,8 @@ pub struct LlvmTypedIndex<'ink> { type_associations: FxHashMap>, pou_type_associations: FxHashMap>, global_values: FxHashMap>, + // TODO: Should this be an Option? + got_indices: FxHashMap, initial_value_associations: FxHashMap>, loaded_variable_associations: FxHashMap>, implementations: FxHashMap>, @@ -29,6 +31,7 @@ impl<'ink> LlvmTypedIndex<'ink> { type_associations: FxHashMap::default(), pou_type_associations: FxHashMap::default(), global_values: FxHashMap::default(), + got_indices: FxHashMap::default(), initial_value_associations: FxHashMap::default(), loaded_variable_associations: FxHashMap::default(), implementations: FxHashMap::default(), @@ -51,6 +54,9 @@ impl<'ink> LlvmTypedIndex<'ink> { for (name, value) in other.global_values.drain() { self.global_values.insert(name, value); } + for (name, index) in other.got_indices.drain() { + self.got_indices.insert(name, index); + } for (name, assocication) in other.initial_value_associations.drain() { self.initial_value_associations.insert(name, assocication); } @@ -110,6 +116,13 @@ impl<'ink> LlvmTypedIndex<'ink> { .or_else(|| self.parent_index.and_then(|it| it.find_global_value(name))) } + pub fn find_got_index(&self, name: &str) -> Option { + self.got_indices + .get(&name.to_lowercase()) + .copied() + .or_else(|| self.parent_index.and_then(|it| it.find_got_index(name))) + } + pub fn find_associated_type(&self, type_name: &str) -> Option> { self.type_associations .get(&type_name.to_lowercase()) @@ -150,6 +163,22 @@ impl<'ink> LlvmTypedIndex<'ink> { self.global_values.insert(variable_name.to_lowercase(), global_variable); self.initial_value_associations .insert(variable_name.to_lowercase(), global_variable.as_pointer_value().into()); + + // FIXME: Do we want to call .insert_new_got_index() here? + + Ok(()) + } + + pub fn associate_got_index(&mut self, variable_name: &str, index: u64) -> Result<(), Diagnostic> { + self.got_indices.insert(variable_name.to_lowercase(), index); + Ok(()) + } + + pub fn insert_new_got_index(&mut self, variable_name: &str) -> Result<(), Diagnostic> { + let idx = self.got_indices.values().max().copied().unwrap_or(0); + + self.got_indices.insert(variable_name.to_lowercase(), idx); + Ok(()) } diff --git a/src/codegen/llvm_typesystem.rs b/src/codegen/llvm_typesystem.rs index d84bf1bbe1f..50823654527 100644 --- a/src/codegen/llvm_typesystem.rs +++ b/src/codegen/llvm_typesystem.rs @@ -114,7 +114,7 @@ impl<'ctx, 'cast> CastInstructionData<'ctx, 'cast> { let value_type = index.get_intrinsic_type_by_name(value_type.get_name()).get_type_information(); let target_type = - if let DataTypeInformation::Pointer { auto_deref: true, inner_type_name, .. } = target_type { + if let DataTypeInformation::Pointer { auto_deref: Some(_), inner_type_name, .. } = target_type { // Deref auto-deref pointers before casting index.get_intrinsic_type_by_name(inner_type_name.as_str()).get_type_information() } else { diff --git a/src/codegen/tests/code_gen_tests.rs b/src/codegen/tests/code_gen_tests.rs index d149b7df350..0d34a3dfd5d 100644 --- a/src/codegen/tests/code_gen_tests.rs +++ b/src/codegen/tests/code_gen_tests.rs @@ -1155,6 +1155,145 @@ fn for_statement_with_references_steps_test() { insta::assert_snapshot!(result); } +#[test] +fn for_statement_with_binary_expressions() { + let result = codegen( + " + PROGRAM prg + VAR + step: DINT; + x : DINT; + y : DINT; + z : DINT; + END_VAR + FOR x := y + 1 TO z - 2 BY step * 3 DO + x; + END_FOR + END_PROGRAM + ", + ); + + insta::assert_snapshot!(result, @r###" + ; ModuleID = 'main' + source_filename = "main" + + %prg = type { i32, i32, i32, i32 } + + @prg_instance = global %prg zeroinitializer, section "var-$RUSTY$prg_instance:r4i32i32i32i32" + + define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { + entry: + %step = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 + %x = getelementptr inbounds %prg, %prg* %0, i32 0, i32 1 + %y = getelementptr inbounds %prg, %prg* %0, i32 0, i32 2 + %z = getelementptr inbounds %prg, %prg* %0, i32 0, i32 3 + %load_y = load i32, i32* %y, align 4 + %tmpVar = add i32 %load_y, 1 + store i32 %tmpVar, i32* %x, align 4 + %load_step = load i32, i32* %step, align 4 + %tmpVar1 = mul i32 %load_step, 3 + %is_incrementing = icmp sgt i32 %tmpVar1, 0 + br i1 %is_incrementing, label %predicate_sle, label %predicate_sge + + predicate_sle: ; preds = %increment, %entry + %load_z = load i32, i32* %z, align 4 + %tmpVar2 = sub i32 %load_z, 2 + %1 = load i32, i32* %x, align 4 + %condition = icmp sle i32 %1, %tmpVar2 + br i1 %condition, label %loop, label %continue + + predicate_sge: ; preds = %increment, %entry + %load_z3 = load i32, i32* %z, align 4 + %tmpVar4 = sub i32 %load_z3, 2 + %2 = load i32, i32* %x, align 4 + %condition5 = icmp sge i32 %2, %tmpVar4 + br i1 %condition5, label %loop, label %continue + + loop: ; preds = %predicate_sge, %predicate_sle + %load_x = load i32, i32* %x, align 4 + br label %increment + + increment: ; preds = %loop + %3 = load i32, i32* %x, align 4 + %load_step6 = load i32, i32* %step, align 4 + %tmpVar7 = mul i32 %load_step6, 3 + %next = add i32 %tmpVar7, %3 + store i32 %next, i32* %x, align 4 + br i1 %is_incrementing, label %predicate_sle, label %predicate_sge + + continue: ; preds = %predicate_sge, %predicate_sle + ret void + } + "###); +} + +#[test] +fn for_statement_type_casting() { + let result = codegen( + "FUNCTION main + VAR + a: USINT; + b: INT := 1; + END_VAR + FOR a := 0 TO 10 BY b DO + b := b * 3; + END_FOR + END_FUNCTION", + ); + insta::assert_snapshot!(result, @r###" + ; ModuleID = 'main' + source_filename = "main" + + define void @main() section "fn-$RUSTY$main:v" { + entry: + %a = alloca i8, align 1 + %b = alloca i16, align 2 + store i8 0, i8* %a, align 1 + store i16 1, i16* %b, align 2 + store i8 0, i8* %a, align 1 + %load_b = load i16, i16* %b, align 2 + %0 = trunc i16 %load_b to i8 + %1 = sext i8 %0 to i32 + %is_incrementing = icmp sgt i32 %1, 0 + br i1 %is_incrementing, label %predicate_sle, label %predicate_sge + + predicate_sle: ; preds = %increment, %entry + %2 = load i8, i8* %a, align 1 + %3 = zext i8 %2 to i32 + %condition = icmp sle i32 %3, 10 + br i1 %condition, label %loop, label %continue + + predicate_sge: ; preds = %increment, %entry + %4 = load i8, i8* %a, align 1 + %5 = zext i8 %4 to i32 + %condition1 = icmp sge i32 %5, 10 + br i1 %condition1, label %loop, label %continue + + loop: ; preds = %predicate_sge, %predicate_sle + %load_b2 = load i16, i16* %b, align 2 + %6 = sext i16 %load_b2 to i32 + %tmpVar = mul i32 %6, 3 + %7 = trunc i32 %tmpVar to i16 + store i16 %7, i16* %b, align 2 + br label %increment + + increment: ; preds = %loop + %8 = load i8, i8* %a, align 1 + %load_b3 = load i16, i16* %b, align 2 + %9 = trunc i16 %load_b3 to i8 + %10 = sext i8 %9 to i32 + %11 = zext i8 %8 to i32 + %next = add i32 %10, %11 + %12 = trunc i32 %next to i8 + store i8 %12, i8* %a, align 1 + br i1 %is_incrementing, label %predicate_sle, label %predicate_sge + + continue: ; preds = %predicate_sge, %predicate_sle + ret void + } + "###); +} + #[test] fn while_statement() { let result = codegen( diff --git a/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__aggregate_return_value_variable_in_function.snap b/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__aggregate_return_value_variable_in_function.snap index 81635ebc497..3ce6a9f94b4 100644 --- a/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__aggregate_return_value_variable_in_function.snap +++ b/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__aggregate_return_value_variable_in_function.snap @@ -7,7 +7,7 @@ source_filename = "main" @utf08_literal_0 = private unnamed_addr constant [6 x i8] c"hello\00" -define void @myFunc([81 x i8]* %0) section "fn-myFunc:s8u81" !dbg !4 { +define void @myFunc([81 x i8]* %0) section "fn-$RUSTY$myFunc:s8u81" !dbg !4 { entry: %myFunc = alloca [81 x i8]*, align 8, !dbg !8 store [81 x i8]* %0, [81 x i8]** %myFunc, align 8, !dbg !8 diff --git a/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__array_size_correctly_set_in_dwarf_info.snap b/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__array_size_correctly_set_in_dwarf_info.snap index ebcd7d42a67..1c24e9fc491 100644 --- a/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__array_size_correctly_set_in_dwarf_info.snap +++ b/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__array_size_correctly_set_in_dwarf_info.snap @@ -5,7 +5,7 @@ expression: result ; ModuleID = 'main' source_filename = "main" -define i32 @foo() section "fn-foo:i32" !dbg !4 { +define i32 @foo() section "fn-$RUSTY$foo:i32" !dbg !4 { entry: %foo = alloca i32, align 4, !dbg !8 %a = alloca [64 x i32], align 4, !dbg !8 diff --git a/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__assignment_statement_have_location.snap b/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__assignment_statement_have_location.snap index ca675c06467..31e1606764c 100644 --- a/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__assignment_statement_have_location.snap +++ b/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__assignment_statement_have_location.snap @@ -5,7 +5,7 @@ expression: result ; ModuleID = 'main' source_filename = "main" -define i32 @myFunc() section "fn-myFunc:i32" !dbg !4 { +define i32 @myFunc() section "fn-$RUSTY$myFunc:i32" !dbg !4 { entry: %myFunc = alloca i32, align 4, !dbg !8 call void @llvm.dbg.declare(metadata i32* %myFunc, metadata !9, metadata !DIExpression()), !dbg !11 diff --git a/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__case_conditions_location_marked.snap b/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__case_conditions_location_marked.snap index 3714952f229..eaba11dbb2f 100644 --- a/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__case_conditions_location_marked.snap +++ b/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__case_conditions_location_marked.snap @@ -5,7 +5,7 @@ expression: result ; ModuleID = 'main' source_filename = "main" -define i32 @myFunc() section "fn-myFunc:i32" !dbg !4 { +define i32 @myFunc() section "fn-$RUSTY$myFunc:i32" !dbg !4 { entry: %myFunc = alloca i32, align 4, !dbg !8 call void @llvm.dbg.declare(metadata i32* %myFunc, metadata !9, metadata !DIExpression()), !dbg !11 diff --git a/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__exit_statement_have_location.snap b/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__exit_statement_have_location.snap index 53c07e43d14..77f390e60e0 100644 --- a/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__exit_statement_have_location.snap +++ b/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__exit_statement_have_location.snap @@ -5,7 +5,7 @@ expression: result ; ModuleID = 'main' source_filename = "main" -define i32 @myFunc() section "fn-myFunc:i32" !dbg !4 { +define i32 @myFunc() section "fn-$RUSTY$myFunc:i32" !dbg !4 { entry: %myFunc = alloca i32, align 4, !dbg !8 call void @llvm.dbg.declare(metadata i32* %myFunc, metadata !9, metadata !DIExpression()), !dbg !11 diff --git a/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__external_impl_is_not_added_as_external_subroutine.snap b/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__external_impl_is_not_added_as_external_subroutine.snap index fe0182cfa99..4cc815874e5 100644 --- a/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__external_impl_is_not_added_as_external_subroutine.snap +++ b/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__external_impl_is_not_added_as_external_subroutine.snap @@ -8,14 +8,14 @@ source_filename = "main" %myPrg = type {} %myFb = type {} -@myPrg_instance = external global %myPrg, !dbg !0 -@__myFb__init = unnamed_addr constant %myFb zeroinitializer, !dbg !5 +@myPrg_instance = external global %myPrg, section "var-$RUSTY$myPrg_instance:r0", !dbg !0 +@__myFb__init = unnamed_addr constant %myFb zeroinitializer, section "var-$RUSTY$__myFb__init:r0", !dbg !5 -declare i32 @myFunc() section "fn-myFunc:i32" +declare i32 @myFunc() section "fn-$RUSTY$myFunc:i32" -declare void @myPrg(%myPrg*) section "fn-myPrg:v" +declare void @myPrg(%myPrg*) section "fn-$RUSTY$myPrg:v" -declare void @myFb(%myFb*) section "fn-myFb:v" +declare void @myFb(%myFb*) section "fn-$RUSTY$myFb:v" !llvm.module.flags = !{!8, !9} !llvm.dbg.cu = !{!10} diff --git a/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__for_conditions_location_marked.snap b/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__for_conditions_location_marked.snap index 25ab7b4faf0..6e12617d29b 100644 --- a/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__for_conditions_location_marked.snap +++ b/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__for_conditions_location_marked.snap @@ -5,73 +5,37 @@ expression: result ; ModuleID = 'main' source_filename = "main" -define i32 @myFunc() section "fn-myFunc:i32" !dbg !4 { +define i32 @myFunc() section "fn-$RUSTY$myFunc:i32" !dbg !4 { entry: %myFunc = alloca i32, align 4, !dbg !8 call void @llvm.dbg.declare(metadata i32* %myFunc, metadata !9, metadata !DIExpression()), !dbg !11 store i32 0, i32* %myFunc, align 4, !dbg !8 store i32 1, i32* %myFunc, align 4, !dbg !12 - br label %condition_check, !dbg !12 + br i1 true, label %predicate_sle, label %predicate_sge, !dbg !12 -condition_check: ; preds = %increment, %entry - %load_myFunc = load i32, i32* %myFunc, align 4, !dbg !12 - %load_myFunc1 = load i32, i32* %myFunc, align 4, !dbg !12 - %tmpVar = icmp sle i32 %load_myFunc1, 20, !dbg !12 - %0 = zext i1 %tmpVar to i8, !dbg !12 - %1 = icmp ne i8 %0, 0, !dbg !12 - br i1 %1, label %2, label %5, !dbg !12 +predicate_sle: ; preds = %increment, %entry + %0 = load i32, i32* %myFunc, align 4, !dbg !12 + %condition = icmp sle i32 %0, 20, !dbg !12 + br i1 %condition, label %loop, label %continue, !dbg !12 -for_body: ; preds = %12 +predicate_sge: ; preds = %increment, %entry + %1 = load i32, i32* %myFunc, align 4, !dbg !12 + %condition1 = icmp sge i32 %1, 20, !dbg !12 + br i1 %condition1, label %loop, label %continue, !dbg !12 + +loop: ; preds = %predicate_sge, %predicate_sle store i32 1, i32* %myFunc, align 4, !dbg !13 br label %increment, !dbg !13 -increment: ; preds = %for_body - %tmpVar8 = add i32 %load_myFunc, 2, !dbg !14 - store i32 %tmpVar8, i32* %myFunc, align 4, !dbg !14 - br label %condition_check, !dbg !14 - -continue: ; preds = %12 - %myFunc_ret = load i32, i32* %myFunc, align 4, !dbg !14 - ret i32 %myFunc_ret, !dbg !14 - -2: ; preds = %condition_check - %load_myFunc2 = load i32, i32* %myFunc, align 4, !dbg !12 - %tmpVar3 = icmp sge i32 %load_myFunc2, 1, !dbg !12 - %3 = zext i1 %tmpVar3 to i8, !dbg !12 - %4 = icmp ne i8 %3, 0, !dbg !12 - br label %5, !dbg !12 - -5: ; preds = %2, %condition_check - %6 = phi i1 [ %1, %condition_check ], [ %4, %2 ], !dbg !12 - %7 = zext i1 %6 to i8, !dbg !12 - %8 = icmp ne i8 %7, 0, !dbg !12 - br i1 %8, label %12, label %9, !dbg !12 - -9: ; preds = %5 - %load_myFunc4 = load i32, i32* %myFunc, align 4, !dbg !12 - %tmpVar5 = icmp sge i32 %load_myFunc4, 20, !dbg !12 - %10 = zext i1 %tmpVar5 to i8, !dbg !12 - %11 = icmp ne i8 %10, 0, !dbg !12 - br i1 %11, label %16, label %19, !dbg !12 - -12: ; preds = %19, %5 - %13 = phi i1 [ %8, %5 ], [ %22, %19 ], !dbg !12 - %14 = zext i1 %13 to i8, !dbg !12 - %15 = icmp ne i8 %14, 0, !dbg !12 - br i1 %15, label %for_body, label %continue, !dbg !12 - -16: ; preds = %9 - %load_myFunc6 = load i32, i32* %myFunc, align 4, !dbg !12 - %tmpVar7 = icmp sle i32 %load_myFunc6, 1, !dbg !12 - %17 = zext i1 %tmpVar7 to i8, !dbg !12 - %18 = icmp ne i8 %17, 0, !dbg !12 - br label %19, !dbg !12 +increment: ; preds = %loop + %2 = load i32, i32* %myFunc, align 4, !dbg !13 + %next = add i32 2, %2, !dbg !13 + store i32 %next, i32* %myFunc, align 4, !dbg !13 + br i1 true, label %predicate_sle, label %predicate_sge, !dbg !13 -19: ; preds = %16, %9 - %20 = phi i1 [ %11, %9 ], [ %18, %16 ], !dbg !12 - %21 = zext i1 %20 to i8, !dbg !12 - %22 = icmp ne i8 %21, 0, !dbg !12 - br label %12, !dbg !12 +continue: ; preds = %predicate_sge, %predicate_sle + %myFunc_ret = load i32, i32* %myFunc, align 4, !dbg !13 + ret i32 %myFunc_ret, !dbg !13 } ; Function Attrs: nofree nosync nounwind readnone speculatable willreturn @@ -96,4 +60,3 @@ attributes #0 = { nofree nosync nounwind readnone speculatable willreturn } !11 = !DILocation(line: 2, column: 17, scope: !4) !12 = !DILocation(line: 3, column: 16, scope: !4) !13 = !DILocation(line: 4, column: 16, scope: !4) -!14 = !DILocation(line: 3, column: 37, scope: !4) diff --git a/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__function_calls_have_location.snap b/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__function_calls_have_location.snap index 63a0d1ca3e6..3ca5c86ad44 100644 --- a/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__function_calls_have_location.snap +++ b/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__function_calls_have_location.snap @@ -5,7 +5,7 @@ expression: result ; ModuleID = 'main' source_filename = "main" -define i32 @myFunc() section "fn-myFunc:i32" !dbg !4 { +define i32 @myFunc() section "fn-$RUSTY$myFunc:i32" !dbg !4 { entry: %myFunc = alloca i32, align 4, !dbg !8 call void @llvm.dbg.declare(metadata i32* %myFunc, metadata !9, metadata !DIExpression()), !dbg !11 diff --git a/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__function_calls_in_expressions_have_location.snap b/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__function_calls_in_expressions_have_location.snap index 44e6a5e1d9a..ecd3a71e1dd 100644 --- a/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__function_calls_in_expressions_have_location.snap +++ b/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__function_calls_in_expressions_have_location.snap @@ -5,7 +5,7 @@ expression: result ; ModuleID = 'main' source_filename = "main" -define i32 @myFunc() section "fn-myFunc:i32" !dbg !4 { +define i32 @myFunc() section "fn-$RUSTY$myFunc:i32" !dbg !4 { entry: %myFunc = alloca i32, align 4, !dbg !8 call void @llvm.dbg.declare(metadata i32* %myFunc, metadata !9, metadata !DIExpression()), !dbg !11 diff --git a/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__if_conditions_location_marked.snap b/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__if_conditions_location_marked.snap index 659d180e98a..a9cd134c7dd 100644 --- a/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__if_conditions_location_marked.snap +++ b/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__if_conditions_location_marked.snap @@ -5,7 +5,7 @@ expression: result ; ModuleID = 'main' source_filename = "main" -define i32 @myFunc() section "fn-myFunc:i32" !dbg !4 { +define i32 @myFunc() section "fn-$RUSTY$myFunc:i32" !dbg !4 { entry: %myFunc = alloca i32, align 4, !dbg !8 call void @llvm.dbg.declare(metadata i32* %myFunc, metadata !9, metadata !DIExpression()), !dbg !11 diff --git a/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__implementation_added_as_subroutine.snap b/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__implementation_added_as_subroutine.snap index e5933b7ee3f..4031d2368c0 100644 --- a/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__implementation_added_as_subroutine.snap +++ b/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__implementation_added_as_subroutine.snap @@ -8,10 +8,10 @@ source_filename = "main" %myPrg = type {} %myFb = type {} -@myPrg_instance = global %myPrg zeroinitializer, !dbg !0 -@__myFb__init = unnamed_addr constant %myFb zeroinitializer, !dbg !5 +@myPrg_instance = global %myPrg zeroinitializer, section "var-$RUSTY$myPrg_instance:r0", !dbg !0 +@__myFb__init = unnamed_addr constant %myFb zeroinitializer, section "var-$RUSTY$__myFb__init:r0", !dbg !5 -define i32 @myFunc() section "fn-myFunc:i32" !dbg !12 { +define i32 @myFunc() section "fn-$RUSTY$myFunc:i32" !dbg !12 { entry: %myFunc = alloca i32, align 4, !dbg !15 call void @llvm.dbg.declare(metadata i32* %myFunc, metadata !16, metadata !DIExpression()), !dbg !18 @@ -20,13 +20,13 @@ entry: ret i32 %myFunc_ret, !dbg !15 } -define void @myPrg(%myPrg* %0) section "fn-myPrg:v" !dbg !19 { +define void @myPrg(%myPrg* %0) section "fn-$RUSTY$myPrg:v" !dbg !19 { entry: call void @llvm.dbg.declare(metadata %myPrg* %0, metadata !20, metadata !DIExpression()), !dbg !21 ret void, !dbg !21 } -define void @myFb(%myFb* %0) section "fn-myFb:v" !dbg !22 { +define void @myFb(%myFb* %0) section "fn-$RUSTY$myFb:v" !dbg !22 { entry: call void @llvm.dbg.declare(metadata %myFb* %0, metadata !23, metadata !DIExpression()), !dbg !24 ret void, !dbg !24 diff --git a/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__nested_function_calls_get_location.snap b/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__nested_function_calls_get_location.snap index 96f7356258a..acecf314cd4 100644 --- a/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__nested_function_calls_get_location.snap +++ b/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__nested_function_calls_get_location.snap @@ -5,7 +5,7 @@ expression: result ; ModuleID = 'main' source_filename = "main" -define i32 @myFunc(i32 %0) section "fn-myFunc:i32[i32]" !dbg !4 { +define i32 @myFunc(i32 %0) section "fn-$RUSTY$myFunc:i32[i32]" !dbg !4 { entry: %myFunc = alloca i32, align 4, !dbg !9 %x = alloca i32, align 4, !dbg !9 diff --git a/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__non_callable_expressions_have_no_location.snap b/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__non_callable_expressions_have_no_location.snap index f43862598fa..7c33e7e21b8 100644 --- a/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__non_callable_expressions_have_no_location.snap +++ b/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__non_callable_expressions_have_no_location.snap @@ -5,7 +5,7 @@ expression: result ; ModuleID = 'main' source_filename = "main" -define i32 @myFunc() section "fn-myFunc:i32" !dbg !4 { +define i32 @myFunc() section "fn-$RUSTY$myFunc:i32" !dbg !4 { entry: %myFunc = alloca i32, align 4, !dbg !8 call void @llvm.dbg.declare(metadata i32* %myFunc, metadata !9, metadata !DIExpression()), !dbg !11 diff --git a/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__non_function_pous_have_struct_as_param.snap b/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__non_function_pous_have_struct_as_param.snap index 99bd0a7cf7b..d1f406fd7bc 100644 --- a/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__non_function_pous_have_struct_as_param.snap +++ b/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__non_function_pous_have_struct_as_param.snap @@ -8,10 +8,10 @@ source_filename = "main" %myProg = type { i32 } %fb = type { i32 } -@myProg_instance = global %myProg zeroinitializer, !dbg !0 -@__fb__init = unnamed_addr constant %fb zeroinitializer, !dbg !7 +@myProg_instance = global %myProg zeroinitializer, section "var-$RUSTY$myProg_instance:r1i32", !dbg !0 +@__fb__init = unnamed_addr constant %fb zeroinitializer, section "var-$RUSTY$__fb__init:r1i32", !dbg !7 -define void @myProg(%myProg* %0) section "fn-myProg:v[i32]" !dbg !16 { +define void @myProg(%myProg* %0) section "fn-$RUSTY$myProg:v[i32]" !dbg !16 { entry: call void @llvm.dbg.declare(metadata %myProg* %0, metadata !20, metadata !DIExpression()), !dbg !21 %x = getelementptr inbounds %myProg, %myProg* %0, i32 0, i32 0, !dbg !21 @@ -21,7 +21,7 @@ entry: ret void, !dbg !21 } -define void @fb(%fb* %0) section "fn-fb:v[i32]" !dbg !22 { +define void @fb(%fb* %0) section "fn-$RUSTY$fb:v[i32]" !dbg !22 { entry: call void @llvm.dbg.declare(metadata %fb* %0, metadata !23, metadata !DIExpression()), !dbg !24 %x = getelementptr inbounds %fb, %fb* %0, i32 0, i32 0, !dbg !24 diff --git a/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__repeat_conditions_location_marked.snap b/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__repeat_conditions_location_marked.snap index c3f649b11a1..bd34efaee8e 100644 --- a/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__repeat_conditions_location_marked.snap +++ b/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__repeat_conditions_location_marked.snap @@ -5,7 +5,7 @@ expression: result ; ModuleID = 'main' source_filename = "main" -define i32 @myFunc() section "fn-myFunc:i32" !dbg !4 { +define i32 @myFunc() section "fn-$RUSTY$myFunc:i32" !dbg !4 { entry: %myFunc = alloca i32, align 4, !dbg !8 call void @llvm.dbg.declare(metadata i32* %myFunc, metadata !9, metadata !DIExpression()), !dbg !11 diff --git a/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__return_statement_have_location.snap b/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__return_statement_have_location.snap index 5c789271297..d8bd529d703 100644 --- a/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__return_statement_have_location.snap +++ b/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__return_statement_have_location.snap @@ -5,7 +5,7 @@ expression: result ; ModuleID = 'main' source_filename = "main" -define i32 @myFunc() section "fn-myFunc:i32" !dbg !4 { +define i32 @myFunc() section "fn-$RUSTY$myFunc:i32" !dbg !4 { entry: %myFunc = alloca i32, align 4, !dbg !8 call void @llvm.dbg.declare(metadata i32* %myFunc, metadata !9, metadata !DIExpression()), !dbg !11 diff --git a/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__string_size_correctly_set_in_dwarf_info.snap b/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__string_size_correctly_set_in_dwarf_info.snap index fd039416b45..f7bc5dbd465 100644 --- a/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__string_size_correctly_set_in_dwarf_info.snap +++ b/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__string_size_correctly_set_in_dwarf_info.snap @@ -5,7 +5,7 @@ expression: result ; ModuleID = 'main' source_filename = "main" -@a = global [65 x i8] zeroinitializer, !dbg !0 +@a = global [65 x i8] zeroinitializer, section "var-$RUSTY$a:s8u65", !dbg !0 !llvm.module.flags = !{!7, !8} !llvm.dbg.cu = !{!9} diff --git a/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__var_and_vartemp_variables_in_pous_added_as_local.snap b/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__var_and_vartemp_variables_in_pous_added_as_local.snap index 09aeddba2fd..41c3cd88b7d 100644 --- a/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__var_and_vartemp_variables_in_pous_added_as_local.snap +++ b/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__var_and_vartemp_variables_in_pous_added_as_local.snap @@ -8,10 +8,10 @@ source_filename = "main" %myPrg = type {} %myFb = type {} -@myPrg_instance = global %myPrg zeroinitializer, !dbg !0 -@__myFb__init = unnamed_addr constant %myFb zeroinitializer, !dbg !9 +@myPrg_instance = global %myPrg zeroinitializer, section "var-$RUSTY$myPrg_instance:r3i32i32i32", !dbg !0 +@__myFb__init = unnamed_addr constant %myFb zeroinitializer, section "var-$RUSTY$__myFb__init:r3i32i32i32", !dbg !9 -define i32 @myFunc() section "fn-myFunc:i32" !dbg !20 { +define i32 @myFunc() section "fn-$RUSTY$myFunc:i32" !dbg !20 { entry: %myFunc = alloca i32, align 4, !dbg !24 %a = alloca i32, align 4, !dbg !24 @@ -29,7 +29,7 @@ entry: ret i32 %myFunc_ret, !dbg !24 } -define void @myPrg(%myPrg* %0) section "fn-myPrg:v" !dbg !33 { +define void @myPrg(%myPrg* %0) section "fn-$RUSTY$myPrg:v" !dbg !33 { entry: call void @llvm.dbg.declare(metadata %myPrg* %0, metadata !34, metadata !DIExpression()), !dbg !35 %a = alloca i32, align 4, !dbg !35 @@ -44,7 +44,7 @@ entry: ret void, !dbg !35 } -define void @myFb(%myFb* %0) section "fn-myFb:v" !dbg !42 { +define void @myFb(%myFb* %0) section "fn-$RUSTY$myFb:v" !dbg !42 { entry: call void @llvm.dbg.declare(metadata %myFb* %0, metadata !43, metadata !DIExpression()), !dbg !44 %a = alloca i32, align 4, !dbg !44 diff --git a/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__var_in_out_inout_in_function_added_as_params.snap b/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__var_in_out_inout_in_function_added_as_params.snap index 497bfb673f4..ae19840b1fd 100644 --- a/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__var_in_out_inout_in_function_added_as_params.snap +++ b/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__var_in_out_inout_in_function_added_as_params.snap @@ -5,7 +5,7 @@ expression: result ; ModuleID = 'main' source_filename = "main" -define i32 @myFunc(i16* %0) section "fn-myFunc:i32[pi16]" !dbg !4 { +define i32 @myFunc(i16* %0) section "fn-$RUSTY$myFunc:i32[pi16]" !dbg !4 { entry: %myFunc = alloca i32, align 4, !dbg !10 %x = alloca i16*, align 8, !dbg !10 diff --git a/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__while_conditions_location_marked.snap b/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__while_conditions_location_marked.snap index eacacdaa227..be5cce04c5a 100644 --- a/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__while_conditions_location_marked.snap +++ b/src/codegen/tests/debug_tests/snapshots/rusty__codegen__tests__debug_tests__expression_debugging__while_conditions_location_marked.snap @@ -5,7 +5,7 @@ expression: result ; ModuleID = 'main' source_filename = "main" -define i32 @myFunc() section "fn-myFunc:i32" !dbg !4 { +define i32 @myFunc() section "fn-$RUSTY$myFunc:i32" !dbg !4 { entry: %myFunc = alloca i32, align 4, !dbg !8 call void @llvm.dbg.declare(metadata i32* %myFunc, metadata !9, metadata !DIExpression()), !dbg !11 diff --git a/src/codegen/tests/directaccess_test.rs b/src/codegen/tests/directaccess_test.rs index df69af8891a..26e2604ff32 100644 --- a/src/codegen/tests/directaccess_test.rs +++ b/src/codegen/tests/directaccess_test.rs @@ -1,3 +1,4 @@ +use insta::assert_snapshot; // Copyright (c) 2020 Ghaith Hachem and Mathias Rieder use crate::test_utils::tests::codegen; @@ -112,3 +113,327 @@ fn qualified_reference_assignment() { ); insta::assert_snapshot!(prog); } + +#[test] +fn direct_acess_in_output_assignment_implicit_explicit_and_mixed() { + let ir = codegen( + r" + FUNCTION_BLOCK FOO + VAR_INPUT + X : BOOL; + END_VAR + VAR_OUTPUT + Y : BOOL; + END_VAR + END_FUNCTION_BLOCK + + FUNCTION main : DINT + VAR + error_bits : BYTE; + f : FOO; + END_VAR + + f(X := error_bits.0, Y => error_bits.0); + f(Y => error_bits.0, x := error_bits.0); + f(error_bits.0, error_bits.0); + f(X := error_bits.0, Y =>); + END_FUNCTION + ", + ); + + assert_snapshot!(ir, @r###" + ; ModuleID = 'main' + source_filename = "main" + + %FOO = type { i8, i8 } + + @__FOO__init = unnamed_addr constant %FOO zeroinitializer, section "var-$RUSTY$__FOO__init:r2u8u8" + + define void @FOO(%FOO* %0) section "fn-$RUSTY$FOO:v[u8][u8]" { + entry: + %X = getelementptr inbounds %FOO, %FOO* %0, i32 0, i32 0 + %Y = getelementptr inbounds %FOO, %FOO* %0, i32 0, i32 1 + ret void + } + + define i32 @main() section "fn-$RUSTY$main:i32" { + entry: + %main = alloca i32, align 4 + %error_bits = alloca i8, align 1 + %f = alloca %FOO, align 8 + store i8 0, i8* %error_bits, align 1 + %0 = bitcast %FOO* %f to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %0, i8* align 1 getelementptr inbounds (%FOO, %FOO* @__FOO__init, i32 0, i32 0), i64 ptrtoint (%FOO* getelementptr (%FOO, %FOO* null, i32 1) to i64), i1 false) + store i32 0, i32* %main, align 4 + %1 = getelementptr inbounds %FOO, %FOO* %f, i32 0, i32 0 + %load_error_bits = load i8, i8* %error_bits, align 1 + %shift = lshr i8 %load_error_bits, 0 + %2 = and i8 %shift, 1 + store i8 %2, i8* %1, align 1 + call void @FOO(%FOO* %f) + %3 = getelementptr inbounds %FOO, %FOO* %f, i32 0, i32 1 + %4 = load i8, i8* %error_bits, align 1 + %5 = load i8, i8* %3, align 1 + %erase = and i8 %4, -2 + %value = shl i8 %5, 0 + %or = or i8 %erase, %value + store i8 %or, i8* %error_bits, align 1 + %6 = getelementptr inbounds %FOO, %FOO* %f, i32 0, i32 0 + %load_error_bits1 = load i8, i8* %error_bits, align 1 + %shift2 = lshr i8 %load_error_bits1, 0 + %7 = and i8 %shift2, 1 + store i8 %7, i8* %6, align 1 + call void @FOO(%FOO* %f) + %8 = getelementptr inbounds %FOO, %FOO* %f, i32 0, i32 1 + %9 = load i8, i8* %error_bits, align 1 + %10 = load i8, i8* %8, align 1 + %erase3 = and i8 %9, -2 + %value4 = shl i8 %10, 0 + %or5 = or i8 %erase3, %value4 + store i8 %or5, i8* %error_bits, align 1 + %11 = getelementptr inbounds %FOO, %FOO* %f, i32 0, i32 0 + %load_error_bits6 = load i8, i8* %error_bits, align 1 + %shift7 = lshr i8 %load_error_bits6, 0 + %12 = and i8 %shift7, 1 + store i8 %12, i8* %11, align 1 + call void @FOO(%FOO* %f) + %13 = getelementptr inbounds %FOO, %FOO* %f, i32 0, i32 1 + %14 = load i8, i8* %error_bits, align 1 + %15 = load i8, i8* %13, align 1 + %erase8 = and i8 %14, -2 + %value9 = shl i8 %15, 0 + %or10 = or i8 %erase8, %value9 + store i8 %or10, i8* %error_bits, align 1 + %16 = getelementptr inbounds %FOO, %FOO* %f, i32 0, i32 0 + %load_error_bits11 = load i8, i8* %error_bits, align 1 + %shift12 = lshr i8 %load_error_bits11, 0 + %17 = and i8 %shift12, 1 + store i8 %17, i8* %16, align 1 + call void @FOO(%FOO* %f) + %main_ret = load i32, i32* %main, align 4 + ret i32 %main_ret + } + + ; Function Attrs: argmemonly nofree nounwind willreturn + declare void @llvm.memcpy.p0i8.p0i8.i64(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i64, i1 immarg) #0 + + attributes #0 = { argmemonly nofree nounwind willreturn } + "###); +} + +#[test] +fn direct_acess_in_output_assignment_with_simple_expression() { + let ir = codegen( + r" + FUNCTION_BLOCK FOO + VAR_OUTPUT + Q : BOOL := TRUE; + END_VAR + END_FUNCTION_BLOCK + + FUNCTION main : DINT + VAR + error_bits : BYTE := 2#1110_1111; + f : FOO; + END_VAR + + f(Q => error_bits.4); + END_FUNCTION + ", + ); + + assert_snapshot!(ir, @r###" + ; ModuleID = 'main' + source_filename = "main" + + %FOO = type { i8 } + + @__FOO__init = unnamed_addr constant %FOO { i8 1 }, section "var-$RUSTY$__FOO__init:r1u8" + + define void @FOO(%FOO* %0) section "fn-$RUSTY$FOO:v[u8]" { + entry: + %Q = getelementptr inbounds %FOO, %FOO* %0, i32 0, i32 0 + ret void + } + + define i32 @main() section "fn-$RUSTY$main:i32" { + entry: + %main = alloca i32, align 4 + %error_bits = alloca i8, align 1 + %f = alloca %FOO, align 8 + store i8 -17, i8* %error_bits, align 1 + %0 = bitcast %FOO* %f to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %0, i8* align 1 getelementptr inbounds (%FOO, %FOO* @__FOO__init, i32 0, i32 0), i64 ptrtoint (%FOO* getelementptr (%FOO, %FOO* null, i32 1) to i64), i1 false) + store i32 0, i32* %main, align 4 + call void @FOO(%FOO* %f) + %1 = getelementptr inbounds %FOO, %FOO* %f, i32 0, i32 0 + %2 = load i8, i8* %error_bits, align 1 + %3 = load i8, i8* %1, align 1 + %erase = and i8 %2, -17 + %value = shl i8 %3, 4 + %or = or i8 %erase, %value + store i8 %or, i8* %error_bits, align 1 + %main_ret = load i32, i32* %main, align 4 + ret i32 %main_ret + } + + ; Function Attrs: argmemonly nofree nounwind willreturn + declare void @llvm.memcpy.p0i8.p0i8.i64(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i64, i1 immarg) #0 + + attributes #0 = { argmemonly nofree nounwind willreturn } + "###); +} + +#[test] +fn direct_acess_in_output_assignment_with_simple_expression_implicit() { + let ir = codegen( + r" + FUNCTION_BLOCK FOO + VAR_OUTPUT + Q : BOOL := TRUE; + END_VAR + END_FUNCTION_BLOCK + + FUNCTION main : DINT + VAR + error_bits : BYTE := 2#1110_1111; + f : FOO; + END_VAR + + f(error_bits.4); + END_FUNCTION + ", + ); + + assert_snapshot!(ir, @r###" + ; ModuleID = 'main' + source_filename = "main" + + %FOO = type { i8 } + + @__FOO__init = unnamed_addr constant %FOO { i8 1 }, section "var-$RUSTY$__FOO__init:r1u8" + + define void @FOO(%FOO* %0) section "fn-$RUSTY$FOO:v[u8]" { + entry: + %Q = getelementptr inbounds %FOO, %FOO* %0, i32 0, i32 0 + ret void + } + + define i32 @main() section "fn-$RUSTY$main:i32" { + entry: + %main = alloca i32, align 4 + %error_bits = alloca i8, align 1 + %f = alloca %FOO, align 8 + store i8 -17, i8* %error_bits, align 1 + %0 = bitcast %FOO* %f to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %0, i8* align 1 getelementptr inbounds (%FOO, %FOO* @__FOO__init, i32 0, i32 0), i64 ptrtoint (%FOO* getelementptr (%FOO, %FOO* null, i32 1) to i64), i1 false) + store i32 0, i32* %main, align 4 + call void @FOO(%FOO* %f) + %1 = getelementptr inbounds %FOO, %FOO* %f, i32 0, i32 0 + %2 = load i8, i8* %error_bits, align 1 + %3 = load i8, i8* %1, align 1 + %erase = and i8 %2, -17 + %value = shl i8 %3, 4 + %or = or i8 %erase, %value + store i8 %or, i8* %error_bits, align 1 + %main_ret = load i32, i32* %main, align 4 + ret i32 %main_ret + } + + ; Function Attrs: argmemonly nofree nounwind willreturn + declare void @llvm.memcpy.p0i8.p0i8.i64(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i64, i1 immarg) #0 + + attributes #0 = { argmemonly nofree nounwind willreturn } + "###); +} + +#[test] +fn direct_acess_in_output_assignment_with_complexe_expression() { + let ir = codegen( + r" + TYPE foo_struct : STRUCT + bar : bar_struct; + END_STRUCT END_TYPE + + TYPE bar_struct : STRUCT + baz : LWORD; + END_STRUCT END_TYPE + + FUNCTION_BLOCK QUUX + VAR_OUTPUT + Q : BOOL; + END_VAR + END_FUNCTION_BLOCK + + FUNCTION main : DINT + VAR + foo : foo_struct; + f : QUUX; + END_VAR + + f(Q => foo.bar.baz.%W3); + f(Q => foo.bar.baz.%W3.%B0.%X2); + END_FUNCTION + ", + ); + + assert_snapshot!(ir, @r###" + ; ModuleID = 'main' + source_filename = "main" + + %QUUX = type { i8 } + %foo_struct = type { %bar_struct } + %bar_struct = type { i64 } + + @__QUUX__init = unnamed_addr constant %QUUX zeroinitializer, section "var-$RUSTY$__QUUX__init:r1u8" + @__foo_struct__init = unnamed_addr constant %foo_struct zeroinitializer, section "var-$RUSTY$__foo_struct__init:r1r1u64" + @__bar_struct__init = unnamed_addr constant %bar_struct zeroinitializer, section "var-$RUSTY$__bar_struct__init:r1u64" + + define void @QUUX(%QUUX* %0) section "fn-$RUSTY$QUUX:v[u8]" { + entry: + %Q = getelementptr inbounds %QUUX, %QUUX* %0, i32 0, i32 0 + ret void + } + + define i32 @main() section "fn-$RUSTY$main:i32" { + entry: + %main = alloca i32, align 4 + %foo = alloca %foo_struct, align 8 + %f = alloca %QUUX, align 8 + %0 = bitcast %foo_struct* %foo to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %0, i8* align 1 bitcast (%foo_struct* @__foo_struct__init to i8*), i64 ptrtoint (%foo_struct* getelementptr (%foo_struct, %foo_struct* null, i32 1) to i64), i1 false) + %1 = bitcast %QUUX* %f to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %1, i8* align 1 getelementptr inbounds (%QUUX, %QUUX* @__QUUX__init, i32 0, i32 0), i64 ptrtoint (%QUUX* getelementptr (%QUUX, %QUUX* null, i32 1) to i64), i1 false) + store i32 0, i32* %main, align 4 + call void @QUUX(%QUUX* %f) + %bar = getelementptr inbounds %foo_struct, %foo_struct* %foo, i32 0, i32 0 + %baz = getelementptr inbounds %bar_struct, %bar_struct* %bar, i32 0, i32 0 + %2 = getelementptr inbounds %QUUX, %QUUX* %f, i32 0, i32 0 + %3 = load i64, i64* %baz, align 4 + %4 = load i8, i8* %2, align 1 + %erase = and i64 %3, -281474976710657 + %5 = zext i8 %4 to i64 + %value = shl i64 %5, 48 + %or = or i64 %erase, %value + store i64 %or, i64* %baz, align 4 + call void @QUUX(%QUUX* %f) + %bar1 = getelementptr inbounds %foo_struct, %foo_struct* %foo, i32 0, i32 0 + %baz2 = getelementptr inbounds %bar_struct, %bar_struct* %bar1, i32 0, i32 0 + %6 = getelementptr inbounds %QUUX, %QUUX* %f, i32 0, i32 0 + %7 = load i64, i64* %baz2, align 4 + %8 = load i8, i8* %6, align 1 + %erase3 = and i64 %7, -1125899906842625 + %9 = zext i8 %8 to i64 + %value4 = shl i64 %9, 50 + %or5 = or i64 %erase3, %value4 + store i64 %or5, i64* %baz2, align 4 + %main_ret = load i32, i32* %main, align 4 + ret i32 %main_ret + } + + ; Function Attrs: argmemonly nofree nounwind willreturn + declare void @llvm.memcpy.p0i8.p0i8.i64(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i64, i1 immarg) #0 + + attributes #0 = { argmemonly nofree nounwind willreturn } + "###); +} diff --git a/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__global_initializers__global_constant_without_initializer_gets_declared_initializer.snap b/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__global_initializers__global_constant_without_initializer_gets_declared_initializer.snap index 157bfcca59b..3b4650feec0 100644 --- a/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__global_initializers__global_constant_without_initializer_gets_declared_initializer.snap +++ b/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__global_initializers__global_constant_without_initializer_gets_declared_initializer.snap @@ -7,9 +7,9 @@ source_filename = "main" %commands = type { i8, i8 } -@__commands__init = unnamed_addr constant %commands { i8 1, i8 0 } +@__commands__init = unnamed_addr constant %commands { i8 1, i8 0 }, section "var-$RUSTY$__commands__init:r2u8u8" -define i32 @main() section "fn-main:i32" { +define i32 @main() section "fn-$RUSTY$main:i32" { entry: %main = alloca i32, align 4 %cmd1 = alloca %commands, align 8 diff --git a/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__global_initializers__global_constant_without_initializer_gets_default_initializer.snap b/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__global_initializers__global_constant_without_initializer_gets_default_initializer.snap index 66373e62305..2eea070ead1 100644 --- a/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__global_initializers__global_constant_without_initializer_gets_default_initializer.snap +++ b/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__global_initializers__global_constant_without_initializer_gets_default_initializer.snap @@ -7,10 +7,10 @@ source_filename = "main" %commands = type { i8, i8 } -@__commands__init = unnamed_addr constant %commands zeroinitializer +@__commands__init = unnamed_addr constant %commands zeroinitializer, section "var-$RUSTY$__commands__init:r2u8u8" @__main.myStr1__init = unnamed_addr constant [81 x i8] zeroinitializer -define i32 @main() section "fn-main:i32" { +define i32 @main() section "fn-$RUSTY$main:i32" { entry: %main = alloca i32, align 4 %cmd1 = alloca %commands, align 8 diff --git a/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__global_initializers__initial_values_in_global_constant_variables.snap b/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__global_initializers__initial_values_in_global_constant_variables.snap index 67066f351dd..5394c610e3a 100644 --- a/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__global_initializers__initial_values_in_global_constant_variables.snap +++ b/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__global_initializers__initial_values_in_global_constant_variables.snap @@ -1,28 +1,25 @@ --- source: src/codegen/tests/initialization_test/global_initializers.rs -assertion_line: 38 expression: result - --- ; ModuleID = 'main' source_filename = "main" -@c_INT = unnamed_addr constant i16 7 -@c_3c = unnamed_addr constant i16 21 -@c_BOOL = unnamed_addr constant i8 1 -@c_not = unnamed_addr constant i8 0 -@c_str = unnamed_addr constant [11 x i8] c"Hello\00\00\00\00\00\00" -@c_wstr = unnamed_addr constant [11 x i16] [i16 87, i16 111, i16 114, i16 108, i16 100, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0] -@c_real = unnamed_addr constant float 0x40091EB860000000 -@c_lreal = unnamed_addr constant double 3.141500e+00 -@x = unnamed_addr constant i16 7 -@y = unnamed_addr constant i16 14 -@z = unnamed_addr constant i16 32 -@b = unnamed_addr constant i8 1 -@nb = unnamed_addr constant i8 0 -@bb = unnamed_addr constant i8 0 -@str = unnamed_addr constant [11 x i8] c"Hello\00\00\00\00\00\00" -@wstr = unnamed_addr constant [11 x i16] [i16 87, i16 111, i16 114, i16 108, i16 100, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0] -@r = unnamed_addr constant float 0x3FF91EB860000000 -@tau = unnamed_addr constant double 6.283000e+00 - +@c_INT = unnamed_addr constant i16 7, section "var-$RUSTY$c_INT:i16" +@c_3c = unnamed_addr constant i16 21, section "var-$RUSTY$c_3c:i16" +@c_BOOL = unnamed_addr constant i8 1, section "var-$RUSTY$c_BOOL:u8" +@c_not = unnamed_addr constant i8 0, section "var-$RUSTY$c_not:u8" +@c_str = unnamed_addr constant [11 x i8] c"Hello\00\00\00\00\00\00", section "var-$RUSTY$c_str:s8u11" +@c_wstr = unnamed_addr constant [11 x i16] [i16 87, i16 111, i16 114, i16 108, i16 100, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0], section "var-$RUSTY$c_wstr:s16u11" +@c_real = unnamed_addr constant float 0x40091EB860000000, section "var-$RUSTY$c_real:f32" +@c_lreal = unnamed_addr constant double 3.141500e+00, section "var-$RUSTY$c_lreal:f64" +@x = unnamed_addr constant i16 7, section "var-$RUSTY$x:i16" +@y = unnamed_addr constant i16 14, section "var-$RUSTY$y:i16" +@z = unnamed_addr constant i16 32, section "var-$RUSTY$z:i16" +@b = unnamed_addr constant i8 1, section "var-$RUSTY$b:u8" +@nb = unnamed_addr constant i8 0, section "var-$RUSTY$nb:u8" +@bb = unnamed_addr constant i8 0, section "var-$RUSTY$bb:u8" +@str = unnamed_addr constant [11 x i8] c"Hello\00\00\00\00\00\00", section "var-$RUSTY$str:s8u11" +@wstr = unnamed_addr constant [11 x i16] [i16 87, i16 111, i16 114, i16 108, i16 100, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0], section "var-$RUSTY$wstr:s16u11" +@r = unnamed_addr constant float 0x3FF91EB860000000, section "var-$RUSTY$r:f32" +@tau = unnamed_addr constant double 6.283000e+00, section "var-$RUSTY$tau:f64" diff --git a/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__global_initializers__initial_values_in_global_variables.snap b/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__global_initializers__initial_values_in_global_variables.snap index 8316de11dc2..2dde3124cb6 100644 --- a/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__global_initializers__initial_values_in_global_variables.snap +++ b/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__global_initializers__initial_values_in_global_variables.snap @@ -1,13 +1,10 @@ --- source: src/codegen/tests/initialization_test/global_initializers.rs -assertion_line: 53 expression: result - --- ; ModuleID = 'main' source_filename = "main" -@x = global i16 7 -@y = global i8 1 -@z = global float 0x400921CAC0000000 - +@x = global i16 7, section "var-$RUSTY$x:i16" +@y = global i8 1, section "var-$RUSTY$y:u8" +@z = global float 0x400921CAC0000000, section "var-$RUSTY$z:f32" diff --git a/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__global_initializers__initial_values_in_global_variables_out_of_order.snap b/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__global_initializers__initial_values_in_global_variables_out_of_order.snap index 6cd804ef790..72ff91eb83a 100644 --- a/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__global_initializers__initial_values_in_global_variables_out_of_order.snap +++ b/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__global_initializers__initial_values_in_global_variables_out_of_order.snap @@ -8,17 +8,17 @@ source_filename = "main" %MyFB = type { i16 } %prg = type { %MyFB } -@x = global %MyFB { i16 77 } -@__MyFB__init = unnamed_addr constant %MyFB { i16 77 } -@prg_instance = global %prg { %MyFB { i16 77 } } +@x = global %MyFB { i16 77 }, section "var-$RUSTY$x:r1i16" +@__MyFB__init = unnamed_addr constant %MyFB { i16 77 }, section "var-$RUSTY$__MyFB__init:r1i16" +@prg_instance = global %prg { %MyFB { i16 77 } }, section "var-$RUSTY$prg_instance:r1r1i16" -define void @MyFB(%MyFB* %0) section "fn-MyFB:v" { +define void @MyFB(%MyFB* %0) section "fn-$RUSTY$MyFB:v" { entry: %x = getelementptr inbounds %MyFB, %MyFB* %0, i32 0, i32 0 ret void } -define void @prg(%prg* %0) section "fn-prg:v" { +define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: %x = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 ret void diff --git a/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__global_initializers__uninitialized_global_array.snap b/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__global_initializers__uninitialized_global_array.snap index 3936b3ed8de..9808139ec98 100644 --- a/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__global_initializers__uninitialized_global_array.snap +++ b/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__global_initializers__uninitialized_global_array.snap @@ -1,10 +1,8 @@ --- source: src/codegen/tests/initialization_test/global_initializers.rs expression: result - --- ; ModuleID = 'main' source_filename = "main" -@a = global [2 x i8] zeroinitializer - +@a = global [2 x i8] zeroinitializer, section "var-$RUSTY$a:au8" diff --git a/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__pou_initializers__class_struct_initialized_in_function.snap b/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__pou_initializers__class_struct_initialized_in_function.snap index f18e7a7f9fa..064fe30b88e 100644 --- a/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__pou_initializers__class_struct_initialized_in_function.snap +++ b/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__pou_initializers__class_struct_initialized_in_function.snap @@ -8,16 +8,16 @@ source_filename = "main" %fb = type { i16 } %main = type { %fb } -@__fb__init = unnamed_addr constant %fb { i16 9 } -@main_instance = global %main { %fb { i16 9 } } +@__fb__init = unnamed_addr constant %fb { i16 9 }, section "var-$RUSTY$__fb__init:r1i16" +@main_instance = global %main { %fb { i16 9 } }, section "var-$RUSTY$main_instance:r1r1i16" -define void @fb(%fb* %0) section "fn-fb:v" { +define void @fb(%fb* %0) section "fn-$RUSTY$fb:v" { entry: %a = getelementptr inbounds %fb, %fb* %0, i32 0, i32 0 ret void } -define i32 @func(%fb* %0) section "fn-func:i32[v]" { +define i32 @func(%fb* %0) section "fn-$RUSTY$func:i32[r1i16]" { entry: %func = alloca i32, align 4 %in = alloca %fb, align 8 @@ -32,7 +32,7 @@ entry: ret i32 %func_ret } -define void @main(%main* %0) section "fn-main:v" { +define void @main(%main* %0) section "fn-$RUSTY$main:v" { entry: %fb0 = getelementptr inbounds %main, %main* %0, i32 0, i32 0 %call = call i32 @func(%fb* %fb0) diff --git a/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__pou_initializers__default_values_for_not_initialized_function_vars.snap b/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__pou_initializers__default_values_for_not_initialized_function_vars.snap index 7a250516934..049192b1e93 100644 --- a/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__pou_initializers__default_values_for_not_initialized_function_vars.snap +++ b/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__pou_initializers__default_values_for_not_initialized_function_vars.snap @@ -5,7 +5,7 @@ expression: result ; ModuleID = 'main' source_filename = "main" -define i16 @func() section "fn-func:i16" { +define i16 @func() section "fn-$RUSTY$func:i16" { entry: %func = alloca i16, align 2 %int_var = alloca i16, align 2 diff --git a/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__pou_initializers__enum_variants_have_precedence_over_global_variables_in_inline_assignment.snap b/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__pou_initializers__enum_variants_have_precedence_over_global_variables_in_inline_assignment.snap index 4814d385abc..e9c5abaf628 100644 --- a/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__pou_initializers__enum_variants_have_precedence_over_global_variables_in_inline_assignment.snap +++ b/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__pou_initializers__enum_variants_have_precedence_over_global_variables_in_inline_assignment.snap @@ -5,13 +5,13 @@ expression: function ; ModuleID = 'main' source_filename = "main" -@x = global i32 10 -@__foo_position.x = unnamed_addr constant i32 1 -@__bar_position.x = unnamed_addr constant i32 3 -@__foo_position.y = unnamed_addr constant i32 2 -@__bar_position.y = unnamed_addr constant i32 4 +@x = global i32 10, section "var-$RUSTY$x:i32" +@__foo_position.x = unnamed_addr constant i32 1, section "var-$RUSTY$x:e2i32" +@__bar_position.x = unnamed_addr constant i32 3, section "var-$RUSTY$x:e2i32" +@__foo_position.y = unnamed_addr constant i32 2, section "var-$RUSTY$y:e2i32" +@__bar_position.y = unnamed_addr constant i32 4, section "var-$RUSTY$y:e2i32" -define i32 @foo() section "fn-foo:i32" { +define i32 @foo() section "fn-$RUSTY$foo:i32" { entry: %foo = alloca i32, align 4 %position = alloca i32, align 4 @@ -21,7 +21,7 @@ entry: ret i32 %foo_ret } -define i32 @bar() section "fn-bar:i32" { +define i32 @bar() section "fn-$RUSTY$bar:i32" { entry: %bar = alloca i32, align 4 %position = alloca i32, align 4 diff --git a/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__pou_initializers__function_block_struct_initialized_in_function.snap b/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__pou_initializers__function_block_struct_initialized_in_function.snap index f4b32717b29..11945294438 100644 --- a/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__pou_initializers__function_block_struct_initialized_in_function.snap +++ b/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__pou_initializers__function_block_struct_initialized_in_function.snap @@ -8,15 +8,15 @@ source_filename = "main" %fb = type {} %main = type { %fb } -@__fb__init = unnamed_addr constant %fb zeroinitializer -@main_instance = global %main zeroinitializer +@__fb__init = unnamed_addr constant %fb zeroinitializer, section "var-$RUSTY$__fb__init:r0" +@main_instance = global %main zeroinitializer, section "var-$RUSTY$main_instance:r1r0" -define void @fb(%fb* %0) section "fn-fb:v" { +define void @fb(%fb* %0) section "fn-$RUSTY$fb:v" { entry: ret void } -define i32 @func(%fb* %0) section "fn-func:i32[v]" { +define i32 @func(%fb* %0) section "fn-$RUSTY$func:i32[r0]" { entry: %func = alloca i32, align 4 %in = alloca %fb, align 8 @@ -31,7 +31,7 @@ entry: ret i32 %func_ret } -define void @main(%main* %0) section "fn-main:v" { +define void @main(%main* %0) section "fn-$RUSTY$main:v" { entry: %fb0 = getelementptr inbounds %main, %main* %0, i32 0, i32 0 %call = call i32 @func(%fb* %fb0) diff --git a/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__pou_initializers__function_return_value_is_initialized.snap b/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__pou_initializers__function_return_value_is_initialized.snap index 8c46762849e..e51987ffe3b 100644 --- a/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__pou_initializers__function_return_value_is_initialized.snap +++ b/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__pou_initializers__function_return_value_is_initialized.snap @@ -7,9 +7,9 @@ source_filename = "main" %MyStruct = type { i32, i16 } -@__MyStruct__init = unnamed_addr constant %MyStruct zeroinitializer +@__MyStruct__init = unnamed_addr constant %MyStruct zeroinitializer, section "var-$RUSTY$__MyStruct__init:r2i32i16" -define i16 @foo_int() section "fn-foo_int:i16" { +define i16 @foo_int() section "fn-$RUSTY$foo_int:i16" { entry: %foo_int = alloca i16, align 2 store i16 0, i16* %foo_int, align 2 @@ -17,7 +17,7 @@ entry: ret i16 %foo_int_ret } -define void @foo_str([11 x i8]* %0) section "fn-foo_str:s8u11" { +define void @foo_str([11 x i8]* %0) section "fn-$RUSTY$foo_str:s8u11" { entry: %foo_str = alloca [11 x i8]*, align 8 store [11 x i8]* %0, [11 x i8]** %foo_str, align 8 @@ -27,7 +27,7 @@ entry: ret void } -define void @foo_arr([10 x float]* %0) section "fn-foo_arr:v" { +define void @foo_arr([10 x float]* %0) section "fn-$RUSTY$foo_arr:af32" { entry: %foo_arr = alloca [10 x float]*, align 8 store [10 x float]* %0, [10 x float]** %foo_arr, align 8 @@ -37,7 +37,7 @@ entry: ret void } -define void @foo_struct(%MyStruct* %0) section "fn-foo_struct:v" { +define void @foo_struct(%MyStruct* %0) section "fn-$RUSTY$foo_struct:r2i32i16" { entry: %foo_struct = alloca %MyStruct*, align 8 store %MyStruct* %0, %MyStruct** %foo_struct, align 8 diff --git a/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__pou_initializers__function_return_value_is_initialized_with_type_initializer.snap b/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__pou_initializers__function_return_value_is_initialized_with_type_initializer.snap index fd1ff02550b..28bcfce8cb2 100644 --- a/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__pou_initializers__function_return_value_is_initialized_with_type_initializer.snap +++ b/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__pou_initializers__function_return_value_is_initialized_with_type_initializer.snap @@ -7,10 +7,10 @@ source_filename = "main" %main = type { [4 x i32], [4 x i32] } -@main_instance = global %main zeroinitializer -@__myArray__init = unnamed_addr constant [4 x i32] [i32 1, i32 2, i32 3, i32 4] +@main_instance = global %main zeroinitializer, section "var-$RUSTY$main_instance:r2ai32ai32" +@__myArray__init = unnamed_addr constant [4 x i32] [i32 1, i32 2, i32 3, i32 4], section "var-$RUSTY$__myArray__init:ai32" -define void @target([4 x i32]* %0) section "fn-target:v" { +define void @target([4 x i32]* %0) section "fn-$RUSTY$target:ai32" { entry: %target = alloca [4 x i32]*, align 8 store [4 x i32]* %0, [4 x i32]** %target, align 8 @@ -23,7 +23,7 @@ entry: ret void } -define void @main(%main* %0) section "fn-main:v" { +define void @main(%main* %0) section "fn-$RUSTY$main:v" { entry: %x = getelementptr inbounds %main, %main* %0, i32 0, i32 0 %y = getelementptr inbounds %main, %main* %0, i32 0, i32 1 diff --git a/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__pou_initializers__function_return_value_with_initializers_is_initialized.snap b/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__pou_initializers__function_return_value_with_initializers_is_initialized.snap index 2c289792cbe..e0f38a2099c 100644 --- a/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__pou_initializers__function_return_value_with_initializers_is_initialized.snap +++ b/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__pou_initializers__function_return_value_with_initializers_is_initialized.snap @@ -7,11 +7,11 @@ source_filename = "main" %MyStrct = type { i32, i32, i32 } -@__MyStr__init = unnamed_addr constant [11 x i8] c"init\00\00\00\00\00\00\00" -@__MyArr__init = unnamed_addr constant [10 x float] [float 0.000000e+00, float 0x3FF19999A0000000, float 0x40019999A0000000, float 0x400A666660000000, float 0x40119999A0000000, float 5.500000e+00, float 0x401A666660000000, float 0x401ECCCCC0000000, float 0x40219999A0000000, float 0x4023CCCCC0000000] -@__MyStrct__init = unnamed_addr constant %MyStrct { i32 1, i32 2, i32 3 } +@__MyStr__init = unnamed_addr constant [11 x i8] c"init\00\00\00\00\00\00\00", section "var-$RUSTY$__MyStr__init:s8u11" +@__MyArr__init = unnamed_addr constant [10 x float] [float 0.000000e+00, float 0x3FF19999A0000000, float 0x40019999A0000000, float 0x400A666660000000, float 0x40119999A0000000, float 5.500000e+00, float 0x401A666660000000, float 0x401ECCCCC0000000, float 0x40219999A0000000, float 0x4023CCCCC0000000], section "var-$RUSTY$__MyArr__init:af32" +@__MyStrct__init = unnamed_addr constant %MyStrct { i32 1, i32 2, i32 3 }, section "var-$RUSTY$__MyStrct__init:r3i32i32i32" -define i16 @foo_int() section "fn-foo_int:v" { +define i16 @foo_int() section "fn-$RUSTY$foo_int:i16" { entry: %foo_int = alloca i16, align 2 store i16 7, i16* %foo_int, align 2 @@ -19,7 +19,7 @@ entry: ret i16 %foo_int_ret } -define void @foo_str([11 x i8]* %0) section "fn-foo_str:s8u11" { +define void @foo_str([11 x i8]* %0) section "fn-$RUSTY$foo_str:s8u11" { entry: %foo_str = alloca [11 x i8]*, align 8 store [11 x i8]* %0, [11 x i8]** %foo_str, align 8 @@ -29,7 +29,7 @@ entry: ret void } -define void @foo_arr([10 x float]* %0) section "fn-foo_arr:v" { +define void @foo_arr([10 x float]* %0) section "fn-$RUSTY$foo_arr:af32" { entry: %foo_arr = alloca [10 x float]*, align 8 store [10 x float]* %0, [10 x float]** %foo_arr, align 8 @@ -39,7 +39,7 @@ entry: ret void } -define void @foo_strct(%MyStrct* %0) section "fn-foo_strct:v" { +define void @foo_strct(%MyStrct* %0) section "fn-$RUSTY$foo_strct:r3i32i32i32" { entry: %foo_strct = alloca %MyStrct*, align 8 store %MyStrct* %0, %MyStrct** %foo_strct, align 8 diff --git a/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__pou_initializers__function_return_value_without_initializers_is_initialized.snap b/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__pou_initializers__function_return_value_without_initializers_is_initialized.snap index 13afea3c3c0..10285ac17ac 100644 --- a/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__pou_initializers__function_return_value_without_initializers_is_initialized.snap +++ b/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__pou_initializers__function_return_value_without_initializers_is_initialized.snap @@ -7,9 +7,9 @@ source_filename = "main" %MyStrct = type { i32, i32, i32 } -@__MyStrct__init = unnamed_addr constant %MyStrct zeroinitializer +@__MyStrct__init = unnamed_addr constant %MyStrct zeroinitializer, section "var-$RUSTY$__MyStrct__init:r3i32i32i32" -define i16 @foo_int() section "fn-foo_int:v" { +define i16 @foo_int() section "fn-$RUSTY$foo_int:i16" { entry: %foo_int = alloca i16, align 2 store i16 0, i16* %foo_int, align 2 @@ -17,7 +17,7 @@ entry: ret i16 %foo_int_ret } -define void @foo_str([11 x i8]* %0) section "fn-foo_str:s8u11" { +define void @foo_str([11 x i8]* %0) section "fn-$RUSTY$foo_str:s8u11" { entry: %foo_str = alloca [11 x i8]*, align 8 store [11 x i8]* %0, [11 x i8]** %foo_str, align 8 @@ -27,7 +27,7 @@ entry: ret void } -define void @foo_arr([10 x float]* %0) section "fn-foo_arr:v" { +define void @foo_arr([10 x float]* %0) section "fn-$RUSTY$foo_arr:af32" { entry: %foo_arr = alloca [10 x float]*, align 8 store [10 x float]* %0, [10 x float]** %foo_arr, align 8 @@ -37,7 +37,7 @@ entry: ret void } -define void @foo_strct(%MyStrct* %0) section "fn-foo_strct:v" { +define void @foo_strct(%MyStrct* %0) section "fn-$RUSTY$foo_strct:r3i32i32i32" { entry: %foo_strct = alloca %MyStrct*, align 8 store %MyStrct* %0, %MyStrct** %foo_strct, align 8 diff --git a/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__pou_initializers__initial_constant_values_in_pou_variables.snap b/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__pou_initializers__initial_constant_values_in_pou_variables.snap index ac5fadd160b..13df4890ba3 100644 --- a/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__pou_initializers__initial_constant_values_in_pou_variables.snap +++ b/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__pou_initializers__initial_constant_values_in_pou_variables.snap @@ -7,12 +7,12 @@ source_filename = "main" %prg = type { i16, i16 } -@MAX_LEN = unnamed_addr constant i16 99 -@MIN_LEN = unnamed_addr constant i16 10 -@LEN = unnamed_addr constant i16 20 -@prg_instance = global %prg { i16 24, i16 89 } +@MAX_LEN = unnamed_addr constant i16 99, section "var-$RUSTY$MAX_LEN:i16" +@MIN_LEN = unnamed_addr constant i16 10, section "var-$RUSTY$MIN_LEN:i16" +@LEN = unnamed_addr constant i16 20, section "var-$RUSTY$LEN:i16" +@prg_instance = global %prg { i16 24, i16 89 }, section "var-$RUSTY$prg_instance:r2i16i16" -define void @prg(%prg* %0) section "fn-prg:v[i16][i16]" { +define void @prg(%prg* %0) section "fn-$RUSTY$prg:v[i16][i16]" { entry: %my_len = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 %my_size = getelementptr inbounds %prg, %prg* %0, i32 0, i32 1 diff --git a/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__pou_initializers__initial_values_in_array_of_array_variable.snap b/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__pou_initializers__initial_values_in_array_of_array_variable.snap index d0331729c00..c1c90a67fad 100644 --- a/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__pou_initializers__initial_values_in_array_of_array_variable.snap +++ b/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__pou_initializers__initial_values_in_array_of_array_variable.snap @@ -1,10 +1,8 @@ --- source: src/codegen/tests/initialization_test/pou_initializers.rs expression: result - --- ; ModuleID = 'main' source_filename = "main" -@a = global [2 x [2 x i8]] [[2 x i8] c"\01\02", [2 x i8] c"\03\04"] - +@a = global [2 x [2 x i8]] [[2 x i8] c"\01\02", [2 x i8] c"\03\04"], section "var-$RUSTY$a:aau8" diff --git a/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__pou_initializers__initial_values_in_function_block_pou.snap b/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__pou_initializers__initial_values_in_function_block_pou.snap index a5929eb7d34..1e8c0d7672a 100644 --- a/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__pou_initializers__initial_values_in_function_block_pou.snap +++ b/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__pou_initializers__initial_values_in_function_block_pou.snap @@ -8,10 +8,10 @@ source_filename = "main" %FB = type { i16, i16, i8, i8, float, float } %main = type { %FB } -@__FB__init = unnamed_addr constant %FB { i16 7, i16 0, i8 1, i8 0, float 0x400921CAC0000000, float 0.000000e+00 } -@main_instance = global %main { %FB { i16 7, i16 0, i8 1, i8 0, float 0x400921CAC0000000, float 0.000000e+00 } } +@__FB__init = unnamed_addr constant %FB { i16 7, i16 0, i8 1, i8 0, float 0x400921CAC0000000, float 0.000000e+00 }, section "var-$RUSTY$__FB__init:r6i16i16u8u8f32f32" +@main_instance = global %main { %FB { i16 7, i16 0, i8 1, i8 0, float 0x400921CAC0000000, float 0.000000e+00 } }, section "var-$RUSTY$main_instance:r1r6i16i16u8u8f32f32" -define void @FB(%FB* %0) section "fn-FB:v" { +define void @FB(%FB* %0) section "fn-$RUSTY$FB:v" { entry: %x = getelementptr inbounds %FB, %FB* %0, i32 0, i32 0 %xx = getelementptr inbounds %FB, %FB* %0, i32 0, i32 1 @@ -22,7 +22,7 @@ entry: ret void } -define void @main(%main* %0) section "fn-main:v" { +define void @main(%main* %0) section "fn-$RUSTY$main:v" { entry: %fb = getelementptr inbounds %main, %main* %0, i32 0, i32 0 ret void diff --git a/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__pou_initializers__initial_values_in_program_pou.snap b/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__pou_initializers__initial_values_in_program_pou.snap index ff7c4eea8f6..321b004892a 100644 --- a/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__pou_initializers__initial_values_in_program_pou.snap +++ b/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__pou_initializers__initial_values_in_program_pou.snap @@ -7,9 +7,9 @@ source_filename = "main" %Main = type { i16, i16, i8, i8, float, float } -@Main_instance = global %Main { i16 7, i16 0, i8 1, i8 0, float 0x400921CAC0000000, float 0.000000e+00 } +@Main_instance = global %Main { i16 7, i16 0, i8 1, i8 0, float 0x400921CAC0000000, float 0.000000e+00 }, section "var-$RUSTY$Main_instance:r6i16i16u8u8f32f32" -define void @Main(%Main* %0) section "fn-Main:v" { +define void @Main(%Main* %0) section "fn-$RUSTY$Main:v" { entry: %x = getelementptr inbounds %Main, %Main* %0, i32 0, i32 0 %xx = getelementptr inbounds %Main, %Main* %0, i32 0, i32 1 diff --git a/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__pou_initializers__initialized_array_in_function.snap b/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__pou_initializers__initialized_array_in_function.snap index ef4b85fed7d..3e0e2de57e8 100644 --- a/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__pou_initializers__initialized_array_in_function.snap +++ b/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__pou_initializers__initialized_array_in_function.snap @@ -7,7 +7,7 @@ source_filename = "main" @__func.arr_var__init = unnamed_addr constant [4 x i32] [i32 1, i32 2, i32 3, i32 4] -define i16 @func() section "fn-func:i16" { +define i16 @func() section "fn-$RUSTY$func:i16" { entry: %func = alloca i16, align 2 %arr_var = alloca [4 x i32], align 4 diff --git a/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__pou_initializers__initialized_array_type_in_function.snap b/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__pou_initializers__initialized_array_type_in_function.snap index 180d254bf34..86a8ac76602 100644 --- a/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__pou_initializers__initialized_array_type_in_function.snap +++ b/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__pou_initializers__initialized_array_type_in_function.snap @@ -5,9 +5,9 @@ expression: result ; ModuleID = 'main' source_filename = "main" -@__arr__init = unnamed_addr constant [4 x i32] [i32 1, i32 2, i32 3, i32 4] +@__arr__init = unnamed_addr constant [4 x i32] [i32 1, i32 2, i32 3, i32 4], section "var-$RUSTY$__arr__init:ai32" -define i16 @func() section "fn-func:i16" { +define i16 @func() section "fn-$RUSTY$func:i16" { entry: %func = alloca i16, align 2 %arr_var = alloca [4 x i32], align 4 diff --git a/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__pou_initializers__memcpy_for_struct_initialization_in_function.snap b/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__pou_initializers__memcpy_for_struct_initialization_in_function.snap index 966bd9624c9..8580832c54d 100644 --- a/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__pou_initializers__memcpy_for_struct_initialization_in_function.snap +++ b/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__pou_initializers__memcpy_for_struct_initialization_in_function.snap @@ -7,9 +7,9 @@ source_filename = "main" %__func_a = type { i16 } -@____func_a__init = unnamed_addr constant %__func_a zeroinitializer +@____func_a__init = unnamed_addr constant %__func_a zeroinitializer, section "var-$RUSTY$____func_a__init:r1i16" -define i16 @func() section "fn-func:i16" { +define i16 @func() section "fn-$RUSTY$func:i16" { entry: %func = alloca i16, align 2 %a = alloca %__func_a, align 8 diff --git a/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__pou_initializers__no_memcpy_for_struct_initialization_in_program.snap b/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__pou_initializers__no_memcpy_for_struct_initialization_in_program.snap index fdd64024ee7..56554b9271e 100644 --- a/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__pou_initializers__no_memcpy_for_struct_initialization_in_program.snap +++ b/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__pou_initializers__no_memcpy_for_struct_initialization_in_program.snap @@ -8,10 +8,10 @@ source_filename = "main" %prog = type { %__prog_a } %__prog_a = type { i16 } -@prog_instance = global %prog zeroinitializer -@____prog_a__init = unnamed_addr constant %__prog_a zeroinitializer +@prog_instance = global %prog zeroinitializer, section "var-$RUSTY$prog_instance:r1r1i16" +@____prog_a__init = unnamed_addr constant %__prog_a zeroinitializer, section "var-$RUSTY$____prog_a__init:r1i16" -define void @prog(%prog* %0) section "fn-prog:v" { +define void @prog(%prog* %0) section "fn-$RUSTY$prog:v" { entry: %a = getelementptr inbounds %prog, %prog* %0, i32 0, i32 0 ret void diff --git a/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__pou_initializers__two_identical_enums_in_different_functions_are_referenced_correctly.snap b/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__pou_initializers__two_identical_enums_in_different_functions_are_referenced_correctly.snap index f29cc3f334e..0b39ed7cff4 100644 --- a/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__pou_initializers__two_identical_enums_in_different_functions_are_referenced_correctly.snap +++ b/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__pou_initializers__two_identical_enums_in_different_functions_are_referenced_correctly.snap @@ -5,12 +5,12 @@ expression: function ; ModuleID = 'main' source_filename = "main" -@__foo_position.x = unnamed_addr constant i32 1 -@__bar_position.x = unnamed_addr constant i32 3 -@__foo_position.y = unnamed_addr constant i32 2 -@__bar_position.y = unnamed_addr constant i32 4 +@__foo_position.x = unnamed_addr constant i32 1, section "var-$RUSTY$x:e2i32" +@__bar_position.x = unnamed_addr constant i32 3, section "var-$RUSTY$x:e2i32" +@__foo_position.y = unnamed_addr constant i32 2, section "var-$RUSTY$y:e2i32" +@__bar_position.y = unnamed_addr constant i32 4, section "var-$RUSTY$y:e2i32" -define i32 @foo() section "fn-foo:i32" { +define i32 @foo() section "fn-$RUSTY$foo:i32" { entry: %foo = alloca i32, align 4 %position = alloca i32, align 4 @@ -20,7 +20,7 @@ entry: ret i32 %foo_ret } -define i32 @bar() section "fn-bar:i32" { +define i32 @bar() section "fn-$RUSTY$bar:i32" { entry: %bar = alloca i32, align 4 %position = alloca i32, align 4 diff --git a/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__pou_initializers__two_identical_enums_in_different_functions_with_similar_names_are_referenced_correctly.snap b/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__pou_initializers__two_identical_enums_in_different_functions_with_similar_names_are_referenced_correctly.snap index 4e12913c16d..909a6194e5b 100644 --- a/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__pou_initializers__two_identical_enums_in_different_functions_with_similar_names_are_referenced_correctly.snap +++ b/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__pou_initializers__two_identical_enums_in_different_functions_with_similar_names_are_referenced_correctly.snap @@ -5,16 +5,16 @@ expression: function ; ModuleID = 'main' source_filename = "main" -@__a_position.x = unnamed_addr constant i32 1 -@__aa_position.x = unnamed_addr constant i32 2 -@__bb_position.x = unnamed_addr constant i32 3 -@__b_position.x = unnamed_addr constant i32 4 -@__a_position.y = unnamed_addr constant i32 5 -@__aa_position.y = unnamed_addr constant i32 5 -@__bb_position.y = unnamed_addr constant i32 5 -@__b_position.y = unnamed_addr constant i32 5 +@__a_position.x = unnamed_addr constant i32 1, section "var-$RUSTY$x:e2i32" +@__aa_position.x = unnamed_addr constant i32 2, section "var-$RUSTY$x:e2i32" +@__bb_position.x = unnamed_addr constant i32 3, section "var-$RUSTY$x:e2i32" +@__b_position.x = unnamed_addr constant i32 4, section "var-$RUSTY$x:e2i32" +@__a_position.y = unnamed_addr constant i32 5, section "var-$RUSTY$y:e2i32" +@__aa_position.y = unnamed_addr constant i32 5, section "var-$RUSTY$y:e2i32" +@__bb_position.y = unnamed_addr constant i32 5, section "var-$RUSTY$y:e2i32" +@__b_position.y = unnamed_addr constant i32 5, section "var-$RUSTY$y:e2i32" -define i32 @a() section "fn-a:i32" { +define i32 @a() section "fn-$RUSTY$a:i32" { entry: %a = alloca i32, align 4 %position = alloca i32, align 4 @@ -24,7 +24,7 @@ entry: ret i32 %a_ret } -define i32 @aa() section "fn-aa:i32" { +define i32 @aa() section "fn-$RUSTY$aa:i32" { entry: %aa = alloca i32, align 4 %position = alloca i32, align 4 @@ -34,7 +34,7 @@ entry: ret i32 %aa_ret } -define i32 @bb() section "fn-bb:i32" { +define i32 @bb() section "fn-$RUSTY$bb:i32" { entry: %bb = alloca i32, align 4 %position = alloca i32, align 4 @@ -44,7 +44,7 @@ entry: ret i32 %bb_ret } -define i32 @b() section "fn-b:i32" { +define i32 @b() section "fn-$RUSTY$b:i32" { entry: %b = alloca i32, align 4 %position = alloca i32, align 4 diff --git a/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__type_initializers__alias_chain_with_lots_of_initializers.snap b/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__type_initializers__alias_chain_with_lots_of_initializers.snap index 02b7546bc92..fc6e1924b42 100644 --- a/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__type_initializers__alias_chain_with_lots_of_initializers.snap +++ b/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__type_initializers__alias_chain_with_lots_of_initializers.snap @@ -1,13 +1,11 @@ --- source: src/codegen/tests/initialization_test/type_initializers.rs expression: result - --- ; ModuleID = 'main' source_filename = "main" -@x0 = global i32 1 -@x1 = global i32 1 -@x2 = global i32 2 -@x3 = global i32 3 - +@x0 = global i32 1, section "var-$RUSTY$x0:i32" +@x1 = global i32 1, section "var-$RUSTY$x1:i32" +@x2 = global i32 2, section "var-$RUSTY$x2:i32" +@x3 = global i32 3, section "var-$RUSTY$x3:i32" diff --git a/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__type_initializers__array_of_struct_initialization.snap b/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__type_initializers__array_of_struct_initialization.snap index c43b1a1b00d..bcdff271ea4 100644 --- a/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__type_initializers__array_of_struct_initialization.snap +++ b/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__type_initializers__array_of_struct_initialization.snap @@ -8,15 +8,15 @@ source_filename = "main" %myStruct = type { i32, i32, [2 x i32] } %main = type { [2 x %myStruct], [2 x %myStruct] } -@str = unnamed_addr constant %myStruct { i32 50, i32 60, [2 x i32] [i32 70, i32 80] } -@__myStruct__init = unnamed_addr constant %myStruct zeroinitializer -@alias_str = unnamed_addr constant %myStruct { i32 50, i32 60, [2 x i32] [i32 70, i32 80] } -@global_arr = unnamed_addr constant [2 x i32] [i32 30, i32 40] -@main_instance = global %main { [2 x %myStruct] [%myStruct { i32 10, i32 20, [2 x i32] [i32 30, i32 40] }, %myStruct { i32 50, i32 60, [2 x i32] [i32 70, i32 80] }], [2 x %myStruct] [%myStruct { i32 10, i32 20, [2 x i32] [i32 30, i32 40] }, %myStruct { i32 50, i32 60, [2 x i32] [i32 70, i32 80] }] } +@str = unnamed_addr constant %myStruct { i32 50, i32 60, [2 x i32] [i32 70, i32 80] }, section "var-$RUSTY$str:r3i32i32ai32" +@__myStruct__init = unnamed_addr constant %myStruct zeroinitializer, section "var-$RUSTY$__myStruct__init:r3i32i32ai32" +@alias_str = unnamed_addr constant %myStruct { i32 50, i32 60, [2 x i32] [i32 70, i32 80] }, section "var-$RUSTY$alias_str:r3i32i32ai32" +@global_arr = unnamed_addr constant [2 x i32] [i32 30, i32 40], section "var-$RUSTY$global_arr:ai32" +@main_instance = global %main { [2 x %myStruct] [%myStruct { i32 10, i32 20, [2 x i32] [i32 30, i32 40] }, %myStruct { i32 50, i32 60, [2 x i32] [i32 70, i32 80] }], [2 x %myStruct] [%myStruct { i32 10, i32 20, [2 x i32] [i32 30, i32 40] }, %myStruct { i32 50, i32 60, [2 x i32] [i32 70, i32 80] }] }, section "var-$RUSTY$main_instance:r2ar3i32i32ai32ar3i32i32ai32" @__main.arr__init = unnamed_addr constant [2 x %myStruct] [%myStruct { i32 10, i32 20, [2 x i32] [i32 30, i32 40] }, %myStruct { i32 50, i32 60, [2 x i32] [i32 70, i32 80] }] @__main.alias_arr__init = unnamed_addr constant [2 x %myStruct] [%myStruct { i32 10, i32 20, [2 x i32] [i32 30, i32 40] }, %myStruct { i32 50, i32 60, [2 x i32] [i32 70, i32 80] }] -define void @main(%main* %0) section "fn-main:v" { +define void @main(%main* %0) section "fn-$RUSTY$main:v" { entry: %arr = getelementptr inbounds %main, %main* %0, i32 0, i32 0 %alias_arr = getelementptr inbounds %main, %main* %0, i32 0, i32 1 diff --git a/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__type_initializers__complex_initial_values_in_struct_variable_using_multiplied_statement.snap b/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__type_initializers__complex_initial_values_in_struct_variable_using_multiplied_statement.snap index e20ef73b71c..c2a03ab1ec6 100644 --- a/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__type_initializers__complex_initial_values_in_struct_variable_using_multiplied_statement.snap +++ b/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__type_initializers__complex_initial_values_in_struct_variable_using_multiplied_statement.snap @@ -8,7 +8,6 @@ source_filename = "main" %MyStruct = type { %MyPoint, [4 x i16], i32 } %MyPoint = type { i32, i32 } -@a = global %MyStruct { %MyPoint { i32 1, i32 2 }, [4 x i16] [i16 0, i16 1, i16 2, i16 3], i32 7 } -@__MyStruct__init = unnamed_addr constant %MyStruct zeroinitializer -@__MyPoint__init = unnamed_addr constant %MyPoint zeroinitializer - +@a = global %MyStruct { %MyPoint { i32 1, i32 2 }, [4 x i16] [i16 0, i16 1, i16 2, i16 3], i32 7 }, section "var-$RUSTY$a:r3r2i32i32ai16i32" +@__MyStruct__init = unnamed_addr constant %MyStruct zeroinitializer, section "var-$RUSTY$__MyStruct__init:r3r2i32i32ai16i32" +@__MyPoint__init = unnamed_addr constant %MyPoint zeroinitializer, section "var-$RUSTY$__MyPoint__init:r2i32i32" diff --git a/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__type_initializers__enums_with_inline_initializer_are_initialized.snap b/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__type_initializers__enums_with_inline_initializer_are_initialized.snap index 54a43a74669..ae268a9d1b6 100644 --- a/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__type_initializers__enums_with_inline_initializer_are_initialized.snap +++ b/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__type_initializers__enums_with_inline_initializer_are_initialized.snap @@ -5,23 +5,23 @@ expression: res ; ModuleID = 'main' source_filename = "main" -@x = global i32 2 -@__main_var1.x1 = unnamed_addr constant i32 1 -@__main_var2.x7 = unnamed_addr constant i32 2 -@__global_x.yellow = unnamed_addr constant i32 1 -@__main_y.redy = unnamed_addr constant i32 1 -@__main_y.yellowy = unnamed_addr constant i32 2 -@__main_y.greeny = unnamed_addr constant i32 3 -@__main_var1.x2 = unnamed_addr constant i32 2 -@__main_var1.x3 = unnamed_addr constant i32 3 -@__main_var2.x5 = unnamed_addr constant i32 0 -@__main_var2.x6 = unnamed_addr constant i32 1 -@__main_var3.x8 = unnamed_addr constant i32 0 -@__main_var3.x9 = unnamed_addr constant i32 1 -@__global_x.red = unnamed_addr constant i32 0 -@__global_x.green = unnamed_addr constant i32 2 +@x = global i32 2, section "var-$RUSTY$x:e3i32" +@__main_var1.x1 = unnamed_addr constant i32 1, section "var-$RUSTY$x1:e3i32" +@__main_var2.x7 = unnamed_addr constant i32 2, section "var-$RUSTY$x7:e3i32" +@__global_x.yellow = unnamed_addr constant i32 1, section "var-$RUSTY$yellow:e3i32" +@__main_y.redy = unnamed_addr constant i32 1, section "var-$RUSTY$redy:e3i32" +@__main_y.yellowy = unnamed_addr constant i32 2, section "var-$RUSTY$yellowy:e3i32" +@__main_y.greeny = unnamed_addr constant i32 3, section "var-$RUSTY$greeny:e3i32" +@__main_var1.x2 = unnamed_addr constant i32 2, section "var-$RUSTY$x2:e3i32" +@__main_var1.x3 = unnamed_addr constant i32 3, section "var-$RUSTY$x3:e3i32" +@__main_var2.x5 = unnamed_addr constant i32 0, section "var-$RUSTY$x5:e3i32" +@__main_var2.x6 = unnamed_addr constant i32 1, section "var-$RUSTY$x6:e3i32" +@__main_var3.x8 = unnamed_addr constant i32 0, section "var-$RUSTY$x8:e2i32" +@__main_var3.x9 = unnamed_addr constant i32 1, section "var-$RUSTY$x9:e2i32" +@__global_x.red = unnamed_addr constant i32 0, section "var-$RUSTY$red:e3i32" +@__global_x.green = unnamed_addr constant i32 2, section "var-$RUSTY$green:e3i32" -define i32 @main() section "fn-main:i32" { +define i32 @main() section "fn-$RUSTY$main:i32" { entry: %main = alloca i32, align 4 %y = alloca i32, align 4 diff --git a/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__type_initializers__expression_list_as_array_initilization.snap b/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__type_initializers__expression_list_as_array_initilization.snap index dd18222fa13..824ad9c5e10 100644 --- a/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__type_initializers__expression_list_as_array_initilization.snap +++ b/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__type_initializers__expression_list_as_array_initilization.snap @@ -1,13 +1,10 @@ --- source: src/codegen/tests/initialization_test/type_initializers.rs -assertion_line: 93 expression: result - --- ; ModuleID = 'main' source_filename = "main" -@arr = global [5 x i16] [i16 1, i16 2, i16 3, i16 0, i16 0] -@b_exp = global [6 x i32] [i32 4, i32 6, i32 6, i32 10, i32 0, i32 0] -@str = global [4 x [81 x i8]] [[81 x i8] c"first\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00", [81 x i8] c"second\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00", [81 x i8] zeroinitializer, [81 x i8] zeroinitializer] - +@arr = global [5 x i16] [i16 1, i16 2, i16 3, i16 0, i16 0], section "var-$RUSTY$arr:ai16" +@b_exp = global [6 x i32] [i32 4, i32 6, i32 6, i32 10, i32 0, i32 0], section "var-$RUSTY$b_exp:ai32" +@str = global [4 x [81 x i8]] [[81 x i8] c"first\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00", [81 x i8] c"second\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00", [81 x i8] zeroinitializer, [81 x i8] zeroinitializer], section "var-$RUSTY$str:as8u81" diff --git a/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__type_initializers__incomplete_array_initialization.snap b/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__type_initializers__incomplete_array_initialization.snap index 584be447f36..021515d7fda 100644 --- a/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__type_initializers__incomplete_array_initialization.snap +++ b/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__type_initializers__incomplete_array_initialization.snap @@ -1,11 +1,8 @@ --- source: src/codegen/tests/initialization_test/type_initializers.rs -assertion_line: 105 expression: result - --- ; ModuleID = 'main' source_filename = "main" -@arr = global [6 x i16] [i16 0, i16 1, i16 2, i16 0, i16 0, i16 0] - +@arr = global [6 x i16] [i16 0, i16 1, i16 2, i16 0, i16 0, i16 0], section "var-$RUSTY$arr:ai16" diff --git a/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__type_initializers__incomplete_array_initialization_with_custom_init_value.snap b/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__type_initializers__incomplete_array_initialization_with_custom_init_value.snap index 66951c1e73b..a6cbce9a07b 100644 --- a/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__type_initializers__incomplete_array_initialization_with_custom_init_value.snap +++ b/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__type_initializers__incomplete_array_initialization_with_custom_init_value.snap @@ -1,11 +1,8 @@ --- source: src/codegen/tests/initialization_test/type_initializers.rs -assertion_line: 119 expression: result - --- ; ModuleID = 'main' source_filename = "main" -@arr = global [6 x i16] [i16 0, i16 1, i16 2, i16 7, i16 7, i16 7] - +@arr = global [6 x i16] [i16 0, i16 1, i16 2, i16 7, i16 7, i16 7], section "var-$RUSTY$arr:ai16" diff --git a/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__type_initializers__initial_nested_struct_delayed_init.snap b/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__type_initializers__initial_nested_struct_delayed_init.snap index 2e399090e9b..aac646fb3fa 100644 --- a/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__type_initializers__initial_nested_struct_delayed_init.snap +++ b/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__type_initializers__initial_nested_struct_delayed_init.snap @@ -8,8 +8,7 @@ source_filename = "main" %MyStruct2 = type { %MyStruct, %MyStruct } %MyStruct = type { i32, i32 } -@a = global %MyStruct2 { %MyStruct { i32 5, i32 7 }, %MyStruct { i32 3, i32 2 } } -@__MyStruct2__init = unnamed_addr constant %MyStruct2 { %MyStruct { i32 5, i32 3 }, %MyStruct { i32 0, i32 7 } } -@__MyStruct__init = unnamed_addr constant %MyStruct zeroinitializer -@b = global %MyStruct2 { %MyStruct { i32 5, i32 3 }, %MyStruct { i32 9, i32 0 } } - +@a = global %MyStruct2 { %MyStruct { i32 5, i32 7 }, %MyStruct { i32 3, i32 2 } }, section "var-$RUSTY$a:r2r2i32i32r2i32i32" +@__MyStruct2__init = unnamed_addr constant %MyStruct2 { %MyStruct { i32 5, i32 3 }, %MyStruct { i32 0, i32 7 } }, section "var-$RUSTY$__MyStruct2__init:r2r2i32i32r2i32i32" +@__MyStruct__init = unnamed_addr constant %MyStruct zeroinitializer, section "var-$RUSTY$__MyStruct__init:r2i32i32" +@b = global %MyStruct2 { %MyStruct { i32 5, i32 3 }, %MyStruct { i32 9, i32 0 } }, section "var-$RUSTY$b:r2r2i32i32r2i32i32" diff --git a/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__type_initializers__initial_values_in_array_variable_using_multiplied_statement.snap b/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__type_initializers__initial_values_in_array_variable_using_multiplied_statement.snap index bb1bd1833f4..86bc9db0b6e 100644 --- a/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__type_initializers__initial_values_in_array_variable_using_multiplied_statement.snap +++ b/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__type_initializers__initial_values_in_array_variable_using_multiplied_statement.snap @@ -1,13 +1,11 @@ --- source: src/codegen/tests/initialization_test/type_initializers.rs expression: result - --- ; ModuleID = 'main' source_filename = "main" -@a = global [4 x i8] c"\07\07\07\07" -@b = global [4 x i8] c"\02\07\07\03" -@c = global [10 x i8] c"\00\01\00\01\00\01\00\01\00\01" -@d = global [10 x i8] c"\00\00\01\01\02\00\00\01\01\02" - +@a = global [4 x i8] c"\07\07\07\07", section "var-$RUSTY$a:au8" +@b = global [4 x i8] c"\02\07\07\03", section "var-$RUSTY$b:au8" +@c = global [10 x i8] c"\00\01\00\01\00\01\00\01\00\01", section "var-$RUSTY$c:au8" +@d = global [10 x i8] c"\00\00\01\01\02\00\00\01\01\02", section "var-$RUSTY$d:au8" diff --git a/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__type_initializers__initial_values_in_fb_variable.snap b/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__type_initializers__initial_values_in_fb_variable.snap index c1d76999b91..7765eaf2090 100644 --- a/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__type_initializers__initial_values_in_fb_variable.snap +++ b/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__type_initializers__initial_values_in_fb_variable.snap @@ -8,19 +8,19 @@ source_filename = "main" %TON = type { i16, i16 } %main = type { i16, %TON, %TON } -@__TON__init = unnamed_addr constant %TON zeroinitializer -@main_instance = global %main { i16 10, %TON { i16 10, i16 17 }, %TON { i16 17, i16 10 } } +@__TON__init = unnamed_addr constant %TON zeroinitializer, section "var-$RUSTY$__TON__init:r2i16i16" +@main_instance = global %main { i16 10, %TON { i16 10, i16 17 }, %TON { i16 17, i16 10 } }, section "var-$RUSTY$main_instance:r3i16r2i16i16r2i16i16" @__main.struct1__init = unnamed_addr constant %TON { i16 10, i16 17 } @__main.struct2__init = unnamed_addr constant %TON { i16 17, i16 10 } -define void @TON(%TON* %0) section "fn-TON:v[i16][i16]" { +define void @TON(%TON* %0) section "fn-$RUSTY$TON:v[i16][i16]" { entry: %a = getelementptr inbounds %TON, %TON* %0, i32 0, i32 0 %b = getelementptr inbounds %TON, %TON* %0, i32 0, i32 1 ret void } -define void @main(%main* %0) section "fn-main:v" { +define void @main(%main* %0) section "fn-$RUSTY$main:v" { entry: %TEN = getelementptr inbounds %main, %main* %0, i32 0, i32 0 %struct1 = getelementptr inbounds %main, %main* %0, i32 0, i32 1 diff --git a/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__type_initializers__initial_values_in_multi_dimension_array_variable.snap b/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__type_initializers__initial_values_in_multi_dimension_array_variable.snap index 0f3864ac7c5..af8103d09fc 100644 --- a/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__type_initializers__initial_values_in_multi_dimension_array_variable.snap +++ b/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__type_initializers__initial_values_in_multi_dimension_array_variable.snap @@ -1,11 +1,8 @@ --- source: src/codegen/tests/initialization_test/type_initializers.rs -assertion_line: 158 expression: result - --- ; ModuleID = 'main' source_filename = "main" -@a = global [4 x i8] c"\01\02\03\04" - +@a = global [4 x i8] c"\01\02\03\04", section "var-$RUSTY$a:au8" diff --git a/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__type_initializers__initial_values_in_single_dimension_array_type.snap b/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__type_initializers__initial_values_in_single_dimension_array_type.snap index efe72cb3123..315a178dbbe 100644 --- a/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__type_initializers__initial_values_in_single_dimension_array_type.snap +++ b/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__type_initializers__initial_values_in_single_dimension_array_type.snap @@ -5,6 +5,5 @@ expression: result ; ModuleID = 'main' source_filename = "main" -@x = global [3 x i16] [i16 1, i16 2, i16 3] -@__MyArray__init = unnamed_addr constant [3 x i16] [i16 1, i16 2, i16 3] - +@x = global [3 x i16] [i16 1, i16 2, i16 3], section "var-$RUSTY$x:ai16" +@__MyArray__init = unnamed_addr constant [3 x i16] [i16 1, i16 2, i16 3], section "var-$RUSTY$__MyArray__init:ai16" diff --git a/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__type_initializers__initial_values_in_single_dimension_array_variable.snap b/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__type_initializers__initial_values_in_single_dimension_array_variable.snap index 387927ce958..11a1256f4eb 100644 --- a/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__type_initializers__initial_values_in_single_dimension_array_variable.snap +++ b/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__type_initializers__initial_values_in_single_dimension_array_variable.snap @@ -1,18 +1,15 @@ --- source: src/codegen/tests/initialization_test/type_initializers.rs -assertion_line: 159 expression: result - --- ; ModuleID = 'main' source_filename = "main" -@a = global [3 x i8] c"\01\02\03" -@b = global [3 x i16] [i16 1, i16 2, i16 3] -@c = global [3 x i32] [i32 1, i32 2, i32 3] -@d = global [3 x i64] [i64 1, i64 2, i64 3] -@e = global [3 x i8] c"\01\02\03" -@f = global [3 x i16] [i16 1, i16 2, i16 3] -@g = global [3 x i64] [i64 1, i64 2, i64 3] -@h = global [3 x i8] [i8 true, i8 false, i8 true] - +@a = global [3 x i8] c"\01\02\03", section "var-$RUSTY$a:ai8" +@b = global [3 x i16] [i16 1, i16 2, i16 3], section "var-$RUSTY$b:ai16" +@c = global [3 x i32] [i32 1, i32 2, i32 3], section "var-$RUSTY$c:ai32" +@d = global [3 x i64] [i64 1, i64 2, i64 3], section "var-$RUSTY$d:ai64" +@e = global [3 x i8] c"\01\02\03", section "var-$RUSTY$e:au8" +@f = global [3 x i16] [i16 1, i16 2, i16 3], section "var-$RUSTY$f:au16" +@g = global [3 x i64] [i64 1, i64 2, i64 3], section "var-$RUSTY$g:au64" +@h = global [3 x i8] [i8 true, i8 false, i8 true], section "var-$RUSTY$h:au8" diff --git a/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__type_initializers__initial_values_in_struct_types.snap b/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__type_initializers__initial_values_in_struct_types.snap index 4371c8d7e68..08cd394f44c 100644 --- a/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__type_initializers__initial_values_in_struct_types.snap +++ b/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__type_initializers__initial_values_in_struct_types.snap @@ -7,6 +7,5 @@ source_filename = "main" %MyStruct = type { i16, i16, i8, i8, float, float } -@x = global %MyStruct { i16 7, i16 0, i8 1, i8 0, float 0x400921CAC0000000, float 0.000000e+00 } -@__MyStruct__init = unnamed_addr constant %MyStruct { i16 7, i16 0, i8 1, i8 0, float 0x400921CAC0000000, float 0.000000e+00 } - +@x = global %MyStruct { i16 7, i16 0, i8 1, i8 0, float 0x400921CAC0000000, float 0.000000e+00 }, section "var-$RUSTY$x:r6i16i16u8u8f32f32" +@__MyStruct__init = unnamed_addr constant %MyStruct { i16 7, i16 0, i8 1, i8 0, float 0x400921CAC0000000, float 0.000000e+00 }, section "var-$RUSTY$__MyStruct__init:r6i16i16u8u8f32f32" diff --git a/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__type_initializers__initial_values_in_struct_variable.snap b/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__type_initializers__initial_values_in_struct_variable.snap index bf4180e4390..81b708c0b7c 100644 --- a/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__type_initializers__initial_values_in_struct_variable.snap +++ b/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__type_initializers__initial_values_in_struct_variable.snap @@ -7,7 +7,6 @@ source_filename = "main" %MyStruct = type { i32, i32 } -@a = global %MyStruct { i32 3, i32 5 } -@__MyStruct__init = unnamed_addr constant %MyStruct zeroinitializer -@b = global %MyStruct { i32 5, i32 3 } - +@a = global %MyStruct { i32 3, i32 5 }, section "var-$RUSTY$a:r2i32i32" +@__MyStruct__init = unnamed_addr constant %MyStruct zeroinitializer, section "var-$RUSTY$__MyStruct__init:r2i32i32" +@b = global %MyStruct { i32 5, i32 3 }, section "var-$RUSTY$b:r2i32i32" diff --git a/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__type_initializers__initial_values_in_struct_variable_missing_init.snap b/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__type_initializers__initial_values_in_struct_variable_missing_init.snap index efd2696cdd4..1af6b57f9ac 100644 --- a/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__type_initializers__initial_values_in_struct_variable_missing_init.snap +++ b/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__type_initializers__initial_values_in_struct_variable_missing_init.snap @@ -7,7 +7,6 @@ source_filename = "main" %MyStruct = type { i32, i32, i32 } -@a = global %MyStruct { i32 5, i32 0, i32 10 } -@__MyStruct__init = unnamed_addr constant %MyStruct zeroinitializer -@b = global %MyStruct { i32 0, i32 3, i32 10 } - +@a = global %MyStruct { i32 5, i32 0, i32 10 }, section "var-$RUSTY$a:r3i32i32i32" +@__MyStruct__init = unnamed_addr constant %MyStruct zeroinitializer, section "var-$RUSTY$__MyStruct__init:r3i32i32i32" +@b = global %MyStruct { i32 0, i32 3, i32 10 }, section "var-$RUSTY$b:r3i32i32i32" diff --git a/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__type_initializers__initial_values_in_sub_range_type.snap b/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__type_initializers__initial_values_in_sub_range_type.snap index f41b371bc40..19e4368276a 100644 --- a/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__type_initializers__initial_values_in_sub_range_type.snap +++ b/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__type_initializers__initial_values_in_sub_range_type.snap @@ -1,10 +1,8 @@ --- source: src/codegen/tests/initialization_test/type_initializers.rs expression: result - --- ; ModuleID = 'main' source_filename = "main" -@x = global i16 7 - +@x = global i16 7, section "var-$RUSTY$x:i16" diff --git a/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__type_initializers__initial_values_in_type_alias.snap b/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__type_initializers__initial_values_in_type_alias.snap index f41b371bc40..19e4368276a 100644 --- a/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__type_initializers__initial_values_in_type_alias.snap +++ b/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__type_initializers__initial_values_in_type_alias.snap @@ -1,10 +1,8 @@ --- source: src/codegen/tests/initialization_test/type_initializers.rs expression: result - --- ; ModuleID = 'main' source_filename = "main" -@x = global i16 7 - +@x = global i16 7, section "var-$RUSTY$x:i16" diff --git a/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__type_initializers__partly_uninitialized_const_struct_will_get_default_values.snap b/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__type_initializers__partly_uninitialized_const_struct_will_get_default_values.snap index 5085a5dbb3c..7f537a59618 100644 --- a/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__type_initializers__partly_uninitialized_const_struct_will_get_default_values.snap +++ b/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__type_initializers__partly_uninitialized_const_struct_will_get_default_values.snap @@ -7,7 +7,6 @@ source_filename = "main" %Point = type { i32, i32, i32 } -@x = unnamed_addr constant %Point { i32 1, i32 2, i32 3 } -@__Point__init = unnamed_addr constant %Point { i32 0, i32 2, i32 3 } -@empty = unnamed_addr constant %Point { i32 0, i32 2, i32 3 } - +@x = unnamed_addr constant %Point { i32 1, i32 2, i32 3 }, section "var-$RUSTY$x:r3i32i32i32" +@__Point__init = unnamed_addr constant %Point { i32 0, i32 2, i32 3 }, section "var-$RUSTY$__Point__init:r3i32i32i32" +@empty = unnamed_addr constant %Point { i32 0, i32 2, i32 3 }, section "var-$RUSTY$empty:r3i32i32i32" diff --git a/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__type_initializers__skipped_field_members_for_array_of_structs_are_zero_initialized.snap b/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__type_initializers__skipped_field_members_for_array_of_structs_are_zero_initialized.snap index ed8acdc1818..46b624c2e8f 100644 --- a/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__type_initializers__skipped_field_members_for_array_of_structs_are_zero_initialized.snap +++ b/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__type_initializers__skipped_field_members_for_array_of_structs_are_zero_initialized.snap @@ -9,12 +9,12 @@ source_filename = "main" %STRUCT1 = type { i32, [2 x %STRUCT2] } %STRUCT2 = type { i32, i32 } -@main_instance = global %main { [3 x %STRUCT1] [%STRUCT1 { i32 0, [2 x %STRUCT2] [%STRUCT2 { i32 1, i32 0 }, %STRUCT2 zeroinitializer] }, %STRUCT1 { i32 2, [2 x %STRUCT2] [%STRUCT2 { i32 1, i32 1 }, %STRUCT2 zeroinitializer] }, %STRUCT1 { i32 1, [2 x %STRUCT2] [%STRUCT2 { i32 1, i32 0 }, %STRUCT2 { i32 0, i32 2 }] }] } -@__STRUCT1__init = unnamed_addr constant %STRUCT1 zeroinitializer -@__STRUCT2__init = unnamed_addr constant %STRUCT2 zeroinitializer +@main_instance = global %main { [3 x %STRUCT1] [%STRUCT1 { i32 0, [2 x %STRUCT2] [%STRUCT2 { i32 1, i32 0 }, %STRUCT2 zeroinitializer] }, %STRUCT1 { i32 2, [2 x %STRUCT2] [%STRUCT2 { i32 1, i32 1 }, %STRUCT2 zeroinitializer] }, %STRUCT1 { i32 1, [2 x %STRUCT2] [%STRUCT2 { i32 1, i32 0 }, %STRUCT2 { i32 0, i32 2 }] }] }, section "var-$RUSTY$main_instance:r1ar2i32ar2i32i32" +@__STRUCT1__init = unnamed_addr constant %STRUCT1 zeroinitializer, section "var-$RUSTY$__STRUCT1__init:r2i32ar2i32i32" +@__STRUCT2__init = unnamed_addr constant %STRUCT2 zeroinitializer, section "var-$RUSTY$__STRUCT2__init:r2i32i32" @__main.var_init1__init = unnamed_addr constant [3 x %STRUCT1] [%STRUCT1 { i32 0, [2 x %STRUCT2] [%STRUCT2 { i32 1, i32 0 }, %STRUCT2 zeroinitializer] }, %STRUCT1 { i32 2, [2 x %STRUCT2] [%STRUCT2 { i32 1, i32 1 }, %STRUCT2 zeroinitializer] }, %STRUCT1 { i32 1, [2 x %STRUCT2] [%STRUCT2 { i32 1, i32 0 }, %STRUCT2 { i32 0, i32 2 }] }] -define void @main(%main* %0) section "fn-main:v" { +define void @main(%main* %0) section "fn-$RUSTY$main:v" { entry: %var_init1 = getelementptr inbounds %main, %main* %0, i32 0, i32 0 ret void diff --git a/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__type_initializers__struct_initial_values_different_data_types.snap b/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__type_initializers__struct_initial_values_different_data_types.snap index 16b3f1ef6cb..ef300e26065 100644 --- a/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__type_initializers__struct_initial_values_different_data_types.snap +++ b/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__type_initializers__struct_initial_values_different_data_types.snap @@ -7,6 +7,5 @@ source_filename = "main" %MyStruct = type { i8, i8, i8, i16, i16, i16, i32, i32, i32, i64, i64, i64, float, double } -@x = global %MyStruct { i8 7, i8 7, i8 7, i16 7, i16 7, i16 7, i32 7, i32 7, i32 7, i64 7, i64 7, i64 7, float 0x401ECCCCC0000000, double 7.700000e+00 } -@__MyStruct__init = unnamed_addr constant %MyStruct { i8 7, i8 7, i8 7, i16 7, i16 7, i16 7, i32 7, i32 7, i32 7, i64 7, i64 7, i64 7, float 0x401ECCCCC0000000, double 7.700000e+00 } - +@x = global %MyStruct { i8 7, i8 7, i8 7, i16 7, i16 7, i16 7, i32 7, i32 7, i32 7, i64 7, i64 7, i64 7, float 0x401ECCCCC0000000, double 7.700000e+00 }, section "var-$RUSTY$x:r14u8i8u8u16i16u16u32i32u32u64i64u64f32f64" +@__MyStruct__init = unnamed_addr constant %MyStruct { i8 7, i8 7, i8 7, i16 7, i16 7, i16 7, i32 7, i32 7, i32 7, i64 7, i64 7, i64 7, float 0x401ECCCCC0000000, double 7.700000e+00 }, section "var-$RUSTY$__MyStruct__init:r14u8i8u8u16i16u16u32i32u32u64i64u64f32f64" diff --git a/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__type_initializers__struct_initialization_uses_types_default_if_not_provided.snap b/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__type_initializers__struct_initialization_uses_types_default_if_not_provided.snap index d5d1781a3b3..7be6b8fac0e 100644 --- a/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__type_initializers__struct_initialization_uses_types_default_if_not_provided.snap +++ b/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__type_initializers__struct_initialization_uses_types_default_if_not_provided.snap @@ -7,6 +7,5 @@ source_filename = "main" %Point = type { i32, i32, i32 } -@x = global %Point { i32 1, i32 2, i32 7 } -@__Point__init = unnamed_addr constant %Point { i32 0, i32 0, i32 7 } - +@x = global %Point { i32 1, i32 2, i32 7 }, section "var-$RUSTY$x:r3i32i32i32" +@__Point__init = unnamed_addr constant %Point { i32 0, i32 0, i32 7 }, section "var-$RUSTY$__Point__init:r3i32i32i32" diff --git a/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__type_initializers__struct_initializer_uses_fallback_to_field_default.snap b/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__type_initializers__struct_initializer_uses_fallback_to_field_default.snap index d7a15081874..91134e83f04 100644 --- a/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__type_initializers__struct_initializer_uses_fallback_to_field_default.snap +++ b/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__type_initializers__struct_initializer_uses_fallback_to_field_default.snap @@ -7,6 +7,5 @@ source_filename = "main" %Point = type { i32, i32, i32 } -@x = global %Point { i32 1, i32 2, i32 3 } -@__Point__init = unnamed_addr constant %Point { i32 0, i32 2, i32 3 } - +@x = global %Point { i32 1, i32 2, i32 3 }, section "var-$RUSTY$x:r3i32i32i32" +@__Point__init = unnamed_addr constant %Point { i32 0, i32 2, i32 3 }, section "var-$RUSTY$__Point__init:r3i32i32i32" diff --git a/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__type_initializers__struct_with_one_field_can_be_initialized.snap b/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__type_initializers__struct_with_one_field_can_be_initialized.snap index f3c20bd570f..89fb1065d4d 100644 --- a/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__type_initializers__struct_with_one_field_can_be_initialized.snap +++ b/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__type_initializers__struct_with_one_field_can_be_initialized.snap @@ -7,6 +7,5 @@ source_filename = "main" %MyPoint = type { i32 } -@a = global %MyPoint { i32 7 } -@__MyPoint__init = unnamed_addr constant %MyPoint zeroinitializer - +@a = global %MyPoint { i32 7 }, section "var-$RUSTY$a:r1i32" +@__MyPoint__init = unnamed_addr constant %MyPoint zeroinitializer, section "var-$RUSTY$__MyPoint__init:r1i32" diff --git a/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__type_initializers__type_defaults_are_used_for_uninitialized_constants.snap b/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__type_initializers__type_defaults_are_used_for_uninitialized_constants.snap index 908bd3460a0..70a71050f98 100644 --- a/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__type_initializers__type_defaults_are_used_for_uninitialized_constants.snap +++ b/src/codegen/tests/initialization_test/snapshots/rusty__codegen__tests__initialization_test__type_initializers__type_defaults_are_used_for_uninitialized_constants.snap @@ -5,8 +5,7 @@ expression: result.unwrap() ; ModuleID = 'main' source_filename = "main" -@a = unnamed_addr constant i16 7 -@b = unnamed_addr constant i16 21 -@c = unnamed_addr constant i32 2 -@d = unnamed_addr constant i32 30 - +@a = unnamed_addr constant i16 7, section "var-$RUSTY$a:i16" +@b = unnamed_addr constant i16 21, section "var-$RUSTY$b:i16" +@c = unnamed_addr constant i32 2, section "var-$RUSTY$c:i32" +@d = unnamed_addr constant i32 30, section "var-$RUSTY$d:i32" diff --git a/src/codegen/tests/parameters_tests.rs b/src/codegen/tests/parameters_tests.rs index 0e2745257ab..f13d221a36a 100644 --- a/src/codegen/tests/parameters_tests.rs +++ b/src/codegen/tests/parameters_tests.rs @@ -711,7 +711,7 @@ fn by_value_function_arg_builtin_type_strings_are_memcopied() { ; ModuleID = 'main' source_filename = "main" - define i32 @main() section "fn-main:i32" { + define i32 @main() section "fn-$RUSTY$main:i32" { entry: %main = alloca i32, align 4 %str = alloca [81 x i8], align 1 @@ -724,7 +724,7 @@ fn by_value_function_arg_builtin_type_strings_are_memcopied() { ret i32 %main_ret } - define i32 @foo(i8* %0) section "fn-foo:i32[s8u81]" { + define i32 @foo(i8* %0) section "fn-$RUSTY$foo:i32[s8u81]" { entry: %foo = alloca i32, align 4 %val = alloca [81 x i8], align 1 @@ -770,7 +770,7 @@ fn by_value_function_arg_user_type_strings_are_memcopied() { ; ModuleID = 'main' source_filename = "main" - define i32 @main() section "fn-main:i32" { + define i32 @main() section "fn-$RUSTY$main:i32" { entry: %main = alloca i32, align 4 %str = alloca [65537 x i8], align 1 @@ -783,7 +783,7 @@ fn by_value_function_arg_user_type_strings_are_memcopied() { ret i32 %main_ret } - define i32 @foo(i8* %0) section "fn-foo:i32[s8u65537]" { + define i32 @foo(i8* %0) section "fn-$RUSTY$foo:i32[s8u65537]" { entry: %foo = alloca i32, align 4 %val = alloca [65537 x i8], align 1 @@ -829,7 +829,7 @@ fn by_value_function_arg_arrays_are_memcopied() { ; ModuleID = 'main' source_filename = "main" - define i32 @main() section "fn-main:i32" { + define i32 @main() section "fn-$RUSTY$main:i32" { entry: %main = alloca i32, align 4 %arr = alloca [65537 x i32], align 4 @@ -842,7 +842,7 @@ fn by_value_function_arg_arrays_are_memcopied() { ret i32 %main_ret } - define i32 @foo(i32* %0) section "fn-foo:i32[v]" { + define i32 @foo(i32* %0) section "fn-$RUSTY$foo:i32[ai32]" { entry: %foo = alloca i32, align 4 %val = alloca [65537 x i32], align 4 @@ -897,9 +897,9 @@ fn by_value_function_arg_structs_are_memcopied() { %S_TY = type { i8, i8 } - @__S_TY__init = unnamed_addr constant %S_TY zeroinitializer + @__S_TY__init = unnamed_addr constant %S_TY zeroinitializer, section "var-$RUSTY$__S_TY__init:r2u8u8" - define i32 @foo(%S_TY* %0) section "fn-foo:i32[v]" { + define i32 @foo(%S_TY* %0) section "fn-$RUSTY$foo:i32[r2u8u8]" { entry: %foo = alloca i32, align 4 %val = alloca %S_TY, align 8 @@ -911,7 +911,7 @@ fn by_value_function_arg_structs_are_memcopied() { ret i32 %foo_ret } - define i32 @main() section "fn-main:i32" { + define i32 @main() section "fn-$RUSTY$main:i32" { entry: %main = alloca i32, align 4 %s = alloca %S_TY, align 8 @@ -969,10 +969,10 @@ fn by_value_function_arg_structs_with_aggregate_members_are_memcopied() { %AGGREGATE_COLLECTOR_TY = type { [65537 x i32], [65537 x i8], %S_TY } %S_TY = type { i8, i8 } - @__AGGREGATE_COLLECTOR_TY__init = unnamed_addr constant %AGGREGATE_COLLECTOR_TY zeroinitializer - @__S_TY__init = unnamed_addr constant %S_TY zeroinitializer + @__AGGREGATE_COLLECTOR_TY__init = unnamed_addr constant %AGGREGATE_COLLECTOR_TY zeroinitializer, section "var-$RUSTY$__AGGREGATE_COLLECTOR_TY__init:r3ai32s8u65537r2u8u8" + @__S_TY__init = unnamed_addr constant %S_TY zeroinitializer, section "var-$RUSTY$__S_TY__init:r2u8u8" - define i32 @foo(%AGGREGATE_COLLECTOR_TY* %0) section "fn-foo:i32[v]" { + define i32 @foo(%AGGREGATE_COLLECTOR_TY* %0) section "fn-$RUSTY$foo:i32[r3ai32s8u65537r2u8u8]" { entry: %foo = alloca i32, align 4 %val = alloca %AGGREGATE_COLLECTOR_TY, align 8 @@ -984,7 +984,7 @@ fn by_value_function_arg_structs_with_aggregate_members_are_memcopied() { ret i32 %foo_ret } - define i32 @main() section "fn-main:i32" { + define i32 @main() section "fn-$RUSTY$main:i32" { entry: %main = alloca i32, align 4 %s = alloca %AGGREGATE_COLLECTOR_TY, align 8 @@ -1031,9 +1031,9 @@ fn by_value_fb_arg_aggregates_are_memcopied() { %FOO = type { [65537 x i8], [1024 x i32] } - @__FOO__init = unnamed_addr constant %FOO zeroinitializer + @__FOO__init = unnamed_addr constant %FOO zeroinitializer, section "var-$RUSTY$__FOO__init:r2s8u65537ai32" - define i32 @main() section "fn-main:i32" { + define i32 @main() section "fn-$RUSTY$main:i32" { entry: %main = alloca i32, align 4 %str = alloca [65537 x i8], align 1 @@ -1059,7 +1059,7 @@ fn by_value_fb_arg_aggregates_are_memcopied() { ret i32 %main_ret } - define void @FOO(%FOO* %0) section "fn-FOO:v[s8u65537][v]" { + define void @FOO(%FOO* %0) section "fn-$RUSTY$FOO:v[s8u65537][ai32]" { entry: %val = getelementptr inbounds %FOO, %FOO* %0, i32 0, i32 0 %field = getelementptr inbounds %FOO, %FOO* %0, i32 0, i32 1 @@ -1121,11 +1121,11 @@ fn var_output_aggregate_types_are_memcopied() { %OUT_TYPE = type { i8 } %PRG = type { %OUT_TYPE, [11 x i32], [11 x %OUT_TYPE], [81 x i8], [81 x i16], %FB } - @__FB__init = unnamed_addr constant %FB zeroinitializer - @__OUT_TYPE__init = unnamed_addr constant %OUT_TYPE zeroinitializer - @PRG_instance = global %PRG zeroinitializer + @__FB__init = unnamed_addr constant %FB zeroinitializer, section "var-$RUSTY$__FB__init:r5r1u8ai32ar1u8s8u81s16u81" + @__OUT_TYPE__init = unnamed_addr constant %OUT_TYPE zeroinitializer, section "var-$RUSTY$__OUT_TYPE__init:r1u8" + @PRG_instance = global %PRG zeroinitializer, section "var-$RUSTY$PRG_instance:r6r1u8ai32ar1u8s8u81s16u81r5r1u8ai32ar1u8s8u81s16u81" - define void @FB(%FB* %0) section "fn-FB:v[v][v][v][s8u81][s16u81]" { + define void @FB(%FB* %0) section "fn-$RUSTY$FB:v[r1u8][ai32][ar1u8][s8u81][s16u81]" { entry: %output = getelementptr inbounds %FB, %FB* %0, i32 0, i32 0 %output2 = getelementptr inbounds %FB, %FB* %0, i32 0, i32 1 @@ -1135,7 +1135,7 @@ fn var_output_aggregate_types_are_memcopied() { ret void } - define void @PRG(%PRG* %0) section "fn-PRG:v" { + define void @PRG(%PRG* %0) section "fn-$RUSTY$PRG:v" { entry: %out = getelementptr inbounds %PRG, %PRG* %0, i32 0, i32 0 %out2 = getelementptr inbounds %PRG, %PRG* %0, i32 0, i32 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__a_global_variables_generates_in_separate_global_variables.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__a_global_variables_generates_in_separate_global_variables.snap index 109b0bd442e..7634d39be5c 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__a_global_variables_generates_in_separate_global_variables.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__a_global_variables_generates_in_separate_global_variables.snap @@ -7,11 +7,11 @@ source_filename = "main" %main = type {} -@gX = global i16 0 -@gY = global i8 0 -@main_instance = global %main zeroinitializer +@gX = global i16 0, section "var-$RUSTY$gX:i16" +@gY = global i8 0, section "var-$RUSTY$gY:u8" +@main_instance = global %main zeroinitializer, section "var-$RUSTY$main_instance:r0" -define void @main(%main* %0) section "fn-main:v" { +define void @main(%main* %0) section "fn-$RUSTY$main:v" { entry: ret void } diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__accessing_nested_array_in_struct.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__accessing_nested_array_in_struct.snap index 29682365fe6..cb25e9ba1a8 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__accessing_nested_array_in_struct.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__accessing_nested_array_in_struct.snap @@ -8,10 +8,10 @@ source_filename = "main" %Main = type { %MyStruct } %MyStruct = type { [5 x i16] } -@Main_instance = global %Main zeroinitializer -@__MyStruct__init = unnamed_addr constant %MyStruct zeroinitializer +@Main_instance = global %Main zeroinitializer, section "var-$RUSTY$Main_instance:r1r1ai16" +@__MyStruct__init = unnamed_addr constant %MyStruct zeroinitializer, section "var-$RUSTY$__MyStruct__init:r1ai16" -define void @Main(%Main* %0) section "fn-Main:v" { +define void @Main(%Main* %0) section "fn-$RUSTY$Main:v" { entry: %m = getelementptr inbounds %Main, %Main* %0, i32 0, i32 0 %field1 = getelementptr inbounds %MyStruct, %MyStruct* %m, i32 0, i32 0 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__accessing_nested_structs.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__accessing_nested_structs.snap index e32a4f30981..304525bce44 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__accessing_nested_structs.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__accessing_nested_structs.snap @@ -9,11 +9,11 @@ source_filename = "main" %OuterStruct = type { %InnerStruct, %InnerStruct } %InnerStruct = type { i16, i16 } -@Main_instance = global %Main zeroinitializer -@__OuterStruct__init = unnamed_addr constant %OuterStruct zeroinitializer -@__InnerStruct__init = unnamed_addr constant %InnerStruct zeroinitializer +@Main_instance = global %Main zeroinitializer, section "var-$RUSTY$Main_instance:r1r2r2i16i16r2i16i16" +@__OuterStruct__init = unnamed_addr constant %OuterStruct zeroinitializer, section "var-$RUSTY$__OuterStruct__init:r2r2i16i16r2i16i16" +@__InnerStruct__init = unnamed_addr constant %InnerStruct zeroinitializer, section "var-$RUSTY$__InnerStruct__init:r2i16i16" -define void @Main(%Main* %0) section "fn-Main:v" { +define void @Main(%Main* %0) section "fn-$RUSTY$Main:v" { entry: %m = getelementptr inbounds %Main, %Main* %0, i32 0, i32 0 %out1 = getelementptr inbounds %OuterStruct, %OuterStruct* %m, i32 0, i32 0 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__action_called_in_program.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__action_called_in_program.snap index 112d4e99aa4..ae2766bb081 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__action_called_in_program.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__action_called_in_program.snap @@ -7,16 +7,16 @@ source_filename = "main" %prg = type { i32 } -@prg_instance = global %prg zeroinitializer +@prg_instance = global %prg zeroinitializer, section "var-$RUSTY$prg_instance:r1i32" -define void @prg(%prg* %0) section "fn-prg:v" { +define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: %x = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 call void @prg.foo(%prg* %0) ret void } -define void @prg.foo(%prg* %0) section "fn-prg.foo:v" { +define void @prg.foo(%prg* %0) section "fn-$RUSTY$prg.foo:v" { entry: %x = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 store i32 2, i32* %x, align 4 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__array_of_cast_int_type_generated.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__array_of_cast_int_type_generated.snap index 3f8c29168c9..e2aa3a0c5e8 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__array_of_cast_int_type_generated.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__array_of_cast_int_type_generated.snap @@ -7,9 +7,9 @@ source_filename = "main" %prg = type { [11 x i16] } -@prg_instance = global %prg zeroinitializer +@prg_instance = global %prg zeroinitializer, section "var-$RUSTY$prg_instance:r1ai16" -define void @prg(%prg* %0) section "fn-prg:v" { +define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: %x = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 ret void diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__array_of_int_non_zero_negative_type_generated.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__array_of_int_non_zero_negative_type_generated.snap index a3273bd0e94..c8c90ea6375 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__array_of_int_non_zero_negative_type_generated.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__array_of_int_non_zero_negative_type_generated.snap @@ -7,9 +7,9 @@ source_filename = "main" %prg = type { [31 x i16] } -@prg_instance = global %prg zeroinitializer +@prg_instance = global %prg zeroinitializer, section "var-$RUSTY$prg_instance:r1ai16" -define void @prg(%prg* %0) section "fn-prg:v" { +define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: %x = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 ret void diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__array_of_int_non_zero_type_generated.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__array_of_int_non_zero_type_generated.snap index 3f8c29168c9..e2aa3a0c5e8 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__array_of_int_non_zero_type_generated.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__array_of_int_non_zero_type_generated.snap @@ -7,9 +7,9 @@ source_filename = "main" %prg = type { [11 x i16] } -@prg_instance = global %prg zeroinitializer +@prg_instance = global %prg zeroinitializer, section "var-$RUSTY$prg_instance:r1ai16" -define void @prg(%prg* %0) section "fn-prg:v" { +define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: %x = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 ret void diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__array_of_int_type_generated.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__array_of_int_type_generated.snap index 3f8c29168c9..e2aa3a0c5e8 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__array_of_int_type_generated.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__array_of_int_type_generated.snap @@ -7,9 +7,9 @@ source_filename = "main" %prg = type { [11 x i16] } -@prg_instance = global %prg zeroinitializer +@prg_instance = global %prg zeroinitializer, section "var-$RUSTY$prg_instance:r1ai16" -define void @prg(%prg* %0) section "fn-prg:v" { +define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: %x = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 ret void diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__array_of_int_type_used.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__array_of_int_type_used.snap index afcb9daee65..82c76115c38 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__array_of_int_type_used.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__array_of_int_type_used.snap @@ -7,9 +7,9 @@ source_filename = "main" %prg = type { [4 x i32] } -@prg_instance = global %prg zeroinitializer +@prg_instance = global %prg zeroinitializer, section "var-$RUSTY$prg_instance:r1ai32" -define void @prg(%prg* %0) section "fn-prg:v" { +define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: %x = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 %tmpVar = getelementptr inbounds [4 x i32], [4 x i32]* %x, i32 0, i32 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__array_of_int_type_with_non_zero_negative_start_used.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__array_of_int_type_with_non_zero_negative_start_used.snap index 605324ede9a..0a2219c7292 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__array_of_int_type_with_non_zero_negative_start_used.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__array_of_int_type_with_non_zero_negative_start_used.snap @@ -7,9 +7,9 @@ source_filename = "main" %prg = type { [6 x i32] } -@prg_instance = global %prg zeroinitializer +@prg_instance = global %prg zeroinitializer, section "var-$RUSTY$prg_instance:r1ai32" -define void @prg(%prg* %0) section "fn-prg:v" { +define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: %x = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 %tmpVar = getelementptr inbounds [6 x i32], [6 x i32]* %x, i32 0, i32 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__array_of_int_type_with_non_zero_start_used.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__array_of_int_type_with_non_zero_start_used.snap index 6ed961f13e7..de08512f595 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__array_of_int_type_with_non_zero_start_used.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__array_of_int_type_with_non_zero_start_used.snap @@ -7,9 +7,9 @@ source_filename = "main" %prg = type { [3 x i32] } -@prg_instance = global %prg zeroinitializer +@prg_instance = global %prg zeroinitializer, section "var-$RUSTY$prg_instance:r1ai32" -define void @prg(%prg* %0) section "fn-prg:v" { +define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: %x = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 %tmpVar = getelementptr inbounds [3 x i32], [3 x i32]* %x, i32 0, i32 0 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__array_of_struct_as_member_of_another_struct_and_variable_declaration_is_initialized.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__array_of_struct_as_member_of_another_struct_and_variable_declaration_is_initialized.snap index 3c096b12859..ab227e820fe 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__array_of_struct_as_member_of_another_struct_and_variable_declaration_is_initialized.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__array_of_struct_as_member_of_another_struct_and_variable_declaration_is_initialized.snap @@ -9,12 +9,12 @@ source_filename = "main" %STRUCT1 = type { i16, [5 x %STRUCT2] } %STRUCT2 = type { i8, i32 } -@mainProg_instance = global %mainProg { [5 x %STRUCT1] [%STRUCT1 { i16 1, [5 x %STRUCT2] [%STRUCT2 { i8 1, i32 128 }, %STRUCT2 { i8 0, i32 1024 }, %STRUCT2 zeroinitializer, %STRUCT2 zeroinitializer, %STRUCT2 zeroinitializer] }, %STRUCT1 { i16 2, [5 x %STRUCT2] [%STRUCT2 { i8 1, i32 256 }, %STRUCT2 { i8 0, i32 2048 }, %STRUCT2 zeroinitializer, %STRUCT2 zeroinitializer, %STRUCT2 zeroinitializer] }, %STRUCT1 zeroinitializer, %STRUCT1 zeroinitializer, %STRUCT1 zeroinitializer] } -@__STRUCT1__init = unnamed_addr constant %STRUCT1 zeroinitializer -@__STRUCT2__init = unnamed_addr constant %STRUCT2 zeroinitializer +@mainProg_instance = global %mainProg { [5 x %STRUCT1] [%STRUCT1 { i16 1, [5 x %STRUCT2] [%STRUCT2 { i8 1, i32 128 }, %STRUCT2 { i8 0, i32 1024 }, %STRUCT2 zeroinitializer, %STRUCT2 zeroinitializer, %STRUCT2 zeroinitializer] }, %STRUCT1 { i16 2, [5 x %STRUCT2] [%STRUCT2 { i8 1, i32 256 }, %STRUCT2 { i8 0, i32 2048 }, %STRUCT2 zeroinitializer, %STRUCT2 zeroinitializer, %STRUCT2 zeroinitializer] }, %STRUCT1 zeroinitializer, %STRUCT1 zeroinitializer, %STRUCT1 zeroinitializer] }, section "var-$RUSTY$mainProg_instance:r1ar2i16ar2u8i32" +@__STRUCT1__init = unnamed_addr constant %STRUCT1 zeroinitializer, section "var-$RUSTY$__STRUCT1__init:r2i16ar2u8i32" +@__STRUCT2__init = unnamed_addr constant %STRUCT2 zeroinitializer, section "var-$RUSTY$__STRUCT2__init:r2u8i32" @__mainProg.var_str1__init = unnamed_addr constant [5 x %STRUCT1] [%STRUCT1 { i16 1, [5 x %STRUCT2] [%STRUCT2 { i8 1, i32 128 }, %STRUCT2 { i8 0, i32 1024 }, %STRUCT2 zeroinitializer, %STRUCT2 zeroinitializer, %STRUCT2 zeroinitializer] }, %STRUCT1 { i16 2, [5 x %STRUCT2] [%STRUCT2 { i8 1, i32 256 }, %STRUCT2 { i8 0, i32 2048 }, %STRUCT2 zeroinitializer, %STRUCT2 zeroinitializer, %STRUCT2 zeroinitializer] }, %STRUCT1 zeroinitializer, %STRUCT1 zeroinitializer, %STRUCT1 zeroinitializer] -define void @mainProg(%mainProg* %0) section "fn-mainProg:v" { +define void @mainProg(%mainProg* %0) section "fn-$RUSTY$mainProg:v" { entry: %var_str1 = getelementptr inbounds %mainProg, %mainProg* %0, i32 0, i32 0 ret void diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__array_of_struct_as_member_of_another_struct_is_initialized.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__array_of_struct_as_member_of_another_struct_is_initialized.snap index 671390a36aa..d26b1b97d47 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__array_of_struct_as_member_of_another_struct_is_initialized.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__array_of_struct_as_member_of_another_struct_is_initialized.snap @@ -9,12 +9,12 @@ source_filename = "main" %STRUCT1 = type { i16, [11 x %STRUCT2] } %STRUCT2 = type { i8, i32 } -@mainProg_instance = global %mainProg { %STRUCT1 { i16 10, [11 x %STRUCT2] [%STRUCT2 { i8 1, i32 128 }, %STRUCT2 { i8 0, i32 1024 }, %STRUCT2 zeroinitializer, %STRUCT2 zeroinitializer, %STRUCT2 zeroinitializer, %STRUCT2 zeroinitializer, %STRUCT2 zeroinitializer, %STRUCT2 zeroinitializer, %STRUCT2 zeroinitializer, %STRUCT2 zeroinitializer, %STRUCT2 zeroinitializer] } } -@__STRUCT1__init = unnamed_addr constant %STRUCT1 zeroinitializer -@__STRUCT2__init = unnamed_addr constant %STRUCT2 zeroinitializer +@mainProg_instance = global %mainProg { %STRUCT1 { i16 10, [11 x %STRUCT2] [%STRUCT2 { i8 1, i32 128 }, %STRUCT2 { i8 0, i32 1024 }, %STRUCT2 zeroinitializer, %STRUCT2 zeroinitializer, %STRUCT2 zeroinitializer, %STRUCT2 zeroinitializer, %STRUCT2 zeroinitializer, %STRUCT2 zeroinitializer, %STRUCT2 zeroinitializer, %STRUCT2 zeroinitializer, %STRUCT2 zeroinitializer] } }, section "var-$RUSTY$mainProg_instance:r1r2i16ar2u8i32" +@__STRUCT1__init = unnamed_addr constant %STRUCT1 zeroinitializer, section "var-$RUSTY$__STRUCT1__init:r2i16ar2u8i32" +@__STRUCT2__init = unnamed_addr constant %STRUCT2 zeroinitializer, section "var-$RUSTY$__STRUCT2__init:r2u8i32" @__mainProg.var_str1__init = unnamed_addr constant %STRUCT1 { i16 10, [11 x %STRUCT2] [%STRUCT2 { i8 1, i32 128 }, %STRUCT2 { i8 0, i32 1024 }, %STRUCT2 zeroinitializer, %STRUCT2 zeroinitializer, %STRUCT2 zeroinitializer, %STRUCT2 zeroinitializer, %STRUCT2 zeroinitializer, %STRUCT2 zeroinitializer, %STRUCT2 zeroinitializer, %STRUCT2 zeroinitializer, %STRUCT2 zeroinitializer] } -define void @mainProg(%mainProg* %0) section "fn-mainProg:v" { +define void @mainProg(%mainProg* %0) section "fn-$RUSTY$mainProg:v" { entry: %var_str1 = getelementptr inbounds %mainProg, %mainProg* %0, i32 0, i32 0 ret void diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__arrays_are_generated.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__arrays_are_generated.snap index 6057650a3a4..6c6d0bea958 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__arrays_are_generated.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__arrays_are_generated.snap @@ -1,11 +1,9 @@ --- source: src/codegen/tests/code_gen_tests.rs expression: result - --- ; ModuleID = 'main' source_filename = "main" -@x = global [10 x i16] zeroinitializer -@y = global [6 x float] zeroinitializer - +@x = global [10 x i16] zeroinitializer, section "var-$RUSTY$x:ai16" +@y = global [6 x float] zeroinitializer, section "var-$RUSTY$y:af32" diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__arrays_with_global_const_size_are_generated.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__arrays_with_global_const_size_are_generated.snap index d03111f3e69..dd64c485d5c 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__arrays_with_global_const_size_are_generated.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__arrays_with_global_const_size_are_generated.snap @@ -1,18 +1,15 @@ --- source: src/codegen/tests/code_gen_tests.rs -assertion_line: 1989 expression: result - --- ; ModuleID = 'main' source_filename = "main" -@THREE = unnamed_addr constant i16 3 -@ZERO = unnamed_addr constant i16 0 -@LEN = unnamed_addr constant i16 9 -@x = global [10 x i16] zeroinitializer -@y = global [11 x i32] zeroinitializer -@z = global [19 x i8] zeroinitializer -@zz = global [100 x i8] zeroinitializer -@zzz = global [10 x [8 x i8]] zeroinitializer - +@THREE = unnamed_addr constant i16 3, section "var-$RUSTY$THREE:i16" +@ZERO = unnamed_addr constant i16 0, section "var-$RUSTY$ZERO:i16" +@LEN = unnamed_addr constant i16 9, section "var-$RUSTY$LEN:i16" +@x = global [10 x i16] zeroinitializer, section "var-$RUSTY$x:ai16" +@y = global [11 x i32] zeroinitializer, section "var-$RUSTY$y:ai32" +@z = global [19 x i8] zeroinitializer, section "var-$RUSTY$z:au8" +@zz = global [100 x i8] zeroinitializer, section "var-$RUSTY$zz:au8" +@zzz = global [10 x [8 x i8]] zeroinitializer, section "var-$RUSTY$zzz:aau8" diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__basic_datatypes_generated.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__basic_datatypes_generated.snap index bfa2c326410..5936e502fda 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__basic_datatypes_generated.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__basic_datatypes_generated.snap @@ -1,23 +1,20 @@ --- source: src/codegen/tests/code_gen_tests.rs -assertion_line: 2224 expression: result - --- ; ModuleID = 'main' source_filename = "main" -@bool_1 = global i8 0 -@byte_2 = global i8 0 -@sint_3 = global i8 0 -@usint_4 = global i8 0 -@word_5 = global i16 0 -@int_6 = global i16 0 -@uint_7 = global i16 0 -@dword_8 = global i32 0 -@dint_9 = global i32 0 -@udint_10 = global i32 0 -@lword_11 = global i64 0 -@lint_12 = global i64 0 -@ulint_13 = global i64 0 - +@bool_1 = global i8 0, section "var-$RUSTY$bool_1:u8" +@byte_2 = global i8 0, section "var-$RUSTY$byte_2:u8" +@sint_3 = global i8 0, section "var-$RUSTY$sint_3:i8" +@usint_4 = global i8 0, section "var-$RUSTY$usint_4:u8" +@word_5 = global i16 0, section "var-$RUSTY$word_5:u16" +@int_6 = global i16 0, section "var-$RUSTY$int_6:i16" +@uint_7 = global i16 0, section "var-$RUSTY$uint_7:u16" +@dword_8 = global i32 0, section "var-$RUSTY$dword_8:u32" +@dint_9 = global i32 0, section "var-$RUSTY$dint_9:i32" +@udint_10 = global i32 0, section "var-$RUSTY$udint_10:u32" +@lword_11 = global i64 0, section "var-$RUSTY$lword_11:u64" +@lint_12 = global i64 0, section "var-$RUSTY$lint_12:i64" +@ulint_13 = global i64 0, section "var-$RUSTY$ulint_13:u64" diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__case_with_constant_expressions_in_case_selectors.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__case_with_constant_expressions_in_case_selectors.snap index e527800ea1e..52ff058371e 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__case_with_constant_expressions_in_case_selectors.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__case_with_constant_expressions_in_case_selectors.snap @@ -5,11 +5,11 @@ expression: result ; ModuleID = 'main' source_filename = "main" -@FORWARD = unnamed_addr constant i32 7 -@UP = unnamed_addr constant i32 8 -@DOWN = unnamed_addr constant i32 15 +@FORWARD = unnamed_addr constant i32 7, section "var-$RUSTY$FORWARD:i32" +@UP = unnamed_addr constant i32 8, section "var-$RUSTY$UP:i32" +@DOWN = unnamed_addr constant i32 15, section "var-$RUSTY$DOWN:i32" -define i32 @drive() section "fn-drive:i32" { +define i32 @drive() section "fn-$RUSTY$drive:i32" { entry: %drive = alloca i32, align 4 %input = alloca i32, align 4 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__case_with_enum_expressions_in_case_selectors.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__case_with_enum_expressions_in_case_selectors.snap index 5588e2370f6..c92e8dcee53 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__case_with_enum_expressions_in_case_selectors.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__case_with_enum_expressions_in_case_selectors.snap @@ -5,12 +5,12 @@ expression: result ; ModuleID = 'main' source_filename = "main" -@BASE = unnamed_addr constant i32 7 -@Direction.FORWARD = unnamed_addr constant i32 7 -@Direction.UP = unnamed_addr constant i32 8 -@Direction.DOWN = unnamed_addr constant i32 28 +@BASE = unnamed_addr constant i32 7, section "var-$RUSTY$BASE:i32" +@Direction.FORWARD = unnamed_addr constant i32 7, section "var-$RUSTY$FORWARD:e3i32" +@Direction.UP = unnamed_addr constant i32 8, section "var-$RUSTY$UP:e3i32" +@Direction.DOWN = unnamed_addr constant i32 28, section "var-$RUSTY$DOWN:e3i32" -define i32 @drive() section "fn-drive:i32" { +define i32 @drive() section "fn-$RUSTY$drive:i32" { entry: %drive = alloca i32, align 4 %input = alloca i32, align 4 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__case_with_multiple_labels_statement.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__case_with_multiple_labels_statement.snap index 75209200609..55a652984bf 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__case_with_multiple_labels_statement.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__case_with_multiple_labels_statement.snap @@ -7,9 +7,9 @@ source_filename = "main" %prg = type { i32, i32 } -@prg_instance = global %prg zeroinitializer +@prg_instance = global %prg zeroinitializer, section "var-$RUSTY$prg_instance:r2i32i32" -define void @prg(%prg* %0) section "fn-prg:v" { +define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: %x = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 %y = getelementptr inbounds %prg, %prg* %0, i32 0, i32 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__case_with_ranges_statement.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__case_with_ranges_statement.snap index 58fe060d197..3d517cb7c7f 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__case_with_ranges_statement.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__case_with_ranges_statement.snap @@ -7,9 +7,9 @@ source_filename = "main" %prg = type { i32, i32 } -@prg_instance = global %prg zeroinitializer +@prg_instance = global %prg zeroinitializer, section "var-$RUSTY$prg_instance:r2i32i32" -define void @prg(%prg* %0) section "fn-prg:v" { +define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: %x = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 %y = getelementptr inbounds %prg, %prg* %0, i32 0, i32 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__casted_literals_bool_code_gen_test.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__casted_literals_bool_code_gen_test.snap index b84a0b5054d..225e7ac1cc1 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__casted_literals_bool_code_gen_test.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__casted_literals_bool_code_gen_test.snap @@ -7,9 +7,9 @@ source_filename = "main" %prg = type { i8 } -@prg_instance = global %prg zeroinitializer +@prg_instance = global %prg zeroinitializer, section "var-$RUSTY$prg_instance:r1u8" -define void @prg(%prg* %0) section "fn-prg:v" { +define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: %z = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 store i8 1, i8* %z, align 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__casted_literals_code_gen_test.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__casted_literals_code_gen_test.snap index 55408b7bd88..8e7ce4e7efe 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__casted_literals_code_gen_test.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__casted_literals_code_gen_test.snap @@ -7,9 +7,9 @@ source_filename = "main" %prg = type { i16, i16 } -@prg_instance = global %prg zeroinitializer +@prg_instance = global %prg zeroinitializer, section "var-$RUSTY$prg_instance:r2i16i16" -define void @prg(%prg* %0) section "fn-prg:v" { +define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: %x = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 %z = getelementptr inbounds %prg, %prg* %0, i32 0, i32 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__casted_literals_hex_code_gen_test.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__casted_literals_hex_code_gen_test.snap index e7a4f21bb4c..58b69425f35 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__casted_literals_hex_code_gen_test.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__casted_literals_hex_code_gen_test.snap @@ -7,9 +7,9 @@ source_filename = "main" %prg = type { i16, i16 } -@prg_instance = global %prg zeroinitializer +@prg_instance = global %prg zeroinitializer, section "var-$RUSTY$prg_instance:r2i16i16" -define void @prg(%prg* %0) section "fn-prg:v" { +define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: %x = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 %z = getelementptr inbounds %prg, %prg* %0, i32 0, i32 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__casted_literals_hex_ints_code_gen_test.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__casted_literals_hex_ints_code_gen_test.snap index 3a57568ae38..0d6aa79303e 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__casted_literals_hex_ints_code_gen_test.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__casted_literals_hex_ints_code_gen_test.snap @@ -7,9 +7,9 @@ source_filename = "main" %prg = type { i32 } -@prg_instance = global %prg zeroinitializer +@prg_instance = global %prg zeroinitializer, section "var-$RUSTY$prg_instance:r1i32" -define void @prg(%prg* %0) section "fn-prg:v" { +define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: %x = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 store i32 -1, i32* %x, align 4 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__casted_literals_lreal_code_gen_test.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__casted_literals_lreal_code_gen_test.snap index 2468140ebe1..3c7fb322309 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__casted_literals_lreal_code_gen_test.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__casted_literals_lreal_code_gen_test.snap @@ -7,9 +7,9 @@ source_filename = "main" %prg = type { float, float } -@prg_instance = global %prg zeroinitializer +@prg_instance = global %prg zeroinitializer, section "var-$RUSTY$prg_instance:r2f32f32" -define void @prg(%prg* %0) section "fn-prg:v" { +define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: %x = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 %z = getelementptr inbounds %prg, %prg* %0, i32 0, i32 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__casted_literals_real_code_gen_test.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__casted_literals_real_code_gen_test.snap index 846e5eedf5e..0da2859836e 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__casted_literals_real_code_gen_test.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__casted_literals_real_code_gen_test.snap @@ -7,9 +7,9 @@ source_filename = "main" %prg = type { i16, float } -@prg_instance = global %prg zeroinitializer +@prg_instance = global %prg zeroinitializer, section "var-$RUSTY$prg_instance:r2i16f32" -define void @prg(%prg* %0) section "fn-prg:v" { +define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: %x = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 %z = getelementptr inbounds %prg, %prg* %0, i32 0, i32 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__class_member_access_from_method.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__class_member_access_from_method.snap index 90e79736909..013bcce3592 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__class_member_access_from_method.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__class_member_access_from_method.snap @@ -8,16 +8,16 @@ source_filename = "main" %MyClass = type { i16, i16 } %MyClass.testMethod = type { i16, i16 } -@__MyClass__init = unnamed_addr constant %MyClass zeroinitializer +@__MyClass__init = unnamed_addr constant %MyClass zeroinitializer, section "var-$RUSTY$__MyClass__init:r2i16i16" -define void @MyClass(%MyClass* %0) section "fn-MyClass:v" { +define void @MyClass(%MyClass* %0) section "fn-$RUSTY$MyClass:v" { entry: %x = getelementptr inbounds %MyClass, %MyClass* %0, i32 0, i32 0 %y = getelementptr inbounds %MyClass, %MyClass* %0, i32 0, i32 1 ret void } -define void @MyClass.testMethod(%MyClass* %0, %MyClass.testMethod* %1) section "fn-MyClass.testMethod:v[i16]" { +define void @MyClass.testMethod(%MyClass* %0, %MyClass.testMethod* %1) section "fn-$RUSTY$MyClass.testMethod:v[i16]" { entry: %x = getelementptr inbounds %MyClass, %MyClass* %0, i32 0, i32 0 %y = getelementptr inbounds %MyClass, %MyClass* %0, i32 0, i32 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__class_method_in_pou.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__class_method_in_pou.snap index 3c0ea0e41ce..b6d4db0881b 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__class_method_in_pou.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__class_method_in_pou.snap @@ -9,17 +9,17 @@ source_filename = "main" %prg = type { %MyClass, i16 } %MyClass.testMethod = type { i16, i16 } -@__MyClass__init = unnamed_addr constant %MyClass zeroinitializer -@prg_instance = global %prg zeroinitializer +@__MyClass__init = unnamed_addr constant %MyClass zeroinitializer, section "var-$RUSTY$__MyClass__init:r2i16i16" +@prg_instance = global %prg zeroinitializer, section "var-$RUSTY$prg_instance:r2r2i16i16i16" -define void @MyClass(%MyClass* %0) section "fn-MyClass:v" { +define void @MyClass(%MyClass* %0) section "fn-$RUSTY$MyClass:v" { entry: %x = getelementptr inbounds %MyClass, %MyClass* %0, i32 0, i32 0 %y = getelementptr inbounds %MyClass, %MyClass* %0, i32 0, i32 1 ret void } -define void @MyClass.testMethod(%MyClass* %0, %MyClass.testMethod* %1) section "fn-MyClass.testMethod:v[i16]" { +define void @MyClass.testMethod(%MyClass* %0, %MyClass.testMethod* %1) section "fn-$RUSTY$MyClass.testMethod:v[i16]" { entry: %x = getelementptr inbounds %MyClass, %MyClass* %0, i32 0, i32 0 %y = getelementptr inbounds %MyClass, %MyClass* %0, i32 0, i32 1 @@ -38,7 +38,7 @@ entry: ret void } -define void @prg(%prg* %0) section "fn-prg:v" { +define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: %cl = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 %x = getelementptr inbounds %prg, %prg* %0, i32 0, i32 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__complex_pointers.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__complex_pointers.snap index 9ad5dd85ed6..0d9e5429060 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__complex_pointers.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__complex_pointers.snap @@ -7,9 +7,9 @@ source_filename = "main" %prg = type { i16, [10 x i16], [10 x i16*], [10 x i16]* } -@prg_instance = global %prg zeroinitializer +@prg_instance = global %prg zeroinitializer, section "var-$RUSTY$prg_instance:r4i16ai16api16pai16" -define void @prg(%prg* %0) section "fn-prg:v" { +define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: %X = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 %arrX = getelementptr inbounds %prg, %prg* %0, i32 0, i32 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__constant_expression_in_function_blocks_are_propagated.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__constant_expression_in_function_blocks_are_propagated.snap index 1942b71c28c..6cd81f4e4b7 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__constant_expression_in_function_blocks_are_propagated.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__constant_expression_in_function_blocks_are_propagated.snap @@ -7,9 +7,9 @@ source_filename = "main" %fbWithConstant = type { i16, i16 } -@__fbWithConstant__init = unnamed_addr constant %fbWithConstant { i16 0, i16 2 } +@__fbWithConstant__init = unnamed_addr constant %fbWithConstant { i16 0, i16 2 }, section "var-$RUSTY$__fbWithConstant__init:r2i16i16" -define void @fbWithConstant(%fbWithConstant* %0) section "fn-fbWithConstant:v" { +define void @fbWithConstant(%fbWithConstant* %0) section "fn-$RUSTY$fbWithConstant:v" { entry: %x = getelementptr inbounds %fbWithConstant, %fbWithConstant* %0, i32 0, i32 0 %const = getelementptr inbounds %fbWithConstant, %fbWithConstant* %0, i32 0, i32 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__constant_expressions_in_ranged_type_declaration_are_propagated.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__constant_expressions_in_ranged_type_declaration_are_propagated.snap index a018dd2f695..f1184db8de6 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__constant_expressions_in_ranged_type_declaration_are_propagated.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__constant_expressions_in_ranged_type_declaration_are_propagated.snap @@ -7,10 +7,10 @@ source_filename = "main" %prg = type { i16 } -@MIN = unnamed_addr constant i16 7 -@prg_instance = global %prg zeroinitializer +@MIN = unnamed_addr constant i16 7, section "var-$RUSTY$MIN:i16" +@prg_instance = global %prg zeroinitializer, section "var-$RUSTY$prg_instance:r1i16" -define i16 @CheckRangeSigned(i16 %0, i16 %1, i16 %2) section "fn-CheckRangeSigned:i16[i16][i16][i16]" { +define i16 @CheckRangeSigned(i16 %0, i16 %1, i16 %2) section "fn-$RUSTY$CheckRangeSigned:i16[i16][i16][i16]" { entry: %CheckRangeSigned = alloca i16, align 2 %value = alloca i16, align 2 @@ -26,7 +26,7 @@ entry: ret i16 %CheckRangeSigned_ret } -define void @prg(%prg* %0) section "fn-prg:v" { +define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: %x = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 %call = call i16 @CheckRangeSigned(i16 5, i16 0, i16 8) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__constant_propagation_of_struct_fields_on_assignment.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__constant_propagation_of_struct_fields_on_assignment.snap index 5e0d5cda0ce..2bed0e81abb 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__constant_propagation_of_struct_fields_on_assignment.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__constant_propagation_of_struct_fields_on_assignment.snap @@ -7,10 +7,10 @@ source_filename = "main" %STRUCT1 = type { i32 } -@MyStruct = unnamed_addr constant %STRUCT1 { i32 99 } -@__STRUCT1__init = unnamed_addr constant %STRUCT1 zeroinitializer +@MyStruct = unnamed_addr constant %STRUCT1 { i32 99 }, section "var-$RUSTY$MyStruct:r1i32" +@__STRUCT1__init = unnamed_addr constant %STRUCT1 zeroinitializer, section "var-$RUSTY$__STRUCT1__init:r1i32" -define i32 @main() section "fn-main:i32" { +define i32 @main() section "fn-$RUSTY$main:i32" { entry: %main = alloca i32, align 4 %local_value = alloca i32, align 4 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__contants_in_case_statements_resolved.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__contants_in_case_statements_resolved.snap index f922abe4168..41d5a82ad48 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__contants_in_case_statements_resolved.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__contants_in_case_statements_resolved.snap @@ -7,9 +7,9 @@ source_filename = "main" %main = type { i32, i32 } -@main_instance = global %main { i32 0, i32 60 } +@main_instance = global %main { i32 0, i32 60 }, section "var-$RUSTY$main_instance:r2i32i32" -define void @main(%main* %0) section "fn-main:v" { +define void @main(%main* %0) section "fn-$RUSTY$main:v" { entry: %DAYS_IN_MONTH = getelementptr inbounds %main, %main* %0, i32 0, i32 0 %SIXTY = getelementptr inbounds %main, %main* %0, i32 0, i32 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__date_and_time_addition_in_var_output.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__date_and_time_addition_in_var_output.snap index 44f3117f1b3..3b0fa08f841 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__date_and_time_addition_in_var_output.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__date_and_time_addition_in_var_output.snap @@ -5,7 +5,7 @@ expression: result ; ModuleID = 'main' source_filename = "main" -define i32 @func(i64* %0, i64* %1) section "fn-func:i32[pi64][pi64]" { +define i32 @func(i64* %0, i64* %1) section "fn-$RUSTY$func:i32[pi64][pi64]" { entry: %func = alloca i32, align 4 %d_and_t = alloca i64*, align 8 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__date_and_time_global_constants_initialize.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__date_and_time_global_constants_initialize.snap index 9c46fc7beea..55a96725a2c 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__date_and_time_global_constants_initialize.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__date_and_time_global_constants_initialize.snap @@ -7,25 +7,25 @@ source_filename = "main" %main = type {} -@cT = unnamed_addr constant i64 1000000000 -@cT_SHORT = unnamed_addr constant i64 1000000000 -@cLT = unnamed_addr constant i64 1000000000000 -@cLT_SHORT = unnamed_addr constant i64 1000000000000 -@cD = unnamed_addr constant i64 0 -@cD_SHORT = unnamed_addr constant i64 161308800000000000 -@cLD = unnamed_addr constant i64 161308800000000000 -@cLD_SHORT = unnamed_addr constant i64 161308800000000000 -@cTOD = unnamed_addr constant i64 0 -@cTOD_SHORT = unnamed_addr constant i64 0 -@cLTOD = unnamed_addr constant i64 86399999999999 -@cLTOD_SHORT = unnamed_addr constant i64 86399999999999 -@cDT = unnamed_addr constant i64 172799000000000 -@cDT_SHORT = unnamed_addr constant i64 172799000000000 -@cLDT = unnamed_addr constant i64 172799123000000 -@cLDT_SHORT = unnamed_addr constant i64 172799123000000 -@main_instance = global %main zeroinitializer +@cT = unnamed_addr constant i64 1000000000, section "var-$RUSTY$cT:i64" +@cT_SHORT = unnamed_addr constant i64 1000000000, section "var-$RUSTY$cT_SHORT:i64" +@cLT = unnamed_addr constant i64 1000000000000, section "var-$RUSTY$cLT:i64" +@cLT_SHORT = unnamed_addr constant i64 1000000000000, section "var-$RUSTY$cLT_SHORT:i64" +@cD = unnamed_addr constant i64 0, section "var-$RUSTY$cD:i64" +@cD_SHORT = unnamed_addr constant i64 161308800000000000, section "var-$RUSTY$cD_SHORT:i64" +@cLD = unnamed_addr constant i64 161308800000000000, section "var-$RUSTY$cLD:i64" +@cLD_SHORT = unnamed_addr constant i64 161308800000000000, section "var-$RUSTY$cLD_SHORT:i64" +@cTOD = unnamed_addr constant i64 0, section "var-$RUSTY$cTOD:i64" +@cTOD_SHORT = unnamed_addr constant i64 0, section "var-$RUSTY$cTOD_SHORT:i64" +@cLTOD = unnamed_addr constant i64 86399999999999, section "var-$RUSTY$cLTOD:i64" +@cLTOD_SHORT = unnamed_addr constant i64 86399999999999, section "var-$RUSTY$cLTOD_SHORT:i64" +@cDT = unnamed_addr constant i64 172799000000000, section "var-$RUSTY$cDT:i64" +@cDT_SHORT = unnamed_addr constant i64 172799000000000, section "var-$RUSTY$cDT_SHORT:i64" +@cLDT = unnamed_addr constant i64 172799123000000, section "var-$RUSTY$cLDT:i64" +@cLDT_SHORT = unnamed_addr constant i64 172799123000000, section "var-$RUSTY$cLDT_SHORT:i64" +@main_instance = global %main zeroinitializer, section "var-$RUSTY$main_instance:r16i64i64i64i64i64i64i64i64i64i64i64i64i64i64i64i64" -define void @main(%main* %0) section "fn-main:v" { +define void @main(%main* %0) section "fn-$RUSTY$main:v" { entry: %t1 = alloca i64, align 8 %t2 = alloca i64, align 8 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__date_comparisons.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__date_comparisons.snap index b8f8ee1f3d4..b01ef6be320 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__date_comparisons.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__date_comparisons.snap @@ -7,9 +7,9 @@ source_filename = "main" %prg = type { i64, i64, i64, i64 } -@prg_instance = global %prg zeroinitializer +@prg_instance = global %prg zeroinitializer, section "var-$RUSTY$prg_instance:r4i64i64i64i64" -define void @prg(%prg* %0) section "fn-prg:v" { +define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: %a = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 %b = getelementptr inbounds %prg, %prg* %0, i32 0, i32 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__default_values_for_not_initialized_function_vars.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__default_values_for_not_initialized_function_vars.snap index 8adc6947eff..6accb260f68 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__default_values_for_not_initialized_function_vars.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__default_values_for_not_initialized_function_vars.snap @@ -5,7 +5,7 @@ expression: result ; ModuleID = 'main' source_filename = "main" -define i16 @func() section "fn-func:i16" { +define i16 @func() section "fn-$RUSTY$func:i16" { entry: %func = alloca i16, align 2 %int_var = alloca i16, align 2 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__different_case_references.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__different_case_references.snap index 714f7af5895..55c7afa92fa 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__different_case_references.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__different_case_references.snap @@ -7,9 +7,9 @@ source_filename = "main" %prg = type { i16, i16, i32 } -@prg_instance = global %prg { i16 0, i16 1, i32 2 } +@prg_instance = global %prg { i16 0, i16 1, i32 2 }, section "var-$RUSTY$prg_instance:r3i16i16i32" -define void @prg(%prg* %0) section "fn-prg:v" { +define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: %y = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 %z = getelementptr inbounds %prg, %prg* %0, i32 0, i32 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__empty_function_with_name_generates_int_function.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__empty_function_with_name_generates_int_function.snap index 644374ab5a0..1d50aaf7097 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__empty_function_with_name_generates_int_function.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__empty_function_with_name_generates_int_function.snap @@ -5,7 +5,7 @@ expression: result ; ModuleID = 'main' source_filename = "main" -define i16 @foo() section "fn-foo:i16" { +define i16 @foo() section "fn-$RUSTY$foo:i16" { entry: %foo = alloca i16, align 2 store i16 0, i16* %foo, align 2 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__empty_global_variable_list_generates_nothing.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__empty_global_variable_list_generates_nothing.snap index 687716fc304..58ead4ad4c7 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__empty_global_variable_list_generates_nothing.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__empty_global_variable_list_generates_nothing.snap @@ -7,9 +7,9 @@ source_filename = "main" %main = type {} -@main_instance = global %main zeroinitializer +@main_instance = global %main zeroinitializer, section "var-$RUSTY$main_instance:r0" -define void @main(%main* %0) section "fn-main:v" { +define void @main(%main* %0) section "fn-$RUSTY$main:v" { entry: ret void } diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__empty_program_with_name_generates_void_function.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__empty_program_with_name_generates_void_function.snap index 8518c00c821..cc9d1a042be 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__empty_program_with_name_generates_void_function.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__empty_program_with_name_generates_void_function.snap @@ -7,9 +7,9 @@ source_filename = "main" %prg = type {} -@prg_instance = global %prg zeroinitializer +@prg_instance = global %prg zeroinitializer, section "var-$RUSTY$prg_instance:r0" -define void @prg(%prg* %0) section "fn-prg:v" { +define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: ret void } diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__empty_statements_dont_generate_anything.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__empty_statements_dont_generate_anything.snap index 8e502d81c9b..45c105a08d4 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__empty_statements_dont_generate_anything.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__empty_statements_dont_generate_anything.snap @@ -7,9 +7,9 @@ source_filename = "main" %prg = type { i32, i32 } -@prg_instance = global %prg zeroinitializer +@prg_instance = global %prg zeroinitializer, section "var-$RUSTY$prg_instance:r2i32i32" -define void @prg(%prg* %0) section "fn-prg:v" { +define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: %x = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 %y = getelementptr inbounds %prg, %prg* %0, i32 0, i32 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__enum_members_can_be_used_in_asignments.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__enum_members_can_be_used_in_asignments.snap index aa2572299d3..ef1c55f2b2f 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__enum_members_can_be_used_in_asignments.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__enum_members_can_be_used_in_asignments.snap @@ -7,12 +7,12 @@ source_filename = "main" %main = type { i32 } -@main_instance = global %main zeroinitializer -@MyEnum.red = unnamed_addr constant i32 0 -@MyEnum.yellow = unnamed_addr constant i32 1 -@MyEnum.green = unnamed_addr constant i32 2 +@main_instance = global %main zeroinitializer, section "var-$RUSTY$main_instance:r1e3i32" +@MyEnum.red = unnamed_addr constant i32 0, section "var-$RUSTY$red:e3i32" +@MyEnum.yellow = unnamed_addr constant i32 1, section "var-$RUSTY$yellow:e3i32" +@MyEnum.green = unnamed_addr constant i32 2, section "var-$RUSTY$green:e3i32" -define void @main(%main* %0) section "fn-main:v" { +define void @main(%main* %0) section "fn-$RUSTY$main:v" { entry: %color = getelementptr inbounds %main, %main* %0, i32 0, i32 0 store i32 0, i32* %color, align 4 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__enums_are_generated.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__enums_are_generated.snap index 0abe1ca826f..057b3adc4da 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__enums_are_generated.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__enums_are_generated.snap @@ -5,7 +5,7 @@ expression: result ; ModuleID = 'main' source_filename = "main" -@x = global i32 0 -@MyEnum.red = unnamed_addr constant i32 0 -@MyEnum.yellow = unnamed_addr constant i32 1 -@MyEnum.green = unnamed_addr constant i32 2 +@x = global i32 0, section "var-$RUSTY$x:e3i32" +@MyEnum.red = unnamed_addr constant i32 0, section "var-$RUSTY$red:e3i32" +@MyEnum.yellow = unnamed_addr constant i32 1, section "var-$RUSTY$yellow:e3i32" +@MyEnum.green = unnamed_addr constant i32 2, section "var-$RUSTY$green:e3i32" diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__enums_custom_type_are_generated.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__enums_custom_type_are_generated.snap index e0d826b4519..bd82fedca37 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__enums_custom_type_are_generated.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__enums_custom_type_are_generated.snap @@ -7,13 +7,13 @@ source_filename = "main" %main = type { i32 } -@main_instance = global %main zeroinitializer -@TrafficLight.White = unnamed_addr constant i32 0 -@TrafficLight.Red = unnamed_addr constant i32 1 -@TrafficLight.Yellow = unnamed_addr constant i32 2 -@TrafficLight.Green = unnamed_addr constant i32 3 +@main_instance = global %main zeroinitializer, section "var-$RUSTY$main_instance:r1e4i32" +@TrafficLight.White = unnamed_addr constant i32 0, section "var-$RUSTY$White:e4i32" +@TrafficLight.Red = unnamed_addr constant i32 1, section "var-$RUSTY$Red:e4i32" +@TrafficLight.Yellow = unnamed_addr constant i32 2, section "var-$RUSTY$Yellow:e4i32" +@TrafficLight.Green = unnamed_addr constant i32 3, section "var-$RUSTY$Green:e4i32" -define void @main(%main* %0) section "fn-main:v" { +define void @main(%main* %0) section "fn-$RUSTY$main:v" { entry: %tf1 = getelementptr inbounds %main, %main* %0, i32 0, i32 0 ret void diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__expression_list_as_array_initilization.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__expression_list_as_array_initilization.snap index 74e64e517a1..dc31c6e4534 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__expression_list_as_array_initilization.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__expression_list_as_array_initilization.snap @@ -1,13 +1,10 @@ --- source: src/codegen/tests/code_gen_tests.rs -assertion_line: 2719 expression: result - --- ; ModuleID = 'main' source_filename = "main" -@arr = global [4 x i16] [i16 1, i16 2, i16 3, i16 0] -@b_exp = global [5 x i32] [i32 4, i32 6, i32 6, i32 10, i32 0] -@str = global [3 x [81 x i8]] [[81 x i8] c"first\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00", [81 x i8] c"second\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00", [81 x i8] zeroinitializer] - +@arr = global [4 x i16] [i16 1, i16 2, i16 3, i16 0], section "var-$RUSTY$arr:ai16" +@b_exp = global [5 x i32] [i32 4, i32 6, i32 6, i32 10, i32 0], section "var-$RUSTY$b_exp:ai32" +@str = global [3 x [81 x i8]] [[81 x i8] c"first\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00", [81 x i8] c"second\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00", [81 x i8] zeroinitializer], section "var-$RUSTY$str:as8u81" diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__external_function_called_in_program.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__external_function_called_in_program.snap index cccc8d51d2e..6fc1325f79e 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__external_function_called_in_program.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__external_function_called_in_program.snap @@ -7,11 +7,11 @@ source_filename = "main" %prg = type {} -@prg_instance = global %prg zeroinitializer +@prg_instance = global %prg zeroinitializer, section "var-$RUSTY$prg_instance:r0" -declare i32 @foo() section "fn-foo:i32" +declare i32 @foo() section "fn-$RUSTY$foo:i32" -define void @prg(%prg* %0) section "fn-prg:v" { +define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: %call = call i32 @foo() ret void diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__external_global_variable_generates_as_external.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__external_global_variable_generates_as_external.snap index f1e2407e55a..b7e06b1f739 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__external_global_variable_generates_as_external.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__external_global_variable_generates_as_external.snap @@ -7,11 +7,11 @@ source_filename = "main" %main = type {} -@gX = external global i16 -@gY = external global i8 -@main_instance = global %main zeroinitializer +@gX = external global i16, section "var-$RUSTY$gX:i16" +@gY = external global i8, section "var-$RUSTY$gY:u8" +@main_instance = global %main zeroinitializer, section "var-$RUSTY$main_instance:r0" -define void @main(%main* %0) section "fn-main:v" { +define void @main(%main* %0) section "fn-$RUSTY$main:v" { entry: ret void } diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__external_program_global_var_is_external.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__external_program_global_var_is_external.snap index 36e7bbb9af5..d9521f41def 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__external_program_global_var_is_external.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__external_program_global_var_is_external.snap @@ -7,6 +7,6 @@ source_filename = "main" %prg = type { i32, i32 } -@prg_instance = external global %prg +@prg_instance = external global %prg, section "var-$RUSTY$prg_instance:r2i32i32" -declare void @prg(%prg*) section "fn-prg:v" +declare void @prg(%prg*) section "fn-$RUSTY$prg:v" diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__fb_method_in_pou.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__fb_method_in_pou.snap index 3c0ea0e41ce..b6d4db0881b 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__fb_method_in_pou.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__fb_method_in_pou.snap @@ -9,17 +9,17 @@ source_filename = "main" %prg = type { %MyClass, i16 } %MyClass.testMethod = type { i16, i16 } -@__MyClass__init = unnamed_addr constant %MyClass zeroinitializer -@prg_instance = global %prg zeroinitializer +@__MyClass__init = unnamed_addr constant %MyClass zeroinitializer, section "var-$RUSTY$__MyClass__init:r2i16i16" +@prg_instance = global %prg zeroinitializer, section "var-$RUSTY$prg_instance:r2r2i16i16i16" -define void @MyClass(%MyClass* %0) section "fn-MyClass:v" { +define void @MyClass(%MyClass* %0) section "fn-$RUSTY$MyClass:v" { entry: %x = getelementptr inbounds %MyClass, %MyClass* %0, i32 0, i32 0 %y = getelementptr inbounds %MyClass, %MyClass* %0, i32 0, i32 1 ret void } -define void @MyClass.testMethod(%MyClass* %0, %MyClass.testMethod* %1) section "fn-MyClass.testMethod:v[i16]" { +define void @MyClass.testMethod(%MyClass* %0, %MyClass.testMethod* %1) section "fn-$RUSTY$MyClass.testMethod:v[i16]" { entry: %x = getelementptr inbounds %MyClass, %MyClass* %0, i32 0, i32 0 %y = getelementptr inbounds %MyClass, %MyClass* %0, i32 0, i32 1 @@ -38,7 +38,7 @@ entry: ret void } -define void @prg(%prg* %0) section "fn-prg:v" { +define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: %cl = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 %x = getelementptr inbounds %prg, %prg* %0, i32 0, i32 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__for_statement_continue.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__for_statement_continue.snap index 9158760cb76..ccff95cd6ee 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__for_statement_continue.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__for_statement_continue.snap @@ -7,70 +7,34 @@ source_filename = "main" %prg = type { i32 } -@prg_instance = global %prg zeroinitializer +@prg_instance = global %prg zeroinitializer, section "var-$RUSTY$prg_instance:r1i32" -define void @prg(%prg* %0) section "fn-prg:v" { +define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: %x = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 store i32 3, i32* %x, align 4 - br label %condition_check + br i1 true, label %predicate_sle, label %predicate_sge -condition_check: ; preds = %increment, %entry - %load_x = load i32, i32* %x, align 4 - %load_x1 = load i32, i32* %x, align 4 - %tmpVar = icmp sle i32 %load_x1, 10 - %1 = zext i1 %tmpVar to i8 - %2 = icmp ne i8 %1, 0 - br i1 %2, label %3, label %6 +predicate_sle: ; preds = %increment, %entry + %1 = load i32, i32* %x, align 4 + %condition = icmp sle i32 %1, 10 + br i1 %condition, label %loop, label %continue + +predicate_sge: ; preds = %increment, %entry + %2 = load i32, i32* %x, align 4 + %condition1 = icmp sge i32 %2, 10 + br i1 %condition1, label %loop, label %continue -for_body: ; preds = %13 +loop: ; preds = %predicate_sge, %predicate_sle br label %increment -increment: ; preds = %for_body - %tmpVar8 = add i32 %load_x, 1 - store i32 %tmpVar8, i32* %x, align 4 - br label %condition_check +increment: ; preds = %loop + %3 = load i32, i32* %x, align 4 + %next = add i32 1, %3 + store i32 %next, i32* %x, align 4 + br i1 true, label %predicate_sle, label %predicate_sge -continue: ; preds = %13 - %load_x9 = load i32, i32* %x, align 4 +continue: ; preds = %predicate_sge, %predicate_sle + %load_x = load i32, i32* %x, align 4 ret void - -3: ; preds = %condition_check - %load_x2 = load i32, i32* %x, align 4 - %tmpVar3 = icmp sge i32 %load_x2, 3 - %4 = zext i1 %tmpVar3 to i8 - %5 = icmp ne i8 %4, 0 - br label %6 - -6: ; preds = %3, %condition_check - %7 = phi i1 [ %2, %condition_check ], [ %5, %3 ] - %8 = zext i1 %7 to i8 - %9 = icmp ne i8 %8, 0 - br i1 %9, label %13, label %10 - -10: ; preds = %6 - %load_x4 = load i32, i32* %x, align 4 - %tmpVar5 = icmp sge i32 %load_x4, 10 - %11 = zext i1 %tmpVar5 to i8 - %12 = icmp ne i8 %11, 0 - br i1 %12, label %17, label %20 - -13: ; preds = %20, %6 - %14 = phi i1 [ %9, %6 ], [ %23, %20 ] - %15 = zext i1 %14 to i8 - %16 = icmp ne i8 %15, 0 - br i1 %16, label %for_body, label %continue - -17: ; preds = %10 - %load_x6 = load i32, i32* %x, align 4 - %tmpVar7 = icmp sle i32 %load_x6, 3 - %18 = zext i1 %tmpVar7 to i8 - %19 = icmp ne i8 %18, 0 - br label %20 - -20: ; preds = %17, %10 - %21 = phi i1 [ %12, %10 ], [ %19, %17 ] - %22 = zext i1 %21 to i8 - %23 = icmp ne i8 %22, 0 - br label %13 } diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__for_statement_int.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__for_statement_int.snap index 5f745081384..58c3bc0e70c 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__for_statement_int.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__for_statement_int.snap @@ -7,70 +7,38 @@ source_filename = "main" %prg = type { i16 } -@prg_instance = global %prg zeroinitializer +@prg_instance = global %prg zeroinitializer, section "var-$RUSTY$prg_instance:r1i16" -define void @prg(%prg* %0) section "fn-prg:v" { +define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: %x = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 store i16 3, i16* %x, align 2 - br label %condition_check + br i1 true, label %predicate_sle, label %predicate_sge -condition_check: ; preds = %increment, %entry - %load_x = load i16, i16* %x, align 2 - %load_x1 = load i16, i16* %x, align 2 - %tmpVar = icmp sle i16 %load_x1, 10 - %1 = zext i1 %tmpVar to i8 - %2 = icmp ne i8 %1, 0 - br i1 %2, label %3, label %6 +predicate_sle: ; preds = %increment, %entry + %1 = load i16, i16* %x, align 2 + %2 = sext i16 %1 to i32 + %condition = icmp sle i32 %2, 10 + br i1 %condition, label %loop, label %continue + +predicate_sge: ; preds = %increment, %entry + %3 = load i16, i16* %x, align 2 + %4 = sext i16 %3 to i32 + %condition1 = icmp sge i32 %4, 10 + br i1 %condition1, label %loop, label %continue -for_body: ; preds = %13 - %load_x8 = load i16, i16* %x, align 2 +loop: ; preds = %predicate_sge, %predicate_sle + %load_x = load i16, i16* %x, align 2 br label %increment -increment: ; preds = %for_body - %tmpVar9 = add i16 %load_x, 1 - store i16 %tmpVar9, i16* %x, align 2 - br label %condition_check +increment: ; preds = %loop + %5 = load i16, i16* %x, align 2 + %6 = sext i16 %5 to i32 + %next = add i32 1, %6 + %7 = trunc i32 %next to i16 + store i16 %7, i16* %x, align 2 + br i1 true, label %predicate_sle, label %predicate_sge -continue: ; preds = %13 +continue: ; preds = %predicate_sge, %predicate_sle ret void - -3: ; preds = %condition_check - %load_x2 = load i16, i16* %x, align 2 - %tmpVar3 = icmp sge i16 %load_x2, 3 - %4 = zext i1 %tmpVar3 to i8 - %5 = icmp ne i8 %4, 0 - br label %6 - -6: ; preds = %3, %condition_check - %7 = phi i1 [ %2, %condition_check ], [ %5, %3 ] - %8 = zext i1 %7 to i8 - %9 = icmp ne i8 %8, 0 - br i1 %9, label %13, label %10 - -10: ; preds = %6 - %load_x4 = load i16, i16* %x, align 2 - %tmpVar5 = icmp sge i16 %load_x4, 10 - %11 = zext i1 %tmpVar5 to i8 - %12 = icmp ne i8 %11, 0 - br i1 %12, label %17, label %20 - -13: ; preds = %20, %6 - %14 = phi i1 [ %9, %6 ], [ %23, %20 ] - %15 = zext i1 %14 to i8 - %16 = icmp ne i8 %15, 0 - br i1 %16, label %for_body, label %continue - -17: ; preds = %10 - %load_x6 = load i16, i16* %x, align 2 - %tmpVar7 = icmp sle i16 %load_x6, 3 - %18 = zext i1 %tmpVar7 to i8 - %19 = icmp ne i8 %18, 0 - br label %20 - -20: ; preds = %17, %10 - %21 = phi i1 [ %12, %10 ], [ %19, %17 ] - %22 = zext i1 %21 to i8 - %23 = icmp ne i8 %22, 0 - br label %13 } diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__for_statement_lint.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__for_statement_lint.snap index a1c90f3e7bd..f0ba9385472 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__for_statement_lint.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__for_statement_lint.snap @@ -7,70 +7,34 @@ source_filename = "main" %prg = type { i64 } -@prg_instance = global %prg zeroinitializer +@prg_instance = global %prg zeroinitializer, section "var-$RUSTY$prg_instance:r1i64" -define void @prg(%prg* %0) section "fn-prg:v" { +define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: %x = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 store i64 3, i64* %x, align 4 - br label %condition_check + br i1 true, label %predicate_sle, label %predicate_sge -condition_check: ; preds = %increment, %entry - %load_x = load i64, i64* %x, align 4 - %load_x1 = load i64, i64* %x, align 4 - %tmpVar = icmp sle i64 %load_x1, 10 - %1 = zext i1 %tmpVar to i8 - %2 = icmp ne i8 %1, 0 - br i1 %2, label %3, label %6 +predicate_sle: ; preds = %increment, %entry + %1 = load i64, i64* %x, align 4 + %condition = icmp sle i64 %1, 10 + br i1 %condition, label %loop, label %continue + +predicate_sge: ; preds = %increment, %entry + %2 = load i64, i64* %x, align 4 + %condition1 = icmp sge i64 %2, 10 + br i1 %condition1, label %loop, label %continue -for_body: ; preds = %13 - %load_x8 = load i64, i64* %x, align 4 +loop: ; preds = %predicate_sge, %predicate_sle + %load_x = load i64, i64* %x, align 4 br label %increment -increment: ; preds = %for_body - %tmpVar9 = add i64 %load_x, 1 - store i64 %tmpVar9, i64* %x, align 4 - br label %condition_check +increment: ; preds = %loop + %3 = load i64, i64* %x, align 4 + %next = add i64 1, %3 + store i64 %next, i64* %x, align 4 + br i1 true, label %predicate_sle, label %predicate_sge -continue: ; preds = %13 +continue: ; preds = %predicate_sge, %predicate_sle ret void - -3: ; preds = %condition_check - %load_x2 = load i64, i64* %x, align 4 - %tmpVar3 = icmp sge i64 %load_x2, 3 - %4 = zext i1 %tmpVar3 to i8 - %5 = icmp ne i8 %4, 0 - br label %6 - -6: ; preds = %3, %condition_check - %7 = phi i1 [ %2, %condition_check ], [ %5, %3 ] - %8 = zext i1 %7 to i8 - %9 = icmp ne i8 %8, 0 - br i1 %9, label %13, label %10 - -10: ; preds = %6 - %load_x4 = load i64, i64* %x, align 4 - %tmpVar5 = icmp sge i64 %load_x4, 10 - %11 = zext i1 %tmpVar5 to i8 - %12 = icmp ne i8 %11, 0 - br i1 %12, label %17, label %20 - -13: ; preds = %20, %6 - %14 = phi i1 [ %9, %6 ], [ %23, %20 ] - %15 = zext i1 %14 to i8 - %16 = icmp ne i8 %15, 0 - br i1 %16, label %for_body, label %continue - -17: ; preds = %10 - %load_x6 = load i64, i64* %x, align 4 - %tmpVar7 = icmp sle i64 %load_x6, 3 - %18 = zext i1 %tmpVar7 to i8 - %19 = icmp ne i8 %18, 0 - br label %20 - -20: ; preds = %17, %10 - %21 = phi i1 [ %12, %10 ], [ %19, %17 ] - %22 = zext i1 %21 to i8 - %23 = icmp ne i8 %22, 0 - br label %13 } diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__for_statement_sint.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__for_statement_sint.snap index fb9981f1eef..939f4cbb483 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__for_statement_sint.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__for_statement_sint.snap @@ -7,70 +7,38 @@ source_filename = "main" %prg = type { i8 } -@prg_instance = global %prg zeroinitializer +@prg_instance = global %prg zeroinitializer, section "var-$RUSTY$prg_instance:r1i8" -define void @prg(%prg* %0) section "fn-prg:v" { +define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: %x = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 store i8 3, i8* %x, align 1 - br label %condition_check + br i1 true, label %predicate_sle, label %predicate_sge -condition_check: ; preds = %increment, %entry - %load_x = load i8, i8* %x, align 1 - %load_x1 = load i8, i8* %x, align 1 - %tmpVar = icmp sle i8 %load_x1, 10 - %1 = zext i1 %tmpVar to i8 - %2 = icmp ne i8 %1, 0 - br i1 %2, label %3, label %6 +predicate_sle: ; preds = %increment, %entry + %1 = load i8, i8* %x, align 1 + %2 = sext i8 %1 to i32 + %condition = icmp sle i32 %2, 10 + br i1 %condition, label %loop, label %continue + +predicate_sge: ; preds = %increment, %entry + %3 = load i8, i8* %x, align 1 + %4 = sext i8 %3 to i32 + %condition1 = icmp sge i32 %4, 10 + br i1 %condition1, label %loop, label %continue -for_body: ; preds = %13 - %load_x8 = load i8, i8* %x, align 1 +loop: ; preds = %predicate_sge, %predicate_sle + %load_x = load i8, i8* %x, align 1 br label %increment -increment: ; preds = %for_body - %tmpVar9 = add i8 %load_x, 1 - store i8 %tmpVar9, i8* %x, align 1 - br label %condition_check +increment: ; preds = %loop + %5 = load i8, i8* %x, align 1 + %6 = sext i8 %5 to i32 + %next = add i32 1, %6 + %7 = trunc i32 %next to i8 + store i8 %7, i8* %x, align 1 + br i1 true, label %predicate_sle, label %predicate_sge -continue: ; preds = %13 +continue: ; preds = %predicate_sge, %predicate_sle ret void - -3: ; preds = %condition_check - %load_x2 = load i8, i8* %x, align 1 - %tmpVar3 = icmp sge i8 %load_x2, 3 - %4 = zext i1 %tmpVar3 to i8 - %5 = icmp ne i8 %4, 0 - br label %6 - -6: ; preds = %3, %condition_check - %7 = phi i1 [ %2, %condition_check ], [ %5, %3 ] - %8 = zext i1 %7 to i8 - %9 = icmp ne i8 %8, 0 - br i1 %9, label %13, label %10 - -10: ; preds = %6 - %load_x4 = load i8, i8* %x, align 1 - %tmpVar5 = icmp sge i8 %load_x4, 10 - %11 = zext i1 %tmpVar5 to i8 - %12 = icmp ne i8 %11, 0 - br i1 %12, label %17, label %20 - -13: ; preds = %20, %6 - %14 = phi i1 [ %9, %6 ], [ %23, %20 ] - %15 = zext i1 %14 to i8 - %16 = icmp ne i8 %15, 0 - br i1 %16, label %for_body, label %continue - -17: ; preds = %10 - %load_x6 = load i8, i8* %x, align 1 - %tmpVar7 = icmp sle i8 %load_x6, 3 - %18 = zext i1 %tmpVar7 to i8 - %19 = icmp ne i8 %18, 0 - br label %20 - -20: ; preds = %17, %10 - %21 = phi i1 [ %12, %10 ], [ %19, %17 ] - %22 = zext i1 %21 to i8 - %23 = icmp ne i8 %22, 0 - br label %13 } diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__for_statement_with_continue.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__for_statement_with_continue.snap index d818614e182..d8dcfd34db5 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__for_statement_with_continue.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__for_statement_with_continue.snap @@ -7,78 +7,42 @@ source_filename = "main" %prg = type { i32 } -@prg_instance = global %prg zeroinitializer +@prg_instance = global %prg zeroinitializer, section "var-$RUSTY$prg_instance:r1i32" -define void @prg(%prg* %0) section "fn-prg:v" { +define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: %x = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 store i32 3, i32* %x, align 4 - br label %condition_check + br i1 true, label %predicate_sle, label %predicate_sge -condition_check: ; preds = %increment, %entry - %load_x = load i32, i32* %x, align 4 - %load_x1 = load i32, i32* %x, align 4 - %tmpVar = icmp sle i32 %load_x1, 10 - %1 = zext i1 %tmpVar to i8 - %2 = icmp ne i8 %1, 0 - br i1 %2, label %3, label %6 +predicate_sle: ; preds = %increment, %entry + %1 = load i32, i32* %x, align 4 + %condition = icmp sle i32 %1, 10 + br i1 %condition, label %loop, label %continue + +predicate_sge: ; preds = %increment, %entry + %2 = load i32, i32* %x, align 4 + %condition1 = icmp sge i32 %2, 10 + br i1 %condition1, label %loop, label %continue -for_body: ; preds = %13 - %load_x8 = load i32, i32* %x, align 4 - %tmpVar9 = add i32 %load_x8, 1 - store i32 %tmpVar9, i32* %x, align 4 +loop: ; preds = %predicate_sge, %predicate_sle + %load_x = load i32, i32* %x, align 4 + %tmpVar = add i32 %load_x, 1 + store i32 %tmpVar, i32* %x, align 4 br label %increment buffer_block: ; No predecessors! - %load_x10 = load i32, i32* %x, align 4 - %tmpVar11 = sub i32 %load_x10, 1 - store i32 %tmpVar11, i32* %x, align 4 + %load_x2 = load i32, i32* %x, align 4 + %tmpVar3 = sub i32 %load_x2, 1 + store i32 %tmpVar3, i32* %x, align 4 br label %increment -increment: ; preds = %buffer_block, %for_body - %tmpVar12 = add i32 %load_x, 7 - store i32 %tmpVar12, i32* %x, align 4 - br label %condition_check +increment: ; preds = %buffer_block, %loop + %3 = load i32, i32* %x, align 4 + %next = add i32 7, %3 + store i32 %next, i32* %x, align 4 + br i1 true, label %predicate_sle, label %predicate_sge -continue: ; preds = %13 +continue: ; preds = %predicate_sge, %predicate_sle ret void - -3: ; preds = %condition_check - %load_x2 = load i32, i32* %x, align 4 - %tmpVar3 = icmp sge i32 %load_x2, 3 - %4 = zext i1 %tmpVar3 to i8 - %5 = icmp ne i8 %4, 0 - br label %6 - -6: ; preds = %3, %condition_check - %7 = phi i1 [ %2, %condition_check ], [ %5, %3 ] - %8 = zext i1 %7 to i8 - %9 = icmp ne i8 %8, 0 - br i1 %9, label %13, label %10 - -10: ; preds = %6 - %load_x4 = load i32, i32* %x, align 4 - %tmpVar5 = icmp sge i32 %load_x4, 10 - %11 = zext i1 %tmpVar5 to i8 - %12 = icmp ne i8 %11, 0 - br i1 %12, label %17, label %20 - -13: ; preds = %20, %6 - %14 = phi i1 [ %9, %6 ], [ %23, %20 ] - %15 = zext i1 %14 to i8 - %16 = icmp ne i8 %15, 0 - br i1 %16, label %for_body, label %continue - -17: ; preds = %10 - %load_x6 = load i32, i32* %x, align 4 - %tmpVar7 = icmp sle i32 %load_x6, 3 - %18 = zext i1 %tmpVar7 to i8 - %19 = icmp ne i8 %18, 0 - br label %20 - -20: ; preds = %17, %10 - %21 = phi i1 [ %12, %10 ], [ %19, %17 ] - %22 = zext i1 %21 to i8 - %23 = icmp ne i8 %22, 0 - br label %13 } diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__for_statement_with_exit.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__for_statement_with_exit.snap index 5b3736b042e..00a9396ea4f 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__for_statement_with_exit.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__for_statement_with_exit.snap @@ -7,78 +7,42 @@ source_filename = "main" %prg = type { i32 } -@prg_instance = global %prg zeroinitializer +@prg_instance = global %prg zeroinitializer, section "var-$RUSTY$prg_instance:r1i32" -define void @prg(%prg* %0) section "fn-prg:v" { +define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: %x = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 store i32 3, i32* %x, align 4 - br label %condition_check + br i1 true, label %predicate_sle, label %predicate_sge -condition_check: ; preds = %increment, %entry - %load_x = load i32, i32* %x, align 4 - %load_x1 = load i32, i32* %x, align 4 - %tmpVar = icmp sle i32 %load_x1, 10 - %1 = zext i1 %tmpVar to i8 - %2 = icmp ne i8 %1, 0 - br i1 %2, label %3, label %6 +predicate_sle: ; preds = %increment, %entry + %1 = load i32, i32* %x, align 4 + %condition = icmp sle i32 %1, 10 + br i1 %condition, label %loop, label %continue + +predicate_sge: ; preds = %increment, %entry + %2 = load i32, i32* %x, align 4 + %condition1 = icmp sge i32 %2, 10 + br i1 %condition1, label %loop, label %continue -for_body: ; preds = %13 - %load_x8 = load i32, i32* %x, align 4 - %tmpVar9 = add i32 %load_x8, 2 - store i32 %tmpVar9, i32* %x, align 4 +loop: ; preds = %predicate_sge, %predicate_sle + %load_x = load i32, i32* %x, align 4 + %tmpVar = add i32 %load_x, 2 + store i32 %tmpVar, i32* %x, align 4 br label %continue buffer_block: ; No predecessors! - %load_x10 = load i32, i32* %x, align 4 - %tmpVar11 = add i32 %load_x10, 5 - store i32 %tmpVar11, i32* %x, align 4 + %load_x2 = load i32, i32* %x, align 4 + %tmpVar3 = add i32 %load_x2, 5 + store i32 %tmpVar3, i32* %x, align 4 br label %increment increment: ; preds = %buffer_block - %tmpVar12 = add i32 %load_x, 7 - store i32 %tmpVar12, i32* %x, align 4 - br label %condition_check + %3 = load i32, i32* %x, align 4 + %next = add i32 7, %3 + store i32 %next, i32* %x, align 4 + br i1 true, label %predicate_sle, label %predicate_sge -continue: ; preds = %for_body, %13 +continue: ; preds = %loop, %predicate_sge, %predicate_sle ret void - -3: ; preds = %condition_check - %load_x2 = load i32, i32* %x, align 4 - %tmpVar3 = icmp sge i32 %load_x2, 3 - %4 = zext i1 %tmpVar3 to i8 - %5 = icmp ne i8 %4, 0 - br label %6 - -6: ; preds = %3, %condition_check - %7 = phi i1 [ %2, %condition_check ], [ %5, %3 ] - %8 = zext i1 %7 to i8 - %9 = icmp ne i8 %8, 0 - br i1 %9, label %13, label %10 - -10: ; preds = %6 - %load_x4 = load i32, i32* %x, align 4 - %tmpVar5 = icmp sge i32 %load_x4, 10 - %11 = zext i1 %tmpVar5 to i8 - %12 = icmp ne i8 %11, 0 - br i1 %12, label %17, label %20 - -13: ; preds = %20, %6 - %14 = phi i1 [ %9, %6 ], [ %23, %20 ] - %15 = zext i1 %14 to i8 - %16 = icmp ne i8 %15, 0 - br i1 %16, label %for_body, label %continue - -17: ; preds = %10 - %load_x6 = load i32, i32* %x, align 4 - %tmpVar7 = icmp sle i32 %load_x6, 3 - %18 = zext i1 %tmpVar7 to i8 - %19 = icmp ne i8 %18, 0 - br label %20 - -20: ; preds = %17, %10 - %21 = phi i1 [ %12, %10 ], [ %19, %17 ] - %22 = zext i1 %21 to i8 - %23 = icmp ne i8 %22, 0 - br label %13 } diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__for_statement_with_references_steps_test.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__for_statement_with_references_steps_test.snap index 57bce3d6c1b..28d0351a436 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__for_statement_with_references_steps_test.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__for_statement_with_references_steps_test.snap @@ -7,9 +7,9 @@ source_filename = "main" %prg = type { i32, i32, i32, i32 } -@prg_instance = global %prg zeroinitializer +@prg_instance = global %prg zeroinitializer, section "var-$RUSTY$prg_instance:r4i32i32i32i32" -define void @prg(%prg* %0) section "fn-prg:v" { +define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: %step = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 %x = getelementptr inbounds %prg, %prg* %0, i32 0, i32 1 @@ -17,69 +17,33 @@ entry: %z = getelementptr inbounds %prg, %prg* %0, i32 0, i32 3 %load_y = load i32, i32* %y, align 4 store i32 %load_y, i32* %x, align 4 - br label %condition_check - -condition_check: ; preds = %increment, %entry + %load_step = load i32, i32* %step, align 4 + %is_incrementing = icmp sgt i32 %load_step, 0 + br i1 %is_incrementing, label %predicate_sle, label %predicate_sge + +predicate_sle: ; preds = %increment, %entry + %1 = load i32, i32* %z, align 4 + %2 = load i32, i32* %x, align 4 + %condition = icmp sle i32 %2, %1 + br i1 %condition, label %loop, label %continue + +predicate_sge: ; preds = %increment, %entry + %3 = load i32, i32* %z, align 4 + %4 = load i32, i32* %x, align 4 + %condition1 = icmp sge i32 %4, %3 + br i1 %condition1, label %loop, label %continue + +loop: ; preds = %predicate_sge, %predicate_sle %load_x = load i32, i32* %x, align 4 - %load_x1 = load i32, i32* %x, align 4 - %load_z = load i32, i32* %z, align 4 - %tmpVar = icmp sle i32 %load_x1, %load_z - %1 = zext i1 %tmpVar to i8 - %2 = icmp ne i8 %1, 0 - br i1 %2, label %3, label %6 - -for_body: ; preds = %13 - %load_x11 = load i32, i32* %x, align 4 br label %increment -increment: ; preds = %for_body - %load_step = load i32, i32* %step, align 4 - %tmpVar12 = add i32 %load_x, %load_step - store i32 %tmpVar12, i32* %x, align 4 - br label %condition_check +increment: ; preds = %loop + %5 = load i32, i32* %x, align 4 + %load_step2 = load i32, i32* %step, align 4 + %next = add i32 %load_step2, %5 + store i32 %next, i32* %x, align 4 + br i1 %is_incrementing, label %predicate_sle, label %predicate_sge -continue: ; preds = %13 +continue: ; preds = %predicate_sge, %predicate_sle ret void - -3: ; preds = %condition_check - %load_x2 = load i32, i32* %x, align 4 - %load_y3 = load i32, i32* %y, align 4 - %tmpVar4 = icmp sge i32 %load_x2, %load_y3 - %4 = zext i1 %tmpVar4 to i8 - %5 = icmp ne i8 %4, 0 - br label %6 - -6: ; preds = %3, %condition_check - %7 = phi i1 [ %2, %condition_check ], [ %5, %3 ] - %8 = zext i1 %7 to i8 - %9 = icmp ne i8 %8, 0 - br i1 %9, label %13, label %10 - -10: ; preds = %6 - %load_x5 = load i32, i32* %x, align 4 - %load_z6 = load i32, i32* %z, align 4 - %tmpVar7 = icmp sge i32 %load_x5, %load_z6 - %11 = zext i1 %tmpVar7 to i8 - %12 = icmp ne i8 %11, 0 - br i1 %12, label %17, label %20 - -13: ; preds = %20, %6 - %14 = phi i1 [ %9, %6 ], [ %23, %20 ] - %15 = zext i1 %14 to i8 - %16 = icmp ne i8 %15, 0 - br i1 %16, label %for_body, label %continue - -17: ; preds = %10 - %load_x8 = load i32, i32* %x, align 4 - %load_y9 = load i32, i32* %y, align 4 - %tmpVar10 = icmp sle i32 %load_x8, %load_y9 - %18 = zext i1 %tmpVar10 to i8 - %19 = icmp ne i8 %18, 0 - br label %20 - -20: ; preds = %17, %10 - %21 = phi i1 [ %12, %10 ], [ %19, %17 ] - %22 = zext i1 %21 to i8 - %23 = icmp ne i8 %22, 0 - br label %13 } diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__for_statement_with_steps_test.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__for_statement_with_steps_test.snap index 84539899322..d32995dea1f 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__for_statement_with_steps_test.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__for_statement_with_steps_test.snap @@ -7,70 +7,34 @@ source_filename = "main" %prg = type { i32 } -@prg_instance = global %prg zeroinitializer +@prg_instance = global %prg zeroinitializer, section "var-$RUSTY$prg_instance:r1i32" -define void @prg(%prg* %0) section "fn-prg:v" { +define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: %x = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 store i32 3, i32* %x, align 4 - br label %condition_check + br i1 true, label %predicate_sle, label %predicate_sge -condition_check: ; preds = %increment, %entry - %load_x = load i32, i32* %x, align 4 - %load_x1 = load i32, i32* %x, align 4 - %tmpVar = icmp sle i32 %load_x1, 10 - %1 = zext i1 %tmpVar to i8 - %2 = icmp ne i8 %1, 0 - br i1 %2, label %3, label %6 +predicate_sle: ; preds = %increment, %entry + %1 = load i32, i32* %x, align 4 + %condition = icmp sle i32 %1, 10 + br i1 %condition, label %loop, label %continue + +predicate_sge: ; preds = %increment, %entry + %2 = load i32, i32* %x, align 4 + %condition1 = icmp sge i32 %2, 10 + br i1 %condition1, label %loop, label %continue -for_body: ; preds = %13 - %load_x8 = load i32, i32* %x, align 4 +loop: ; preds = %predicate_sge, %predicate_sle + %load_x = load i32, i32* %x, align 4 br label %increment -increment: ; preds = %for_body - %tmpVar9 = add i32 %load_x, 7 - store i32 %tmpVar9, i32* %x, align 4 - br label %condition_check +increment: ; preds = %loop + %3 = load i32, i32* %x, align 4 + %next = add i32 7, %3 + store i32 %next, i32* %x, align 4 + br i1 true, label %predicate_sle, label %predicate_sge -continue: ; preds = %13 +continue: ; preds = %predicate_sge, %predicate_sle ret void - -3: ; preds = %condition_check - %load_x2 = load i32, i32* %x, align 4 - %tmpVar3 = icmp sge i32 %load_x2, 3 - %4 = zext i1 %tmpVar3 to i8 - %5 = icmp ne i8 %4, 0 - br label %6 - -6: ; preds = %3, %condition_check - %7 = phi i1 [ %2, %condition_check ], [ %5, %3 ] - %8 = zext i1 %7 to i8 - %9 = icmp ne i8 %8, 0 - br i1 %9, label %13, label %10 - -10: ; preds = %6 - %load_x4 = load i32, i32* %x, align 4 - %tmpVar5 = icmp sge i32 %load_x4, 10 - %11 = zext i1 %tmpVar5 to i8 - %12 = icmp ne i8 %11, 0 - br i1 %12, label %17, label %20 - -13: ; preds = %20, %6 - %14 = phi i1 [ %9, %6 ], [ %23, %20 ] - %15 = zext i1 %14 to i8 - %16 = icmp ne i8 %15, 0 - br i1 %16, label %for_body, label %continue - -17: ; preds = %10 - %load_x6 = load i32, i32* %x, align 4 - %tmpVar7 = icmp sle i32 %load_x6, 3 - %18 = zext i1 %tmpVar7 to i8 - %19 = icmp ne i8 %18, 0 - br label %20 - -20: ; preds = %17, %10 - %21 = phi i1 [ %12, %10 ], [ %19, %17 ] - %22 = zext i1 %21 to i8 - %23 = icmp ne i8 %22, 0 - br label %13 } diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__for_statement_without_steps_test.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__for_statement_without_steps_test.snap index 5d3fac126f8..411285a0cc2 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__for_statement_without_steps_test.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__for_statement_without_steps_test.snap @@ -7,70 +7,34 @@ source_filename = "main" %prg = type { i32 } -@prg_instance = global %prg zeroinitializer +@prg_instance = global %prg zeroinitializer, section "var-$RUSTY$prg_instance:r1i32" -define void @prg(%prg* %0) section "fn-prg:v" { +define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: %x = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 store i32 3, i32* %x, align 4 - br label %condition_check + br i1 true, label %predicate_sle, label %predicate_sge -condition_check: ; preds = %increment, %entry - %load_x = load i32, i32* %x, align 4 - %load_x1 = load i32, i32* %x, align 4 - %tmpVar = icmp sle i32 %load_x1, 10 - %1 = zext i1 %tmpVar to i8 - %2 = icmp ne i8 %1, 0 - br i1 %2, label %3, label %6 +predicate_sle: ; preds = %increment, %entry + %1 = load i32, i32* %x, align 4 + %condition = icmp sle i32 %1, 10 + br i1 %condition, label %loop, label %continue + +predicate_sge: ; preds = %increment, %entry + %2 = load i32, i32* %x, align 4 + %condition1 = icmp sge i32 %2, 10 + br i1 %condition1, label %loop, label %continue -for_body: ; preds = %13 - %load_x8 = load i32, i32* %x, align 4 +loop: ; preds = %predicate_sge, %predicate_sle + %load_x = load i32, i32* %x, align 4 br label %increment -increment: ; preds = %for_body - %tmpVar9 = add i32 %load_x, 1 - store i32 %tmpVar9, i32* %x, align 4 - br label %condition_check +increment: ; preds = %loop + %3 = load i32, i32* %x, align 4 + %next = add i32 1, %3 + store i32 %next, i32* %x, align 4 + br i1 true, label %predicate_sle, label %predicate_sge -continue: ; preds = %13 +continue: ; preds = %predicate_sge, %predicate_sle ret void - -3: ; preds = %condition_check - %load_x2 = load i32, i32* %x, align 4 - %tmpVar3 = icmp sge i32 %load_x2, 3 - %4 = zext i1 %tmpVar3 to i8 - %5 = icmp ne i8 %4, 0 - br label %6 - -6: ; preds = %3, %condition_check - %7 = phi i1 [ %2, %condition_check ], [ %5, %3 ] - %8 = zext i1 %7 to i8 - %9 = icmp ne i8 %8, 0 - br i1 %9, label %13, label %10 - -10: ; preds = %6 - %load_x4 = load i32, i32* %x, align 4 - %tmpVar5 = icmp sge i32 %load_x4, 10 - %11 = zext i1 %tmpVar5 to i8 - %12 = icmp ne i8 %11, 0 - br i1 %12, label %17, label %20 - -13: ; preds = %20, %6 - %14 = phi i1 [ %9, %6 ], [ %23, %20 ] - %15 = zext i1 %14 to i8 - %16 = icmp ne i8 %15, 0 - br i1 %16, label %for_body, label %continue - -17: ; preds = %10 - %load_x6 = load i32, i32* %x, align 4 - %tmpVar7 = icmp sle i32 %load_x6, 3 - %18 = zext i1 %tmpVar7 to i8 - %19 = icmp ne i8 %18, 0 - br label %20 - -20: ; preds = %17, %10 - %21 = phi i1 [ %12, %10 ], [ %19, %17 ] - %22 = zext i1 %21 to i8 - %23 = icmp ne i8 %22, 0 - br label %13 } diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__function_block_instance_call.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__function_block_instance_call.snap index 005f6caf771..94777d2d7bb 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__function_block_instance_call.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__function_block_instance_call.snap @@ -8,17 +8,17 @@ source_filename = "main" %foo = type { i16, i16 } %prg = type { %foo } -@__foo__init = unnamed_addr constant %foo zeroinitializer -@prg_instance = global %prg zeroinitializer +@__foo__init = unnamed_addr constant %foo zeroinitializer, section "var-$RUSTY$__foo__init:r2i16i16" +@prg_instance = global %prg zeroinitializer, section "var-$RUSTY$prg_instance:r1r2i16i16" -define void @foo(%foo* %0) section "fn-foo:v[i16][i16]" { +define void @foo(%foo* %0) section "fn-$RUSTY$foo:v[i16][i16]" { entry: %x = getelementptr inbounds %foo, %foo* %0, i32 0, i32 0 %y = getelementptr inbounds %foo, %foo* %0, i32 0, i32 1 ret void } -define void @prg(%prg* %0) section "fn-prg:v" { +define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: %fb_inst = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 call void @foo(%foo* %fb_inst) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__function_block_qualified_instance_call.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__function_block_qualified_instance_call.snap index 0b86c010d7c..72d159848b9 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__function_block_qualified_instance_call.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__function_block_qualified_instance_call.snap @@ -9,22 +9,22 @@ source_filename = "main" %bar = type {} %prg = type { %foo } -@__foo__init = unnamed_addr constant %foo zeroinitializer -@__bar__init = unnamed_addr constant %bar zeroinitializer -@prg_instance = global %prg zeroinitializer +@__foo__init = unnamed_addr constant %foo zeroinitializer, section "var-$RUSTY$__foo__init:r1r0" +@__bar__init = unnamed_addr constant %bar zeroinitializer, section "var-$RUSTY$__bar__init:r0" +@prg_instance = global %prg zeroinitializer, section "var-$RUSTY$prg_instance:r1r1r0" -define void @foo(%foo* %0) section "fn-foo:v" { +define void @foo(%foo* %0) section "fn-$RUSTY$foo:v" { entry: %bar_inst = getelementptr inbounds %foo, %foo* %0, i32 0, i32 0 ret void } -define void @bar(%bar* %0) section "fn-bar:v" { +define void @bar(%bar* %0) section "fn-$RUSTY$bar:v" { entry: ret void } -define void @prg(%prg* %0) section "fn-prg:v" { +define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: %foo_inst = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 %bar_inst = getelementptr inbounds %foo, %foo* %foo_inst, i32 0, i32 0 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__function_call_with_same_name_as_return_type.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__function_call_with_same_name_as_return_type.snap index efd50eb79d6..5c36e240874 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__function_call_with_same_name_as_return_type.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__function_call_with_same_name_as_return_type.snap @@ -7,9 +7,9 @@ source_filename = "main" %prg = type {} -@prg_instance = global %prg zeroinitializer +@prg_instance = global %prg zeroinitializer, section "var-$RUSTY$prg_instance:r0" -define i64 @TIME() section "fn-TIME:i64" { +define i64 @TIME() section "fn-$RUSTY$TIME:i64" { entry: %TIME = alloca i64, align 8 store i64 0, i64* %TIME, align 4 @@ -17,7 +17,7 @@ entry: ret i64 %TIME_ret } -define void @prg(%prg* %0) section "fn-prg:v" { +define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: %call = call i64 @TIME() ret void diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__function_called_in_program.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__function_called_in_program.snap index e93b371d6bf..0317488398e 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__function_called_in_program.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__function_called_in_program.snap @@ -7,9 +7,9 @@ source_filename = "main" %prg = type { i32 } -@prg_instance = global %prg zeroinitializer +@prg_instance = global %prg zeroinitializer, section "var-$RUSTY$prg_instance:r1i32" -define i32 @foo() section "fn-foo:i32" { +define i32 @foo() section "fn-$RUSTY$foo:i32" { entry: %foo = alloca i32, align 4 store i32 0, i32* %foo, align 4 @@ -18,7 +18,7 @@ entry: ret i32 %foo_ret } -define void @prg(%prg* %0) section "fn-prg:v" { +define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: %x = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 %call = call i32 @foo() diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__function_called_when_shadowed.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__function_called_when_shadowed.snap index d799007060a..87f13d62a35 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__function_called_when_shadowed.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__function_called_when_shadowed.snap @@ -7,9 +7,9 @@ source_filename = "main" %prg = type { i32 } -@prg_instance = global %prg zeroinitializer +@prg_instance = global %prg zeroinitializer, section "var-$RUSTY$prg_instance:r1i32" -define i32 @foo() section "fn-foo:i32" { +define i32 @foo() section "fn-$RUSTY$foo:i32" { entry: %foo = alloca i32, align 4 store i32 0, i32* %foo, align 4 @@ -18,7 +18,7 @@ entry: ret i32 %foo_ret } -define void @prg(%prg* %0) section "fn-prg:v" { +define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: %froo = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 %call = call i32 @foo() diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__function_with_local_temp_var_initialization.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__function_with_local_temp_var_initialization.snap index e64407254dd..e37a94c26f5 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__function_with_local_temp_var_initialization.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__function_with_local_temp_var_initialization.snap @@ -7,9 +7,9 @@ source_filename = "main" %prg = type {} -@prg_instance = global %prg zeroinitializer +@prg_instance = global %prg zeroinitializer, section "var-$RUSTY$prg_instance:r0" -define i32 @foo(i32 %0) section "fn-foo:i32[i32]" { +define i32 @foo(i32 %0) section "fn-$RUSTY$foo:i32[i32]" { entry: %foo = alloca i32, align 4 %in1 = alloca i32, align 4 @@ -30,7 +30,7 @@ entry: ret i32 %foo_ret } -define void @prg(%prg* %0) section "fn-prg:v" { +define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: %call = call i32 @foo(i32 5) ret void diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__function_with_local_var_initialization_and_call.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__function_with_local_var_initialization_and_call.snap index 502da9643cc..0339a12c6b1 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__function_with_local_var_initialization_and_call.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__function_with_local_var_initialization_and_call.snap @@ -7,9 +7,9 @@ source_filename = "main" %prg = type {} -@prg_instance = global %prg zeroinitializer +@prg_instance = global %prg zeroinitializer, section "var-$RUSTY$prg_instance:r0" -define i32 @foo(i32 %0) section "fn-foo:i32[i32]" { +define i32 @foo(i32 %0) section "fn-$RUSTY$foo:i32[i32]" { entry: %foo = alloca i32, align 4 %in1 = alloca i32, align 4 @@ -26,7 +26,7 @@ entry: ret i32 %foo_ret } -define void @prg(%prg* %0) section "fn-prg:v" { +define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: %call = call i32 @foo(i32 5) ret void diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__function_with_parameters_called_in_program.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__function_with_parameters_called_in_program.snap index 25d554785cb..9746527493a 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__function_with_parameters_called_in_program.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__function_with_parameters_called_in_program.snap @@ -7,9 +7,9 @@ source_filename = "main" %prg = type { i32 } -@prg_instance = global %prg zeroinitializer +@prg_instance = global %prg zeroinitializer, section "var-$RUSTY$prg_instance:r1i32" -define i32 @foo(i32 %0) section "fn-foo:i32[i32]" { +define i32 @foo(i32 %0) section "fn-$RUSTY$foo:i32[i32]" { entry: %foo = alloca i32, align 4 %bar = alloca i32, align 4 @@ -20,7 +20,7 @@ entry: ret i32 %foo_ret } -define void @prg(%prg* %0) section "fn-prg:v" { +define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: %x = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 %call = call i32 @foo(i32 2) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__function_with_two_parameters_called_in_program.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__function_with_two_parameters_called_in_program.snap index c2071bde992..983140bb995 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__function_with_two_parameters_called_in_program.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__function_with_two_parameters_called_in_program.snap @@ -7,9 +7,9 @@ source_filename = "main" %prg = type { i32 } -@prg_instance = global %prg zeroinitializer +@prg_instance = global %prg zeroinitializer, section "var-$RUSTY$prg_instance:r1i32" -define i32 @foo(i32 %0, i8 %1) section "fn-foo:i32[i32][u8]" { +define i32 @foo(i32 %0, i8 %1) section "fn-$RUSTY$foo:i32[i32][u8]" { entry: %foo = alloca i32, align 4 %bar = alloca i32, align 4 @@ -22,7 +22,7 @@ entry: ret i32 %foo_ret } -define void @prg(%prg* %0) section "fn-prg:v" { +define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: %x = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 %call = call i32 @foo(i32 2, i8 1) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__global_variable_reference_is_generated.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__global_variable_reference_is_generated.snap index a86223b3fd6..7ae048cffcf 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__global_variable_reference_is_generated.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__global_variable_reference_is_generated.snap @@ -7,10 +7,10 @@ source_filename = "main" %prg = type { i16 } -@gX = global i16 0 -@prg_instance = global %prg zeroinitializer +@gX = global i16 0, section "var-$RUSTY$gX:i16" +@prg_instance = global %prg zeroinitializer, section "var-$RUSTY$prg_instance:r1i16" -define void @prg(%prg* %0) section "fn-prg:v" { +define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: %x = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 store i16 20, i16* @gX, align 2 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__if_elsif_else_generator_test.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__if_elsif_else_generator_test.snap index 98ed4b0730e..23df0bcab41 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__if_elsif_else_generator_test.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__if_elsif_else_generator_test.snap @@ -7,9 +7,9 @@ source_filename = "main" %prg = type { i32, i32, i32, i32, i8, i8, i8 } -@prg_instance = global %prg zeroinitializer +@prg_instance = global %prg zeroinitializer, section "var-$RUSTY$prg_instance:r7i32i32i32i32u8u8u8" -define void @prg(%prg* %0) section "fn-prg:v" { +define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: %x = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 %y = getelementptr inbounds %prg, %prg* %0, i32 0, i32 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__if_generator_test.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__if_generator_test.snap index e65bc548b99..a824d5337e5 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__if_generator_test.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__if_generator_test.snap @@ -7,9 +7,9 @@ source_filename = "main" %prg = type { i32, i8 } -@prg_instance = global %prg zeroinitializer +@prg_instance = global %prg zeroinitializer, section "var-$RUSTY$prg_instance:r2i32u8" -define void @prg(%prg* %0) section "fn-prg:v" { +define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: %x = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 %b1 = getelementptr inbounds %prg, %prg* %0, i32 0, i32 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__if_with_expression_generator_test.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__if_with_expression_generator_test.snap index b12b4c415c7..e49be94e85b 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__if_with_expression_generator_test.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__if_with_expression_generator_test.snap @@ -7,9 +7,9 @@ source_filename = "main" %prg = type { i32, i8 } -@prg_instance = global %prg zeroinitializer +@prg_instance = global %prg zeroinitializer, section "var-$RUSTY$prg_instance:r2i32u8" -define void @prg(%prg* %0) section "fn-prg:v" { +define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: %x = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 %b1 = getelementptr inbounds %prg, %prg* %0, i32 0, i32 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__inline_enums_are_generated.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__inline_enums_are_generated.snap index 4871a67eca0..a69798fd140 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__inline_enums_are_generated.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__inline_enums_are_generated.snap @@ -5,7 +5,7 @@ expression: result ; ModuleID = 'main' source_filename = "main" -@x = global i32 0 -@__global_x.red = unnamed_addr constant i32 0 -@__global_x.yellow = unnamed_addr constant i32 1 -@__global_x.green = unnamed_addr constant i32 2 +@x = global i32 0, section "var-$RUSTY$x:e3i32" +@__global_x.red = unnamed_addr constant i32 0, section "var-$RUSTY$red:e3i32" +@__global_x.yellow = unnamed_addr constant i32 1, section "var-$RUSTY$yellow:e3i32" +@__global_x.green = unnamed_addr constant i32 2, section "var-$RUSTY$green:e3i32" diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__inline_structs_are_generated.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__inline_structs_are_generated.snap index 342b6acc449..5637181171a 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__inline_structs_are_generated.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__inline_structs_are_generated.snap @@ -7,6 +7,5 @@ source_filename = "main" %__global_x = type { i32, i32 } -@x = global %__global_x zeroinitializer -@____global_x__init = unnamed_addr constant %__global_x zeroinitializer - +@x = global %__global_x zeroinitializer, section "var-$RUSTY$x:r2i32i32" +@____global_x__init = unnamed_addr constant %__global_x zeroinitializer, section "var-$RUSTY$____global_x__init:r2i32i32" diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__inlined_array_size_from_local_scoped_constants.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__inlined_array_size_from_local_scoped_constants.snap index cd41db2ea36..53cc42de783 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__inlined_array_size_from_local_scoped_constants.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__inlined_array_size_from_local_scoped_constants.snap @@ -7,12 +7,12 @@ source_filename = "main" %aaa = type { i16, i16, [5 x i8], [3 x i8] } -@a = unnamed_addr constant i16 0 -@b = unnamed_addr constant i16 2 -@c = unnamed_addr constant i16 5 -@aaa_instance = global %aaa { i16 3, i16 7, [5 x i8] zeroinitializer, [3 x i8] zeroinitializer } +@a = unnamed_addr constant i16 0, section "var-$RUSTY$a:i16" +@b = unnamed_addr constant i16 2, section "var-$RUSTY$b:i16" +@c = unnamed_addr constant i16 5, section "var-$RUSTY$c:i16" +@aaa_instance = global %aaa { i16 3, i16 7, [5 x i8] zeroinitializer, [3 x i8] zeroinitializer }, section "var-$RUSTY$aaa_instance:r4i16i16au8au8" -define void @aaa(%aaa* %0) section "fn-aaa:v" { +define void @aaa(%aaa* %0) section "fn-$RUSTY$aaa:v" { entry: %a = getelementptr inbounds %aaa, %aaa* %0, i32 0, i32 0 %b = getelementptr inbounds %aaa, %aaa* %0, i32 0, i32 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__method_codegen_return.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__method_codegen_return.snap index f0efdafb33d..87c7d9eaa1c 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__method_codegen_return.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__method_codegen_return.snap @@ -8,14 +8,14 @@ source_filename = "main" %MyClass = type {} %MyClass.testMethod = type { i16 } -@__MyClass__init = unnamed_addr constant %MyClass zeroinitializer +@__MyClass__init = unnamed_addr constant %MyClass zeroinitializer, section "var-$RUSTY$__MyClass__init:r0" -define void @MyClass(%MyClass* %0) section "fn-MyClass:v" { +define void @MyClass(%MyClass* %0) section "fn-$RUSTY$MyClass:v" { entry: ret void } -define i16 @MyClass.testMethod(%MyClass* %0, %MyClass.testMethod* %1) section "fn-MyClass.testMethod:i16[i16]" { +define i16 @MyClass.testMethod(%MyClass* %0, %MyClass.testMethod* %1) section "fn-$RUSTY$MyClass.testMethod:i16[i16]" { entry: %myMethodArg = getelementptr inbounds %MyClass.testMethod, %MyClass.testMethod* %1, i32 0, i32 0 %testMethod = alloca i16, align 2 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__method_codegen_void.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__method_codegen_void.snap index 66f3b579fe6..8e9dc9ccaa1 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__method_codegen_void.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__method_codegen_void.snap @@ -8,14 +8,14 @@ source_filename = "main" %MyClass = type {} %MyClass.testMethod = type { i16, i16 } -@__MyClass__init = unnamed_addr constant %MyClass zeroinitializer +@__MyClass__init = unnamed_addr constant %MyClass zeroinitializer, section "var-$RUSTY$__MyClass__init:r0" -define void @MyClass(%MyClass* %0) section "fn-MyClass:v" { +define void @MyClass(%MyClass* %0) section "fn-$RUSTY$MyClass:v" { entry: ret void } -define void @MyClass.testMethod(%MyClass* %0, %MyClass.testMethod* %1) section "fn-MyClass.testMethod:v[i16]" { +define void @MyClass.testMethod(%MyClass* %0, %MyClass.testMethod* %1) section "fn-$RUSTY$MyClass.testMethod:v[i16]" { entry: %myMethodArg = getelementptr inbounds %MyClass.testMethod, %MyClass.testMethod* %1, i32 0, i32 0 %myMethodLocalVar = getelementptr inbounds %MyClass.testMethod, %MyClass.testMethod* %1, i32 0, i32 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__min_max_real_and_lreal_values_do_not_result_in_an_under_or_overflow.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__min_max_real_and_lreal_values_do_not_result_in_an_under_or_overflow.snap index adab6e978bb..1579e045bc3 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__min_max_real_and_lreal_values_do_not_result_in_an_under_or_overflow.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__min_max_real_and_lreal_values_do_not_result_in_an_under_or_overflow.snap @@ -7,9 +7,9 @@ source_filename = "main" %main = type { float, float, double, double } -@main_instance = global %main { float 0xC7EFFFFFE0000000, float 0x47EFFFFFE0000000, double 0xFFEFFFFFFFFFFFFF, double 0x7FEFFFFFFFFFFFFF } +@main_instance = global %main { float 0xC7EFFFFFE0000000, float 0x47EFFFFFE0000000, double 0xFFEFFFFFFFFFFFFF, double 0x7FEFFFFFFFFFFFFF }, section "var-$RUSTY$main_instance:r4f32f32f64f64" -define void @main(%main* %0) section "fn-main:v" { +define void @main(%main* %0) section "fn-$RUSTY$main:v" { entry: %F32_MIN = getelementptr inbounds %main, %main* %0, i32 0, i32 0 %F32_MAX = getelementptr inbounds %main, %main* %0, i32 0, i32 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__multidim_array_access.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__multidim_array_access.snap index b53601e5bb2..736ff837860 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__multidim_array_access.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__multidim_array_access.snap @@ -7,9 +7,9 @@ source_filename = "main" %prg = type { [8 x i32] } -@prg_instance = global %prg zeroinitializer +@prg_instance = global %prg zeroinitializer, section "var-$RUSTY$prg_instance:r1ai32" -define void @prg(%prg* %0) section "fn-prg:v" { +define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: %x = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 %tmpVar = getelementptr inbounds [8 x i32], [8 x i32]* %x, i32 0, i32 4 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__multidim_array_declaration.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__multidim_array_declaration.snap index bf625744037..a234c2d4994 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__multidim_array_declaration.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__multidim_array_declaration.snap @@ -7,9 +7,9 @@ source_filename = "main" %prg = type { [6 x i16] } -@prg_instance = global %prg zeroinitializer +@prg_instance = global %prg zeroinitializer, section "var-$RUSTY$prg_instance:r1ai16" -define void @prg(%prg* %0) section "fn-prg:v" { +define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: %x = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 ret void diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__nested_array_access.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__nested_array_access.snap index c64ea740096..2c82ee55a25 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__nested_array_access.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__nested_array_access.snap @@ -7,9 +7,9 @@ source_filename = "main" %prg = type { [4 x [2 x i32]] } -@prg_instance = global %prg zeroinitializer +@prg_instance = global %prg zeroinitializer, section "var-$RUSTY$prg_instance:r1aai32" -define void @prg(%prg* %0) section "fn-prg:v" { +define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: %x = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 %tmpVar = getelementptr inbounds [4 x [2 x i32]], [4 x [2 x i32]]* %x, i32 0, i32 2 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__nested_array_cube_writes.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__nested_array_cube_writes.snap index 7f655ad893a..5fb0d0ebc4b 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__nested_array_cube_writes.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__nested_array_cube_writes.snap @@ -7,9 +7,9 @@ source_filename = "main" %main = type { i16, i16, i16, [125 x i32] } -@main_instance = global %main zeroinitializer +@main_instance = global %main zeroinitializer, section "var-$RUSTY$main_instance:r4i16i16i16ai32" -define void @main(%main* %0) section "fn-main:v" { +define void @main(%main* %0) section "fn-$RUSTY$main:v" { entry: %x = getelementptr inbounds %main, %main* %0, i32 0, i32 0 %y = getelementptr inbounds %main, %main* %0, i32 0, i32 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__nested_array_cube_writes_negative_start.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__nested_array_cube_writes_negative_start.snap index a742dd204b3..03487be8279 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__nested_array_cube_writes_negative_start.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__nested_array_cube_writes_negative_start.snap @@ -7,9 +7,9 @@ source_filename = "main" %main = type { i16, i16, i16, [125 x i32] } -@main_instance = global %main zeroinitializer +@main_instance = global %main zeroinitializer, section "var-$RUSTY$main_instance:r4i16i16i16ai32" -define void @main(%main* %0) section "fn-main:v" { +define void @main(%main* %0) section "fn-$RUSTY$main:v" { entry: %x = getelementptr inbounds %main, %main* %0, i32 0, i32 0 %y = getelementptr inbounds %main, %main* %0, i32 0, i32 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__nested_array_declaration.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__nested_array_declaration.snap index da38870f591..da7ea64ee9f 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__nested_array_declaration.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__nested_array_declaration.snap @@ -7,9 +7,9 @@ source_filename = "main" %prg = type { [3 x [2 x i16]] } -@prg_instance = global %prg zeroinitializer +@prg_instance = global %prg zeroinitializer, section "var-$RUSTY$prg_instance:r1aai16" -define void @prg(%prg* %0) section "fn-prg:v" { +define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: %x = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 ret void diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__nested_function_called_in_program.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__nested_function_called_in_program.snap index 2b7d27f1de2..ca091a63ba1 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__nested_function_called_in_program.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__nested_function_called_in_program.snap @@ -7,9 +7,9 @@ source_filename = "main" %prg = type { i32 } -@prg_instance = global %prg zeroinitializer +@prg_instance = global %prg zeroinitializer, section "var-$RUSTY$prg_instance:r1i32" -define i32 @bar() section "fn-bar:i32" { +define i32 @bar() section "fn-$RUSTY$bar:i32" { entry: %bar = alloca i32, align 4 store i32 0, i32* %bar, align 4 @@ -18,7 +18,7 @@ entry: ret i32 %bar_ret } -define i32 @foo(i32 %0) section "fn-foo:i32[i32]" { +define i32 @foo(i32 %0) section "fn-$RUSTY$foo:i32[i32]" { entry: %foo = alloca i32, align 4 %in = alloca i32, align 4 @@ -29,7 +29,7 @@ entry: ret i32 %foo_ret } -define void @prg(%prg* %0) section "fn-prg:v" { +define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: %x = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 %call = call i32 @bar() diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__order_var_and_var_temp_block.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__order_var_and_var_temp_block.snap index 97a090218c3..92306239443 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__order_var_and_var_temp_block.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__order_var_and_var_temp_block.snap @@ -7,9 +7,9 @@ source_filename = "main" %main = type { i16 } -@main_instance = global %main zeroinitializer +@main_instance = global %main zeroinitializer, section "var-$RUSTY$main_instance:r2i16i16" -define void @main(%main* %0) section "fn-main:v" { +define void @main(%main* %0) section "fn-$RUSTY$main:v" { entry: %temp = alloca i16, align 2 %var1 = getelementptr inbounds %main, %main* %0, i32 0, i32 0 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__pass_inout_to_inout.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__pass_inout_to_inout.snap index 8e515413218..a8e6b32c9ff 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__pass_inout_to_inout.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__pass_inout_to_inout.snap @@ -9,18 +9,18 @@ source_filename = "main" %foo = type { i32* } %prg = type { i32 } -@foo2_instance = global %foo2 zeroinitializer -@foo_instance = global %foo zeroinitializer -@prg_instance = global %prg zeroinitializer +@foo2_instance = global %foo2 zeroinitializer, section "var-$RUSTY$foo2_instance:r2pi32i32" +@foo_instance = global %foo zeroinitializer, section "var-$RUSTY$foo_instance:r1pi32" +@prg_instance = global %prg zeroinitializer, section "var-$RUSTY$prg_instance:r1i32" -define void @foo2(%foo2* %0) section "fn-foo2:v[pi32][i32]" { +define void @foo2(%foo2* %0) section "fn-$RUSTY$foo2:v[pi32][i32]" { entry: %inout = getelementptr inbounds %foo2, %foo2* %0, i32 0, i32 0 %in = getelementptr inbounds %foo2, %foo2* %0, i32 0, i32 1 ret void } -define void @foo(%foo* %0) section "fn-foo:v[pi32]" { +define void @foo(%foo* %0) section "fn-$RUSTY$foo:v[pi32]" { entry: %inout = getelementptr inbounds %foo, %foo* %0, i32 0, i32 0 %deref = load i32*, i32** %inout, align 8 @@ -32,7 +32,7 @@ entry: ret void } -define void @prg(%prg* %0) section "fn-prg:v" { +define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: %baz = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 store i32* %baz, i32** getelementptr inbounds (%foo, %foo* @foo_instance, i32 0, i32 0), align 8 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__pointer_and_array_access_to_in_out.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__pointer_and_array_access_to_in_out.snap index 8bc8d5535dc..02c169bf672 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__pointer_and_array_access_to_in_out.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__pointer_and_array_access_to_in_out.snap @@ -5,7 +5,7 @@ expression: result ; ModuleID = 'main' source_filename = "main" -define i16 @main(i16** %0, i16* %1) section "fn-main:i16[ppi16][pv]" { +define i16 @main(i16** %0, i16* %1) section "fn-$RUSTY$main:i16[ppi16][pai16]" { entry: %main = alloca i16, align 2 %a = alloca i16**, align 8 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__pointers_generated.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__pointers_generated.snap index 3f57f25b8da..cd9516d4a52 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__pointers_generated.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__pointers_generated.snap @@ -7,9 +7,9 @@ source_filename = "main" %prg = type { i8, i8*, i8* } -@prg_instance = global %prg zeroinitializer +@prg_instance = global %prg zeroinitializer, section "var-$RUSTY$prg_instance:r3u8pu8pu8" -define void @prg(%prg* %0) section "fn-prg:v" { +define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: %X = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 %pX = getelementptr inbounds %prg, %prg* %0, i32 0, i32 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_called_in_program.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_called_in_program.snap index 560393369b8..29ad582599f 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_called_in_program.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_called_in_program.snap @@ -8,15 +8,15 @@ source_filename = "main" %foo = type {} %prg = type {} -@foo_instance = global %foo zeroinitializer -@prg_instance = global %prg zeroinitializer +@foo_instance = global %foo zeroinitializer, section "var-$RUSTY$foo_instance:r0" +@prg_instance = global %prg zeroinitializer, section "var-$RUSTY$prg_instance:r0" -define void @foo(%foo* %0) section "fn-foo:v" { +define void @foo(%foo* %0) section "fn-$RUSTY$foo:v" { entry: ret void } -define void @prg(%prg* %0) section "fn-prg:v" { +define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: call void @foo(%foo* @foo_instance) ret void diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_and_statement.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_and_statement.snap index e361bbf28cb..7b0f68c8dcb 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_and_statement.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_and_statement.snap @@ -7,9 +7,9 @@ source_filename = "main" %prg = type { i8, i8 } -@prg_instance = global %prg zeroinitializer +@prg_instance = global %prg zeroinitializer, section "var-$RUSTY$prg_instance:r2u8u8" -define void @prg(%prg* %0) section "fn-prg:v" { +define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: %x = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 %y = getelementptr inbounds %prg, %prg* %0, i32 0, i32 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_bool_variables_and_references_generates_void_function_and_struct_and_body.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_bool_variables_and_references_generates_void_function_and_struct_and_body.snap index 56448021c18..8597d9c3276 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_bool_variables_and_references_generates_void_function_and_struct_and_body.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_bool_variables_and_references_generates_void_function_and_struct_and_body.snap @@ -7,9 +7,9 @@ source_filename = "main" %prg = type { i8, i8 } -@prg_instance = global %prg zeroinitializer +@prg_instance = global %prg zeroinitializer, section "var-$RUSTY$prg_instance:r2u8u8" -define void @prg(%prg* %0) section "fn-prg:v" { +define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: %x = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 %y = getelementptr inbounds %prg, %prg* %0, i32 0, i32 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_boolean_assignment_generates_void_function_and_struct_and_body.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_boolean_assignment_generates_void_function_and_struct_and_body.snap index c003aa79699..0056daf87ef 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_boolean_assignment_generates_void_function_and_struct_and_body.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_boolean_assignment_generates_void_function_and_struct_and_body.snap @@ -7,9 +7,9 @@ source_filename = "main" %prg = type { i8 } -@prg_instance = global %prg zeroinitializer +@prg_instance = global %prg zeroinitializer, section "var-$RUSTY$prg_instance:r1u8" -define void @prg(%prg* %0) section "fn-prg:v" { +define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: %y = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 store i8 1, i8* %y, align 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_casted_chars_assignment.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_casted_chars_assignment.snap index 4cb7a5f58a2..80a0e3ea47f 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_casted_chars_assignment.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_casted_chars_assignment.snap @@ -7,11 +7,11 @@ source_filename = "main" %mainPROG = type { i8, i16 } -@mainPROG_instance = global %mainPROG zeroinitializer +@mainPROG_instance = global %mainPROG zeroinitializer, section "var-$RUSTY$mainPROG_instance:r2u8u16" @utf08_literal_0 = private unnamed_addr constant [2 x i8] c"B\00" @utf16_literal_0 = private unnamed_addr constant [2 x i16] [i16 65, i16 0] -define void @mainPROG(%mainPROG* %0) section "fn-mainPROG:v" { +define void @mainPROG(%mainPROG* %0) section "fn-$RUSTY$mainPROG:v" { entry: %x = getelementptr inbounds %mainPROG, %mainPROG* %0, i32 0, i32 0 %y = getelementptr inbounds %mainPROG, %mainPROG* %0, i32 0, i32 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_chars.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_chars.snap index a4c73f6983b..bcd7ca81bca 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_chars.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_chars.snap @@ -7,7 +7,7 @@ source_filename = "main" %mainPROG = type { i8, i16 } -@mainPROG_instance = global %mainPROG zeroinitializer +@mainPROG_instance = global %mainPROG zeroinitializer, section "var-$RUSTY$mainPROG_instance:r2u8u16" @utf08_literal_0 = private unnamed_addr constant [2 x i8] c" \00" @utf08_literal_1 = private unnamed_addr constant [2 x i8] c"a\00" @utf16_literal_0 = private unnamed_addr constant [2 x i16] [i16 32, i16 0] @@ -15,7 +15,7 @@ source_filename = "main" @utf16_literal_2 = private unnamed_addr constant [2 x i16] [i16 39, i16 0] @utf16_literal_3 = private unnamed_addr constant [2 x i16] [i16 65, i16 0] -define void @mainPROG(%mainPROG* %0) section "fn-mainPROG:v" { +define void @mainPROG(%mainPROG* %0) section "fn-$RUSTY$mainPROG:v" { entry: %x = getelementptr inbounds %mainPROG, %mainPROG* %0, i32 0, i32 0 %y = getelementptr inbounds %mainPROG, %mainPROG* %0, i32 0, i32 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_date_assignment.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_date_assignment.snap index 8bbb51edf7e..3fd53113a8f 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_date_assignment.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_date_assignment.snap @@ -7,9 +7,9 @@ source_filename = "main" %prg = type { i64, i64, i64, i64 } -@prg_instance = global %prg zeroinitializer +@prg_instance = global %prg zeroinitializer, section "var-$RUSTY$prg_instance:r4i64i64i64i64" -define void @prg(%prg* %0) section "fn-prg:v" { +define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: %w = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 %x = getelementptr inbounds %prg, %prg* %0, i32 0, i32 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_date_assignment_whit_short_datatype_names.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_date_assignment_whit_short_datatype_names.snap index 0ce71bca5bb..e481318994d 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_date_assignment_whit_short_datatype_names.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_date_assignment_whit_short_datatype_names.snap @@ -7,9 +7,9 @@ source_filename = "main" %prg = type { i64, i64, i64, i64 } -@prg_instance = global %prg zeroinitializer +@prg_instance = global %prg zeroinitializer, section "var-$RUSTY$prg_instance:r4i64i64i64i64" -define void @prg(%prg* %0) section "fn-prg:v" { +define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: %w = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 %x = getelementptr inbounds %prg, %prg* %0, i32 0, i32 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_floats_variable_and_comparison_assignment_generates_correctly.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_floats_variable_and_comparison_assignment_generates_correctly.snap index 9b6672b871b..6247fa9ea4a 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_floats_variable_and_comparison_assignment_generates_correctly.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_floats_variable_and_comparison_assignment_generates_correctly.snap @@ -7,9 +7,9 @@ source_filename = "main" %prg = type { float, i8 } -@prg_instance = global %prg zeroinitializer +@prg_instance = global %prg zeroinitializer, section "var-$RUSTY$prg_instance:r2f32u8" -define void @prg(%prg* %0) section "fn-prg:v" { +define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: %x = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 %y = getelementptr inbounds %prg, %prg* %0, i32 0, i32 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_local_temp_var_initialization.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_local_temp_var_initialization.snap index b5460fdea60..aadb49f9e3e 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_local_temp_var_initialization.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_local_temp_var_initialization.snap @@ -8,10 +8,10 @@ source_filename = "main" %foo = type { i16 } %prg = type {} -@foo_instance = global %foo { i16 7 } -@prg_instance = global %prg zeroinitializer +@foo_instance = global %foo { i16 7 }, section "var-$RUSTY$foo_instance:r3i16i16i16" +@prg_instance = global %prg zeroinitializer, section "var-$RUSTY$prg_instance:r0" -define void @foo(%foo* %0) section "fn-foo:v" { +define void @foo(%foo* %0) section "fn-$RUSTY$foo:v" { entry: %x = getelementptr inbounds %foo, %foo* %0, i32 0, i32 0 %y = alloca i16, align 2 @@ -26,7 +26,7 @@ entry: ret void } -define void @prg(%prg* %0) section "fn-prg:v" { +define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: call void @foo(%foo* @foo_instance) ret void diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_long_date_assignment.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_long_date_assignment.snap index 6e14b94318f..6ddd1200b11 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_long_date_assignment.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_long_date_assignment.snap @@ -7,9 +7,9 @@ source_filename = "main" %prg = type { i64, i64, i64, i64 } -@prg_instance = global %prg zeroinitializer +@prg_instance = global %prg zeroinitializer, section "var-$RUSTY$prg_instance:r4i64i64i64i64" -define void @prg(%prg* %0) section "fn-prg:v" { +define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: %w = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 %x = getelementptr inbounds %prg, %prg* %0, i32 0, i32 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_negated_combined_expressions_generates_void_function_and_struct_and_body.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_negated_combined_expressions_generates_void_function_and_struct_and_body.snap index a3a65b3cae3..54552d47b50 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_negated_combined_expressions_generates_void_function_and_struct_and_body.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_negated_combined_expressions_generates_void_function_and_struct_and_body.snap @@ -7,9 +7,9 @@ source_filename = "main" %prg = type { i32, i8 } -@prg_instance = global %prg zeroinitializer +@prg_instance = global %prg zeroinitializer, section "var-$RUSTY$prg_instance:r2i32u8" -define void @prg(%prg* %0) section "fn-prg:v" { +define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: %z = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 %y = getelementptr inbounds %prg, %prg* %0, i32 0, i32 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_negated_expressions_generates_void_function_and_struct_and_body.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_negated_expressions_generates_void_function_and_struct_and_body.snap index 7f36c862247..a0ee38c4451 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_negated_expressions_generates_void_function_and_struct_and_body.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_negated_expressions_generates_void_function_and_struct_and_body.snap @@ -7,9 +7,9 @@ source_filename = "main" %prg = type { i8, i8 } -@prg_instance = global %prg zeroinitializer +@prg_instance = global %prg zeroinitializer, section "var-$RUSTY$prg_instance:r2u8u8" -define void @prg(%prg* %0) section "fn-prg:v" { +define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: %x = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 %y = getelementptr inbounds %prg, %prg* %0, i32 0, i32 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_or_statement.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_or_statement.snap index ad31cb1492f..6529671a52c 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_or_statement.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_or_statement.snap @@ -7,9 +7,9 @@ source_filename = "main" %prg = type { i8, i8 } -@prg_instance = global %prg zeroinitializer +@prg_instance = global %prg zeroinitializer, section "var-$RUSTY$prg_instance:r2u8u8" -define void @prg(%prg* %0) section "fn-prg:v" { +define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: %x = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 %y = getelementptr inbounds %prg, %prg* %0, i32 0, i32 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_real_additions.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_real_additions.snap index dff1485346e..ff2e14ca7eb 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_real_additions.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_real_additions.snap @@ -7,9 +7,9 @@ source_filename = "main" %prg = type { float, float, float } -@prg_instance = global %prg zeroinitializer +@prg_instance = global %prg zeroinitializer, section "var-$RUSTY$prg_instance:r3f32f32f32" -define void @prg(%prg* %0) section "fn-prg:v" { +define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: %x = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 %y = getelementptr inbounds %prg, %prg* %0, i32 0, i32 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_real_assignment.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_real_assignment.snap index 07eb3ab7797..4b50d7ee453 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_real_assignment.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_real_assignment.snap @@ -7,9 +7,9 @@ source_filename = "main" %prg = type { float } -@prg_instance = global %prg zeroinitializer +@prg_instance = global %prg zeroinitializer, section "var-$RUSTY$prg_instance:r1f32" -define void @prg(%prg* %0) section "fn-prg:v" { +define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: %y = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 store float 1.562500e-01, float* %y, align 4 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_real_cast_assignment.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_real_cast_assignment.snap index 314b9c196d4..6e4363b5f17 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_real_cast_assignment.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_real_cast_assignment.snap @@ -7,9 +7,9 @@ source_filename = "main" %prg = type { float, i16 } -@prg_instance = global %prg zeroinitializer +@prg_instance = global %prg zeroinitializer, section "var-$RUSTY$prg_instance:r2f32i16" -define void @prg(%prg* %0) section "fn-prg:v" { +define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: %y = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 %x = getelementptr inbounds %prg, %prg* %0, i32 0, i32 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_signed_combined_expressions.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_signed_combined_expressions.snap index e6fb6122b99..59a354dd178 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_signed_combined_expressions.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_signed_combined_expressions.snap @@ -7,9 +7,9 @@ source_filename = "main" %prg = type { i32, i32 } -@prg_instance = global %prg zeroinitializer +@prg_instance = global %prg zeroinitializer, section "var-$RUSTY$prg_instance:r2i32i32" -define void @prg(%prg* %0) section "fn-prg:v" { +define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: %z = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 %y = getelementptr inbounds %prg, %prg* %0, i32 0, i32 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_special_chars_in_string.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_special_chars_in_string.snap index 4f24fceac15..662befc1eac 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_special_chars_in_string.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_special_chars_in_string.snap @@ -7,13 +7,13 @@ source_filename = "main" %prg = type { [81 x i8], [81 x i8], [81 x i16], [81 x i16] } -@prg_instance = global %prg zeroinitializer +@prg_instance = global %prg zeroinitializer, section "var-$RUSTY$prg_instance:r4s8u81s8u81s16u81s16u81" @utf08_literal_0 = private unnamed_addr constant [19 x i8] c"\0043 $\22no replace$\22\00" @utf08_literal_1 = private unnamed_addr constant [41 x i8] c"a\0A\0A b\0A\0A c\0C\0C d\0D\0D e\09\09 $ 'single' W\F0\9F\92\96\F0\9F\92\96\00" @utf16_literal_0 = private unnamed_addr constant [19 x i16] [i16 36, i16 52, i16 51, i16 32, i16 36, i16 39, i16 110, i16 111, i16 32, i16 114, i16 101, i16 112, i16 108, i16 97, i16 99, i16 101, i16 36, i16 39, i16 0] @utf16_literal_1 = private unnamed_addr constant [41 x i16] [i16 97, i16 10, i16 10, i16 32, i16 98, i16 10, i16 10, i16 32, i16 99, i16 12, i16 12, i16 32, i16 100, i16 13, i16 13, i16 32, i16 101, i16 9, i16 9, i16 32, i16 36, i16 32, i16 34, i16 100, i16 111, i16 117, i16 98, i16 108, i16 101, i16 34, i16 32, i16 87, i16 -10179, i16 -9066, i16 -10179, i16 -9066, i16 0, i16 0, i16 0, i16 0, i16 0] -define void @prg(%prg* %0) section "fn-prg:v" { +define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: %should_replace_s = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 %should_not_replace_s = getelementptr inbounds %prg, %prg* %0, i32 0, i32 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_string_assignment.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_string_assignment.snap index 2e9650b3f9f..cde09cf13e2 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_string_assignment.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_string_assignment.snap @@ -7,11 +7,11 @@ source_filename = "main" %prg = type { [81 x i8], [81 x i16] } -@prg_instance = global %prg zeroinitializer +@prg_instance = global %prg zeroinitializer, section "var-$RUSTY$prg_instance:r2s8u81s16u81" @utf08_literal_0 = private unnamed_addr constant [12 x i8] c"im a genius\00" @utf16_literal_0 = private unnamed_addr constant [18 x i16] [i16 105, i16 109, i16 32, i16 97, i16 32, i16 117, i16 116, i16 102, i16 49, i16 54, i16 32, i16 103, i16 101, i16 110, i16 105, i16 117, i16 115, i16 0] -define void @prg(%prg* %0) section "fn-prg:v" { +define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: %y = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 %z = getelementptr inbounds %prg, %prg* %0, i32 0, i32 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_time_assignment.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_time_assignment.snap index eefda5d4f54..7af52c8f382 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_time_assignment.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_time_assignment.snap @@ -7,9 +7,9 @@ source_filename = "main" %prg = type { i64 } -@prg_instance = global %prg zeroinitializer +@prg_instance = global %prg zeroinitializer, section "var-$RUSTY$prg_instance:r1i64" -define void @prg(%prg* %0) section "fn-prg:v" { +define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: %y = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 store i64 0, i64* %y, align 4 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_time_of_day_assignment.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_time_of_day_assignment.snap index 0e15ee7c805..148f498e94b 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_time_of_day_assignment.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_time_of_day_assignment.snap @@ -7,9 +7,9 @@ source_filename = "main" %prg = type { i64 } -@prg_instance = global %prg zeroinitializer +@prg_instance = global %prg zeroinitializer, section "var-$RUSTY$prg_instance:r1i64" -define void @prg(%prg* %0) section "fn-prg:v" { +define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: %y = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 store i64 0, i64* %y, align 4 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_two_explicit_parameters_called_in_program.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_two_explicit_parameters_called_in_program.snap index bbbe1085558..eeacbb46c4a 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_two_explicit_parameters_called_in_program.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_two_explicit_parameters_called_in_program.snap @@ -8,17 +8,17 @@ source_filename = "main" %foo = type { i32, i8 } %prg = type {} -@foo_instance = global %foo zeroinitializer -@prg_instance = global %prg zeroinitializer +@foo_instance = global %foo zeroinitializer, section "var-$RUSTY$foo_instance:r2i32u8" +@prg_instance = global %prg zeroinitializer, section "var-$RUSTY$prg_instance:r0" -define void @foo(%foo* %0) section "fn-foo:v[i32][u8]" { +define void @foo(%foo* %0) section "fn-$RUSTY$foo:v[i32][u8]" { entry: %bar = getelementptr inbounds %foo, %foo* %0, i32 0, i32 0 %buz = getelementptr inbounds %foo, %foo* %0, i32 0, i32 1 ret void } -define void @prg(%prg* %0) section "fn-prg:v" { +define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: store i8 1, i8* getelementptr inbounds (%foo, %foo* @foo_instance, i32 0, i32 1), align 1 store i32 2, i32* getelementptr inbounds (%foo, %foo* @foo_instance, i32 0, i32 0), align 4 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_two_parameters_called_in_program.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_two_parameters_called_in_program.snap index e12d9f1dad2..af00d4d3f0d 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_two_parameters_called_in_program.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_two_parameters_called_in_program.snap @@ -8,17 +8,17 @@ source_filename = "main" %foo = type { i32, i8 } %prg = type {} -@foo_instance = global %foo zeroinitializer -@prg_instance = global %prg zeroinitializer +@foo_instance = global %foo zeroinitializer, section "var-$RUSTY$foo_instance:r2i32u8" +@prg_instance = global %prg zeroinitializer, section "var-$RUSTY$prg_instance:r0" -define void @foo(%foo* %0) section "fn-foo:v[i32][u8]" { +define void @foo(%foo* %0) section "fn-$RUSTY$foo:v[i32][u8]" { entry: %bar = getelementptr inbounds %foo, %foo* %0, i32 0, i32 0 %buz = getelementptr inbounds %foo, %foo* %0, i32 0, i32 1 ret void } -define void @prg(%prg* %0) section "fn-prg:v" { +define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: store i32 2, i32* getelementptr inbounds (%foo, %foo* @foo_instance, i32 0, i32 0), align 4 store i8 1, i8* getelementptr inbounds (%foo, %foo* @foo_instance, i32 0, i32 1), align 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_var_inout_called_in_program.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_var_inout_called_in_program.snap index ccaeba9880c..d533f19db95 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_var_inout_called_in_program.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_var_inout_called_in_program.snap @@ -8,10 +8,10 @@ source_filename = "main" %foo = type { i32* } %prg = type { i32 } -@foo_instance = global %foo zeroinitializer -@prg_instance = global %prg zeroinitializer +@foo_instance = global %foo zeroinitializer, section "var-$RUSTY$foo_instance:r1pi32" +@prg_instance = global %prg zeroinitializer, section "var-$RUSTY$prg_instance:r1i32" -define void @foo(%foo* %0) section "fn-foo:v[pi32]" { +define void @foo(%foo* %0) section "fn-$RUSTY$foo:v[pi32]" { entry: %inout = getelementptr inbounds %foo, %foo* %0, i32 0, i32 0 %deref = load i32*, i32** %inout, align 8 @@ -22,7 +22,7 @@ entry: ret void } -define void @prg(%prg* %0) section "fn-prg:v" { +define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: %baz = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 store i32 7, i32* %baz, align 4 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_var_out_called_in_program.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_var_out_called_in_program.snap index ffb7db7441e..cc8392f4360 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_var_out_called_in_program.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_var_out_called_in_program.snap @@ -8,17 +8,17 @@ source_filename = "main" %foo = type { i32, i8 } %prg = type { i8 } -@foo_instance = global %foo zeroinitializer -@prg_instance = global %prg zeroinitializer +@foo_instance = global %foo zeroinitializer, section "var-$RUSTY$foo_instance:r2i32u8" +@prg_instance = global %prg zeroinitializer, section "var-$RUSTY$prg_instance:r1u8" -define void @foo(%foo* %0) section "fn-foo:v[i32][u8]" { +define void @foo(%foo* %0) section "fn-$RUSTY$foo:v[i32][u8]" { entry: %bar = getelementptr inbounds %foo, %foo* %0, i32 0, i32 0 %buz = getelementptr inbounds %foo, %foo* %0, i32 0, i32 1 ret void } -define void @prg(%prg* %0) section "fn-prg:v" { +define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: %baz = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 store i32 2, i32* getelementptr inbounds (%foo, %foo* @foo_instance, i32 0, i32 0), align 4 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_var_out_called_mixed_in_program.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_var_out_called_mixed_in_program.snap index ffb7db7441e..cc8392f4360 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_var_out_called_mixed_in_program.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_var_out_called_mixed_in_program.snap @@ -8,17 +8,17 @@ source_filename = "main" %foo = type { i32, i8 } %prg = type { i8 } -@foo_instance = global %foo zeroinitializer -@prg_instance = global %prg zeroinitializer +@foo_instance = global %foo zeroinitializer, section "var-$RUSTY$foo_instance:r2i32u8" +@prg_instance = global %prg zeroinitializer, section "var-$RUSTY$prg_instance:r1u8" -define void @foo(%foo* %0) section "fn-foo:v[i32][u8]" { +define void @foo(%foo* %0) section "fn-$RUSTY$foo:v[i32][u8]" { entry: %bar = getelementptr inbounds %foo, %foo* %0, i32 0, i32 0 %buz = getelementptr inbounds %foo, %foo* %0, i32 0, i32 1 ret void } -define void @prg(%prg* %0) section "fn-prg:v" { +define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: %baz = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 store i32 2, i32* getelementptr inbounds (%foo, %foo* @foo_instance, i32 0, i32 0), align 4 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_variable_and_addition_literal_generates_void_function_and_struct_and_body.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_variable_and_addition_literal_generates_void_function_and_struct_and_body.snap index e97814a1eae..c3a91f18e9c 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_variable_and_addition_literal_generates_void_function_and_struct_and_body.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_variable_and_addition_literal_generates_void_function_and_struct_and_body.snap @@ -7,9 +7,9 @@ source_filename = "main" %prg = type { i32 } -@prg_instance = global %prg zeroinitializer +@prg_instance = global %prg zeroinitializer, section "var-$RUSTY$prg_instance:r1i32" -define void @prg(%prg* %0) section "fn-prg:v" { +define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: %x = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 %load_x = load i32, i32* %x, align 4 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_variable_and_arithmatic_assignment_generates_void_function_and_struct_and_body.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_variable_and_arithmatic_assignment_generates_void_function_and_struct_and_body.snap index 059fb284667..31f63a6092e 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_variable_and_arithmatic_assignment_generates_void_function_and_struct_and_body.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_variable_and_arithmatic_assignment_generates_void_function_and_struct_and_body.snap @@ -7,9 +7,9 @@ source_filename = "main" %prg = type { i32, i32 } -@prg_instance = global %prg zeroinitializer +@prg_instance = global %prg zeroinitializer, section "var-$RUSTY$prg_instance:r2i32i32" -define void @prg(%prg* %0) section "fn-prg:v" { +define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: %x = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 %y = getelementptr inbounds %prg, %prg* %0, i32 0, i32 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_variable_and_comparison_assignment_generates_void_function_and_struct_and_body.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_variable_and_comparison_assignment_generates_void_function_and_struct_and_body.snap index d87b270482d..5e64b1a5343 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_variable_and_comparison_assignment_generates_void_function_and_struct_and_body.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_variable_and_comparison_assignment_generates_void_function_and_struct_and_body.snap @@ -7,9 +7,9 @@ source_filename = "main" %prg = type { i32, i8 } -@prg_instance = global %prg zeroinitializer +@prg_instance = global %prg zeroinitializer, section "var-$RUSTY$prg_instance:r2i32u8" -define void @prg(%prg* %0) section "fn-prg:v" { +define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: %x = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 %y = getelementptr inbounds %prg, %prg* %0, i32 0, i32 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_variable_assignment_generates_void_function_and_struct_and_body.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_variable_assignment_generates_void_function_and_struct_and_body.snap index b1684598282..d8193c60c53 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_variable_assignment_generates_void_function_and_struct_and_body.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_variable_assignment_generates_void_function_and_struct_and_body.snap @@ -7,9 +7,9 @@ source_filename = "main" %prg = type { i32 } -@prg_instance = global %prg zeroinitializer +@prg_instance = global %prg zeroinitializer, section "var-$RUSTY$prg_instance:r1i32" -define void @prg(%prg* %0) section "fn-prg:v" { +define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: %y = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 store i32 7, i32* %y, align 4 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_variables_and_additions_generates_void_function_and_struct_and_body.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_variables_and_additions_generates_void_function_and_struct_and_body.snap index 82bb93e5630..9480d5c1e50 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_variables_and_additions_generates_void_function_and_struct_and_body.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_variables_and_additions_generates_void_function_and_struct_and_body.snap @@ -7,9 +7,9 @@ source_filename = "main" %prg = type { i32, i32 } -@prg_instance = global %prg zeroinitializer +@prg_instance = global %prg zeroinitializer, section "var-$RUSTY$prg_instance:r2i32i32" -define void @prg(%prg* %0) section "fn-prg:v" { +define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: %x = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 %y = getelementptr inbounds %prg, %prg* %0, i32 0, i32 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_variables_and_references_generates_void_function_and_struct_and_body.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_variables_and_references_generates_void_function_and_struct_and_body.snap index 8e502d81c9b..45c105a08d4 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_variables_and_references_generates_void_function_and_struct_and_body.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_variables_and_references_generates_void_function_and_struct_and_body.snap @@ -7,9 +7,9 @@ source_filename = "main" %prg = type { i32, i32 } -@prg_instance = global %prg zeroinitializer +@prg_instance = global %prg zeroinitializer, section "var-$RUSTY$prg_instance:r2i32i32" -define void @prg(%prg* %0) section "fn-prg:v" { +define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: %x = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 %y = getelementptr inbounds %prg, %prg* %0, i32 0, i32 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_variables_generates_void_function_and_struct.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_variables_generates_void_function_and_struct.snap index b7ddb4a0a75..9536961b076 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_variables_generates_void_function_and_struct.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_variables_generates_void_function_and_struct.snap @@ -7,9 +7,9 @@ source_filename = "main" %prg = type { i32, i32 } -@prg_instance = global %prg zeroinitializer +@prg_instance = global %prg zeroinitializer, section "var-$RUSTY$prg_instance:r2i32i32" -define void @prg(%prg* %0) section "fn-prg:v" { +define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: %x = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 %y = getelementptr inbounds %prg, %prg* %0, i32 0, i32 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_xor_statement.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_xor_statement.snap index aec25fbc6fa..4ad950148d8 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_xor_statement.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__program_with_xor_statement.snap @@ -7,9 +7,9 @@ source_filename = "main" %prg = type { i8, i8, i8 } -@prg_instance = global %prg zeroinitializer +@prg_instance = global %prg zeroinitializer, section "var-$RUSTY$prg_instance:r3u8u8u8" -define void @prg(%prg* %0) section "fn-prg:v" { +define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: %x = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 %y = getelementptr inbounds %prg, %prg* %0, i32 0, i32 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__qualified_action_from_fb_called_in_program.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__qualified_action_from_fb_called_in_program.snap index bce25d54138..945e2bde0ae 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__qualified_action_from_fb_called_in_program.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__qualified_action_from_fb_called_in_program.snap @@ -8,23 +8,23 @@ source_filename = "main" %bar = type { %fb } %fb = type { i32 } -@bar_instance = global %bar zeroinitializer -@__fb__init = unnamed_addr constant %fb zeroinitializer +@bar_instance = global %bar zeroinitializer, section "var-$RUSTY$bar_instance:r1r1i32" +@__fb__init = unnamed_addr constant %fb zeroinitializer, section "var-$RUSTY$__fb__init:r1i32" -define void @bar(%bar* %0) section "fn-bar:v" { +define void @bar(%bar* %0) section "fn-$RUSTY$bar:v" { entry: %fb_inst = getelementptr inbounds %bar, %bar* %0, i32 0, i32 0 call void @fb.foo(%fb* %fb_inst) ret void } -define void @fb(%fb* %0) section "fn-fb:v" { +define void @fb(%fb* %0) section "fn-$RUSTY$fb:v" { entry: %x = getelementptr inbounds %fb, %fb* %0, i32 0, i32 0 ret void } -define void @fb.foo(%fb* %0) section "fn-fb.foo:v" { +define void @fb.foo(%fb* %0) section "fn-$RUSTY$fb.foo:v" { entry: %x = getelementptr inbounds %fb, %fb* %0, i32 0, i32 0 store i32 2, i32* %x, align 4 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__qualified_foreign_action_called_in_program.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__qualified_foreign_action_called_in_program.snap index 6f41a49428f..55c0eb2814c 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__qualified_foreign_action_called_in_program.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__qualified_foreign_action_called_in_program.snap @@ -8,22 +8,22 @@ source_filename = "main" %bar = type {} %prg = type { i32 } -@bar_instance = global %bar zeroinitializer -@prg_instance = global %prg zeroinitializer +@bar_instance = global %bar zeroinitializer, section "var-$RUSTY$bar_instance:r0" +@prg_instance = global %prg zeroinitializer, section "var-$RUSTY$prg_instance:r1i32" -define void @bar(%bar* %0) section "fn-bar:v" { +define void @bar(%bar* %0) section "fn-$RUSTY$bar:v" { entry: call void @prg.foo(%prg* @prg_instance) ret void } -define void @prg(%prg* %0) section "fn-prg:v" { +define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: %x = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 ret void } -define void @prg.foo(%prg* %0) section "fn-prg.foo:v" { +define void @prg.foo(%prg* %0) section "fn-$RUSTY$prg.foo:v" { entry: %x = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 store i32 2, i32* %x, align 4 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__qualified_local_action_called_in_program.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__qualified_local_action_called_in_program.snap index 1671c4d3273..40b9b20ea5e 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__qualified_local_action_called_in_program.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__qualified_local_action_called_in_program.snap @@ -7,16 +7,16 @@ source_filename = "main" %prg = type { i32 } -@prg_instance = global %prg zeroinitializer +@prg_instance = global %prg zeroinitializer, section "var-$RUSTY$prg_instance:r1i32" -define void @prg(%prg* %0) section "fn-prg:v" { +define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: %x = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 call void @prg.foo(%prg* @prg_instance) ret void } -define void @prg.foo(%prg* %0) section "fn-prg.foo:v" { +define void @prg.foo(%prg* %0) section "fn-$RUSTY$prg.foo:v" { entry: %x = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 store i32 2, i32* %x, align 4 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__real_function_called_in_program.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__real_function_called_in_program.snap index 80252a1d474..17bbea8e09e 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__real_function_called_in_program.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__real_function_called_in_program.snap @@ -7,9 +7,9 @@ source_filename = "main" %prg = type { i32 } -@prg_instance = global %prg zeroinitializer +@prg_instance = global %prg zeroinitializer, section "var-$RUSTY$prg_instance:r1i32" -define float @foo() section "fn-foo:f32" { +define float @foo() section "fn-$RUSTY$foo:f32" { entry: %foo = alloca float, align 4 store float 0.000000e+00, float* %foo, align 4 @@ -18,7 +18,7 @@ entry: ret float %foo_ret } -define void @prg(%prg* %0) section "fn-prg:v" { +define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: %x = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 %call = call float @foo() diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__reference_qualified_name.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__reference_qualified_name.snap index f058d9cf683..fb28f15ddfc 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__reference_qualified_name.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__reference_qualified_name.snap @@ -9,17 +9,17 @@ source_filename = "main" %foo = type { i32, i32, %fb } %prg = type { i32 } -@__fb__init = unnamed_addr constant %fb zeroinitializer -@foo_instance = global %foo zeroinitializer -@prg_instance = global %prg zeroinitializer +@__fb__init = unnamed_addr constant %fb zeroinitializer, section "var-$RUSTY$__fb__init:r1i32" +@foo_instance = global %foo zeroinitializer, section "var-$RUSTY$foo_instance:r3i32i32r1i32" +@prg_instance = global %prg zeroinitializer, section "var-$RUSTY$prg_instance:r1i32" -define void @fb(%fb* %0) section "fn-fb:v[i32]" { +define void @fb(%fb* %0) section "fn-$RUSTY$fb:v[i32]" { entry: %x = getelementptr inbounds %fb, %fb* %0, i32 0, i32 0 ret void } -define void @foo(%foo* %0) section "fn-foo:v[i32][i32][v]" { +define void @foo(%foo* %0) section "fn-$RUSTY$foo:v[i32][i32][r1i32]" { entry: %x = getelementptr inbounds %foo, %foo* %0, i32 0, i32 0 %y = getelementptr inbounds %foo, %foo* %0, i32 0, i32 1 @@ -27,7 +27,7 @@ entry: ret void } -define void @prg(%prg* %0) section "fn-prg:v" { +define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: %x = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 %load_x = load i32, i32* getelementptr inbounds (%foo, %foo* @foo_instance, i32 0, i32 0), align 4 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__reference_to_reference_assignments_in_function_arguments.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__reference_to_reference_assignments_in_function_arguments.snap index 1a0c976fbb9..6677ce0538b 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__reference_to_reference_assignments_in_function_arguments.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__reference_to_reference_assignments_in_function_arguments.snap @@ -9,24 +9,24 @@ source_filename = "main" %prog = type { %STRUCT_params*, %STRUCT_params* } %main = type {} -@global1 = global %STRUCT_params zeroinitializer -@__STRUCT_params__init = unnamed_addr constant %STRUCT_params zeroinitializer -@global2 = global %STRUCT_params zeroinitializer -@global3 = global %STRUCT_params zeroinitializer -@global4 = global i32 0 -@global5 = global [81 x i8] zeroinitializer -@global6 = global float 0.000000e+00 -@prog_instance = global %prog zeroinitializer -@main_instance = global %main zeroinitializer +@global1 = global %STRUCT_params zeroinitializer, section "var-$RUSTY$global1:r3u8u8u8" +@__STRUCT_params__init = unnamed_addr constant %STRUCT_params zeroinitializer, section "var-$RUSTY$__STRUCT_params__init:r3u8u8u8" +@global2 = global %STRUCT_params zeroinitializer, section "var-$RUSTY$global2:r3u8u8u8" +@global3 = global %STRUCT_params zeroinitializer, section "var-$RUSTY$global3:r3u8u8u8" +@global4 = global i32 0, section "var-$RUSTY$global4:i32" +@global5 = global [81 x i8] zeroinitializer, section "var-$RUSTY$global5:s8u81" +@global6 = global float 0.000000e+00, section "var-$RUSTY$global6:f32" +@prog_instance = global %prog zeroinitializer, section "var-$RUSTY$prog_instance:r2pr3u8u8u8pr3u8u8u8" +@main_instance = global %main zeroinitializer, section "var-$RUSTY$main_instance:r0" -define void @prog(%prog* %0) section "fn-prog:v[pv][pv]" { +define void @prog(%prog* %0) section "fn-$RUSTY$prog:v[pr3u8u8u8][pr3u8u8u8]" { entry: %input1 = getelementptr inbounds %prog, %prog* %0, i32 0, i32 0 %input2 = getelementptr inbounds %prog, %prog* %0, i32 0, i32 1 ret void } -define void @main(%main* %0) section "fn-main:v" { +define void @main(%main* %0) section "fn-$RUSTY$main:v" { entry: store %STRUCT_params* @global1, %STRUCT_params** getelementptr inbounds (%prog, %prog* @prog_instance, i32 0, i32 0), align 8 store %STRUCT_params* @global2, %STRUCT_params** getelementptr inbounds (%prog, %prog* @prog_instance, i32 0, i32 1), align 8 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__repeat_statement.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__repeat_statement.snap index 7412e36a42e..eec9b3d0078 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__repeat_statement.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__repeat_statement.snap @@ -7,9 +7,9 @@ source_filename = "main" %prg = type { i8 } -@prg_instance = global %prg zeroinitializer +@prg_instance = global %prg zeroinitializer, section "var-$RUSTY$prg_instance:r1u8" -define void @prg(%prg* %0) section "fn-prg:v" { +define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: %x = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 br label %while_body diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__returning_early_in_function.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__returning_early_in_function.snap index c2a46131f65..c00bf980ccc 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__returning_early_in_function.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__returning_early_in_function.snap @@ -5,7 +5,7 @@ expression: result ; ModuleID = 'main' source_filename = "main" -define i16 @smaller_than_ten(i8 %0) section "fn-smaller_than_ten:i16[i8]" { +define i16 @smaller_than_ten(i8 %0) section "fn-$RUSTY$smaller_than_ten:i16[i8]" { entry: %smaller_than_ten = alloca i16, align 2 %n = alloca i8, align 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__returning_early_in_function_block.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__returning_early_in_function_block.snap index ae484e44b46..cb295b58858 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__returning_early_in_function_block.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__returning_early_in_function_block.snap @@ -7,9 +7,9 @@ source_filename = "main" %abcdef = type { i8 } -@__abcdef__init = unnamed_addr constant %abcdef zeroinitializer +@__abcdef__init = unnamed_addr constant %abcdef zeroinitializer, section "var-$RUSTY$__abcdef__init:r1i8" -define void @abcdef(%abcdef* %0) section "fn-abcdef:v[i8]" { +define void @abcdef(%abcdef* %0) section "fn-$RUSTY$abcdef:v[i8]" { entry: %n = getelementptr inbounds %abcdef, %abcdef* %0, i32 0, i32 0 %load_n = load i8, i8* %n, align 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__simple_case_i8_statement.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__simple_case_i8_statement.snap index 8786736fca2..c41c610a885 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__simple_case_i8_statement.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__simple_case_i8_statement.snap @@ -7,9 +7,9 @@ source_filename = "main" %prg = type { i8, i8 } -@prg_instance = global %prg zeroinitializer +@prg_instance = global %prg zeroinitializer, section "var-$RUSTY$prg_instance:r2u8u8" -define void @prg(%prg* %0) section "fn-prg:v" { +define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: %x = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 %y = getelementptr inbounds %prg, %prg* %0, i32 0, i32 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__simple_case_statement.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__simple_case_statement.snap index a6e5948dee6..d789eb77214 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__simple_case_statement.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__simple_case_statement.snap @@ -7,9 +7,9 @@ source_filename = "main" %prg = type { i32, i32 } -@prg_instance = global %prg zeroinitializer +@prg_instance = global %prg zeroinitializer, section "var-$RUSTY$prg_instance:r2i32i32" -define void @prg(%prg* %0) section "fn-prg:v" { +define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: %x = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 %y = getelementptr inbounds %prg, %prg* %0, i32 0, i32 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__sizeof_works_in_binary_expression_with_different_size.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__sizeof_works_in_binary_expression_with_different_size.snap index 46398c63e8d..2677cbcb878 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__sizeof_works_in_binary_expression_with_different_size.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__sizeof_works_in_binary_expression_with_different_size.snap @@ -5,7 +5,7 @@ expression: result ; ModuleID = 'main' source_filename = "main" -define i32 @main() section "fn-main:i32" { +define i32 @main() section "fn-$RUSTY$main:i32" { entry: %main = alloca i32, align 4 %i = alloca i32, align 4 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__structs_are_generated.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__structs_are_generated.snap index ca1fd4ce42c..4371bad1814 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__structs_are_generated.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__structs_are_generated.snap @@ -8,8 +8,7 @@ source_filename = "main" %MyStruct = type { i32, i16 } %__global_y = type { i8, i8 } -@x = global %MyStruct zeroinitializer -@__MyStruct__init = unnamed_addr constant %MyStruct zeroinitializer -@y = global %__global_y zeroinitializer -@____global_y__init = unnamed_addr constant %__global_y zeroinitializer - +@x = global %MyStruct zeroinitializer, section "var-$RUSTY$x:r2i32i16" +@__MyStruct__init = unnamed_addr constant %MyStruct zeroinitializer, section "var-$RUSTY$__MyStruct__init:r2i32i16" +@y = global %__global_y zeroinitializer, section "var-$RUSTY$y:r2u8u8" +@____global_y__init = unnamed_addr constant %__global_y zeroinitializer, section "var-$RUSTY$____global_y__init:r2u8u8" diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__structs_members_can_be_referenced.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__structs_members_can_be_referenced.snap index 4333aaab90f..3e83ed11ae7 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__structs_members_can_be_referenced.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__structs_members_can_be_referenced.snap @@ -8,10 +8,10 @@ source_filename = "main" %MainProg = type { %MyStruct } %MyStruct = type { i32, i32 } -@MainProg_instance = global %MainProg zeroinitializer -@__MyStruct__init = unnamed_addr constant %MyStruct zeroinitializer +@MainProg_instance = global %MainProg zeroinitializer, section "var-$RUSTY$MainProg_instance:r1r2i32i32" +@__MyStruct__init = unnamed_addr constant %MyStruct zeroinitializer, section "var-$RUSTY$__MyStruct__init:r2i32i32" -define void @MainProg(%MainProg* %0) section "fn-MainProg:v" { +define void @MainProg(%MainProg* %0) section "fn-$RUSTY$MainProg:v" { entry: %Cord = getelementptr inbounds %MainProg, %MainProg* %0, i32 0, i32 0 %a = getelementptr inbounds %MyStruct, %MyStruct* %Cord, i32 0, i32 0 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__sub_range_check_functions.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__sub_range_check_functions.snap index ed77c405c09..eb3ee8488d1 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__sub_range_check_functions.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__sub_range_check_functions.snap @@ -7,9 +7,9 @@ source_filename = "main" %main = type { i8, i8, i8, i16, i16, i16, i32, i32, i64, i64 } -@main_instance = global %main zeroinitializer +@main_instance = global %main zeroinitializer, section "var-$RUSTY$main_instance:r10u8i8u8u16i16u16i32u32i64u64" -define i32 @CheckRangeSigned(i32 %0, i32 %1, i32 %2) section "fn-CheckRangeSigned:i32[i32][i32][i32]" { +define i32 @CheckRangeSigned(i32 %0, i32 %1, i32 %2) section "fn-$RUSTY$CheckRangeSigned:i32[i32][i32][i32]" { entry: %CheckRangeSigned = alloca i32, align 4 %v = alloca i32, align 4 @@ -24,7 +24,7 @@ entry: ret i32 %CheckRangeSigned_ret } -define i32 @CheckRangeUnsigned(i32 %0, i32 %1, i32 %2) section "fn-CheckRangeUnsigned:u32[u32][u32][u32]" { +define i32 @CheckRangeUnsigned(i32 %0, i32 %1, i32 %2) section "fn-$RUSTY$CheckRangeUnsigned:u32[u32][u32][u32]" { entry: %CheckRangeUnsigned = alloca i32, align 4 %v = alloca i32, align 4 @@ -39,7 +39,7 @@ entry: ret i32 %CheckRangeUnsigned_ret } -define i64 @CheckLRangeSigned(i64 %0, i64 %1, i64 %2) section "fn-CheckLRangeSigned:i64[i64][i64][i64]" { +define i64 @CheckLRangeSigned(i64 %0, i64 %1, i64 %2) section "fn-$RUSTY$CheckLRangeSigned:i64[i64][i64][i64]" { entry: %CheckLRangeSigned = alloca i64, align 8 %v = alloca i64, align 8 @@ -54,7 +54,7 @@ entry: ret i64 %CheckLRangeSigned_ret } -define i64 @CheckLRangeUnsigned(i64 %0, i64 %1, i64 %2) section "fn-CheckLRangeUnsigned:u64[u64][u64][u64]" { +define i64 @CheckLRangeUnsigned(i64 %0, i64 %1, i64 %2) section "fn-$RUSTY$CheckLRangeUnsigned:u64[u64][u64][u64]" { entry: %CheckLRangeUnsigned = alloca i64, align 8 %v = alloca i64, align 8 @@ -69,7 +69,7 @@ entry: ret i64 %CheckLRangeUnsigned_ret } -define void @main(%main* %0) section "fn-main:v" { +define void @main(%main* %0) section "fn-$RUSTY$main:v" { entry: %a = getelementptr inbounds %main, %main* %0, i32 0, i32 0 %b = getelementptr inbounds %main, %main* %0, i32 0, i32 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__sub_range_type_calls_check_function_missing.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__sub_range_type_calls_check_function_missing.snap index b0a81bb92d7..bc09741b3b2 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__sub_range_type_calls_check_function_missing.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__sub_range_type_calls_check_function_missing.snap @@ -7,9 +7,9 @@ source_filename = "main" %Main = type { i16 } -@Main_instance = global %Main zeroinitializer +@Main_instance = global %Main zeroinitializer, section "var-$RUSTY$Main_instance:r1i16" -define i16 @Check_XX_RangeSigned(i16 %0, i16 %1, i16 %2) section "fn-Check_XX_RangeSigned:i16[i16][i16][i16]" { +define i16 @Check_XX_RangeSigned(i16 %0, i16 %1, i16 %2) section "fn-$RUSTY$Check_XX_RangeSigned:i16[i16][i16][i16]" { entry: %Check_XX_RangeSigned = alloca i16, align 2 %value = alloca i16, align 2 @@ -25,7 +25,7 @@ entry: ret i16 %Check_XX_RangeSigned_ret } -define void @Main(%Main* %0) section "fn-Main:v" { +define void @Main(%Main* %0) section "fn-$RUSTY$Main:v" { entry: %x = getelementptr inbounds %Main, %Main* %0, i32 0, i32 0 store i16 7, i16* %x, align 2 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__sub_range_type_calls_check_function_on_assigment.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__sub_range_type_calls_check_function_on_assigment.snap index 2b4de87c62a..dde219b2028 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__sub_range_type_calls_check_function_on_assigment.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__sub_range_type_calls_check_function_on_assigment.snap @@ -7,9 +7,9 @@ source_filename = "main" %Main = type { i16 } -@Main_instance = global %Main zeroinitializer +@Main_instance = global %Main zeroinitializer, section "var-$RUSTY$Main_instance:r1i16" -define i16 @CheckRangeSigned(i16 %0, i16 %1, i16 %2) section "fn-CheckRangeSigned:i16[i16][i16][i16]" { +define i16 @CheckRangeSigned(i16 %0, i16 %1, i16 %2) section "fn-$RUSTY$CheckRangeSigned:i16[i16][i16][i16]" { entry: %CheckRangeSigned = alloca i16, align 2 %value = alloca i16, align 2 @@ -25,7 +25,7 @@ entry: ret i16 %CheckRangeSigned_ret } -define void @Main(%Main* %0) section "fn-Main:v" { +define void @Main(%Main* %0) section "fn-$RUSTY$Main:v" { entry: %x = getelementptr inbounds %Main, %Main* %0, i32 0, i32 0 %call = call i16 @CheckRangeSigned(i16 7, i16 0, i16 100) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__time_variables_have_nano_seconds_resolution.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__time_variables_have_nano_seconds_resolution.snap index fdfbf91e842..19aa36b0dfa 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__time_variables_have_nano_seconds_resolution.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__time_variables_have_nano_seconds_resolution.snap @@ -7,9 +7,9 @@ source_filename = "main" %prg = type { i64 } -@prg_instance = global %prg zeroinitializer +@prg_instance = global %prg zeroinitializer, section "var-$RUSTY$prg_instance:r1i64" -define void @prg(%prg* %0) section "fn-prg:v" { +define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: %y = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 store i64 1000000, i64* %y, align 4 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__two_global_variables_generates_in_separate_global_variables.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__two_global_variables_generates_in_separate_global_variables.snap index dc394dd9577..1184d09cb37 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__two_global_variables_generates_in_separate_global_variables.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__two_global_variables_generates_in_separate_global_variables.snap @@ -7,12 +7,12 @@ source_filename = "main" %main = type {} -@gX = global i16 0 -@gY = global i8 0 -@gA = global i16 0 -@main_instance = global %main zeroinitializer +@gX = global i16 0, section "var-$RUSTY$gX:i16" +@gY = global i8 0, section "var-$RUSTY$gY:u8" +@gA = global i16 0, section "var-$RUSTY$gA:i16" +@main_instance = global %main zeroinitializer, section "var-$RUSTY$main_instance:r0" -define void @main(%main* %0) section "fn-main:v" { +define void @main(%main* %0) section "fn-$RUSTY$main:v" { entry: ret void } diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__typed_enums_are_generated.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__typed_enums_are_generated.snap index dd20ce1e350..9c4d2a95272 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__typed_enums_are_generated.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__typed_enums_are_generated.snap @@ -5,15 +5,15 @@ expression: result ; ModuleID = 'main' source_filename = "main" -@x = global i8 0 -@y = global i16 0 -@z = global i32 0 -@MyEnum.red = unnamed_addr constant i8 0 -@MyEnum.yellow = unnamed_addr constant i8 1 -@MyEnum.green = unnamed_addr constant i8 2 -@MyEnum2.red = unnamed_addr constant i16 0 -@MyEnum2.yellow = unnamed_addr constant i16 1 -@MyEnum2.green = unnamed_addr constant i16 2 -@MyEnum3.red = unnamed_addr constant i32 0 -@MyEnum3.yellow = unnamed_addr constant i32 1 -@MyEnum3.green = unnamed_addr constant i32 2 +@x = global i8 0, section "var-$RUSTY$x:e3u8" +@y = global i16 0, section "var-$RUSTY$y:e3u16" +@z = global i32 0, section "var-$RUSTY$z:e3i32" +@MyEnum.red = unnamed_addr constant i8 0, section "var-$RUSTY$red:e3u8" +@MyEnum.yellow = unnamed_addr constant i8 1, section "var-$RUSTY$yellow:e3u8" +@MyEnum.green = unnamed_addr constant i8 2, section "var-$RUSTY$green:e3u8" +@MyEnum2.red = unnamed_addr constant i16 0, section "var-$RUSTY$red:e3u16" +@MyEnum2.yellow = unnamed_addr constant i16 1, section "var-$RUSTY$yellow:e3u16" +@MyEnum2.green = unnamed_addr constant i16 2, section "var-$RUSTY$green:e3u16" +@MyEnum3.red = unnamed_addr constant i32 0, section "var-$RUSTY$red:e3i32" +@MyEnum3.yellow = unnamed_addr constant i32 1, section "var-$RUSTY$yellow:e3i32" +@MyEnum3.green = unnamed_addr constant i32 2, section "var-$RUSTY$green:e3i32" diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__typed_enums_are_used_properly.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__typed_enums_are_used_properly.snap index 57ad6134cb2..97965f04077 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__typed_enums_are_used_properly.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__typed_enums_are_used_properly.snap @@ -7,18 +7,18 @@ source_filename = "main" %prg = type { i8, i16, i32 } -@prg_instance = global %prg zeroinitializer -@MyEnum.red = unnamed_addr constant i8 5 -@MyEnum.yellow = unnamed_addr constant i8 6 -@MyEnum.green = unnamed_addr constant i8 7 -@MyEnum2.red = unnamed_addr constant i16 15 -@MyEnum2.yellow = unnamed_addr constant i16 16 -@MyEnum2.green = unnamed_addr constant i16 17 -@MyEnum3.red = unnamed_addr constant i32 25 -@MyEnum3.yellow = unnamed_addr constant i32 26 -@MyEnum3.green = unnamed_addr constant i32 27 +@prg_instance = global %prg zeroinitializer, section "var-$RUSTY$prg_instance:r3u8u16i32" +@MyEnum.red = unnamed_addr constant i8 5, section "var-$RUSTY$red:e3u8" +@MyEnum.yellow = unnamed_addr constant i8 6, section "var-$RUSTY$yellow:e3u8" +@MyEnum.green = unnamed_addr constant i8 7, section "var-$RUSTY$green:e3u8" +@MyEnum2.red = unnamed_addr constant i16 15, section "var-$RUSTY$red:e3u16" +@MyEnum2.yellow = unnamed_addr constant i16 16, section "var-$RUSTY$yellow:e3u16" +@MyEnum2.green = unnamed_addr constant i16 17, section "var-$RUSTY$green:e3u16" +@MyEnum3.red = unnamed_addr constant i32 25, section "var-$RUSTY$red:e3i32" +@MyEnum3.yellow = unnamed_addr constant i32 26, section "var-$RUSTY$yellow:e3i32" +@MyEnum3.green = unnamed_addr constant i32 27, section "var-$RUSTY$green:e3i32" -define void @prg(%prg* %0) section "fn-prg:v" { +define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: %x = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 %y = getelementptr inbounds %prg, %prg* %0, i32 0, i32 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__typed_enums_with_initializers_are_generated.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__typed_enums_with_initializers_are_generated.snap index 14f10de461e..abef6cc783e 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__typed_enums_with_initializers_are_generated.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__typed_enums_with_initializers_are_generated.snap @@ -5,15 +5,15 @@ expression: result ; ModuleID = 'main' source_filename = "main" -@x = global i8 0 -@y = global i16 0 -@z = global i32 0 -@MyEnum.red = unnamed_addr constant i8 1 -@MyEnum.yellow = unnamed_addr constant i8 2 -@MyEnum.green = unnamed_addr constant i8 3 -@MyEnum2.red = unnamed_addr constant i16 10 -@MyEnum2.yellow = unnamed_addr constant i16 11 -@MyEnum2.green = unnamed_addr constant i16 12 -@MyEnum3.red = unnamed_addr constant i32 22 -@MyEnum3.yellow = unnamed_addr constant i32 33 -@MyEnum3.green = unnamed_addr constant i32 44 +@x = global i8 0, section "var-$RUSTY$x:e3u8" +@y = global i16 0, section "var-$RUSTY$y:e3u16" +@z = global i32 0, section "var-$RUSTY$z:e3i32" +@MyEnum.red = unnamed_addr constant i8 1, section "var-$RUSTY$red:e3u8" +@MyEnum.yellow = unnamed_addr constant i8 2, section "var-$RUSTY$yellow:e3u8" +@MyEnum.green = unnamed_addr constant i8 3, section "var-$RUSTY$green:e3u8" +@MyEnum2.red = unnamed_addr constant i16 10, section "var-$RUSTY$red:e3u16" +@MyEnum2.yellow = unnamed_addr constant i16 11, section "var-$RUSTY$yellow:e3u16" +@MyEnum2.green = unnamed_addr constant i16 12, section "var-$RUSTY$green:e3u16" +@MyEnum3.red = unnamed_addr constant i32 22, section "var-$RUSTY$red:e3i32" +@MyEnum3.yellow = unnamed_addr constant i32 33, section "var-$RUSTY$yellow:e3i32" +@MyEnum3.green = unnamed_addr constant i32 44, section "var-$RUSTY$green:e3i32" diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__typed_enums_with_partly_initializers_are_generated.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__typed_enums_with_partly_initializers_are_generated.snap index a6f7759b1da..c5505b5caaf 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__typed_enums_with_partly_initializers_are_generated.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__typed_enums_with_partly_initializers_are_generated.snap @@ -5,15 +5,15 @@ expression: result ; ModuleID = 'main' source_filename = "main" -@twenty = unnamed_addr constant i16 20 -@x = global i8 0 -@MyEnum.red = unnamed_addr constant i8 7 -@MyEnum.yellow = unnamed_addr constant i8 8 -@MyEnum.green = unnamed_addr constant i8 9 -@MyEnum2.a = unnamed_addr constant i8 0 -@MyEnum2.b = unnamed_addr constant i8 1 -@MyEnum2.c = unnamed_addr constant i8 7 -@MyEnum2.d = unnamed_addr constant i8 8 -@MyEnum2.e = unnamed_addr constant i8 9 -@MyEnum2.f = unnamed_addr constant i8 20 -@MyEnum2.g = unnamed_addr constant i8 21 +@twenty = unnamed_addr constant i16 20, section "var-$RUSTY$twenty:i16" +@x = global i8 0, section "var-$RUSTY$x:e3u8" +@MyEnum.red = unnamed_addr constant i8 7, section "var-$RUSTY$red:e3u8" +@MyEnum.yellow = unnamed_addr constant i8 8, section "var-$RUSTY$yellow:e3u8" +@MyEnum.green = unnamed_addr constant i8 9, section "var-$RUSTY$green:e3u8" +@MyEnum2.a = unnamed_addr constant i8 0, section "var-$RUSTY$a:e7u8" +@MyEnum2.b = unnamed_addr constant i8 1, section "var-$RUSTY$b:e7u8" +@MyEnum2.c = unnamed_addr constant i8 7, section "var-$RUSTY$c:e7u8" +@MyEnum2.d = unnamed_addr constant i8 8, section "var-$RUSTY$d:e7u8" +@MyEnum2.e = unnamed_addr constant i8 9, section "var-$RUSTY$e:e7u8" +@MyEnum2.f = unnamed_addr constant i8 20, section "var-$RUSTY$f:e7u8" +@MyEnum2.g = unnamed_addr constant i8 21, section "var-$RUSTY$g:e7u8" diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__using_cast_statement_as_const_expression.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__using_cast_statement_as_const_expression.snap index 8272ecf6dea..5f55331eb1e 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__using_cast_statement_as_const_expression.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__using_cast_statement_as_const_expression.snap @@ -7,9 +7,9 @@ source_filename = "main" %prg = type { [14 x i16] } -@prg_instance = global %prg zeroinitializer +@prg_instance = global %prg zeroinitializer, section "var-$RUSTY$prg_instance:r1ai16" -define void @prg(%prg* %0) section "fn-prg:v" { +define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: %x = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 ret void diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__using_const_expression_in_range_type.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__using_const_expression_in_range_type.snap index fda711bc8df..bf6f679b635 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__using_const_expression_in_range_type.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__using_const_expression_in_range_type.snap @@ -7,11 +7,11 @@ source_filename = "main" %prg = type { i16 } -@CONST = global i16 7 -@MIN = global i16 7 -@prg_instance = global %prg zeroinitializer +@CONST = global i16 7, section "var-$RUSTY$CONST:i16" +@MIN = global i16 7, section "var-$RUSTY$MIN:i16" +@prg_instance = global %prg zeroinitializer, section "var-$RUSTY$prg_instance:r1i16" -define i16 @CheckRangeSigned(i16 %0, i16 %1, i16 %2) section "fn-CheckRangeSigned:i16[i16][i16][i16]" { +define i16 @CheckRangeSigned(i16 %0, i16 %1, i16 %2) section "fn-$RUSTY$CheckRangeSigned:i16[i16][i16][i16]" { entry: %CheckRangeSigned = alloca i16, align 2 %value = alloca i16, align 2 @@ -27,7 +27,7 @@ entry: ret i16 %CheckRangeSigned_ret } -define void @prg(%prg* %0) section "fn-prg:v" { +define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: %x = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 %load_MIN = load i16, i16* @MIN, align 2 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__using_global_consts_in_expressions.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__using_global_consts_in_expressions.snap index 92306c19a08..f03fe9d1c1e 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__using_global_consts_in_expressions.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__using_global_consts_in_expressions.snap @@ -7,12 +7,12 @@ source_filename = "main" %prg = type { i32 } -@cA = unnamed_addr constant i16 1 -@cB = unnamed_addr constant i16 2 -@cC = unnamed_addr constant i16 3 -@prg_instance = global %prg zeroinitializer +@cA = unnamed_addr constant i16 1, section "var-$RUSTY$cA:i16" +@cB = unnamed_addr constant i16 2, section "var-$RUSTY$cB:i16" +@cC = unnamed_addr constant i16 3, section "var-$RUSTY$cC:i16" +@prg_instance = global %prg zeroinitializer, section "var-$RUSTY$prg_instance:r1i32" -define void @prg(%prg* %0) section "fn-prg:v" { +define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: %z = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 store i32 6, i32* %z, align 4 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__variable_with_same_name_as_data_type.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__variable_with_same_name_as_data_type.snap index 244c5340aeb..51c2a26aa43 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__variable_with_same_name_as_data_type.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__variable_with_same_name_as_data_type.snap @@ -7,9 +7,9 @@ source_filename = "main" %prog = type { i64 } -@prog_instance = global %prog zeroinitializer +@prog_instance = global %prog zeroinitializer, section "var-$RUSTY$prog_instance:r1i64" -define i64 @func() section "fn-func:i64" { +define i64 @func() section "fn-$RUSTY$func:i64" { entry: %func = alloca i64, align 8 %TIME = alloca i64, align 8 @@ -19,7 +19,7 @@ entry: ret i64 %func_ret } -define void @prog(%prog* %0) section "fn-prog:v" { +define void @prog(%prog* %0) section "fn-$RUSTY$prog:v" { entry: %TIME = getelementptr inbounds %prog, %prog* %0, i32 0, i32 0 ret void diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__while_loop_with_if_exit.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__while_loop_with_if_exit.snap index 35f2497d9a0..bb75b11e967 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__while_loop_with_if_exit.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__while_loop_with_if_exit.snap @@ -7,9 +7,9 @@ source_filename = "main" %prg = type { i32 } -@prg_instance = global %prg zeroinitializer +@prg_instance = global %prg zeroinitializer, section "var-$RUSTY$prg_instance:r1i32" -define void @prg(%prg* %0) section "fn-prg:v" { +define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: %x = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 br label %condition_check diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__while_statement.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__while_statement.snap index fb30b7ee89a..2da5f62bc80 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__while_statement.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__while_statement.snap @@ -7,9 +7,9 @@ source_filename = "main" %prg = type { i8 } -@prg_instance = global %prg zeroinitializer +@prg_instance = global %prg zeroinitializer, section "var-$RUSTY$prg_instance:r1u8" -define void @prg(%prg* %0) section "fn-prg:v" { +define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: %x = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 br label %condition_check diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__while_with_expression_statement.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__while_with_expression_statement.snap index 3619b8afd0c..ff1fc737a2b 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__while_with_expression_statement.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__code_gen_tests__while_with_expression_statement.snap @@ -7,9 +7,9 @@ source_filename = "main" %prg = type { i8 } -@prg_instance = global %prg zeroinitializer +@prg_instance = global %prg zeroinitializer, section "var-$RUSTY$prg_instance:r1u8" -define void @prg(%prg* %0) section "fn-prg:v" { +define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: %x = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 br label %condition_check diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__compare_instructions_tests__aliased_number_type_comparing_test.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__compare_instructions_tests__aliased_number_type_comparing_test.snap index 294ce2caff2..e00468537da 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__compare_instructions_tests__aliased_number_type_comparing_test.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__compare_instructions_tests__aliased_number_type_comparing_test.snap @@ -5,7 +5,7 @@ expression: result ; ModuleID = 'main' source_filename = "main" -define i16 @baz() section "fn-baz:i16" { +define i16 @baz() section "fn-$RUSTY$baz:i16" { entry: %baz = alloca i16, align 2 %x = alloca i16, align 2 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__compare_instructions_tests__aliased_ranged_number_type_comparing_test.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__compare_instructions_tests__aliased_ranged_number_type_comparing_test.snap index 294ce2caff2..e00468537da 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__compare_instructions_tests__aliased_ranged_number_type_comparing_test.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__compare_instructions_tests__aliased_ranged_number_type_comparing_test.snap @@ -5,7 +5,7 @@ expression: result ; ModuleID = 'main' source_filename = "main" -define i16 @baz() section "fn-baz:i16" { +define i16 @baz() section "fn-$RUSTY$baz:i16" { entry: %baz = alloca i16, align 2 %x = alloca i16, align 2 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__compare_instructions_tests__compare_datetime_types.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__compare_instructions_tests__compare_datetime_types.snap index 33b062d4cfe..cb1dcf50c36 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__compare_instructions_tests__compare_datetime_types.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__compare_instructions_tests__compare_datetime_types.snap @@ -7,9 +7,9 @@ source_filename = "main" %main = type { i64, i64, i64, i64 } -@main_instance = global %main zeroinitializer +@main_instance = global %main zeroinitializer, section "var-$RUSTY$main_instance:r4i64i64i64i64" -define void @main(%main* %0) section "fn-main:v" { +define void @main(%main* %0) section "fn-$RUSTY$main:v" { entry: %var_time = getelementptr inbounds %main, %main* %0, i32 0, i32 0 %var_time_of_day = getelementptr inbounds %main, %main* %0, i32 0, i32 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__compare_instructions_tests__compare_instruction_functions_with_different_types.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__compare_instructions_tests__compare_instruction_functions_with_different_types.snap index 30f7cd9e8a7..23745331956 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__compare_instructions_tests__compare_instruction_functions_with_different_types.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__compare_instructions_tests__compare_instruction_functions_with_different_types.snap @@ -7,9 +7,9 @@ source_filename = "main" %main = type { float*, i16, i32, float, double, i8, i16, i32, i64, i8, i16, i32, i64 } -@main_instance = global %main zeroinitializer +@main_instance = global %main zeroinitializer, section "var-$RUSTY$main_instance:r13pf32i16i32f32f64i8i16i32i64u8u16u32u64" -define float @foo() section "fn-foo:f32" { +define float @foo() section "fn-$RUSTY$foo:f32" { entry: %foo = alloca float, align 4 store float 0.000000e+00, float* %foo, align 4 @@ -17,7 +17,7 @@ entry: ret float %foo_ret } -define void @main(%main* %0) section "fn-main:v" { +define void @main(%main* %0) section "fn-$RUSTY$main:v" { entry: %ptr_float = getelementptr inbounds %main, %main* %0, i32 0, i32 0 %a = getelementptr inbounds %main, %main* %0, i32 0, i32 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__compare_instructions_tests__compare_instructions_with_different_types.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__compare_instructions_tests__compare_instructions_with_different_types.snap index 09104ad5ec2..7061563847c 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__compare_instructions_tests__compare_instructions_with_different_types.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__compare_instructions_tests__compare_instructions_with_different_types.snap @@ -7,9 +7,9 @@ source_filename = "main" %main = type { i16*, i16, i32, i8, i16, i32, i64, i8, i16, i32, i64 } -@main_instance = global %main zeroinitializer +@main_instance = global %main zeroinitializer, section "var-$RUSTY$main_instance:r11pi16i16i32i8i16i32i64u8u16u32u64" -define i64 @foo() section "fn-foo:i64" { +define i64 @foo() section "fn-$RUSTY$foo:i64" { entry: %foo = alloca i64, align 8 store i64 0, i64* %foo, align 4 @@ -17,7 +17,7 @@ entry: ret i64 %foo_ret } -define void @main(%main* %0) section "fn-main:v" { +define void @main(%main* %0) section "fn-$RUSTY$main:v" { entry: %ptr_int = getelementptr inbounds %main, %main* %0, i32 0, i32 0 %a = getelementptr inbounds %main, %main* %0, i32 0, i32 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__compare_instructions_tests__pointer_compare_instructions.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__compare_instructions_tests__pointer_compare_instructions.snap index b528b614047..8ea2a13eb6a 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__compare_instructions_tests__pointer_compare_instructions.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__compare_instructions_tests__pointer_compare_instructions.snap @@ -7,9 +7,9 @@ source_filename = "main" %main = type { i16, i16, i16*, i8 } -@main_instance = global %main { i16 10, i16 20, i16* null, i8 0 } +@main_instance = global %main { i16 10, i16 20, i16* null, i8 0 }, section "var-$RUSTY$main_instance:r4i16i16pi16u8" -define void @main(%main* %0) section "fn-main:v" { +define void @main(%main* %0) section "fn-$RUSTY$main:v" { entry: %x = getelementptr inbounds %main, %main* %0, i32 0, i32 0 %y = getelementptr inbounds %main, %main* %0, i32 0, i32 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__compare_instructions_tests__pointer_function_call_compare_instructions.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__compare_instructions_tests__pointer_function_call_compare_instructions.snap index 71ab97bb9d9..e1405db64d5 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__compare_instructions_tests__pointer_function_call_compare_instructions.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__compare_instructions_tests__pointer_function_call_compare_instructions.snap @@ -7,9 +7,9 @@ source_filename = "main" %main = type { i16*, i16, i8 } -@main_instance = global %main zeroinitializer +@main_instance = global %main zeroinitializer, section "var-$RUSTY$main_instance:r3pi16i16u8" -define i64 @foo() section "fn-foo:i64" { +define i64 @foo() section "fn-$RUSTY$foo:i64" { entry: %foo = alloca i64, align 8 store i64 0, i64* %foo, align 4 @@ -17,7 +17,7 @@ entry: ret i64 %foo_ret } -define void @main(%main* %0) section "fn-main:v" { +define void @main(%main* %0) section "fn-$RUSTY$main:v" { entry: %pt = getelementptr inbounds %main, %main* %0, i32 0, i32 0 %x = getelementptr inbounds %main, %main* %0, i32 0, i32 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__compare_instructions_tests__ranged_number_type_comparing_test.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__compare_instructions_tests__ranged_number_type_comparing_test.snap index 294ce2caff2..e00468537da 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__compare_instructions_tests__ranged_number_type_comparing_test.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__compare_instructions_tests__ranged_number_type_comparing_test.snap @@ -5,7 +5,7 @@ expression: result ; ModuleID = 'main' source_filename = "main" -define i16 @baz() section "fn-baz:i16" { +define i16 @baz() section "fn-$RUSTY$baz:i16" { entry: %baz = alloca i16, align 2 %x = alloca i16, align 2 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__compare_instructions_tests__string_comparison_test.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__compare_instructions_tests__string_comparison_test.snap index f692225ced3..48267d94d4a 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__compare_instructions_tests__string_comparison_test.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__compare_instructions_tests__string_comparison_test.snap @@ -8,7 +8,7 @@ source_filename = "main" @utf08_literal_0 = private unnamed_addr constant [2 x i8] c"a\00" @utf08_literal_1 = private unnamed_addr constant [2 x i8] c"b\00" -define i8 @STRING_EQUAL(i8* %0, i8* %1) section "fn-STRING_EQUAL:u8[s8u1025][s8u1025]" { +define i8 @STRING_EQUAL(i8* %0, i8* %1) section "fn-$RUSTY$STRING_EQUAL:u8[s8u1025][s8u1025]" { entry: %STRING_EQUAL = alloca i8, align 1 %op1 = alloca [1025 x i8], align 1 @@ -24,7 +24,7 @@ entry: ret i8 %STRING_EQUAL_ret } -define i16 @baz() section "fn-baz:i16" { +define i16 @baz() section "fn-$RUSTY$baz:i16" { entry: %baz = alloca i16, align 2 %a = alloca [81 x i8], align 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__compare_instructions_tests__string_equal_with_constant_test.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__compare_instructions_tests__string_equal_with_constant_test.snap index 68c952ff72e..96d9c979e57 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__compare_instructions_tests__string_equal_with_constant_test.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__compare_instructions_tests__string_equal_with_constant_test.snap @@ -8,7 +8,7 @@ source_filename = "main" @utf08_literal_0 = private unnamed_addr constant [2 x i8] c"a\00" @utf08_literal_1 = private unnamed_addr constant [2 x i8] c"b\00" -define i8 @STRING_EQUAL(i8* %0, i8* %1) section "fn-STRING_EQUAL:u8[s8u1025][s8u1025]" { +define i8 @STRING_EQUAL(i8* %0, i8* %1) section "fn-$RUSTY$STRING_EQUAL:u8[s8u1025][s8u1025]" { entry: %STRING_EQUAL = alloca i8, align 1 %op1 = alloca [1025 x i8], align 1 @@ -24,7 +24,7 @@ entry: ret i8 %STRING_EQUAL_ret } -define i16 @baz() section "fn-baz:i16" { +define i16 @baz() section "fn-$RUSTY$baz:i16" { entry: %baz = alloca i16, align 2 %a = alloca [81 x i8], align 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__compare_instructions_tests__string_greater_or_equal_with_constant_test.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__compare_instructions_tests__string_greater_or_equal_with_constant_test.snap index a569845d5f3..9f9a9afc1f0 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__compare_instructions_tests__string_greater_or_equal_with_constant_test.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__compare_instructions_tests__string_greater_or_equal_with_constant_test.snap @@ -7,7 +7,7 @@ source_filename = "main" @utf08_literal_0 = private unnamed_addr constant [2 x i8] c"b\00" -define i8 @STRING_GREATER(i8* %0, i8* %1) section "fn-STRING_GREATER:u8[s8u1025][s8u1025]" { +define i8 @STRING_GREATER(i8* %0, i8* %1) section "fn-$RUSTY$STRING_GREATER:u8[s8u1025][s8u1025]" { entry: %STRING_GREATER = alloca i8, align 1 %op1 = alloca [1025 x i8], align 1 @@ -23,7 +23,7 @@ entry: ret i8 %STRING_GREATER_ret } -define i8 @STRING_EQUAL(i8* %0, i8* %1) section "fn-STRING_EQUAL:u8[s8u1025][s8u1025]" { +define i8 @STRING_EQUAL(i8* %0, i8* %1) section "fn-$RUSTY$STRING_EQUAL:u8[s8u1025][s8u1025]" { entry: %STRING_EQUAL = alloca i8, align 1 %op1 = alloca [1025 x i8], align 1 @@ -39,7 +39,7 @@ entry: ret i8 %STRING_EQUAL_ret } -define i16 @baz() section "fn-baz:i16" { +define i16 @baz() section "fn-$RUSTY$baz:i16" { entry: %baz = alloca i16, align 2 %a = alloca [81 x i8], align 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__compare_instructions_tests__string_greater_with_constant_test.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__compare_instructions_tests__string_greater_with_constant_test.snap index cbebe3cb1fc..0df19053b22 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__compare_instructions_tests__string_greater_with_constant_test.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__compare_instructions_tests__string_greater_with_constant_test.snap @@ -7,7 +7,7 @@ source_filename = "main" @utf08_literal_0 = private unnamed_addr constant [2 x i8] c"b\00" -define i8 @STRING_GREATER(i8* %0, i8* %1) section "fn-STRING_GREATER:u8[s8u1025][s8u1025]" { +define i8 @STRING_GREATER(i8* %0, i8* %1) section "fn-$RUSTY$STRING_GREATER:u8[s8u1025][s8u1025]" { entry: %STRING_GREATER = alloca i8, align 1 %op1 = alloca [1025 x i8], align 1 @@ -23,7 +23,7 @@ entry: ret i8 %STRING_GREATER_ret } -define i16 @baz() section "fn-baz:i16" { +define i16 @baz() section "fn-$RUSTY$baz:i16" { entry: %baz = alloca i16, align 2 %a = alloca [81 x i8], align 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__compare_instructions_tests__string_less_with_constant_test.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__compare_instructions_tests__string_less_with_constant_test.snap index 37ce4183d3a..1c657cb42ff 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__compare_instructions_tests__string_less_with_constant_test.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__compare_instructions_tests__string_less_with_constant_test.snap @@ -7,7 +7,7 @@ source_filename = "main" @utf08_literal_0 = private unnamed_addr constant [2 x i8] c"b\00" -define i8 @STRING_LESS(i8* %0, i8* %1) section "fn-STRING_LESS:u8[s8u1025][s8u1025]" { +define i8 @STRING_LESS(i8* %0, i8* %1) section "fn-$RUSTY$STRING_LESS:u8[s8u1025][s8u1025]" { entry: %STRING_LESS = alloca i8, align 1 %op1 = alloca [1025 x i8], align 1 @@ -23,7 +23,7 @@ entry: ret i8 %STRING_LESS_ret } -define i16 @baz() section "fn-baz:i16" { +define i16 @baz() section "fn-$RUSTY$baz:i16" { entry: %baz = alloca i16, align 2 %a = alloca [81 x i8], align 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__compare_instructions_tests__string_not_equal_with_constant_test.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__compare_instructions_tests__string_not_equal_with_constant_test.snap index 038ff3e2f85..f92c7987105 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__compare_instructions_tests__string_not_equal_with_constant_test.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__compare_instructions_tests__string_not_equal_with_constant_test.snap @@ -7,7 +7,7 @@ source_filename = "main" @utf08_literal_0 = private unnamed_addr constant [2 x i8] c"b\00" -define i8 @STRING_EQUAL(i8* %0, i8* %1) section "fn-STRING_EQUAL:u8[s8u1025][s8u1025]" { +define i8 @STRING_EQUAL(i8* %0, i8* %1) section "fn-$RUSTY$STRING_EQUAL:u8[s8u1025][s8u1025]" { entry: %STRING_EQUAL = alloca i8, align 1 %op1 = alloca [1025 x i8], align 1 @@ -23,7 +23,7 @@ entry: ret i8 %STRING_EQUAL_ret } -define i16 @baz() section "fn-baz:i16" { +define i16 @baz() section "fn-$RUSTY$baz:i16" { entry: %baz = alloca i16, align 2 %a = alloca [81 x i8], align 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__compare_instructions_tests__string_smaller_or_equal_with_constant_test.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__compare_instructions_tests__string_smaller_or_equal_with_constant_test.snap index db2db49d736..4ae435d7488 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__compare_instructions_tests__string_smaller_or_equal_with_constant_test.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__compare_instructions_tests__string_smaller_or_equal_with_constant_test.snap @@ -7,7 +7,7 @@ source_filename = "main" @utf08_literal_0 = private unnamed_addr constant [2 x i8] c"b\00" -define i8 @STRING_LESS(i8* %0, i8* %1) section "fn-STRING_LESS:u8[s8u1025][s8u1025]" { +define i8 @STRING_LESS(i8* %0, i8* %1) section "fn-$RUSTY$STRING_LESS:u8[s8u1025][s8u1025]" { entry: %STRING_LESS = alloca i8, align 1 %op1 = alloca [1025 x i8], align 1 @@ -23,7 +23,7 @@ entry: ret i8 %STRING_LESS_ret } -define i8 @STRING_EQUAL(i8* %0, i8* %1) section "fn-STRING_EQUAL:u8[s8u1025][s8u1025]" { +define i8 @STRING_EQUAL(i8* %0, i8* %1) section "fn-$RUSTY$STRING_EQUAL:u8[s8u1025][s8u1025]" { entry: %STRING_EQUAL = alloca i8, align 1 %op1 = alloca [1025 x i8], align 1 @@ -39,7 +39,7 @@ entry: ret i8 %STRING_EQUAL_ret } -define i16 @baz() section "fn-baz:i16" { +define i16 @baz() section "fn-$RUSTY$baz:i16" { entry: %baz = alloca i16, align 2 %a = alloca [81 x i8], align 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__constants_tests__assigning_const_array_variable.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__constants_tests__assigning_const_array_variable.snap index 6ab566dc672..ea2fbfae188 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__constants_tests__assigning_const_array_variable.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__constants_tests__assigning_const_array_variable.snap @@ -7,10 +7,10 @@ source_filename = "main" %main = type { [4 x i16] } -@const_arr = unnamed_addr constant [4 x i16] [i16 1, i16 2, i16 3, i16 4] -@main_instance = global %main zeroinitializer +@const_arr = unnamed_addr constant [4 x i16] [i16 1, i16 2, i16 3, i16 4], section "var-$RUSTY$const_arr:ai16" +@main_instance = global %main zeroinitializer, section "var-$RUSTY$main_instance:r1ai16" -define void @main(%main* %0) section "fn-main:v" { +define void @main(%main* %0) section "fn-$RUSTY$main:v" { entry: %arr = getelementptr inbounds %main, %main* %0, i32 0, i32 0 %1 = bitcast [4 x i16]* %arr to i8* diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__constants_tests__assigning_const_string_variable.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__constants_tests__assigning_const_string_variable.snap index 98e3e4218a2..2b61ed25b8f 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__constants_tests__assigning_const_string_variable.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__constants_tests__assigning_const_string_variable.snap @@ -7,10 +7,10 @@ source_filename = "main" %main = type { [81 x i8] } -@const_str = unnamed_addr constant [81 x i8] c"global constant string\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00" -@main_instance = global %main zeroinitializer +@const_str = unnamed_addr constant [81 x i8] c"global constant string\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00", section "var-$RUSTY$const_str:s8u81" +@main_instance = global %main zeroinitializer, section "var-$RUSTY$main_instance:r1s8u81" -define void @main(%main* %0) section "fn-main:v" { +define void @main(%main* %0) section "fn-$RUSTY$main:v" { entry: %str = getelementptr inbounds %main, %main* %0, i32 0, i32 0 %1 = bitcast [81 x i8]* %str to i8* diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__constants_tests__assigning_const_struct_variable.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__constants_tests__assigning_const_struct_variable.snap index 1504e0742fa..2691f18820d 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__constants_tests__assigning_const_struct_variable.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__constants_tests__assigning_const_struct_variable.snap @@ -8,11 +8,11 @@ source_filename = "main" %Point = type { i16, i16 } %main = type { %Point } -@const_strct = unnamed_addr constant %Point { i16 1, i16 2 } -@__Point__init = unnamed_addr constant %Point zeroinitializer -@main_instance = global %main zeroinitializer +@const_strct = unnamed_addr constant %Point { i16 1, i16 2 }, section "var-$RUSTY$const_strct:r2i16i16" +@__Point__init = unnamed_addr constant %Point zeroinitializer, section "var-$RUSTY$__Point__init:r2i16i16" +@main_instance = global %main zeroinitializer, section "var-$RUSTY$main_instance:r1r2i16i16" -define void @main(%main* %0) section "fn-main:v" { +define void @main(%main* %0) section "fn-$RUSTY$main:v" { entry: %strct = getelementptr inbounds %main, %main* %0, i32 0, i32 0 %1 = bitcast %Point* %strct to i8* diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__debug_tests__dwarf_version_override.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__debug_tests__dwarf_version_override.snap index 97f35d7d5af..f73180c2823 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__debug_tests__dwarf_version_override.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__debug_tests__dwarf_version_override.snap @@ -5,7 +5,7 @@ expression: codegen ; ModuleID = 'main' source_filename = "main" -@gInt = global i32 0, !dbg !0 +@gInt = global i32 0, section "var-$RUSTY$gInt:i32", !dbg !0 !llvm.module.flags = !{!5, !6} !llvm.dbg.cu = !{!7} @@ -19,4 +19,3 @@ source_filename = "main" !6 = !{i32 2, !"Debug Info Version", i32 3} !7 = distinct !DICompileUnit(language: DW_LANG_C, file: !2, producer: "RuSTy Structured text Compiler", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, globals: !8, splitDebugInlining: false) !8 = !{!0} - diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__debug_tests__global_alias_type.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__debug_tests__global_alias_type.snap index f768c755d42..1811dc5f2f6 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__debug_tests__global_alias_type.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__debug_tests__global_alias_type.snap @@ -5,7 +5,7 @@ expression: codegen ; ModuleID = 'main' source_filename = "main" -@gInt = global i32 0, !dbg !0 +@gInt = global i32 0, section "var-$RUSTY$gInt:i32", !dbg !0 !llvm.module.flags = !{!5, !6} !llvm.dbg.cu = !{!7} @@ -19,4 +19,3 @@ source_filename = "main" !6 = !{i32 2, !"Debug Info Version", i32 3} !7 = distinct !DICompileUnit(language: DW_LANG_C, file: !2, producer: "RuSTy Structured text Compiler", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, globals: !8, splitDebugInlining: false) !8 = !{!0} - diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__debug_tests__global_var_array_added_to_debug_info.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__debug_tests__global_var_array_added_to_debug_info.snap index bc8939baec6..6de29550fd9 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__debug_tests__global_var_array_added_to_debug_info.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__debug_tests__global_var_array_added_to_debug_info.snap @@ -5,9 +5,9 @@ expression: codegen ; ModuleID = 'main' source_filename = "main" -@a = global [11 x i32] zeroinitializer, !dbg !0 -@b = global [110 x i32] zeroinitializer, !dbg !7 -@c = global [11 x [10 x i32]] zeroinitializer, !dbg !12 +@a = global [11 x i32] zeroinitializer, section "var-$RUSTY$a:ai32", !dbg !0 +@b = global [110 x i32] zeroinitializer, section "var-$RUSTY$b:ai32", !dbg !7 +@c = global [11 x [10 x i32]] zeroinitializer, section "var-$RUSTY$c:aai32", !dbg !12 !llvm.module.flags = !{!17, !18} !llvm.dbg.cu = !{!19} diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__debug_tests__global_var_byteseq_added_to_debug_info.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__debug_tests__global_var_byteseq_added_to_debug_info.snap index c3bcfd9c53a..5f3be0978ec 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__debug_tests__global_var_byteseq_added_to_debug_info.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__debug_tests__global_var_byteseq_added_to_debug_info.snap @@ -5,11 +5,11 @@ expression: codegen ; ModuleID = 'main' source_filename = "main" -@a = global i8 0, !dbg !0 -@b = global i8 0, !dbg !4 -@c = global i16 0, !dbg !7 -@d = global i32 0, !dbg !10 -@e = global i64 0, !dbg !13 +@a = global i8 0, section "var-$RUSTY$a:u8", !dbg !0 +@b = global i8 0, section "var-$RUSTY$b:u8", !dbg !4 +@c = global i16 0, section "var-$RUSTY$c:u16", !dbg !7 +@d = global i32 0, section "var-$RUSTY$d:u32", !dbg !10 +@e = global i64 0, section "var-$RUSTY$e:u64", !dbg !13 !llvm.module.flags = !{!16, !17} !llvm.dbg.cu = !{!18} @@ -34,4 +34,3 @@ source_filename = "main" !17 = !{i32 2, !"Debug Info Version", i32 3} !18 = distinct !DICompileUnit(language: DW_LANG_C, file: !2, producer: "RuSTy Structured text Compiler", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, globals: !19, splitDebugInlining: false) !19 = !{!0, !4, !7, !10, !13} - diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__debug_tests__global_var_enum_added_to_debug_info.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__debug_tests__global_var_enum_added_to_debug_info.snap index f2e51fc23c9..aa115753be5 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__debug_tests__global_var_enum_added_to_debug_info.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__debug_tests__global_var_enum_added_to_debug_info.snap @@ -5,16 +5,16 @@ expression: codegen ; ModuleID = 'main' source_filename = "main" -@en3 = global i64 0, !dbg !0 -@en1.a = unnamed_addr constant i32 0, !dbg !5 -@en1.b = unnamed_addr constant i32 1, !dbg !9 -@en1.c = unnamed_addr constant i32 2, !dbg !11 -@en2.d = unnamed_addr constant i8 0, !dbg !13 -@en2.e = unnamed_addr constant i8 1, !dbg !17 -@en2.f = unnamed_addr constant i8 2, !dbg !19 -@__global_en3.a = unnamed_addr constant i64 0, !dbg !21 -@__global_en3.b = unnamed_addr constant i64 1, !dbg !23 -@__global_en3.c = unnamed_addr constant i64 2, !dbg !25 +@en3 = global i64 0, section "var-$RUSTY$en3:e3i64", !dbg !0 +@en1.a = unnamed_addr constant i32 0, section "var-$RUSTY$a:e3i32", !dbg !5 +@en1.b = unnamed_addr constant i32 1, section "var-$RUSTY$b:e3i32", !dbg !9 +@en1.c = unnamed_addr constant i32 2, section "var-$RUSTY$c:e3i32", !dbg !11 +@en2.d = unnamed_addr constant i8 0, section "var-$RUSTY$d:e3u8", !dbg !13 +@en2.e = unnamed_addr constant i8 1, section "var-$RUSTY$e:e3u8", !dbg !17 +@en2.f = unnamed_addr constant i8 2, section "var-$RUSTY$f:e3u8", !dbg !19 +@__global_en3.a = unnamed_addr constant i64 0, section "var-$RUSTY$a:e3i64", !dbg !21 +@__global_en3.b = unnamed_addr constant i64 1, section "var-$RUSTY$b:e3i64", !dbg !23 +@__global_en3.c = unnamed_addr constant i64 2, section "var-$RUSTY$c:e3i64", !dbg !25 !llvm.module.flags = !{!27, !28} !llvm.dbg.cu = !{!29} diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__debug_tests__global_var_float_added_to_debug_info.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__debug_tests__global_var_float_added_to_debug_info.snap index 3072a3a70e7..0b88473ac83 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__debug_tests__global_var_float_added_to_debug_info.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__debug_tests__global_var_float_added_to_debug_info.snap @@ -5,8 +5,8 @@ expression: codegen ; ModuleID = 'main' source_filename = "main" -@a = global float 0.000000e+00, !dbg !0 -@b = global double 0.000000e+00, !dbg !4 +@a = global float 0.000000e+00, section "var-$RUSTY$a:f32", !dbg !0 +@b = global double 0.000000e+00, section "var-$RUSTY$b:f64", !dbg !4 !llvm.module.flags = !{!7, !8} !llvm.dbg.cu = !{!9} @@ -22,4 +22,3 @@ source_filename = "main" !8 = !{i32 2, !"Debug Info Version", i32 3} !9 = distinct !DICompileUnit(language: DW_LANG_C, file: !2, producer: "RuSTy Structured text Compiler", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, globals: !10, splitDebugInlining: false) !10 = !{!0, !4} - diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__debug_tests__global_var_int_added_to_debug_info.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__debug_tests__global_var_int_added_to_debug_info.snap index ef994f3a9ec..28d2d68c713 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__debug_tests__global_var_int_added_to_debug_info.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__debug_tests__global_var_int_added_to_debug_info.snap @@ -5,14 +5,14 @@ expression: codegen ; ModuleID = 'main' source_filename = "main" -@a = global i8 0, !dbg !0 -@b = global i8 0, !dbg !4 -@c = global i16 0, !dbg !7 -@d = global i16 0, !dbg !10 -@e = global i32 0, !dbg !13 -@f = global i32 0, !dbg !16 -@g = global i64 0, !dbg !19 -@h = global i64 0, !dbg !22 +@a = global i8 0, section "var-$RUSTY$a:i8", !dbg !0 +@b = global i8 0, section "var-$RUSTY$b:u8", !dbg !4 +@c = global i16 0, section "var-$RUSTY$c:i16", !dbg !7 +@d = global i16 0, section "var-$RUSTY$d:u16", !dbg !10 +@e = global i32 0, section "var-$RUSTY$e:i32", !dbg !13 +@f = global i32 0, section "var-$RUSTY$f:u32", !dbg !16 +@g = global i64 0, section "var-$RUSTY$g:i64", !dbg !19 +@h = global i64 0, section "var-$RUSTY$h:u64", !dbg !22 !llvm.module.flags = !{!25, !26} !llvm.dbg.cu = !{!27} @@ -46,4 +46,3 @@ source_filename = "main" !26 = !{i32 2, !"Debug Info Version", i32 3} !27 = distinct !DICompileUnit(language: DW_LANG_C, file: !2, producer: "RuSTy Structured text Compiler", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, globals: !28, splitDebugInlining: false) !28 = !{!0, !4, !7, !10, !13, !16, !19, !22} - diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__debug_tests__global_var_nested_struct_added_to_debug_info.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__debug_tests__global_var_nested_struct_added_to_debug_info.snap index 77a450c403c..803a57f3496 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__debug_tests__global_var_nested_struct_added_to_debug_info.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__debug_tests__global_var_nested_struct_added_to_debug_info.snap @@ -8,9 +8,9 @@ source_filename = "main" %myStruct = type { i32, %myStruct2 } %myStruct2 = type { i32, double } -@gStruct = global %myStruct zeroinitializer, !dbg !0 -@__myStruct__init = unnamed_addr constant %myStruct zeroinitializer, !dbg !13 -@__myStruct2__init = unnamed_addr constant %myStruct2 zeroinitializer, !dbg !15 +@gStruct = global %myStruct zeroinitializer, section "var-$RUSTY$gStruct:r2i32r2i32f64", !dbg !0 +@__myStruct__init = unnamed_addr constant %myStruct zeroinitializer, section "var-$RUSTY$__myStruct__init:r2i32r2i32f64", !dbg !13 +@__myStruct2__init = unnamed_addr constant %myStruct2 zeroinitializer, section "var-$RUSTY$__myStruct2__init:r2i32f64", !dbg !15 !llvm.module.flags = !{!17, !18} !llvm.dbg.cu = !{!19} @@ -36,4 +36,3 @@ source_filename = "main" !18 = !{i32 2, !"Debug Info Version", i32 3} !19 = distinct !DICompileUnit(language: DW_LANG_C, file: !2, producer: "RuSTy Structured text Compiler", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, globals: !20, splitDebugInlining: false) !20 = !{!0, !13, !15} - diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__debug_tests__global_var_pointer_added_to_debug_info.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__debug_tests__global_var_pointer_added_to_debug_info.snap index 627648ab048..866adc90253 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__debug_tests__global_var_pointer_added_to_debug_info.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__debug_tests__global_var_pointer_added_to_debug_info.snap @@ -5,7 +5,7 @@ expression: codegen ; ModuleID = 'main' source_filename = "main" -@a = global i32* null, !dbg !0 +@a = global i32* null, section "var-$RUSTY$a:pi32", !dbg !0 !llvm.module.flags = !{!5, !6} !llvm.dbg.cu = !{!7} @@ -19,4 +19,3 @@ source_filename = "main" !6 = !{i32 2, !"Debug Info Version", i32 3} !7 = distinct !DICompileUnit(language: DW_LANG_C, file: !2, producer: "RuSTy Structured text Compiler", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, globals: !8, splitDebugInlining: false) !8 = !{!0} - diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__debug_tests__global_var_string_added_to_debug_info.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__debug_tests__global_var_string_added_to_debug_info.snap index eb898b7e821..864e7f4fba5 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__debug_tests__global_var_string_added_to_debug_info.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__debug_tests__global_var_string_added_to_debug_info.snap @@ -5,8 +5,8 @@ expression: codegen ; ModuleID = 'main' source_filename = "main" -@a = global [81 x i8] zeroinitializer, !dbg !0 -@b = global [81 x i16] zeroinitializer, !dbg !7 +@a = global [81 x i8] zeroinitializer, section "var-$RUSTY$a:s8u81", !dbg !0 +@b = global [81 x i16] zeroinitializer, section "var-$RUSTY$b:s16u81", !dbg !7 !llvm.module.flags = !{!11, !12} !llvm.dbg.cu = !{!13} diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__debug_tests__global_var_struct_added_to_debug_info.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__debug_tests__global_var_struct_added_to_debug_info.snap index e4da745f10c..0597974f4c3 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__debug_tests__global_var_struct_added_to_debug_info.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__debug_tests__global_var_struct_added_to_debug_info.snap @@ -7,9 +7,9 @@ source_filename = "main" %myStruct = type { i32, double, [11 x i32] } -@gStruct = global %myStruct zeroinitializer, !dbg !0 -@__myStruct__init = unnamed_addr constant %myStruct zeroinitializer, !dbg !13 -@b = global [11 x %myStruct] zeroinitializer, !dbg !15 +@gStruct = global %myStruct zeroinitializer, section "var-$RUSTY$gStruct:r3i32f64ai32", !dbg !0 +@__myStruct__init = unnamed_addr constant %myStruct zeroinitializer, section "var-$RUSTY$__myStruct__init:r3i32f64ai32", !dbg !13 +@b = global [11 x %myStruct] zeroinitializer, section "var-$RUSTY$b:ar3i32f64ai32", !dbg !15 !llvm.module.flags = !{!18, !19} !llvm.dbg.cu = !{!20} diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__directaccess_test__bitaccess_assignment.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__directaccess_test__bitaccess_assignment.snap index 7d43f2e95ae..17b1cc07805 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__directaccess_test__bitaccess_assignment.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__directaccess_test__bitaccess_assignment.snap @@ -5,7 +5,7 @@ expression: prog ; ModuleID = 'main' source_filename = "main" -define i16 @main() section "fn-main:i16" { +define i16 @main() section "fn-$RUSTY$main:i16" { entry: %main = alloca i16, align 2 %a = alloca i8, align 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__directaccess_test__byteaccess_assignment.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__directaccess_test__byteaccess_assignment.snap index a2afbc1809b..9dd16c7c5e7 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__directaccess_test__byteaccess_assignment.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__directaccess_test__byteaccess_assignment.snap @@ -5,7 +5,7 @@ expression: prog ; ModuleID = 'main' source_filename = "main" -define i16 @main() section "fn-main:i16" { +define i16 @main() section "fn-$RUSTY$main:i16" { entry: %main = alloca i16, align 2 %b = alloca i16, align 2 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__directaccess_test__chained_bit_assignment.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__directaccess_test__chained_bit_assignment.snap index 3bdd26d450d..be0753e99e9 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__directaccess_test__chained_bit_assignment.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__directaccess_test__chained_bit_assignment.snap @@ -5,7 +5,7 @@ expression: prog ; ModuleID = 'main' source_filename = "main" -define i16 @main() section "fn-main:i16" { +define i16 @main() section "fn-$RUSTY$main:i16" { entry: %main = alloca i16, align 2 %d = alloca i64, align 8 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__directaccess_test__dwordaccess_assignment.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__directaccess_test__dwordaccess_assignment.snap index ef35b7c34e6..3e4cf086736 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__directaccess_test__dwordaccess_assignment.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__directaccess_test__dwordaccess_assignment.snap @@ -5,7 +5,7 @@ expression: prog ; ModuleID = 'main' source_filename = "main" -define i16 @main() section "fn-main:i16" { +define i16 @main() section "fn-$RUSTY$main:i16" { entry: %main = alloca i16, align 2 %d = alloca i64, align 8 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__directaccess_test__lwordaccess_assignment.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__directaccess_test__lwordaccess_assignment.snap index 414c121c50b..4b2a62507b6 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__directaccess_test__lwordaccess_assignment.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__directaccess_test__lwordaccess_assignment.snap @@ -5,7 +5,7 @@ expression: prog ; ModuleID = 'main' source_filename = "main" -define i16 @main() section "fn-main:i16" { +define i16 @main() section "fn-$RUSTY$main:i16" { entry: %main = alloca i16, align 2 %d = alloca i64, align 8 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__directaccess_test__qualified_reference_assignment.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__directaccess_test__qualified_reference_assignment.snap index 18595e72682..178b8710e93 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__directaccess_test__qualified_reference_assignment.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__directaccess_test__qualified_reference_assignment.snap @@ -7,9 +7,9 @@ source_filename = "main" %myStruct = type { i8 } -@__myStruct__init = unnamed_addr constant %myStruct { i8 1 } +@__myStruct__init = unnamed_addr constant %myStruct { i8 1 }, section "var-$RUSTY$__myStruct__init:r1u8" -define i16 @main() section "fn-main:i16" { +define i16 @main() section "fn-$RUSTY$main:i16" { entry: %main = alloca i16, align 2 %str = alloca %myStruct, align 8 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__directaccess_test__wordaccess_assignment.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__directaccess_test__wordaccess_assignment.snap index d2ce83e27ca..b0ac3abacac 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__directaccess_test__wordaccess_assignment.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__directaccess_test__wordaccess_assignment.snap @@ -5,7 +5,7 @@ expression: prog ; ModuleID = 'main' source_filename = "main" -define i16 @main() section "fn-main:i16" { +define i16 @main() section "fn-$RUSTY$main:i16" { entry: %main = alloca i16, align 2 %c = alloca i32, align 4 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__access_string_via_byte_array.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__access_string_via_byte_array.snap index 68a042fcf58..7b186085efd 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__access_string_via_byte_array.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__access_string_via_byte_array.snap @@ -7,9 +7,9 @@ source_filename = "main" %baz = type { [11 x i8], i8*, [10 x i8]* } -@baz_instance = global %baz zeroinitializer +@baz_instance = global %baz zeroinitializer, section "var-$RUSTY$baz_instance:r3s8u11pu8pau8" -define void @baz(%baz* %0) section "fn-baz:v" { +define void @baz(%baz* %0) section "fn-$RUSTY$baz:v" { entry: %str = getelementptr inbounds %baz, %baz* %0, i32 0, i32 0 %ptr = getelementptr inbounds %baz, %baz* %0, i32 0, i32 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__allowed_assignable_types.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__allowed_assignable_types.snap index 32fb59a6dc5..772275ede2a 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__allowed_assignable_types.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__allowed_assignable_types.snap @@ -7,9 +7,9 @@ source_filename = "main" %main = type { i16, [2 x i16], i16*, [2 x i16]* } -@main_instance = global %main zeroinitializer +@main_instance = global %main zeroinitializer, section "var-$RUSTY$main_instance:r4i16ai16pi16pai16" -define void @main(%main* %0) section "fn-main:v" { +define void @main(%main* %0) section "fn-$RUSTY$main:v" { entry: %v = getelementptr inbounds %main, %main* %0, i32 0, i32 0 %x = getelementptr inbounds %main, %main* %0, i32 0, i32 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_add_float.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_add_float.snap index 34fcd40fde5..28886fa044f 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_add_float.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_add_float.snap @@ -5,7 +5,7 @@ expression: res ; ModuleID = 'main' source_filename = "main" -define i32 @main() section "fn-main:i32" { +define i32 @main() section "fn-$RUSTY$main:i32" { entry: %main = alloca i32, align 4 %x1 = alloca float, align 4 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_add_ints.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_add_ints.snap index 53f6c8618b3..f8efd2d2ac1 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_add_ints.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_add_ints.snap @@ -5,7 +5,7 @@ expression: res ; ModuleID = 'main' source_filename = "main" -define i32 @main() section "fn-main:i32" { +define i32 @main() section "fn-$RUSTY$main:i32" { entry: %main = alloca i32, align 4 %x1 = alloca i32, align 4 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_add_mixed.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_add_mixed.snap index 36adeb195f9..3007b561279 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_add_mixed.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_add_mixed.snap @@ -5,7 +5,7 @@ expression: res ; ModuleID = 'main' source_filename = "main" -define i32 @main() section "fn-main:i32" { +define i32 @main() section "fn-$RUSTY$main:i32" { entry: %main = alloca i32, align 4 %x1 = alloca float, align 4 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_div_float.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_div_float.snap index 8fff2dea878..34a91ddfc71 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_div_float.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_div_float.snap @@ -5,7 +5,7 @@ expression: res ; ModuleID = 'main' source_filename = "main" -define i32 @main() section "fn-main:i32" { +define i32 @main() section "fn-$RUSTY$main:i32" { entry: %main = alloca i32, align 4 %x1 = alloca float, align 4 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_div_ints.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_div_ints.snap index c3559a71d3c..c08bacfc033 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_div_ints.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_div_ints.snap @@ -5,7 +5,7 @@ expression: res ; ModuleID = 'main' source_filename = "main" -define i32 @main() section "fn-main:i32" { +define i32 @main() section "fn-$RUSTY$main:i32" { entry: %main = alloca i32, align 4 %x1 = alloca i32, align 4 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_div_mixed.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_div_mixed.snap index 0cc25f9daf7..d6d8a79ac06 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_div_mixed.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_div_mixed.snap @@ -5,7 +5,7 @@ expression: res ; ModuleID = 'main' source_filename = "main" -define i32 @main() section "fn-main:i32" { +define i32 @main() section "fn-$RUSTY$main:i32" { entry: %main = alloca i32, align 4 %x1 = alloca float, align 4 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_function_call_adr.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_function_call_adr.snap index 8f00ddfb91a..8b30fb03c9b 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_function_call_adr.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_function_call_adr.snap @@ -7,9 +7,9 @@ source_filename = "main" %main = type { i32*, i32 } -@main_instance = global %main zeroinitializer +@main_instance = global %main zeroinitializer, section "var-$RUSTY$main_instance:r2pi32i32" -define void @main(%main* %0) section "fn-main:v" { +define void @main(%main* %0) section "fn-$RUSTY$main:v" { entry: %a = getelementptr inbounds %main, %main* %0, i32 0, i32 0 %b = getelementptr inbounds %main, %main* %0, i32 0, i32 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_function_call_lower_bound.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_function_call_lower_bound.snap index aa7a2bb241a..8a90e7a9607 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_function_call_lower_bound.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_function_call_lower_bound.snap @@ -8,10 +8,10 @@ source_filename = "main" %main = type { [2 x i32], i32 } %__foo_vla = type { i32*, [2 x i32] } -@main_instance = global %main zeroinitializer -@____foo_vla__init = unnamed_addr constant %__foo_vla zeroinitializer +@main_instance = global %main zeroinitializer, section "var-$RUSTY$main_instance:r2ai32i32" +@____foo_vla__init = unnamed_addr constant %__foo_vla zeroinitializer, section "var-$RUSTY$____foo_vla__init:r2pai32ai32" -define void @main(%main* %0) section "fn-main:v" { +define void @main(%main* %0) section "fn-$RUSTY$main:v" { entry: %a = getelementptr inbounds %main, %main* %0, i32 0, i32 0 %b = getelementptr inbounds %main, %main* %0, i32 0, i32 1 @@ -30,7 +30,7 @@ entry: ret void } -define i32 @foo(%__foo_vla* %0) section "fn-foo:i32[pv]" { +define i32 @foo(%__foo_vla* %0) section "fn-$RUSTY$foo:i32[pr2pai32ai32]" { entry: %foo = alloca i32, align 4 %vla = alloca %__foo_vla*, align 8 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_function_call_move.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_function_call_move.snap index 5d0484af4b8..48d5aecaccf 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_function_call_move.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_function_call_move.snap @@ -7,9 +7,9 @@ source_filename = "main" %main = type { i32, i32 } -@main_instance = global %main zeroinitializer +@main_instance = global %main zeroinitializer, section "var-$RUSTY$main_instance:r2i32i32" -define void @main(%main* %0) section "fn-main:v" { +define void @main(%main* %0) section "fn-$RUSTY$main:v" { entry: %a = getelementptr inbounds %main, %main* %0, i32 0, i32 0 %b = getelementptr inbounds %main, %main* %0, i32 0, i32 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_function_call_mux.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_function_call_mux.snap index 27229cc276f..83fc6f99f0c 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_function_call_mux.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_function_call_mux.snap @@ -7,9 +7,9 @@ source_filename = "main" %main = type { i32, i32, i32, i32, i32 } -@main_instance = global %main zeroinitializer +@main_instance = global %main zeroinitializer, section "var-$RUSTY$main_instance:r5i32i32i32i32i32" -define void @main(%main* %0) section "fn-main:v" { +define void @main(%main* %0) section "fn-$RUSTY$main:v" { entry: %a = getelementptr inbounds %main, %main* %0, i32 0, i32 0 %b = getelementptr inbounds %main, %main* %0, i32 0, i32 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_function_call_mux_with_aggregate_type.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_function_call_mux_with_aggregate_type.snap index 75f90dd458b..25482f90dbe 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_function_call_mux_with_aggregate_type.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_function_call_mux_with_aggregate_type.snap @@ -7,13 +7,13 @@ source_filename = "main" %main = type { [81 x i8] } -@main_instance = global %main zeroinitializer +@main_instance = global %main zeroinitializer, section "var-$RUSTY$main_instance:r1s8u81" @utf08_literal_0 = private unnamed_addr constant [6 x i8] c"dolor\00" @utf08_literal_1 = private unnamed_addr constant [6 x i8] c"ipsum\00" @utf08_literal_2 = private unnamed_addr constant [6 x i8] c"lorem\00" @utf08_literal_3 = private unnamed_addr constant [4 x i8] c"sit\00" -define void @main(%main* %0) section "fn-main:v" { +define void @main(%main* %0) section "fn-$RUSTY$main:v" { entry: %str1 = getelementptr inbounds %main, %main* %0, i32 0, i32 0 %1 = alloca [81 x i8], align 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_function_call_ref.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_function_call_ref.snap index 43033311c3d..e4be51277bc 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_function_call_ref.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_function_call_ref.snap @@ -7,9 +7,9 @@ source_filename = "main" %main = type { i32*, i32 } -@main_instance = global %main zeroinitializer +@main_instance = global %main zeroinitializer, section "var-$RUSTY$main_instance:r2pi32i32" -define void @main(%main* %0) section "fn-main:v" { +define void @main(%main* %0) section "fn-$RUSTY$main:v" { entry: %a = getelementptr inbounds %main, %main* %0, i32 0, i32 0 %b = getelementptr inbounds %main, %main* %0, i32 0, i32 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_function_call_sel.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_function_call_sel.snap index df8babe7d6e..bd9ab0f2a90 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_function_call_sel.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_function_call_sel.snap @@ -7,9 +7,9 @@ source_filename = "main" %main = type { i32, i32, i32 } -@main_instance = global %main zeroinitializer +@main_instance = global %main zeroinitializer, section "var-$RUSTY$main_instance:r3i32i32i32" -define void @main(%main* %0) section "fn-main:v" { +define void @main(%main* %0) section "fn-$RUSTY$main:v" { entry: %a = getelementptr inbounds %main, %main* %0, i32 0, i32 0 %b = getelementptr inbounds %main, %main* %0, i32 0, i32 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_function_call_sel_as_expression.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_function_call_sel_as_expression.snap index 367c4cb9f0b..035232f1692 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_function_call_sel_as_expression.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_function_call_sel_as_expression.snap @@ -7,9 +7,9 @@ source_filename = "main" %main = type { i32, i32, i32 } -@main_instance = global %main zeroinitializer +@main_instance = global %main zeroinitializer, section "var-$RUSTY$main_instance:r3i32i32i32" -define void @main(%main* %0) section "fn-main:v" { +define void @main(%main* %0) section "fn-$RUSTY$main:v" { entry: %a = getelementptr inbounds %main, %main* %0, i32 0, i32 0 %b = getelementptr inbounds %main, %main* %0, i32 0, i32 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_function_call_sizeof.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_function_call_sizeof.snap index f4f198abfd3..be59e2f268a 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_function_call_sizeof.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_function_call_sizeof.snap @@ -7,9 +7,9 @@ source_filename = "main" %main = type { i32, i64 } -@main_instance = global %main zeroinitializer +@main_instance = global %main zeroinitializer, section "var-$RUSTY$main_instance:r2i32i64" -define void @main(%main* %0) section "fn-main:v" { +define void @main(%main* %0) section "fn-$RUSTY$main:v" { entry: %a = getelementptr inbounds %main, %main* %0, i32 0, i32 0 %b = getelementptr inbounds %main, %main* %0, i32 0, i32 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_function_call_upper_bound.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_function_call_upper_bound.snap index fd899f8f69a..f652e3b20de 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_function_call_upper_bound.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_function_call_upper_bound.snap @@ -8,10 +8,10 @@ source_filename = "main" %main = type { [2 x i32], i32 } %__foo_vla = type { i32*, [2 x i32] } -@main_instance = global %main zeroinitializer -@____foo_vla__init = unnamed_addr constant %__foo_vla zeroinitializer +@main_instance = global %main zeroinitializer, section "var-$RUSTY$main_instance:r2ai32i32" +@____foo_vla__init = unnamed_addr constant %__foo_vla zeroinitializer, section "var-$RUSTY$____foo_vla__init:r2pai32ai32" -define void @main(%main* %0) section "fn-main:v" { +define void @main(%main* %0) section "fn-$RUSTY$main:v" { entry: %a = getelementptr inbounds %main, %main* %0, i32 0, i32 0 %b = getelementptr inbounds %main, %main* %0, i32 0, i32 1 @@ -30,7 +30,7 @@ entry: ret void } -define i32 @foo(%__foo_vla* %0) section "fn-foo:i32[pv]" { +define i32 @foo(%__foo_vla* %0) section "fn-$RUSTY$foo:i32[pr2pai32ai32]" { entry: %foo = alloca i32, align 4 %vla = alloca %__foo_vla*, align 8 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_function_call_upper_bound_expr.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_function_call_upper_bound_expr.snap index 36f5e9ee4dd..6451ebd31bc 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_function_call_upper_bound_expr.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_function_call_upper_bound_expr.snap @@ -8,11 +8,11 @@ source_filename = "main" %main = type { [16 x i32], i32 } %__foo_vla = type { i32*, [2 x i32] } -@MY_CONST = unnamed_addr constant i32 10 -@main_instance = global %main zeroinitializer -@____foo_vla__init = unnamed_addr constant %__foo_vla zeroinitializer +@MY_CONST = unnamed_addr constant i32 10, section "var-$RUSTY$MY_CONST:i32" +@main_instance = global %main zeroinitializer, section "var-$RUSTY$main_instance:r2ai32i32" +@____foo_vla__init = unnamed_addr constant %__foo_vla zeroinitializer, section "var-$RUSTY$____foo_vla__init:r2pai32ai32" -define void @main(%main* %0) section "fn-main:v" { +define void @main(%main* %0) section "fn-$RUSTY$main:v" { entry: %a = getelementptr inbounds %main, %main* %0, i32 0, i32 0 %b = getelementptr inbounds %main, %main* %0, i32 0, i32 1 @@ -31,7 +31,7 @@ entry: ret void } -define i32 @foo(%__foo_vla* %0) section "fn-foo:i32[pv]" { +define i32 @foo(%__foo_vla* %0) section "fn-$RUSTY$foo:i32[pr2pai32ai32]" { entry: %foo = alloca i32, align 4 %vla = alloca %__foo_vla*, align 8 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_mul_float.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_mul_float.snap index db2dcd61de4..ee02b908f5c 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_mul_float.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_mul_float.snap @@ -5,7 +5,7 @@ expression: res ; ModuleID = 'main' source_filename = "main" -define i32 @main() section "fn-main:i32" { +define i32 @main() section "fn-$RUSTY$main:i32" { entry: %main = alloca i32, align 4 %x1 = alloca float, align 4 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_mul_ints.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_mul_ints.snap index f2f1b0fb5a2..f8ff9fdbf9a 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_mul_ints.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_mul_ints.snap @@ -5,7 +5,7 @@ expression: res ; ModuleID = 'main' source_filename = "main" -define i32 @main() section "fn-main:i32" { +define i32 @main() section "fn-$RUSTY$main:i32" { entry: %main = alloca i32, align 4 %x1 = alloca i32, align 4 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_mul_mixed.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_mul_mixed.snap index 5dd59ae0085..20a48a564fb 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_mul_mixed.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_mul_mixed.snap @@ -5,7 +5,7 @@ expression: res ; ModuleID = 'main' source_filename = "main" -define i32 @main() section "fn-main:i32" { +define i32 @main() section "fn-$RUSTY$main:i32" { entry: %main = alloca i32, align 4 %x1 = alloca float, align 4 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_sub_float.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_sub_float.snap index 018095b01f4..36e78e620c4 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_sub_float.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_sub_float.snap @@ -5,7 +5,7 @@ expression: res ; ModuleID = 'main' source_filename = "main" -define i32 @main() section "fn-main:i32" { +define i32 @main() section "fn-$RUSTY$main:i32" { entry: %main = alloca i32, align 4 %x1 = alloca float, align 4 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_sub_ints.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_sub_ints.snap index 6b2e8e4fa38..a3fd7da5db2 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_sub_ints.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_sub_ints.snap @@ -5,7 +5,7 @@ expression: res ; ModuleID = 'main' source_filename = "main" -define i32 @main() section "fn-main:i32" { +define i32 @main() section "fn-$RUSTY$main:i32" { entry: %main = alloca i32, align 4 %x1 = alloca i32, align 4 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_sub_mixed.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_sub_mixed.snap index 1db3a1d24c5..db9b19e5834 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_sub_mixed.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__builtin_sub_mixed.snap @@ -5,7 +5,7 @@ expression: res ; ModuleID = 'main' source_filename = "main" -define i32 @main() section "fn-main:i32" { +define i32 @main() section "fn-$RUSTY$main:i32" { entry: %main = alloca i32, align 4 %x1 = alloca float, align 4 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__calling_strings_in_function_return.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__calling_strings_in_function_return.snap index 491ea335728..4171b614530 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__calling_strings_in_function_return.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__calling_strings_in_function_return.snap @@ -7,10 +7,10 @@ source_filename = "main" %main = type { [81 x i8] } -@main_instance = global %main zeroinitializer +@main_instance = global %main zeroinitializer, section "var-$RUSTY$main_instance:r1s8u81" @utf08_literal_0 = private unnamed_addr constant [6 x i8] c"hello\00" -define void @func([81 x i8]* %0) section "fn-func:s8u81" { +define void @func([81 x i8]* %0) section "fn-$RUSTY$func:s8u81" { entry: %func = alloca [81 x i8]*, align 8 store [81 x i8]* %0, [81 x i8]** %func, align 8 @@ -23,7 +23,7 @@ entry: ret void } -define void @main(%main* %0) section "fn-main:v" { +define void @main(%main* %0) section "fn-$RUSTY$main:v" { entry: %x = getelementptr inbounds %main, %main* %0, i32 0, i32 0 %1 = alloca [81 x i8], align 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__cast_between_pointer_types.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__cast_between_pointer_types.snap index 934a893e2b3..e9f7708b718 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__cast_between_pointer_types.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__cast_between_pointer_types.snap @@ -7,9 +7,9 @@ source_filename = "main" %baz = type { i8*, i16 } -@baz_instance = global %baz zeroinitializer +@baz_instance = global %baz zeroinitializer, section "var-$RUSTY$baz_instance:r2pu8u16" -define void @baz(%baz* %0) section "fn-baz:v" { +define void @baz(%baz* %0) section "fn-$RUSTY$baz:v" { entry: %ptr_x = getelementptr inbounds %baz, %baz* %0, i32 0, i32 0 %y = getelementptr inbounds %baz, %baz* %0, i32 0, i32 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__cast_lword_to_pointer.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__cast_lword_to_pointer.snap index e6506fd430f..32dc6e8eb66 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__cast_lword_to_pointer.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__cast_lword_to_pointer.snap @@ -5,7 +5,7 @@ expression: result ; ModuleID = 'main' source_filename = "main" -define i16 @baz() section "fn-baz:i16" { +define i16 @baz() section "fn-$RUSTY$baz:i16" { entry: %baz = alloca i16, align 2 %ptr_x = alloca i16*, align 8 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__cast_pointer_to_lword.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__cast_pointer_to_lword.snap index 2aa73303cdc..57b04fefea2 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__cast_pointer_to_lword.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__cast_pointer_to_lword.snap @@ -5,7 +5,7 @@ expression: result ; ModuleID = 'main' source_filename = "main" -define i16 @baz() section "fn-baz:i16" { +define i16 @baz() section "fn-$RUSTY$baz:i16" { entry: %baz = alloca i16, align 2 %ptr_x = alloca i16*, align 8 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__compare_date_time_literals.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__compare_date_time_literals.snap index 3599d8dfc17..2d4d578bcb4 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__compare_date_time_literals.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__compare_date_time_literals.snap @@ -7,9 +7,9 @@ source_filename = "main" %main = type {} -@main_instance = global %main zeroinitializer +@main_instance = global %main zeroinitializer, section "var-$RUSTY$main_instance:r8u8u8u8u8u8u8u8u8" -define void @main(%main* %0) section "fn-main:v" { +define void @main(%main* %0) section "fn-$RUSTY$main:v" { entry: %cmp1 = alloca i8, align 1 %cmp2 = alloca i8, align 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__hardware_access_assign_codegen.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__hardware_access_assign_codegen.snap index 5c9db0d4731..2b0dd2a5773 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__hardware_access_assign_codegen.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__hardware_access_assign_codegen.snap @@ -7,9 +7,9 @@ source_filename = "main" %prg = type { i8, i8, i8 } -@prg_instance = global %prg zeroinitializer +@prg_instance = global %prg zeroinitializer, section "var-$RUSTY$prg_instance:r3u8u8u8" -define void @prg(%prg* %0) section "fn-prg:v" { +define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: %x = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 %y = getelementptr inbounds %prg, %prg* %0, i32 0, i32 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__hardware_access_codegen.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__hardware_access_codegen.snap index 8aaf65c189c..de482e43a16 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__hardware_access_codegen.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__hardware_access_codegen.snap @@ -7,9 +7,9 @@ source_filename = "main" %prg = type { i8, i8, i8 } -@prg_instance = global %prg zeroinitializer +@prg_instance = global %prg zeroinitializer, section "var-$RUSTY$prg_instance:r3u8u8u8" -define void @prg(%prg* %0) section "fn-prg:v" { +define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: %x = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 %y = getelementptr inbounds %prg, %prg* %0, i32 0, i32 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__max_int.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__max_int.snap index 137f73001bf..eb1dc9ec1c5 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__max_int.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__max_int.snap @@ -5,7 +5,7 @@ expression: result ; ModuleID = 'main' source_filename = "main" -define i16 @main() section "fn-main:i16" { +define i16 @main() section "fn-$RUSTY$main:i16" { entry: %main = alloca i16, align 2 store i16 0, i16* %main, align 2 @@ -31,4 +31,4 @@ entry: ret i16 %main_ret } -declare i16 @MAX__INT(i32, i16*) section "fn-MAX__INT:i16" +declare i16 @MAX__INT(i32, i16*) section "fn-$RUSTY$MAX__INT:i16" diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__nested_call_statements.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__nested_call_statements.snap index 702898de621..6857bb5d92f 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__nested_call_statements.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__nested_call_statements.snap @@ -7,9 +7,9 @@ source_filename = "main" %main = type {} -@main_instance = global %main zeroinitializer +@main_instance = global %main zeroinitializer, section "var-$RUSTY$main_instance:r0" -define i32 @foo(i32 %0) section "fn-foo:i32[i32]" { +define i32 @foo(i32 %0) section "fn-$RUSTY$foo:i32[i32]" { entry: %foo = alloca i32, align 4 %a = alloca i32, align 4 @@ -19,7 +19,7 @@ entry: ret i32 %foo_ret } -define void @main(%main* %0) section "fn-main:v" { +define void @main(%main* %0) section "fn-$RUSTY$main:v" { entry: %call = call i32 @foo(i32 2) %call1 = call i32 @foo(i32 %call) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__pointer_arithmetics.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__pointer_arithmetics.snap index 66d17c646b5..fd925253078 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__pointer_arithmetics.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__pointer_arithmetics.snap @@ -7,9 +7,9 @@ source_filename = "main" %main = type { i16, i16, i16* } -@main_instance = global %main { i16 10, i16 20, i16* null } +@main_instance = global %main { i16 10, i16 20, i16* null }, section "var-$RUSTY$main_instance:r3i16i16pi16" -define void @main(%main* %0) section "fn-main:v" { +define void @main(%main* %0) section "fn-$RUSTY$main:v" { entry: %x = getelementptr inbounds %main, %main* %0, i32 0, i32 0 %y = getelementptr inbounds %main, %main* %0, i32 0, i32 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__pointer_arithmetics_function_call.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__pointer_arithmetics_function_call.snap index f402dd63149..0820ec9a248 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__pointer_arithmetics_function_call.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__pointer_arithmetics_function_call.snap @@ -7,9 +7,9 @@ source_filename = "main" %main = type { i16*, i16 } -@main_instance = global %main zeroinitializer +@main_instance = global %main zeroinitializer, section "var-$RUSTY$main_instance:r2pi16i16" -define i64 @foo() section "fn-foo:i64" { +define i64 @foo() section "fn-$RUSTY$foo:i64" { entry: %foo = alloca i64, align 8 store i64 0, i64* %foo, align 4 @@ -17,7 +17,7 @@ entry: ret i64 %foo_ret } -define void @main(%main* %0) section "fn-main:v" { +define void @main(%main* %0) section "fn-$RUSTY$main:v" { entry: %pt = getelementptr inbounds %main, %main* %0, i32 0, i32 0 %x = getelementptr inbounds %main, %main* %0, i32 0, i32 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__pointers_in_function_return.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__pointers_in_function_return.snap index 47f7065d73b..f4aef10525f 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__pointers_in_function_return.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__pointers_in_function_return.snap @@ -5,7 +5,7 @@ expression: result ; ModuleID = 'main' source_filename = "main" -define i16* @func() section "fn-func:pi16" { +define i16* @func() section "fn-$RUSTY$func:pi16" { entry: %func = alloca i16*, align 8 store i16* null, i16** %func, align 8 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__strings_in_function_return.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__strings_in_function_return.snap index ff548ae5b6c..941ea6b3e65 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__strings_in_function_return.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__strings_in_function_return.snap @@ -7,7 +7,7 @@ source_filename = "main" @utf08_literal_0 = private unnamed_addr constant [6 x i8] c"hello\00" -define void @func([81 x i8]* %0, [81 x i8]* %1) section "fn-func:s8u81[ps8u81]" { +define void @func([81 x i8]* %0, [81 x i8]* %1) section "fn-$RUSTY$func:s8u81[ps8u81]" { entry: %func = alloca [81 x i8]*, align 8 store [81 x i8]* %0, [81 x i8]** %func, align 8 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__structs_in_function_return.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__structs_in_function_return.snap index 87dce219e80..cfe7c759084 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__structs_in_function_return.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__structs_in_function_return.snap @@ -7,9 +7,9 @@ source_filename = "main" %myStruct = type { i16 } -@__myStruct__init = unnamed_addr constant %myStruct zeroinitializer +@__myStruct__init = unnamed_addr constant %myStruct zeroinitializer, section "var-$RUSTY$__myStruct__init:r1i16" -define void @func(%myStruct* %0, %myStruct* %1) section "fn-func:v[pv]" { +define void @func(%myStruct* %0, %myStruct* %1) section "fn-$RUSTY$func:r1i16[pr1i16]" { entry: %func = alloca %myStruct*, align 8 store %myStruct* %0, %myStruct** %func, align 8 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__type_mix_in_call.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__type_mix_in_call.snap index 30e41c84a7d..5905a187d29 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__type_mix_in_call.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__type_mix_in_call.snap @@ -5,7 +5,7 @@ expression: result ; ModuleID = 'main' source_filename = "main" -define i16 @foo(i16 %0) section "fn-foo:i16[i16]" { +define i16 @foo(i16 %0) section "fn-$RUSTY$foo:i16[i16]" { entry: %foo = alloca i16, align 2 %in = alloca i16, align 2 @@ -15,7 +15,7 @@ entry: ret i16 %foo_ret } -define i16 @baz() section "fn-baz:i16" { +define i16 @baz() section "fn-$RUSTY$baz:i16" { entry: %baz = alloca i16, align 2 store i16 0, i16* %baz, align 2 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__unary_expressions_can_be_real.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__unary_expressions_can_be_real.snap index b0d68fe813d..9aded1e339e 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__unary_expressions_can_be_real.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__unary_expressions_can_be_real.snap @@ -7,9 +7,9 @@ source_filename = "main" %prg = type { float, float } -@prg_instance = global %prg zeroinitializer +@prg_instance = global %prg zeroinitializer, section "var-$RUSTY$prg_instance:r2f32f32" -define void @prg(%prg* %0) section "fn-prg:v" { +define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: %a = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 %b = getelementptr inbounds %prg, %prg* %0, i32 0, i32 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__unnecessary_casts_between_pointer_types.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__unnecessary_casts_between_pointer_types.snap index 1c78aafcc18..885da78a65f 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__unnecessary_casts_between_pointer_types.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__expression_tests__unnecessary_casts_between_pointer_types.snap @@ -7,9 +7,9 @@ source_filename = "main" %baz = type { i8*, i8, i8, i8 } -@baz_instance = global %baz zeroinitializer +@baz_instance = global %baz zeroinitializer, section "var-$RUSTY$baz_instance:r4pu8u8i8u8" -define void @baz(%baz* %0) section "fn-baz:v" { +define void @baz(%baz* %0) section "fn-$RUSTY$baz:v" { entry: %ptr = getelementptr inbounds %baz, %baz* %0, i32 0, i32 0 %b = getelementptr inbounds %baz, %baz* %0, i32 0, i32 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__function_tests__argument_fed_by_ref_then_by_val.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__function_tests__argument_fed_by_ref_then_by_val.snap index ef7538caaea..cb493902b8c 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__function_tests__argument_fed_by_ref_then_by_val.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__function_tests__argument_fed_by_ref_then_by_val.snap @@ -5,7 +5,7 @@ expression: result ; ModuleID = 'main' source_filename = "main" -define i32 @main() section "fn-main:i32" { +define i32 @main() section "fn-$RUSTY$main:i32" { entry: %main = alloca i32, align 4 %arr = alloca [5 x i32], align 4 @@ -18,7 +18,7 @@ entry: ret i32 %main_ret } -define i32 @fn_by_ref(i32* %0) section "fn-fn_by_ref:i32[pv]" { +define i32 @fn_by_ref(i32* %0) section "fn-$RUSTY$fn_by_ref:i32[pau32]" { entry: %fn_by_ref = alloca i32, align 4 %arg_by_ref = alloca i32*, align 8 @@ -30,7 +30,7 @@ entry: ret i32 %fn_by_ref_ret } -define i32 @fn_by_val(i32* %0) section "fn-fn_by_val:i32[v]" { +define i32 @fn_by_val(i32* %0) section "fn-$RUSTY$fn_by_val:i32[au32]" { entry: %fn_by_val = alloca i32, align 4 %arg_by_val = alloca [5 x i32], align 4 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__function_tests__autocast_argument_literals_for_function_call.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__function_tests__autocast_argument_literals_for_function_call.snap index 760a8ba1dce..a43fa0ad8da 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__function_tests__autocast_argument_literals_for_function_call.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__function_tests__autocast_argument_literals_for_function_call.snap @@ -7,9 +7,9 @@ source_filename = "main" %main = type {} -@main_instance = global %main zeroinitializer +@main_instance = global %main zeroinitializer, section "var-$RUSTY$main_instance:r0" -define i32 @func(i8* %0, i16* %1, i32* %2, i64* %3, float* %4, double* %5) section "fn-func:i32[pi8][pi16][pi32][pi64][pf32][pf64]" { +define i32 @func(i8* %0, i16* %1, i32* %2, i64* %3, float* %4, double* %5) section "fn-$RUSTY$func:i32[pi8][pi16][pi32][pi64][pf32][pf64]" { entry: %func = alloca i32, align 4 %byInt1 = alloca i8*, align 8 @@ -30,7 +30,7 @@ entry: ret i32 %func_ret } -define void @main(%main* %0) section "fn-main:v" { +define void @main(%main* %0) section "fn-$RUSTY$main:v" { entry: %1 = alloca i8, align 1 store i8 1, i8* %1, align 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__function_tests__bitcast_argument_references_for_function_call.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__function_tests__bitcast_argument_references_for_function_call.snap index 7eeed6da58c..eba1401e347 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__function_tests__bitcast_argument_references_for_function_call.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__function_tests__bitcast_argument_references_for_function_call.snap @@ -7,9 +7,9 @@ source_filename = "main" %main = type { i8, i8, i16, i16, i32, i32, i64, i64, float, float, double, double } -@main_instance = global %main { i8 1, i8 1, i16 2, i16 2, i32 3, i32 3, i64 4, i64 4, float 5.000000e+00, float 5.000000e+00, double 6.000000e+00, double 6.000000e+00 } +@main_instance = global %main { i8 1, i8 1, i16 2, i16 2, i32 3, i32 3, i64 4, i64 4, float 5.000000e+00, float 5.000000e+00, double 6.000000e+00, double 6.000000e+00 }, section "var-$RUSTY$main_instance:r12i8i8i16i16i32i32i64i64f32f32f64f64" -define i8 @fn_sint(i8* %0, i8* %1) section "fn-fn_sint:i8[pi8][pi8]" { +define i8 @fn_sint(i8* %0, i8* %1) section "fn-$RUSTY$fn_sint:i8[pi8][pi8]" { entry: %fn_sint = alloca i8, align 1 %in_ref = alloca i8*, align 8 @@ -21,7 +21,7 @@ entry: ret i8 %fn_sint_ret } -define i64 @fn_lint(i64* %0, i64* %1) section "fn-fn_lint:i64[pi64][pi64]" { +define i64 @fn_lint(i64* %0, i64* %1) section "fn-$RUSTY$fn_lint:i64[pi64][pi64]" { entry: %fn_lint = alloca i64, align 8 %in_ref = alloca i64*, align 8 @@ -33,7 +33,7 @@ entry: ret i64 %fn_lint_ret } -define i64 @fn_real(float* %0, float* %1) section "fn-fn_real:i64[pf32][pf32]" { +define i64 @fn_real(float* %0, float* %1) section "fn-$RUSTY$fn_real:i64[pf32][pf32]" { entry: %fn_real = alloca i64, align 8 %in_ref = alloca float*, align 8 @@ -45,7 +45,7 @@ entry: ret i64 %fn_real_ret } -define i64 @fn_lreal(double* %0, double* %1) section "fn-fn_lreal:i64[pf64][pf64]" { +define i64 @fn_lreal(double* %0, double* %1) section "fn-$RUSTY$fn_lreal:i64[pf64][pf64]" { entry: %fn_lreal = alloca i64, align 8 %in_ref = alloca double*, align 8 @@ -57,7 +57,7 @@ entry: ret i64 %fn_lreal_ret } -define void @main(%main* %0) section "fn-main:v" { +define void @main(%main* %0) section "fn-$RUSTY$main:v" { entry: %var1_sint = getelementptr inbounds %main, %main* %0, i32 0, i32 0 %var2_sint = getelementptr inbounds %main, %main* %0, i32 0, i32 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__function_tests__function_with_ref_sized_string_varargs_called_in_program.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__function_tests__function_with_ref_sized_string_varargs_called_in_program.snap index c83905fbf90..dce4f413a14 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__function_tests__function_with_ref_sized_string_varargs_called_in_program.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__function_tests__function_with_ref_sized_string_varargs_called_in_program.snap @@ -7,14 +7,14 @@ source_filename = "main" %prg = type { i32 } -@prg_instance = global %prg zeroinitializer +@prg_instance = global %prg zeroinitializer, section "var-$RUSTY$prg_instance:r1i32" @utf08_literal_0 = private unnamed_addr constant [2 x i8] c"a\00" @utf08_literal_1 = private unnamed_addr constant [4 x i8] c"abc\00" @utf08_literal_2 = private unnamed_addr constant [7 x i8] c"abcdef\00" -declare i32 @foo(i32, i8**) section "fn-foo:i32" +declare i32 @foo(i32, i8**) section "fn-$RUSTY$foo:i32" -define void @prg(%prg* %0) section "fn-prg:v" { +define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: %x = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 %1 = alloca [3 x i8*], align 8 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__function_tests__function_with_sized_varargs_called_in_program.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__function_tests__function_with_sized_varargs_called_in_program.snap index 6908aaecc33..d91b7b02edd 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__function_tests__function_with_sized_varargs_called_in_program.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__function_tests__function_with_sized_varargs_called_in_program.snap @@ -7,11 +7,11 @@ source_filename = "main" %prg = type { i32 } -@prg_instance = global %prg zeroinitializer +@prg_instance = global %prg zeroinitializer, section "var-$RUSTY$prg_instance:r1i32" -declare i32 @foo(i32, i32*) section "fn-foo:i32" +declare i32 @foo(i32, i32*) section "fn-$RUSTY$foo:i32" -define void @prg(%prg* %0) section "fn-prg:v" { +define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: %x = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 %load_x = load i32, i32* %x, align 4 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__function_tests__function_with_varargs_called_in_program.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__function_tests__function_with_varargs_called_in_program.snap index 7e7b60961ea..1be4fb41172 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__function_tests__function_with_varargs_called_in_program.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__function_tests__function_with_varargs_called_in_program.snap @@ -7,11 +7,11 @@ source_filename = "main" %prg = type { i32 } -@prg_instance = global %prg zeroinitializer +@prg_instance = global %prg zeroinitializer, section "var-$RUSTY$prg_instance:r1i32" -declare i32 @foo(...) section "fn-foo:i32" +declare i32 @foo(...) section "fn-$RUSTY$foo:i32" -define void @prg(%prg* %0) section "fn-prg:v" { +define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: %x = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 %load_x = load i32, i32* %x, align 4 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__function_tests__literal_string_argument_passed_by_ref.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__function_tests__literal_string_argument_passed_by_ref.snap index 5d3bad001d5..2e5636d68b7 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__function_tests__literal_string_argument_passed_by_ref.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__function_tests__literal_string_argument_passed_by_ref.snap @@ -7,12 +7,12 @@ source_filename = "main" %main = type { [81 x i8] } -@main_instance = global %main zeroinitializer +@main_instance = global %main zeroinitializer, section "var-$RUSTY$main_instance:r1s8u81" @utf08_literal_0 = private unnamed_addr constant [6 x i8] c"hello\00" -declare void @func([81 x i8]*, i8*) section "fn-func:s8u81[ps8u81]" +declare void @func([81 x i8]*, i8*) section "fn-$RUSTY$func:s8u81[ps8u81]" -define void @main(%main* %0) section "fn-main:v" { +define void @main(%main* %0) section "fn-$RUSTY$main:v" { entry: %res = getelementptr inbounds %main, %main* %0, i32 0, i32 0 %1 = alloca [81 x i8], align 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__function_tests__member_variables_in_body.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__function_tests__member_variables_in_body.snap index 87f407e59ff..94c6a39e2c2 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__function_tests__member_variables_in_body.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__function_tests__member_variables_in_body.snap @@ -5,7 +5,7 @@ expression: result ; ModuleID = 'main' source_filename = "main" -define i32 @func(i16 %0, i8* %1, i64* %2) section "fn-func:i32[i16][pi8][pi64]" { +define i32 @func(i16 %0, i8* %1, i64* %2) section "fn-$RUSTY$func:i32[i16][pi8][pi64]" { entry: %func = alloca i32, align 4 %i = alloca i16, align 2 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__function_tests__on_functions_var_output_should_be_passed_as_a_pointer.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__function_tests__on_functions_var_output_should_be_passed_as_a_pointer.snap index 1c13b04b7f6..770242651b5 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__function_tests__on_functions_var_output_should_be_passed_as_a_pointer.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__function_tests__on_functions_var_output_should_be_passed_as_a_pointer.snap @@ -5,7 +5,7 @@ expression: result ; ModuleID = 'main' source_filename = "main" -define i32 @bump(i8* %0) section "fn-bump:i32[pi8]" { +define i32 @bump(i8* %0) section "fn-$RUSTY$bump:i32[pi8]" { entry: %bump = alloca i32, align 4 %v = alloca i8*, align 8 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__function_tests__passing_a_string_to_a_function.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__function_tests__passing_a_string_to_a_function.snap index 1411ca6172b..082aa876117 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__function_tests__passing_a_string_to_a_function.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__function_tests__passing_a_string_to_a_function.snap @@ -7,10 +7,10 @@ source_filename = "main" %main = type { [6 x i8] } -@main_instance = global %main zeroinitializer +@main_instance = global %main zeroinitializer, section "var-$RUSTY$main_instance:r1s8u6" @utf08_literal_0 = private unnamed_addr constant [6 x i8] c"12345\00" -define i32 @func(i8* %0) section "fn-func:i32[s8u6]" { +define i32 @func(i8* %0) section "fn-$RUSTY$func:i32[s8u6]" { entry: %func = alloca i32, align 4 %x = alloca [6 x i8], align 1 @@ -22,7 +22,7 @@ entry: ret i32 %func_ret } -define void @main(%main* %0) section "fn-main:v" { +define void @main(%main* %0) section "fn-$RUSTY$main:v" { entry: %a = getelementptr inbounds %main, %main* %0, i32 0, i32 0 %1 = bitcast [6 x i8]* %a to i8* diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__function_tests__passing_a_string_to_a_function_as_reference.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__function_tests__passing_a_string_to_a_function_as_reference.snap index 2bd5e485a1e..1a2b372911b 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__function_tests__passing_a_string_to_a_function_as_reference.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__function_tests__passing_a_string_to_a_function_as_reference.snap @@ -7,10 +7,10 @@ source_filename = "main" %main = type { [6 x i8] } -@main_instance = global %main zeroinitializer +@main_instance = global %main zeroinitializer, section "var-$RUSTY$main_instance:r1s8u6" @utf08_literal_0 = private unnamed_addr constant [6 x i8] c"12345\00" -define i32 @func(i8* %0) section "fn-func:i32[ps8u6]" { +define i32 @func(i8* %0) section "fn-$RUSTY$func:i32[ps8u6]" { entry: %func = alloca i32, align 4 %x = alloca i8*, align 8 @@ -20,7 +20,7 @@ entry: ret i32 %func_ret } -define void @main(%main* %0) section "fn-main:v" { +define void @main(%main* %0) section "fn-$RUSTY$main:v" { entry: %a = getelementptr inbounds %main, %main* %0, i32 0, i32 0 %1 = bitcast [6 x i8]* %a to i8* diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__function_tests__passing_arguments_to_functions_by_ref_and_val.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__function_tests__passing_arguments_to_functions_by_ref_and_val.snap index 3bb606f5909..e6cf5dc9520 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__function_tests__passing_arguments_to_functions_by_ref_and_val.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__function_tests__passing_arguments_to_functions_by_ref_and_val.snap @@ -7,9 +7,9 @@ source_filename = "main" %main = type {} -@main_instance = global %main zeroinitializer +@main_instance = global %main zeroinitializer, section "var-$RUSTY$main_instance:r0" -define i32 @func(i16* %0, i32* %1, i16 %2, i32 %3) section "fn-func:i32[pi16][pi32][i16][i32]" { +define i32 @func(i16* %0, i32* %1, i16 %2, i32 %3) section "fn-$RUSTY$func:i32[pi16][pi32][i16][i32]" { entry: %func = alloca i32, align 4 %byRef1 = alloca i16*, align 8 @@ -38,7 +38,7 @@ entry: ret i32 %func_ret } -define void @main(%main* %0) section "fn-main:v" { +define void @main(%main* %0) section "fn-$RUSTY$main:v" { entry: %1 = alloca i16, align 2 store i16 1, i16* %1, align 2 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__function_tests__return_variable_in_nested_call.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__function_tests__return_variable_in_nested_call.snap index 468a05a0d28..10118853240 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__function_tests__return_variable_in_nested_call.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__function_tests__return_variable_in_nested_call.snap @@ -5,7 +5,7 @@ expression: codegen(src) ; ModuleID = 'main' source_filename = "main" -define i32 @main() section "fn-main:i32" { +define i32 @main() section "fn-$RUSTY$main:i32" { entry: %main = alloca i32, align 4 %x1 = alloca i32, align 4 @@ -20,7 +20,7 @@ entry: ret i32 %main_ret } -define i32 @SMC_Read(i64 %0) section "fn-SMC_Read:i32[u64]" { +define i32 @SMC_Read(i64 %0) section "fn-$RUSTY$SMC_Read:i32[u64]" { entry: %SMC_Read = alloca i32, align 4 %ValAddr = alloca i64, align 8 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__function_tests__simple_call.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__function_tests__simple_call.snap index 2355a116c6f..b0d691e2619 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__function_tests__simple_call.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__function_tests__simple_call.snap @@ -7,9 +7,9 @@ source_filename = "main" %main = type { i32 } -@main_instance = global %main zeroinitializer +@main_instance = global %main zeroinitializer, section "var-$RUSTY$main_instance:r1i32" -define i32 @func(i32 %0) section "fn-func:i32[i32]" { +define i32 @func(i32 %0) section "fn-$RUSTY$func:i32[i32]" { entry: %func = alloca i32, align 4 %x = alloca i32, align 4 @@ -19,7 +19,7 @@ entry: ret i32 %func_ret } -define void @main(%main* %0) section "fn-main:v" { +define void @main(%main* %0) section "fn-$RUSTY$main:v" { entry: %a = getelementptr inbounds %main, %main* %0, i32 0, i32 0 %load_a = load i32, i32* %a, align 4 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__function_tests__var_output_in_function_call.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__function_tests__var_output_in_function_call.snap index 7babfb50431..93ce1a318bb 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__function_tests__var_output_in_function_call.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__function_tests__var_output_in_function_call.snap @@ -7,9 +7,9 @@ source_filename = "main" %main = type { i16 } -@main_instance = global %main { i16 4 } +@main_instance = global %main { i16 4 }, section "var-$RUSTY$main_instance:r1i16" -define i32 @func(i16* %0) section "fn-func:i32[pi16]" { +define i32 @func(i16* %0) section "fn-$RUSTY$func:i32[pi16]" { entry: %func = alloca i32, align 4 %o = alloca i16*, align 8 @@ -22,7 +22,7 @@ entry: ret i32 %func_ret } -define void @main(%main* %0) section "fn-main:v" { +define void @main(%main* %0) section "fn-$RUSTY$main:v" { entry: %x = getelementptr inbounds %main, %main* %0, i32 0, i32 0 %call = call i32 @func(i16* %x) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__generics_test__any_real_function_called_with_ints.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__generics_test__any_real_function_called_with_ints.snap index f4cd2fde23b..8c1b8cb6f56 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__generics_test__any_real_function_called_with_ints.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__generics_test__any_real_function_called_with_ints.snap @@ -7,9 +7,9 @@ source_filename = "main" %prg = type { float, float, float, double, float, float, float, double } -@prg_instance = global %prg zeroinitializer +@prg_instance = global %prg zeroinitializer, section "var-$RUSTY$prg_instance:r10f32f32f32f64f32f32f32f64i32i32" -define float @foo__REAL(float %0) section "fn-foo__REAL:f32[f32]" { +define float @foo__REAL(float %0) section "fn-$RUSTY$foo__REAL:f32[f32]" { entry: %foo__REAL = alloca float, align 4 %in1 = alloca float, align 4 @@ -19,7 +19,7 @@ entry: ret float %foo__REAL_ret } -define void @prg(%prg* %0) section "fn-prg:v" { +define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: %res_sint = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 %res_int = getelementptr inbounds %prg, %prg* %0, i32 0, i32 1 @@ -56,4 +56,4 @@ entry: ret void } -declare double @foo__LREAL(double) section "fn-foo__LREAL:f64[f64]" +declare double @foo__LREAL(double) section "fn-$RUSTY$foo__LREAL:f64[f64]" diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__generics_test__generic_call_gets_cast_to_biggest_type.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__generics_test__generic_call_gets_cast_to_biggest_type.snap index fa1248d4855..e60815a9c2a 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__generics_test__generic_call_gets_cast_to_biggest_type.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__generics_test__generic_call_gets_cast_to_biggest_type.snap @@ -5,7 +5,7 @@ expression: codegen(src) ; ModuleID = 'main' source_filename = "main" -define double @main() section "fn-main:f64" { +define double @main() section "fn-$RUSTY$main:f64" { entry: %main = alloca double, align 8 store double 0.000000e+00, double* %main, align 8 @@ -25,4 +25,4 @@ entry: ret double %main_ret } -declare double @MAX__LREAL(i32, double*) section "fn-MAX__LREAL:f64" +declare double @MAX__LREAL(i32, double*) section "fn-$RUSTY$MAX__LREAL:f64" diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__generics_test__generic_function_call_generates_real_type_call.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__generics_test__generic_function_call_generates_real_type_call.snap index 06744fe4a59..e689ca4ee8c 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__generics_test__generic_function_call_generates_real_type_call.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__generics_test__generic_function_call_generates_real_type_call.snap @@ -7,9 +7,9 @@ source_filename = "main" %prg = type { i16, i16 } -@prg_instance = global %prg zeroinitializer +@prg_instance = global %prg zeroinitializer, section "var-$RUSTY$prg_instance:r2i16i16" -define i32 @MAX__DINT(i32 %0, i32 %1) section "fn-MAX__DINT:i32[i32][i32]" { +define i32 @MAX__DINT(i32 %0, i32 %1) section "fn-$RUSTY$MAX__DINT:i32[i32][i32]" { entry: %MAX__DINT = alloca i32, align 4 %in1 = alloca i32, align 4 @@ -21,7 +21,7 @@ entry: ret i32 %MAX__DINT_ret } -define void @prg(%prg* %0) section "fn-prg:v" { +define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: %a = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 %b = getelementptr inbounds %prg, %prg* %0, i32 0, i32 1 @@ -32,4 +32,4 @@ entry: ret void } -declare i16 @MAX__INT(i16, i16) section "fn-MAX__INT:i16[i16][i16]" +declare i16 @MAX__INT(i16, i16) section "fn-$RUSTY$MAX__INT:i16[i16][i16]" diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__generics_test__generic_output_parameter.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__generics_test__generic_output_parameter.snap index f0b16563c7c..800a20c0765 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__generics_test__generic_output_parameter.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__generics_test__generic_output_parameter.snap @@ -7,9 +7,9 @@ source_filename = "main" %prg = type { i16, i16, i64 } -@prg_instance = global %prg zeroinitializer +@prg_instance = global %prg zeroinitializer, section "var-$RUSTY$prg_instance:r3i16i16i64" -define i16 @foo__INT(i64 %0, i16* %1) section "fn-foo__INT:i16[i64][pi16]" { +define i16 @foo__INT(i64 %0, i16* %1) section "fn-$RUSTY$foo__INT:i16[i64][pi16]" { entry: %foo__INT = alloca i16, align 2 %in1 = alloca i64, align 8 @@ -21,7 +21,7 @@ entry: ret i16 %foo__INT_ret } -define void @prg(%prg* %0) section "fn-prg:v" { +define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: %theInt = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 %iResult = getelementptr inbounds %prg, %prg* %0, i32 0, i32 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__multifile_codegen_tests__datatype_defined_in_external_file_in_module.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__multifile_codegen_tests__datatype_defined_in_external_file_in_module.snap index 41c47d74c2a..51630a2755a 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__multifile_codegen_tests__datatype_defined_in_external_file_in_module.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__multifile_codegen_tests__datatype_defined_in_external_file_in_module.snap @@ -7,7 +7,7 @@ source_filename = "myStruct.st" %myStruct = type { i32, i16* } -@__myStruct__init = unnamed_addr constant %myStruct zeroinitializer +@__myStruct__init = unnamed_addr constant %myStruct zeroinitializer, section "var-$RUSTY$__myStruct__init:r2i32pi16" ; ModuleID = 'prog.st' source_filename = "prog.st" @@ -15,10 +15,10 @@ source_filename = "prog.st" %prog = type { %myStruct.1 } %myStruct.1 = type { i32, i16* } -@prog_instance = global %prog zeroinitializer -@__myStruct__init = external global %myStruct.1 +@prog_instance = global %prog zeroinitializer, section "var-$RUSTY$prog_instance:r1r2i32pi16" +@__myStruct__init = external global %myStruct.1, section "var-$RUSTY$__myStruct__init:r2i32pi16" -define void @prog(%prog* %0) section "fn-prog:v" { +define void @prog(%prog* %0) section "fn-$RUSTY$prog:v" { entry: %x = getelementptr inbounds %prog, %prog* %0, i32 0, i32 0 ret void diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__multifile_codegen_tests__datatype_defined_in_external_file_no_deps_in_module.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__multifile_codegen_tests__datatype_defined_in_external_file_no_deps_in_module.snap index 65414424ad0..c988a330045 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__multifile_codegen_tests__datatype_defined_in_external_file_no_deps_in_module.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__multifile_codegen_tests__datatype_defined_in_external_file_no_deps_in_module.snap @@ -7,16 +7,16 @@ source_filename = "myStruct.st" %myStruct = type { i32, i16* } -@__myStruct__init = unnamed_addr constant %myStruct { i32 20, i16* null } +@__myStruct__init = unnamed_addr constant %myStruct { i32 20, i16* null }, section "var-$RUSTY$__myStruct__init:r2i32pi16" ; ModuleID = 'prog.st' source_filename = "prog.st" %prog = type { i32 } -@prog_instance = global %prog zeroinitializer +@prog_instance = global %prog zeroinitializer, section "var-$RUSTY$prog_instance:r1i32" -define void @prog(%prog* %0) section "fn-prog:v" { +define void @prog(%prog* %0) section "fn-$RUSTY$prog:v" { entry: %x = getelementptr inbounds %prog, %prog* %0, i32 0, i32 0 ret void diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__multifile_codegen_tests__datatype_initialized_in_external_file_in_module.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__multifile_codegen_tests__datatype_initialized_in_external_file_in_module.snap index 6c5e306f9dc..dd5914128e6 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__multifile_codegen_tests__datatype_initialized_in_external_file_in_module.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__multifile_codegen_tests__datatype_initialized_in_external_file_in_module.snap @@ -10,9 +10,9 @@ source_filename = "prog.st" %prog = type { i16 } -@prog_instance = global %prog { i16 5 } +@prog_instance = global %prog { i16 5 }, section "var-$RUSTY$prog_instance:r1i16" -define void @prog(%prog* %0) section "fn-prog:v" { +define void @prog(%prog* %0) section "fn-$RUSTY$prog:v" { entry: %x = getelementptr inbounds %prog, %prog* %0, i32 0, i32 0 ret void diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__multifile_codegen_tests__enum_referenced_in_fb_nested.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__multifile_codegen_tests__enum_referenced_in_fb_nested.snap index 0868c261e60..72d74b90c36 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__multifile_codegen_tests__enum_referenced_in_fb_nested.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__multifile_codegen_tests__enum_referenced_in_fb_nested.snap @@ -5,18 +5,18 @@ expression: "codegen_multi(units, crate::DebugLevel::None).join(\"\\n\")" ; ModuleID = 'myEnum.st' source_filename = "myEnum.st" -@myEnum.a = unnamed_addr constant i32 1 -@myEnum.b = unnamed_addr constant i32 2 -@myEnum.c = unnamed_addr constant i32 3 +@myEnum.a = unnamed_addr constant i32 1, section "var-$RUSTY$a:e3i32" +@myEnum.b = unnamed_addr constant i32 2, section "var-$RUSTY$b:e3i32" +@myEnum.c = unnamed_addr constant i32 3, section "var-$RUSTY$c:e3i32" ; ModuleID = 'fb.st' source_filename = "fb.st" %fb = type { i32 } -@__fb__init = unnamed_addr constant %fb zeroinitializer +@__fb__init = unnamed_addr constant %fb zeroinitializer, section "var-$RUSTY$__fb__init:r1e3i32" -define void @fb(%fb* %0) section "fn-fb:v" { +define void @fb(%fb* %0) section "fn-$RUSTY$fb:v" { entry: %x = getelementptr inbounds %fb, %fb* %0, i32 0, i32 0 ret void @@ -28,10 +28,10 @@ source_filename = "myStruct.st" %myStruct = type { %fb.2 } %fb.2 = type { i32 } -@__myStruct__init = unnamed_addr constant %myStruct zeroinitializer -@__fb__init = external global %fb.2 +@__myStruct__init = unnamed_addr constant %myStruct zeroinitializer, section "var-$RUSTY$__myStruct__init:r1r1e3i32" +@__fb__init = external global %fb.2, section "var-$RUSTY$__fb__init:r1e3i32" -declare void @fb(%fb.2*) section "fn-fb:v" +declare void @fb(%fb.2*) section "fn-$RUSTY$fb:v" ; ModuleID = 'fb2.st' source_filename = "fb2.st" @@ -40,26 +40,26 @@ source_filename = "fb2.st" %myStruct.4 = type { %fb.5 } %fb.5 = type { i32 } -@__fb2__init = unnamed_addr constant %fb2 zeroinitializer -@__myStruct__init = external global %myStruct.4 -@__fb__init = external global %fb.5 +@__fb2__init = unnamed_addr constant %fb2 zeroinitializer, section "var-$RUSTY$__fb2__init:r1r1r1e3i32" +@__myStruct__init = external global %myStruct.4, section "var-$RUSTY$__myStruct__init:r1r1e3i32" +@__fb__init = external global %fb.5, section "var-$RUSTY$__fb__init:r1e3i32" -define void @fb2(%fb2* %0) section "fn-fb2:v" { +define void @fb2(%fb2* %0) section "fn-$RUSTY$fb2:v" { entry: %x = getelementptr inbounds %fb2, %fb2* %0, i32 0, i32 0 ret void } -declare void @fb(%fb.5*) section "fn-fb:v" +declare void @fb(%fb.5*) section "fn-$RUSTY$fb:v" ; ModuleID = 'fb3.st' source_filename = "fb3.st" %fb3 = type {} -@__fb3__init = unnamed_addr constant %fb3 zeroinitializer +@__fb3__init = unnamed_addr constant %fb3 zeroinitializer, section "var-$RUSTY$__fb3__init:r0" -define void @fb3(%fb3* %0) section "fn-fb3:v" { +define void @fb3(%fb3* %0) section "fn-$RUSTY$fb3:v" { entry: ret void } diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__multifile_codegen_tests__function_defined_in_external_file.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__multifile_codegen_tests__function_defined_in_external_file.snap index d25ccf90a35..f0db85384b1 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__multifile_codegen_tests__function_defined_in_external_file.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__multifile_codegen_tests__function_defined_in_external_file.snap @@ -5,7 +5,7 @@ expression: "codegen_multi(units, crate::DebugLevel::None).join(\"\\n\")" ; ModuleID = 'func.st' source_filename = "func.st" -define i32 @func() section "fn-func:i32" { +define i32 @func() section "fn-$RUSTY$func:i32" { entry: %func = alloca i32, align 4 store i32 0, i32* %func, align 4 @@ -18,9 +18,9 @@ source_filename = "fb.st" %fb = type {} -@__fb__init = unnamed_addr constant %fb zeroinitializer +@__fb__init = unnamed_addr constant %fb zeroinitializer, section "var-$RUSTY$__fb__init:r0" -define void @fb(%fb* %0) section "fn-fb:v" { +define void @fb(%fb* %0) section "fn-$RUSTY$fb:v" { entry: ret void } @@ -30,9 +30,9 @@ source_filename = "prg.st" %prg = type { i32 } -@prg_instance = global %prg zeroinitializer +@prg_instance = global %prg zeroinitializer, section "var-$RUSTY$prg_instance:r1i32" -define void @prg(%prg* %0) section "fn-prg:v" { +define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: %a = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 ret void @@ -43,9 +43,9 @@ source_filename = "prg2.st" %prg2 = type { i32 } -@prg2_instance = global %prg2 zeroinitializer +@prg2_instance = global %prg2 zeroinitializer, section "var-$RUSTY$prg2_instance:r1i32" -define void @prg2(%prg2* %0) section "fn-prg2:v" { +define void @prg2(%prg2* %0) section "fn-$RUSTY$prg2:v" { entry: %b = getelementptr inbounds %prg2, %prg2* %0, i32 0, i32 0 ret void @@ -59,12 +59,12 @@ source_filename = "prog.st" %prg.5 = type { i32 } %prg2.6 = type { i32 } -@prog_instance = global %prog zeroinitializer -@__fb__init = external global %fb.4 -@prg_instance = external global %prg.5 -@prg2_instance = external global %prg2.6 +@prog_instance = global %prog zeroinitializer, section "var-$RUSTY$prog_instance:r1r0" +@__fb__init = external global %fb.4, section "var-$RUSTY$__fb__init:r0" +@prg_instance = external global %prg.5, section "var-$RUSTY$prg_instance:r1i32" +@prg2_instance = external global %prg2.6, section "var-$RUSTY$prg2_instance:r1i32" -define void @prog(%prog* %0) section "fn-prog:v" { +define void @prog(%prog* %0) section "fn-$RUSTY$prog:v" { entry: %myFb = getelementptr inbounds %prog, %prog* %0, i32 0, i32 0 %load_a = load i32, i32* getelementptr inbounds (%prg.5, %prg.5* @prg_instance, i32 0, i32 0), align 4 @@ -74,10 +74,10 @@ entry: ret void } -declare void @fb(%fb.4*) section "fn-fb:v" +declare void @fb(%fb.4*) section "fn-$RUSTY$fb:v" -declare void @prg(%prg.5*) section "fn-prg:v" +declare void @prg(%prg.5*) section "fn-$RUSTY$prg:v" -declare void @prg2(%prg2.6*) section "fn-prg2:v" +declare void @prg2(%prg2.6*) section "fn-$RUSTY$prg2:v" -declare i32 @func() section "fn-func:i32" +declare i32 @func() section "fn-$RUSTY$func:i32" diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__multifile_codegen_tests__global_value_from_different_file.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__multifile_codegen_tests__global_value_from_different_file.snap index 9742323315d..1bc2997856f 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__multifile_codegen_tests__global_value_from_different_file.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__multifile_codegen_tests__global_value_from_different_file.snap @@ -5,28 +5,28 @@ expression: "codegen_multi(units, crate::DebugLevel::None).join(\"\\n\")" ; ModuleID = 'g1.st' source_filename = "g1.st" -@x = global i32 6 -@d = external global i32 -@y = global i32 7 -@e = external global i32 +@x = global i32 6, section "var-$RUSTY$x:i32" +@d = external global i32, section "var-$RUSTY$d:i32" +@y = global i32 7, section "var-$RUSTY$y:i32" +@e = external global i32, section "var-$RUSTY$e:i32" ; ModuleID = 'g2.st' source_filename = "g2.st" -@c = unnamed_addr constant i32 5 -@d = unnamed_addr constant i32 6 -@e = unnamed_addr constant i32 7 +@c = unnamed_addr constant i32 5, section "var-$RUSTY$c:i32" +@d = unnamed_addr constant i32 6, section "var-$RUSTY$d:i32" +@e = unnamed_addr constant i32 7, section "var-$RUSTY$e:i32" ; ModuleID = 'prog.st' source_filename = "prog.st" %prog = type {} -@prog_instance = global %prog zeroinitializer -@c = external global i32 -@x = external global i32 +@prog_instance = global %prog zeroinitializer, section "var-$RUSTY$prog_instance:r0" +@c = external global i32, section "var-$RUSTY$c:i32" +@x = external global i32, section "var-$RUSTY$x:i32" -define void @prog(%prog* %0) section "fn-prog:v" { +define void @prog(%prog* %0) section "fn-$RUSTY$prog:v" { entry: store i32 7, i32* @x, align 4 ret void diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__multifile_codegen_tests__struct_with_custom_init_in_different_file.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__multifile_codegen_tests__struct_with_custom_init_in_different_file.snap index 08f55ab4cda..722b4754f87 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__multifile_codegen_tests__struct_with_custom_init_in_different_file.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__multifile_codegen_tests__struct_with_custom_init_in_different_file.snap @@ -7,14 +7,14 @@ source_filename = "myStruct.st" %myStruct = type { i32, i16 } -@__myStruct__init = unnamed_addr constant %myStruct { i32 6, i16 2 } +@__myStruct__init = unnamed_addr constant %myStruct { i32 6, i16 2 }, section "var-$RUSTY$__myStruct__init:r2i32i16" ; ModuleID = 'myStruct2.st' source_filename = "myStruct2.st" %myStruct2 = type { i32, i16 } -@__myStruct2__init = unnamed_addr constant %myStruct2 { i32 6, i16 2 } +@__myStruct2__init = unnamed_addr constant %myStruct2 { i32 6, i16 2 }, section "var-$RUSTY$__myStruct2__init:r2i32i16" ; ModuleID = 'prog.st' source_filename = "prog.st" @@ -23,12 +23,12 @@ source_filename = "prog.st" %myStruct.2 = type { i32, i16 } %myStruct2.3 = type { i32, i16 } -@prog_instance = global %prog { %myStruct.2 { i32 5, i16 2 }, %myStruct2.3 { i32 6, i16 2 } } -@__myStruct__init = external global %myStruct.2 -@__myStruct2__init = external global %myStruct2.3 +@prog_instance = global %prog { %myStruct.2 { i32 5, i16 2 }, %myStruct2.3 { i32 6, i16 2 } }, section "var-$RUSTY$prog_instance:r2r2i32i16r2i32i16" +@__myStruct__init = external global %myStruct.2, section "var-$RUSTY$__myStruct__init:r2i32i16" +@__myStruct2__init = external global %myStruct2.3, section "var-$RUSTY$__myStruct2__init:r2i32i16" @__prog.x__init = unnamed_addr constant %myStruct.2 { i32 5, i16 2 } -define void @prog(%prog* %0) section "fn-prog:v" { +define void @prog(%prog* %0) section "fn-$RUSTY$prog:v" { entry: %x = getelementptr inbounds %prog, %prog* %0, i32 0, i32 0 %y = getelementptr inbounds %prog, %prog* %0, i32 0, i32 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__fb_accepts_empty_statement_as_input_param.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__fb_accepts_empty_statement_as_input_param.snap index 9f0a2624970..c9a5612cc4f 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__fb_accepts_empty_statement_as_input_param.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__fb_accepts_empty_statement_as_input_param.snap @@ -8,17 +8,17 @@ source_filename = "main" %fb_t = type { i32, i32 } %main = type { %fb_t } -@__fb_t__init = unnamed_addr constant %fb_t zeroinitializer -@main_instance = global %main zeroinitializer +@__fb_t__init = unnamed_addr constant %fb_t zeroinitializer, section "var-$RUSTY$__fb_t__init:r2i32i32" +@main_instance = global %main zeroinitializer, section "var-$RUSTY$main_instance:r1r2i32i32" -define void @fb_t(%fb_t* %0) section "fn-fb_t:v[i32][i32]" { +define void @fb_t(%fb_t* %0) section "fn-$RUSTY$fb_t:v[i32][i32]" { entry: %in1 = getelementptr inbounds %fb_t, %fb_t* %0, i32 0, i32 0 %in2 = getelementptr inbounds %fb_t, %fb_t* %0, i32 0, i32 1 ret void } -define void @main(%main* %0) section "fn-main:v" { +define void @main(%main* %0) section "fn-$RUSTY$main:v" { entry: %fb = getelementptr inbounds %main, %main* %0, i32 0, i32 0 %1 = getelementptr inbounds %fb_t, %fb_t* %fb, i32 0, i32 0 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__fb_accepts_empty_statement_as_output_param.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__fb_accepts_empty_statement_as_output_param.snap index a6cfbe4ab16..21a90da4c60 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__fb_accepts_empty_statement_as_output_param.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__fb_accepts_empty_statement_as_output_param.snap @@ -8,17 +8,17 @@ source_filename = "main" %fb_t = type { i32, i32 } %main = type { %fb_t, i32 } -@__fb_t__init = unnamed_addr constant %fb_t zeroinitializer -@main_instance = global %main zeroinitializer +@__fb_t__init = unnamed_addr constant %fb_t zeroinitializer, section "var-$RUSTY$__fb_t__init:r2i32i32" +@main_instance = global %main zeroinitializer, section "var-$RUSTY$main_instance:r2r2i32i32i32" -define void @fb_t(%fb_t* %0) section "fn-fb_t:v[i32][i32]" { +define void @fb_t(%fb_t* %0) section "fn-$RUSTY$fb_t:v[i32][i32]" { entry: %out1 = getelementptr inbounds %fb_t, %fb_t* %0, i32 0, i32 0 %out2 = getelementptr inbounds %fb_t, %fb_t* %0, i32 0, i32 1 ret void } -define void @main(%main* %0) section "fn-main:v" { +define void @main(%main* %0) section "fn-$RUSTY$main:v" { entry: %fb = getelementptr inbounds %main, %main* %0, i32 0, i32 0 %x = getelementptr inbounds %main, %main* %0, i32 0, i32 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__function_accepts_empty_statement_as_input_param.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__function_accepts_empty_statement_as_input_param.snap index 39324edd55e..c09ca8415aa 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__function_accepts_empty_statement_as_input_param.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__function_accepts_empty_statement_as_input_param.snap @@ -7,9 +7,9 @@ source_filename = "main" %main = type {} -@main_instance = global %main zeroinitializer +@main_instance = global %main zeroinitializer, section "var-$RUSTY$main_instance:r0" -define void @foo(i32 %0, i32 %1) section "fn-foo:v[i32][i32]" { +define void @foo(i32 %0, i32 %1) section "fn-$RUSTY$foo:v[i32][i32]" { entry: %in1 = alloca i32, align 4 store i32 %0, i32* %in1, align 4 @@ -18,7 +18,7 @@ entry: ret void } -define void @main(%main* %0) section "fn-main:v" { +define void @main(%main* %0) section "fn-$RUSTY$main:v" { entry: %1 = alloca i32, align 4 %2 = load i32, i32* %1, align 4 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__function_accepts_empty_statement_as_output_param.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__function_accepts_empty_statement_as_output_param.snap index 52e8f828de7..77bd2105681 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__function_accepts_empty_statement_as_output_param.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__function_accepts_empty_statement_as_output_param.snap @@ -7,9 +7,9 @@ source_filename = "main" %main = type { i32 } -@main_instance = global %main zeroinitializer +@main_instance = global %main zeroinitializer, section "var-$RUSTY$main_instance:r1i32" -define void @foo(i32* %0, i32* %1) section "fn-foo:v[pi32][pi32]" { +define void @foo(i32* %0, i32* %1) section "fn-$RUSTY$foo:v[pi32][pi32]" { entry: %out1 = alloca i32*, align 8 store i32* %0, i32** %out1, align 8 @@ -18,7 +18,7 @@ entry: ret void } -define void @main(%main* %0) section "fn-main:v" { +define void @main(%main* %0) section "fn-$RUSTY$main:v" { entry: %x = getelementptr inbounds %main, %main* %0, i32 0, i32 0 %1 = alloca i32, align 4 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__function_all_parameters_assigned.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__function_all_parameters_assigned.snap index 094ab12b375..7f1397cbf19 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__function_all_parameters_assigned.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__function_all_parameters_assigned.snap @@ -7,9 +7,9 @@ source_filename = "main" %main = type { i32, i32, i32 } -@main_instance = global %main zeroinitializer +@main_instance = global %main zeroinitializer, section "var-$RUSTY$main_instance:r3i32i32i32" -define i32 @foo(i32 %0, i32* %1, i32* %2) section "fn-foo:i32[i32][pi32][pi32]" { +define i32 @foo(i32 %0, i32* %1, i32* %2) section "fn-$RUSTY$foo:i32[i32][pi32][pi32]" { entry: %foo = alloca i32, align 4 %input1 = alloca i32, align 4 @@ -23,7 +23,7 @@ entry: ret i32 %foo_ret } -define void @main(%main* %0) section "fn-main:v" { +define void @main(%main* %0) section "fn-$RUSTY$main:v" { entry: %var1 = getelementptr inbounds %main, %main* %0, i32 0, i32 0 %var2 = getelementptr inbounds %main, %main* %0, i32 0, i32 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__function_default_value_parameter_type.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__function_default_value_parameter_type.snap index bfc66e6526f..1ab6960d563 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__function_default_value_parameter_type.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__function_default_value_parameter_type.snap @@ -7,9 +7,9 @@ source_filename = "main" %main = type { i32, i32, i32 } -@main_instance = global %main zeroinitializer +@main_instance = global %main zeroinitializer, section "var-$RUSTY$main_instance:r3i32i32i32" -define i32 @foo(i32 %0, i32* %1, i32* %2, i32* %3) section "fn-foo:i32[i32][pi32][pi32][pi32]" { +define i32 @foo(i32 %0, i32* %1, i32* %2, i32* %3) section "fn-$RUSTY$foo:i32[i32][pi32][pi32][pi32]" { entry: %foo = alloca i32, align 4 %input1 = alloca i32, align 4 @@ -25,7 +25,7 @@ entry: ret i32 %foo_ret } -define void @main(%main* %0) section "fn-main:v" { +define void @main(%main* %0) section "fn-$RUSTY$main:v" { entry: %var1 = getelementptr inbounds %main, %main* %0, i32 0, i32 0 %var2 = getelementptr inbounds %main, %main* %0, i32 0, i32 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__function_empty_inout_assignment.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__function_empty_inout_assignment.snap index 1e544425eed..ce8d64e4d17 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__function_empty_inout_assignment.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__function_empty_inout_assignment.snap @@ -7,9 +7,9 @@ source_filename = "main" %main = type { i32, i32, i32 } -@main_instance = global %main zeroinitializer +@main_instance = global %main zeroinitializer, section "var-$RUSTY$main_instance:r3i32i32i32" -define i32 @foo(i32 %0, i32* %1, i32* %2) section "fn-foo:i32[i32][pi32][pi32]" { +define i32 @foo(i32 %0, i32* %1, i32* %2) section "fn-$RUSTY$foo:i32[i32][pi32][pi32]" { entry: %foo = alloca i32, align 4 %input1 = alloca i32, align 4 @@ -23,7 +23,7 @@ entry: ret i32 %foo_ret } -define void @main(%main* %0) section "fn-main:v" { +define void @main(%main* %0) section "fn-$RUSTY$main:v" { entry: %var1 = getelementptr inbounds %main, %main* %0, i32 0, i32 0 %var2 = getelementptr inbounds %main, %main* %0, i32 0, i32 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__function_empty_input_assignment.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__function_empty_input_assignment.snap index b57f573c602..1f61d44c229 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__function_empty_input_assignment.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__function_empty_input_assignment.snap @@ -7,9 +7,9 @@ source_filename = "main" %main = type { i32, i32, i32 } -@main_instance = global %main zeroinitializer +@main_instance = global %main zeroinitializer, section "var-$RUSTY$main_instance:r3i32i32i32" -define i32 @foo(i32 %0, i32* %1, i32* %2) section "fn-foo:i32[i32][pi32][pi32]" { +define i32 @foo(i32 %0, i32* %1, i32* %2) section "fn-$RUSTY$foo:i32[i32][pi32][pi32]" { entry: %foo = alloca i32, align 4 %input1 = alloca i32, align 4 @@ -23,7 +23,7 @@ entry: ret i32 %foo_ret } -define void @main(%main* %0) section "fn-main:v" { +define void @main(%main* %0) section "fn-$RUSTY$main:v" { entry: %var1 = getelementptr inbounds %main, %main* %0, i32 0, i32 0 %var2 = getelementptr inbounds %main, %main* %0, i32 0, i32 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__function_empty_output_assignment.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__function_empty_output_assignment.snap index ea03ab08ecb..4d4a4078796 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__function_empty_output_assignment.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__function_empty_output_assignment.snap @@ -7,9 +7,9 @@ source_filename = "main" %main = type { i32, i32, i32 } -@main_instance = global %main zeroinitializer +@main_instance = global %main zeroinitializer, section "var-$RUSTY$main_instance:r3i32i32i32" -define i32 @foo(i32 %0, i32* %1, i32* %2) section "fn-foo:i32[i32][pi32][pi32]" { +define i32 @foo(i32 %0, i32* %1, i32* %2) section "fn-$RUSTY$foo:i32[i32][pi32][pi32]" { entry: %foo = alloca i32, align 4 %input1 = alloca i32, align 4 @@ -23,7 +23,7 @@ entry: ret i32 %foo_ret } -define void @main(%main* %0) section "fn-main:v" { +define void @main(%main* %0) section "fn-$RUSTY$main:v" { entry: %var1 = getelementptr inbounds %main, %main* %0, i32 0, i32 0 %var2 = getelementptr inbounds %main, %main* %0, i32 0, i32 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__function_empty_output_default_value_assignment.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__function_empty_output_default_value_assignment.snap index 0aa2e8f3429..ef1bc546979 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__function_empty_output_default_value_assignment.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__function_empty_output_default_value_assignment.snap @@ -7,9 +7,9 @@ source_filename = "main" %main = type { i32, i32, i32 } -@main_instance = global %main zeroinitializer +@main_instance = global %main zeroinitializer, section "var-$RUSTY$main_instance:r3i32i32i32" -define i32 @foo(i32 %0, i32* %1, i32* %2) section "fn-foo:i32[i32][pi32][pi32]" { +define i32 @foo(i32 %0, i32* %1, i32* %2) section "fn-$RUSTY$foo:i32[i32][pi32][pi32]" { entry: %foo = alloca i32, align 4 %input1 = alloca i32, align 4 @@ -23,7 +23,7 @@ entry: ret i32 %foo_ret } -define void @main(%main* %0) section "fn-main:v" { +define void @main(%main* %0) section "fn-$RUSTY$main:v" { entry: %var1 = getelementptr inbounds %main, %main* %0, i32 0, i32 0 %var2 = getelementptr inbounds %main, %main* %0, i32 0, i32 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__function_missing_inout_assignment.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__function_missing_inout_assignment.snap index 1e544425eed..ce8d64e4d17 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__function_missing_inout_assignment.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__function_missing_inout_assignment.snap @@ -7,9 +7,9 @@ source_filename = "main" %main = type { i32, i32, i32 } -@main_instance = global %main zeroinitializer +@main_instance = global %main zeroinitializer, section "var-$RUSTY$main_instance:r3i32i32i32" -define i32 @foo(i32 %0, i32* %1, i32* %2) section "fn-foo:i32[i32][pi32][pi32]" { +define i32 @foo(i32 %0, i32* %1, i32* %2) section "fn-$RUSTY$foo:i32[i32][pi32][pi32]" { entry: %foo = alloca i32, align 4 %input1 = alloca i32, align 4 @@ -23,7 +23,7 @@ entry: ret i32 %foo_ret } -define void @main(%main* %0) section "fn-main:v" { +define void @main(%main* %0) section "fn-$RUSTY$main:v" { entry: %var1 = getelementptr inbounds %main, %main* %0, i32 0, i32 0 %var2 = getelementptr inbounds %main, %main* %0, i32 0, i32 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__function_missing_input_assignment.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__function_missing_input_assignment.snap index b57f573c602..1f61d44c229 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__function_missing_input_assignment.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__function_missing_input_assignment.snap @@ -7,9 +7,9 @@ source_filename = "main" %main = type { i32, i32, i32 } -@main_instance = global %main zeroinitializer +@main_instance = global %main zeroinitializer, section "var-$RUSTY$main_instance:r3i32i32i32" -define i32 @foo(i32 %0, i32* %1, i32* %2) section "fn-foo:i32[i32][pi32][pi32]" { +define i32 @foo(i32 %0, i32* %1, i32* %2) section "fn-$RUSTY$foo:i32[i32][pi32][pi32]" { entry: %foo = alloca i32, align 4 %input1 = alloca i32, align 4 @@ -23,7 +23,7 @@ entry: ret i32 %foo_ret } -define void @main(%main* %0) section "fn-main:v" { +define void @main(%main* %0) section "fn-$RUSTY$main:v" { entry: %var1 = getelementptr inbounds %main, %main* %0, i32 0, i32 0 %var2 = getelementptr inbounds %main, %main* %0, i32 0, i32 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__function_missing_input_default_value_assignment.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__function_missing_input_default_value_assignment.snap index 4401729c257..81994a15703 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__function_missing_input_default_value_assignment.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__function_missing_input_default_value_assignment.snap @@ -7,9 +7,9 @@ source_filename = "main" %main = type { i32, i32, i32 } -@main_instance = global %main zeroinitializer +@main_instance = global %main zeroinitializer, section "var-$RUSTY$main_instance:r3i32i32i32" -define i32 @foo(i32 %0, i32* %1, i32* %2) section "fn-foo:i32[i32][pi32][pi32]" { +define i32 @foo(i32 %0, i32* %1, i32* %2) section "fn-$RUSTY$foo:i32[i32][pi32][pi32]" { entry: %foo = alloca i32, align 4 %input1 = alloca i32, align 4 @@ -23,7 +23,7 @@ entry: ret i32 %foo_ret } -define void @main(%main* %0) section "fn-main:v" { +define void @main(%main* %0) section "fn-$RUSTY$main:v" { entry: %var1 = getelementptr inbounds %main, %main* %0, i32 0, i32 0 %var2 = getelementptr inbounds %main, %main* %0, i32 0, i32 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__function_missing_output_assignment.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__function_missing_output_assignment.snap index ea03ab08ecb..4d4a4078796 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__function_missing_output_assignment.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__function_missing_output_assignment.snap @@ -7,9 +7,9 @@ source_filename = "main" %main = type { i32, i32, i32 } -@main_instance = global %main zeroinitializer +@main_instance = global %main zeroinitializer, section "var-$RUSTY$main_instance:r3i32i32i32" -define i32 @foo(i32 %0, i32* %1, i32* %2) section "fn-foo:i32[i32][pi32][pi32]" { +define i32 @foo(i32 %0, i32* %1, i32* %2) section "fn-$RUSTY$foo:i32[i32][pi32][pi32]" { entry: %foo = alloca i32, align 4 %input1 = alloca i32, align 4 @@ -23,7 +23,7 @@ entry: ret i32 %foo_ret } -define void @main(%main* %0) section "fn-main:v" { +define void @main(%main* %0) section "fn-$RUSTY$main:v" { entry: %var1 = getelementptr inbounds %main, %main* %0, i32 0, i32 0 %var2 = getelementptr inbounds %main, %main* %0, i32 0, i32 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__function_missing_output_default_value_assignment.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__function_missing_output_default_value_assignment.snap index 0aa2e8f3429..ef1bc546979 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__function_missing_output_default_value_assignment.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__function_missing_output_default_value_assignment.snap @@ -7,9 +7,9 @@ source_filename = "main" %main = type { i32, i32, i32 } -@main_instance = global %main zeroinitializer +@main_instance = global %main zeroinitializer, section "var-$RUSTY$main_instance:r3i32i32i32" -define i32 @foo(i32 %0, i32* %1, i32* %2) section "fn-foo:i32[i32][pi32][pi32]" { +define i32 @foo(i32 %0, i32* %1, i32* %2) section "fn-$RUSTY$foo:i32[i32][pi32][pi32]" { entry: %foo = alloca i32, align 4 %input1 = alloca i32, align 4 @@ -23,7 +23,7 @@ entry: ret i32 %foo_ret } -define void @main(%main* %0) section "fn-main:v" { +define void @main(%main* %0) section "fn-$RUSTY$main:v" { entry: %var1 = getelementptr inbounds %main, %main* %0, i32 0, i32 0 %var2 = getelementptr inbounds %main, %main* %0, i32 0, i32 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__parameters_behind_function_block_pointer_are_assigned_to.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__parameters_behind_function_block_pointer_are_assigned_to.snap index 185a060f5b8..997d9285978 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__parameters_behind_function_block_pointer_are_assigned_to.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__parameters_behind_function_block_pointer_are_assigned_to.snap @@ -8,10 +8,10 @@ source_filename = "main" %main = type { %file_t, %file_t* } %file_t = type { i8, i8 } -@main_instance = global %main zeroinitializer -@__file_t__init = unnamed_addr constant %file_t zeroinitializer +@main_instance = global %main zeroinitializer, section "var-$RUSTY$main_instance:r2r2u8u8pr2u8u8" +@__file_t__init = unnamed_addr constant %file_t zeroinitializer, section "var-$RUSTY$__file_t__init:r2u8u8" -define void @main(%main* %0) section "fn-main:v" { +define void @main(%main* %0) section "fn-$RUSTY$main:v" { entry: %file = getelementptr inbounds %main, %main* %0, i32 0, i32 0 %FileOpen = getelementptr inbounds %main, %main* %0, i32 0, i32 1 @@ -23,7 +23,7 @@ entry: ret void } -define void @file_t(%file_t* %0) section "fn-file_t:v[u8][u8]" { +define void @file_t(%file_t* %0) section "fn-$RUSTY$file_t:v[u8][u8]" { entry: %var1 = getelementptr inbounds %file_t, %file_t* %0, i32 0, i32 0 %var2 = getelementptr inbounds %file_t, %file_t* %0, i32 0, i32 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__program_accepts_empty_statement_as_input_param.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__program_accepts_empty_statement_as_input_param.snap index 31f71c8838b..461ca281a03 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__program_accepts_empty_statement_as_input_param.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__program_accepts_empty_statement_as_input_param.snap @@ -8,17 +8,17 @@ source_filename = "main" %prog = type { i32, i32 } %main = type {} -@prog_instance = global %prog zeroinitializer -@main_instance = global %main zeroinitializer +@prog_instance = global %prog zeroinitializer, section "var-$RUSTY$prog_instance:r2i32i32" +@main_instance = global %main zeroinitializer, section "var-$RUSTY$main_instance:r0" -define void @prog(%prog* %0) section "fn-prog:v[i32][i32]" { +define void @prog(%prog* %0) section "fn-$RUSTY$prog:v[i32][i32]" { entry: %in1 = getelementptr inbounds %prog, %prog* %0, i32 0, i32 0 %in2 = getelementptr inbounds %prog, %prog* %0, i32 0, i32 1 ret void } -define void @main(%main* %0) section "fn-main:v" { +define void @main(%main* %0) section "fn-$RUSTY$main:v" { entry: store i32 1, i32* getelementptr inbounds (%prog, %prog* @prog_instance, i32 0, i32 0), align 4 call void @prog(%prog* @prog_instance) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__program_accepts_empty_statement_as_output_param.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__program_accepts_empty_statement_as_output_param.snap index 093ab00e9f2..72fae89445f 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__program_accepts_empty_statement_as_output_param.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__program_accepts_empty_statement_as_output_param.snap @@ -8,10 +8,10 @@ source_filename = "main" %prog = type { i32, i32 } %main = type { i32 } -@prog_instance = global %prog zeroinitializer -@main_instance = global %main zeroinitializer +@prog_instance = global %prog zeroinitializer, section "var-$RUSTY$prog_instance:r2i32i32" +@main_instance = global %main zeroinitializer, section "var-$RUSTY$main_instance:r1i32" -define void @prog(%prog* %0) section "fn-prog:v[i32][i32]" { +define void @prog(%prog* %0) section "fn-$RUSTY$prog:v[i32][i32]" { entry: %out1 = getelementptr inbounds %prog, %prog* %0, i32 0, i32 0 %out2 = getelementptr inbounds %prog, %prog* %0, i32 0, i32 1 @@ -20,7 +20,7 @@ entry: ret void } -define void @main(%main* %0) section "fn-main:v" { +define void @main(%main* %0) section "fn-$RUSTY$main:v" { entry: %x = getelementptr inbounds %main, %main* %0, i32 0, i32 0 call void @prog(%prog* @prog_instance) diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__program_all_parameters_assigned_explicit.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__program_all_parameters_assigned_explicit.snap index 1dd9d67c128..d4904984eec 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__program_all_parameters_assigned_explicit.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__program_all_parameters_assigned_explicit.snap @@ -8,10 +8,10 @@ source_filename = "main" %prog = type { i32, i32, i32* } %main = type { i32, i32, i32 } -@prog_instance = global %prog zeroinitializer -@main_instance = global %main zeroinitializer +@prog_instance = global %prog zeroinitializer, section "var-$RUSTY$prog_instance:r3i32i32pi32" +@main_instance = global %main zeroinitializer, section "var-$RUSTY$main_instance:r3i32i32i32" -define void @prog(%prog* %0) section "fn-prog:v[i32][i32][pi32]" { +define void @prog(%prog* %0) section "fn-$RUSTY$prog:v[i32][i32][pi32]" { entry: %input1 = getelementptr inbounds %prog, %prog* %0, i32 0, i32 0 %output1 = getelementptr inbounds %prog, %prog* %0, i32 0, i32 1 @@ -19,7 +19,7 @@ entry: ret void } -define void @main(%main* %0) section "fn-main:v" { +define void @main(%main* %0) section "fn-$RUSTY$main:v" { entry: %var1 = getelementptr inbounds %main, %main* %0, i32 0, i32 0 %var2 = getelementptr inbounds %main, %main* %0, i32 0, i32 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__program_all_parameters_assigned_implicit.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__program_all_parameters_assigned_implicit.snap index 35d2ffb07af..aadcc395ccc 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__program_all_parameters_assigned_implicit.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__program_all_parameters_assigned_implicit.snap @@ -8,10 +8,10 @@ source_filename = "main" %prog = type { i32, i32, i32* } %main = type { i32, i32, i32 } -@prog_instance = global %prog zeroinitializer -@main_instance = global %main zeroinitializer +@prog_instance = global %prog zeroinitializer, section "var-$RUSTY$prog_instance:r3i32i32pi32" +@main_instance = global %main zeroinitializer, section "var-$RUSTY$main_instance:r3i32i32i32" -define void @prog(%prog* %0) section "fn-prog:v[i32][i32][pi32]" { +define void @prog(%prog* %0) section "fn-$RUSTY$prog:v[i32][i32][pi32]" { entry: %input1 = getelementptr inbounds %prog, %prog* %0, i32 0, i32 0 %output1 = getelementptr inbounds %prog, %prog* %0, i32 0, i32 1 @@ -19,7 +19,7 @@ entry: ret void } -define void @main(%main* %0) section "fn-main:v" { +define void @main(%main* %0) section "fn-$RUSTY$main:v" { entry: %var1 = getelementptr inbounds %main, %main* %0, i32 0, i32 0 %var2 = getelementptr inbounds %main, %main* %0, i32 0, i32 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__program_empty_inout_assignment.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__program_empty_inout_assignment.snap index 5754af5b20f..633ef5775a5 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__program_empty_inout_assignment.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__program_empty_inout_assignment.snap @@ -8,10 +8,10 @@ source_filename = "main" %prog = type { i32, i32, i32* } %main = type { i32, i32, i32 } -@prog_instance = global %prog zeroinitializer -@main_instance = global %main zeroinitializer +@prog_instance = global %prog zeroinitializer, section "var-$RUSTY$prog_instance:r3i32i32pi32" +@main_instance = global %main zeroinitializer, section "var-$RUSTY$main_instance:r3i32i32i32" -define void @prog(%prog* %0) section "fn-prog:v[i32][i32][pi32]" { +define void @prog(%prog* %0) section "fn-$RUSTY$prog:v[i32][i32][pi32]" { entry: %input1 = getelementptr inbounds %prog, %prog* %0, i32 0, i32 0 %output1 = getelementptr inbounds %prog, %prog* %0, i32 0, i32 1 @@ -19,7 +19,7 @@ entry: ret void } -define void @main(%main* %0) section "fn-main:v" { +define void @main(%main* %0) section "fn-$RUSTY$main:v" { entry: %var1 = getelementptr inbounds %main, %main* %0, i32 0, i32 0 %var2 = getelementptr inbounds %main, %main* %0, i32 0, i32 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__program_missing_input_assignment.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__program_missing_input_assignment.snap index ebae600179e..7b3e689396d 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__program_missing_input_assignment.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__program_missing_input_assignment.snap @@ -8,10 +8,10 @@ source_filename = "main" %prog = type { i32, i32, i32* } %main = type { i32, i32, i32 } -@prog_instance = global %prog zeroinitializer -@main_instance = global %main zeroinitializer +@prog_instance = global %prog zeroinitializer, section "var-$RUSTY$prog_instance:r3i32i32pi32" +@main_instance = global %main zeroinitializer, section "var-$RUSTY$main_instance:r3i32i32i32" -define void @prog(%prog* %0) section "fn-prog:v[i32][i32][pi32]" { +define void @prog(%prog* %0) section "fn-$RUSTY$prog:v[i32][i32][pi32]" { entry: %input1 = getelementptr inbounds %prog, %prog* %0, i32 0, i32 0 %output1 = getelementptr inbounds %prog, %prog* %0, i32 0, i32 1 @@ -19,7 +19,7 @@ entry: ret void } -define void @main(%main* %0) section "fn-main:v" { +define void @main(%main* %0) section "fn-$RUSTY$main:v" { entry: %var1 = getelementptr inbounds %main, %main* %0, i32 0, i32 0 %var2 = getelementptr inbounds %main, %main* %0, i32 0, i32 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__program_missing_output_assignment.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__program_missing_output_assignment.snap index 87d98a06417..296ca297db4 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__program_missing_output_assignment.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__program_missing_output_assignment.snap @@ -8,10 +8,10 @@ source_filename = "main" %prog = type { i32, i32, i32* } %main = type { i32, i32, i32 } -@prog_instance = global %prog zeroinitializer -@main_instance = global %main zeroinitializer +@prog_instance = global %prog zeroinitializer, section "var-$RUSTY$prog_instance:r3i32i32pi32" +@main_instance = global %main zeroinitializer, section "var-$RUSTY$main_instance:r3i32i32i32" -define void @prog(%prog* %0) section "fn-prog:v[i32][i32][pi32]" { +define void @prog(%prog* %0) section "fn-$RUSTY$prog:v[i32][i32][pi32]" { entry: %input1 = getelementptr inbounds %prog, %prog* %0, i32 0, i32 0 %output1 = getelementptr inbounds %prog, %prog* %0, i32 0, i32 1 @@ -19,7 +19,7 @@ entry: ret void } -define void @main(%main* %0) section "fn-main:v" { +define void @main(%main* %0) section "fn-$RUSTY$main:v" { entry: %var1 = getelementptr inbounds %main, %main* %0, i32 0, i32 0 %var2 = getelementptr inbounds %main, %main* %0, i32 0, i32 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__var_in_out_params_can_be_out_of_order.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__var_in_out_params_can_be_out_of_order.snap index ec2c998881e..56d71b38e2f 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__var_in_out_params_can_be_out_of_order.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__parameters_tests__var_in_out_params_can_be_out_of_order.snap @@ -8,10 +8,10 @@ source_filename = "main" %mainProg = type { %fb_t, i8, i8 } %fb_t = type { i8, i8, i8*, i8, i8* } -@mainProg_instance = global %mainProg zeroinitializer -@__fb_t__init = unnamed_addr constant %fb_t zeroinitializer +@mainProg_instance = global %mainProg zeroinitializer, section "var-$RUSTY$mainProg_instance:r3r5u8u8pu8u8pu8u8u8" +@__fb_t__init = unnamed_addr constant %fb_t zeroinitializer, section "var-$RUSTY$__fb_t__init:r5u8u8pu8u8pu8" -define void @mainProg(%mainProg* %0) section "fn-mainProg:v" { +define void @mainProg(%mainProg* %0) section "fn-$RUSTY$mainProg:v" { entry: %fb = getelementptr inbounds %mainProg, %mainProg* %0, i32 0, i32 0 %out1 = getelementptr inbounds %mainProg, %mainProg* %0, i32 0, i32 1 @@ -35,7 +35,7 @@ entry: ret void } -define void @fb_t(%fb_t* %0) section "fn-fb_t:v[u8][pu8][u8][pu8]" { +define void @fb_t(%fb_t* %0) section "fn-$RUSTY$fb_t:v[u8][pu8][u8][pu8]" { entry: %myVar = getelementptr inbounds %fb_t, %fb_t* %0, i32 0, i32 0 %myInput = getelementptr inbounds %fb_t, %fb_t* %0, i32 0, i32 1 @@ -45,7 +45,7 @@ entry: ret void } -define void @fb_t.foo(%fb_t* %0) section "fn-fb_t.foo:v" { +define void @fb_t.foo(%fb_t* %0) section "fn-$RUSTY$fb_t.foo:v" { entry: %myVar = getelementptr inbounds %fb_t, %fb_t* %0, i32 0, i32 0 %myInput = getelementptr inbounds %fb_t, %fb_t* %0, i32 0, i32 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__statement_codegen_test__bitaccess_generated_as_rsh_and_trunc_i1.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__statement_codegen_test__bitaccess_generated_as_rsh_and_trunc_i1.snap index a339d326d61..e9e2500aabd 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__statement_codegen_test__bitaccess_generated_as_rsh_and_trunc_i1.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__statement_codegen_test__bitaccess_generated_as_rsh_and_trunc_i1.snap @@ -7,9 +7,9 @@ source_filename = "main" %prg = type { i8, i32, i32 } -@prg_instance = global %prg zeroinitializer +@prg_instance = global %prg zeroinitializer, section "var-$RUSTY$prg_instance:r3u8u32i32" -define void @prg(%prg* %0) section "fn-prg:v" { +define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: %a = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 %x = getelementptr inbounds %prg, %prg* %0, i32 0, i32 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__statement_codegen_test__byteaccess_generated_as_rsh_and_trunc_i8.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__statement_codegen_test__byteaccess_generated_as_rsh_and_trunc_i8.snap index 607a355c179..867df6704bb 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__statement_codegen_test__byteaccess_generated_as_rsh_and_trunc_i8.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__statement_codegen_test__byteaccess_generated_as_rsh_and_trunc_i8.snap @@ -7,9 +7,9 @@ source_filename = "main" %prg = type { i8, i32, i32 } -@prg_instance = global %prg zeroinitializer +@prg_instance = global %prg zeroinitializer, section "var-$RUSTY$prg_instance:r3u8u32i32" -define void @prg(%prg* %0) section "fn-prg:v" { +define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: %a = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 %x = getelementptr inbounds %prg, %prg* %0, i32 0, i32 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__statement_codegen_test__dwordaccess_generated_as_rsh_and_trunc_i32.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__statement_codegen_test__dwordaccess_generated_as_rsh_and_trunc_i32.snap index 8c93248cf29..b3afe4628db 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__statement_codegen_test__dwordaccess_generated_as_rsh_and_trunc_i32.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__statement_codegen_test__dwordaccess_generated_as_rsh_and_trunc_i32.snap @@ -7,9 +7,9 @@ source_filename = "main" %prg = type { i32, i64, i64 } -@prg_instance = global %prg zeroinitializer +@prg_instance = global %prg zeroinitializer, section "var-$RUSTY$prg_instance:r3u32u64i64" -define void @prg(%prg* %0) section "fn-prg:v" { +define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: %a = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 %x = getelementptr inbounds %prg, %prg* %0, i32 0, i32 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__statement_codegen_test__floating_point_type_casting.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__statement_codegen_test__floating_point_type_casting.snap index a95abc87da0..1f93b11da81 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__statement_codegen_test__floating_point_type_casting.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__statement_codegen_test__floating_point_type_casting.snap @@ -5,7 +5,7 @@ expression: result ; ModuleID = 'main' source_filename = "main" -define i32 @fn() section "fn-fn:i32" { +define i32 @fn() section "fn-$RUSTY$fn:i32" { entry: %fn = alloca i32, align 4 %a = alloca float, align 4 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__statement_codegen_test__function_result_assignment_on_aliased_string.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__statement_codegen_test__function_result_assignment_on_aliased_string.snap index 36383987b3b..8932121af18 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__statement_codegen_test__function_result_assignment_on_aliased_string.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__statement_codegen_test__function_result_assignment_on_aliased_string.snap @@ -5,9 +5,9 @@ expression: result ; ModuleID = 'main' source_filename = "main" -declare void @CONCAT([1025 x i8]*, i8*, i8*) section "fn-CONCAT:s8u1025[s8u1025][s8u1025]" +declare void @CONCAT([1025 x i8]*, i8*, i8*) section "fn-$RUSTY$CONCAT:s8u1025[s8u1025][s8u1025]" -define i8 @LIST_ADD(i8* %0, i8* %1) section "fn-LIST_ADD:u8[s8u1001][s8u2]" { +define i8 @LIST_ADD(i8* %0, i8* %1) section "fn-$RUSTY$LIST_ADD:u8[s8u1001][s8u2]" { entry: %LIST_ADD = alloca i8, align 1 %INS = alloca [1001 x i8], align 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__statement_codegen_test__function_result_assignment_on_string.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__statement_codegen_test__function_result_assignment_on_string.snap index 36383987b3b..8932121af18 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__statement_codegen_test__function_result_assignment_on_string.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__statement_codegen_test__function_result_assignment_on_string.snap @@ -5,9 +5,9 @@ expression: result ; ModuleID = 'main' source_filename = "main" -declare void @CONCAT([1025 x i8]*, i8*, i8*) section "fn-CONCAT:s8u1025[s8u1025][s8u1025]" +declare void @CONCAT([1025 x i8]*, i8*, i8*) section "fn-$RUSTY$CONCAT:s8u1025[s8u1025][s8u1025]" -define i8 @LIST_ADD(i8* %0, i8* %1) section "fn-LIST_ADD:u8[s8u1001][s8u2]" { +define i8 @LIST_ADD(i8* %0, i8* %1) section "fn-$RUSTY$LIST_ADD:u8[s8u1001][s8u2]" { entry: %LIST_ADD = alloca i8, align 1 %INS = alloca [1001 x i8], align 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__statement_codegen_test__nested_bitwise_access.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__statement_codegen_test__nested_bitwise_access.snap index 53c5974e89e..21697941632 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__statement_codegen_test__nested_bitwise_access.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__statement_codegen_test__nested_bitwise_access.snap @@ -7,9 +7,9 @@ source_filename = "main" %prg = type { i8, i64 } -@prg_instance = global %prg zeroinitializer +@prg_instance = global %prg zeroinitializer, section "var-$RUSTY$prg_instance:r2u8u64" -define void @prg(%prg* %0) section "fn-prg:v" { +define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: %a = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 %x = getelementptr inbounds %prg, %prg* %0, i32 0, i32 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__statement_codegen_test__variable_based_bitwise_access.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__statement_codegen_test__variable_based_bitwise_access.snap index 66581e44377..ff8e6e1eff6 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__statement_codegen_test__variable_based_bitwise_access.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__statement_codegen_test__variable_based_bitwise_access.snap @@ -7,9 +7,9 @@ source_filename = "main" %prg = type { i8, i8, i16, i16 } -@prg_instance = global %prg zeroinitializer +@prg_instance = global %prg zeroinitializer, section "var-$RUSTY$prg_instance:r4u8u8i16i16" -define void @prg(%prg* %0) section "fn-prg:v" { +define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: %a = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 %b = getelementptr inbounds %prg, %prg* %0, i32 0, i32 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__statement_codegen_test__wordaccess_generated_as_rsh_and_trunc_i16.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__statement_codegen_test__wordaccess_generated_as_rsh_and_trunc_i16.snap index 846ec42e0b9..52722c634fe 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__statement_codegen_test__wordaccess_generated_as_rsh_and_trunc_i16.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__statement_codegen_test__wordaccess_generated_as_rsh_and_trunc_i16.snap @@ -7,9 +7,9 @@ source_filename = "main" %prg = type { i16, i32, i32 } -@prg_instance = global %prg zeroinitializer +@prg_instance = global %prg zeroinitializer, section "var-$RUSTY$prg_instance:r3u16u32i32" -define void @prg(%prg* %0) section "fn-prg:v" { +define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: %a = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 %x = getelementptr inbounds %prg, %prg* %0, i32 0, i32 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__string_tests__casted_string_assignment_uses_memcpy.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__string_tests__casted_string_assignment_uses_memcpy.snap index c22cb172237..9acdab89c7e 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__string_tests__casted_string_assignment_uses_memcpy.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__string_tests__casted_string_assignment_uses_memcpy.snap @@ -7,11 +7,11 @@ source_filename = "main" %prg = type { [81 x i8], [81 x i16] } -@prg_instance = global %prg zeroinitializer +@prg_instance = global %prg zeroinitializer, section "var-$RUSTY$prg_instance:r2s8u81s16u81" @utf08_literal_0 = private unnamed_addr constant [4 x i8] c"abc\00" @utf16_literal_0 = private unnamed_addr constant [4 x i16] [i16 97, i16 98, i16 99, i16 0] -define void @prg(%prg* %0) section "fn-prg:v" { +define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: %a = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 %b = getelementptr inbounds %prg, %prg* %0, i32 0, i32 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__string_tests__function_returning_generic_string_should_return_by_ref.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__string_tests__function_returning_generic_string_should_return_by_ref.snap index 196004e2c04..29fa2da807d 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__string_tests__function_returning_generic_string_should_return_by_ref.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__string_tests__function_returning_generic_string_should_return_by_ref.snap @@ -7,10 +7,10 @@ source_filename = "main" %main = type { [61 x i8], [81 x i8] } -@main_instance = global %main zeroinitializer +@main_instance = global %main zeroinitializer, section "var-$RUSTY$main_instance:r2s8u61s8u81" @utf08_literal_0 = private unnamed_addr constant [4 x i8] c"abc\00" -define void @MID__STRING([81 x i8]* %0, i8* %1, i32 %2, i32 %3) section "fn-MID__STRING:s8u81[ps8u81][i32][i32]" { +define void @MID__STRING([81 x i8]* %0, i8* %1, i32 %2, i32 %3) section "fn-$RUSTY$MID__STRING:s8u81[ps8u81][i32][i32]" { entry: %MID__STRING = alloca [81 x i8]*, align 8 store [81 x i8]* %0, [81 x i8]** %MID__STRING, align 8 @@ -29,7 +29,7 @@ entry: ret void } -define void @main(%main* %0) section "fn-main:v[s8u61][s8u81]" { +define void @main(%main* %0) section "fn-$RUSTY$main:v[s8u61][s8u81]" { entry: %fmt = getelementptr inbounds %main, %main* %0, i32 0, i32 0 %x = getelementptr inbounds %main, %main* %0, i32 0, i32 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__string_tests__function_returns_a_literal_string.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__string_tests__function_returns_a_literal_string.snap index 46621822794..bdc1540913e 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__string_tests__function_returns_a_literal_string.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__string_tests__function_returns_a_literal_string.snap @@ -7,10 +7,10 @@ source_filename = "main" %main = type { [81 x i8] } -@main_instance = global %main zeroinitializer +@main_instance = global %main zeroinitializer, section "var-$RUSTY$main_instance:r1s8u81" @utf08_literal_0 = private unnamed_addr constant [4 x i8] c"abc\00" -define void @ret([81 x i8]* %0) section "fn-ret:s8u81" { +define void @ret([81 x i8]* %0) section "fn-$RUSTY$ret:s8u81" { entry: %ret = alloca [81 x i8]*, align 8 store [81 x i8]* %0, [81 x i8]** %ret, align 8 @@ -23,7 +23,7 @@ entry: ret void } -define void @main(%main* %0) section "fn-main:v" { +define void @main(%main* %0) section "fn-$RUSTY$main:v" { entry: %str = getelementptr inbounds %main, %main* %0, i32 0, i32 0 %1 = alloca [81 x i8], align 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__string_tests__function_takes_string_paramter_and_returns_string.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__string_tests__function_takes_string_paramter_and_returns_string.snap index f6f317c2fd4..385f0cc4706 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__string_tests__function_takes_string_paramter_and_returns_string.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__string_tests__function_takes_string_paramter_and_returns_string.snap @@ -7,10 +7,10 @@ source_filename = "main" %main = type { [81 x i8] } -@main_instance = global %main zeroinitializer +@main_instance = global %main zeroinitializer, section "var-$RUSTY$main_instance:r1s8u81" @utf08_literal_0 = private unnamed_addr constant [154 x i8] c"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\00" -define void @read_string([81 x i8]* %0, i8* %1) section "fn-read_string:s8u81[s8u81]" { +define void @read_string([81 x i8]* %0, i8* %1) section "fn-$RUSTY$read_string:s8u81[s8u81]" { entry: %read_string = alloca [81 x i8]*, align 8 store [81 x i8]* %0, [81 x i8]** %read_string, align 8 @@ -28,7 +28,7 @@ entry: ret void } -define void @main(%main* %0) section "fn-main:v" { +define void @main(%main* %0) section "fn-$RUSTY$main:v" { entry: %text1 = getelementptr inbounds %main, %main* %0, i32 0, i32 0 %1 = alloca [81 x i8], align 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__string_tests__function_var_constant_strings_should_be_collected_as_literals.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__string_tests__function_var_constant_strings_should_be_collected_as_literals.snap index abd14006e4b..9e9c351040b 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__string_tests__function_var_constant_strings_should_be_collected_as_literals.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__string_tests__function_var_constant_strings_should_be_collected_as_literals.snap @@ -10,7 +10,7 @@ source_filename = "main" @utf08_literal_0 = private unnamed_addr constant [2 x i8] c"#\00" @utf08_literal_1 = private unnamed_addr constant [2 x i8] c"*\00" -define i64 @FSTRING_TO_DT() section "fn-FSTRING_TO_DT:v" { +define i64 @FSTRING_TO_DT() section "fn-$RUSTY$FSTRING_TO_DT:i64" { entry: %FSTRING_TO_DT = alloca i64, align 8 %ignore = alloca [2 x i8], align 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__string_tests__nested_struct_initialization_of_multi_dim_string_arrays.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__string_tests__nested_struct_initialization_of_multi_dim_string_arrays.snap index 3a44ecd3b04..e9a7ca8dc58 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__string_tests__nested_struct_initialization_of_multi_dim_string_arrays.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__string_tests__nested_struct_initialization_of_multi_dim_string_arrays.snap @@ -7,6 +7,5 @@ source_filename = "main" %CONSTANTS_LANGUAGE = type { i16, i16, [21 x [11 x i8]], [21 x [3 x i8]], [36 x [11 x i8]], [36 x [4 x i8]], [48 x [4 x i8]] } -@x = global %CONSTANTS_LANGUAGE { i16 1, i16 3, [21 x [11 x i8]] [[11 x i8] c"Monday\00\00\00\00\00", [11 x i8] c"Tuesday\00\00\00\00", [11 x i8] c"Wednesday\00\00", [11 x i8] c"Thursday\00\00\00", [11 x i8] c"Friday\00\00\00\00\00", [11 x i8] c"Saturday\00\00\00", [11 x i8] c"Sunday\00\00\00\00\00", [11 x i8] c"Montag\00\00\00\00\00", [11 x i8] c"Dienstag\00\00\00", [11 x i8] c"Mittwoch\00\00\00", [11 x i8] c"Donnerstag\00", [11 x i8] c"Freitag\00\00\00\00", [11 x i8] c"Samstag\00\00\00\00", [11 x i8] c"Sonntag\00\00\00\00", [11 x i8] c"Lundi\00\00\00\00\00\00", [11 x i8] c"Mardi\00\00\00\00\00\00", [11 x i8] c"Mercredi\00\00\00", [11 x i8] c"Jeudi\00\00\00\00\00\00", [11 x i8] c"Vendredi\00\00\00", [11 x i8] c"Samedi\00\00\00\00\00", [11 x i8] c"Dimanche\00\00\00"], [21 x [3 x i8]] [[3 x i8] c"Mo\00", [3 x i8] c"Tu\00", [3 x i8] c"We\00", [3 x i8] c"Th\00", [3 x i8] c"Fr\00", [3 x i8] c"Sa\00", [3 x i8] c"Su\00", [3 x i8] c"Mo\00", [3 x i8] c"Di\00", [3 x i8] c"Mi\00", [3 x i8] c"Do\00", [3 x i8] c"Fr\00", [3 x i8] c"Sa\00", [3 x i8] c"So\00", [3 x i8] c"Lu\00", [3 x i8] c"Ma\00", [3 x i8] c"Me\00", [3 x i8] c"Je\00", [3 x i8] c"Ve\00", [3 x i8] c"Sa\00", [3 x i8] c"Di\00"], [36 x [11 x i8]] [[11 x i8] c"January\00\00\00\00", [11 x i8] c"February\00\00\00", [11 x i8] c"March\00\00\00\00\00\00", [11 x i8] c"April\00\00\00\00\00\00", [11 x i8] c"May\00\00\00\00\00\00\00\00", [11 x i8] c"June\00\00\00\00\00\00\00", [11 x i8] c"July\00\00\00\00\00\00\00", [11 x i8] c"August\00\00\00\00\00", [11 x i8] c"September\00\00", [11 x i8] c"October\00\00\00\00", [11 x i8] c"November\00\00\00", [11 x i8] c"December\00\00\00", [11 x i8] c"Januar\00\00\00\00\00", [11 x i8] c"Februar\00\00\00\00", [11 x i8] c"M\C3\A4rz\00\00\00\00\00\00", [11 x i8] c"April\00\00\00\00\00\00", [11 x i8] c"Mai\00\00\00\00\00\00\00\00", [11 x i8] c"Juni\00\00\00\00\00\00\00", [11 x i8] c"Juli\00\00\00\00\00\00\00", [11 x i8] c"August\00\00\00\00\00", [11 x i8] c"September\00\00", [11 x i8] c"Oktober\00\00\00\00", [11 x i8] c"November\00\00\00", [11 x i8] c"Dezember\00\00\00", [11 x i8] c"Janvier\00\00\00\00", [11 x i8] c"F\C3\A9vrier\00\00\00", [11 x i8] c"mars\00\00\00\00\00\00\00", [11 x i8] c"Avril\00\00\00\00\00\00", [11 x i8] c"Mai\00\00\00\00\00\00\00\00", [11 x i8] c"Juin\00\00\00\00\00\00\00", [11 x i8] c"Juillet\00\00\00\00", [11 x i8] c"Ao\C3\BBt\00\00\00\00\00\00", [11 x i8] c"Septembre\00\00", [11 x i8] c"Octobre\00\00\00\00", [11 x i8] c"Novembre\00\00\00", [11 x i8] c"Decembre\00\00\00"], [36 x [4 x i8]] [[4 x i8] c"Jan\00", [4 x i8] c"Feb\00", [4 x i8] c"Mar\00", [4 x i8] c"Apr\00", [4 x i8] c"May\00", [4 x i8] c"Jun\00", [4 x i8] c"Jul\00", [4 x i8] c"Aug\00", [4 x i8] c"Sep\00", [4 x i8] c"Oct\00", [4 x i8] c"Nov\00", [4 x i8] c"Dec\00", [4 x i8] c"Jan\00", [4 x i8] c"Feb\00", [4 x i8] c"Mrz\00", [4 x i8] c"Apr\00", [4 x i8] c"Mai\00", [4 x i8] c"Jun\00", [4 x i8] c"Jul\00", [4 x i8] c"Aug\00", [4 x i8] c"Sep\00", [4 x i8] c"Okt\00", [4 x i8] c"Nov\00", [4 x i8] c"Dez\00", [4 x i8] c"Jan\00", [4 x i8] c"Fev\00", [4 x i8] c"Mar\00", [4 x i8] c"Avr\00", [4 x i8] c"Mai\00", [4 x i8] c"Jun\00", [4 x i8] c"Jul\00", [4 x i8] c"Aou\00", [4 x i8] c"Sep\00", [4 x i8] c"Oct\00", [4 x i8] c"Nov\00", [4 x i8] c"Dec\00"], [48 x [4 x i8]] [[4 x i8] c"N\00\00\00", [4 x i8] c"NNE\00", [4 x i8] c"NE\00\00", [4 x i8] c"ENE\00", [4 x i8] c"E\00\00\00", [4 x i8] c"ESE\00", [4 x i8] c"SE\00\00", [4 x i8] c"SSE\00", [4 x i8] c"S\00\00\00", [4 x i8] c"SSW\00", [4 x i8] c"SW\00\00", [4 x i8] c"WSW\00", [4 x i8] c"W\00\00\00", [4 x i8] c"WNW\00", [4 x i8] c"NW\00\00", [4 x i8] c"NNW\00", [4 x i8] c"N\00\00\00", [4 x i8] c"NNO\00", [4 x i8] c"NO\00\00", [4 x i8] c"ONO\00", [4 x i8] c"O\00\00\00", [4 x i8] c"OSO\00", [4 x i8] c"SO\00\00", [4 x i8] c"SSO\00", [4 x i8] c"S\00\00\00", [4 x i8] c"SSW\00", [4 x i8] c"SW\00\00", [4 x i8] c"WSW\00", [4 x i8] c"W\00\00\00", [4 x i8] c"WNW\00", [4 x i8] c"NW\00\00", [4 x i8] c"NNW\00", [4 x i8] c"N\00\00\00", [4 x i8] c"NNO\00", [4 x i8] c"NO\00\00", [4 x i8] c"ONO\00", [4 x i8] c"O\00\00\00", [4 x i8] c"OSO\00", [4 x i8] c"SO\00\00", [4 x i8] c"SSO\00", [4 x i8] c"S\00\00\00", [4 x i8] c"SSW\00", [4 x i8] c"SW\00\00", [4 x i8] c"WSW\00", [4 x i8] c"W\00\00\00", [4 x i8] c"WNW\00", [4 x i8] c"NW\00\00", [4 x i8] c"NNW\00"] } -@__CONSTANTS_LANGUAGE__init = unnamed_addr constant %CONSTANTS_LANGUAGE { i16 1, i16 3, [21 x [11 x i8]] [[11 x i8] c"Monday\00\00\00\00\00", [11 x i8] c"Tuesday\00\00\00\00", [11 x i8] c"Wednesday\00\00", [11 x i8] c"Thursday\00\00\00", [11 x i8] c"Friday\00\00\00\00\00", [11 x i8] c"Saturday\00\00\00", [11 x i8] c"Sunday\00\00\00\00\00", [11 x i8] c"Montag\00\00\00\00\00", [11 x i8] c"Dienstag\00\00\00", [11 x i8] c"Mittwoch\00\00\00", [11 x i8] c"Donnerstag\00", [11 x i8] c"Freitag\00\00\00\00", [11 x i8] c"Samstag\00\00\00\00", [11 x i8] c"Sonntag\00\00\00\00", [11 x i8] c"Lundi\00\00\00\00\00\00", [11 x i8] c"Mardi\00\00\00\00\00\00", [11 x i8] c"Mercredi\00\00\00", [11 x i8] c"Jeudi\00\00\00\00\00\00", [11 x i8] c"Vendredi\00\00\00", [11 x i8] c"Samedi\00\00\00\00\00", [11 x i8] c"Dimanche\00\00\00"], [21 x [3 x i8]] [[3 x i8] c"Mo\00", [3 x i8] c"Tu\00", [3 x i8] c"We\00", [3 x i8] c"Th\00", [3 x i8] c"Fr\00", [3 x i8] c"Sa\00", [3 x i8] c"Su\00", [3 x i8] c"Mo\00", [3 x i8] c"Di\00", [3 x i8] c"Mi\00", [3 x i8] c"Do\00", [3 x i8] c"Fr\00", [3 x i8] c"Sa\00", [3 x i8] c"So\00", [3 x i8] c"Lu\00", [3 x i8] c"Ma\00", [3 x i8] c"Me\00", [3 x i8] c"Je\00", [3 x i8] c"Ve\00", [3 x i8] c"Sa\00", [3 x i8] c"Di\00"], [36 x [11 x i8]] [[11 x i8] c"January\00\00\00\00", [11 x i8] c"February\00\00\00", [11 x i8] c"March\00\00\00\00\00\00", [11 x i8] c"April\00\00\00\00\00\00", [11 x i8] c"May\00\00\00\00\00\00\00\00", [11 x i8] c"June\00\00\00\00\00\00\00", [11 x i8] c"July\00\00\00\00\00\00\00", [11 x i8] c"August\00\00\00\00\00", [11 x i8] c"September\00\00", [11 x i8] c"October\00\00\00\00", [11 x i8] c"November\00\00\00", [11 x i8] c"December\00\00\00", [11 x i8] c"Januar\00\00\00\00\00", [11 x i8] c"Februar\00\00\00\00", [11 x i8] c"M\C3\A4rz\00\00\00\00\00\00", [11 x i8] c"April\00\00\00\00\00\00", [11 x i8] c"Mai\00\00\00\00\00\00\00\00", [11 x i8] c"Juni\00\00\00\00\00\00\00", [11 x i8] c"Juli\00\00\00\00\00\00\00", [11 x i8] c"August\00\00\00\00\00", [11 x i8] c"September\00\00", [11 x i8] c"Oktober\00\00\00\00", [11 x i8] c"November\00\00\00", [11 x i8] c"Dezember\00\00\00", [11 x i8] c"Janvier\00\00\00\00", [11 x i8] c"F\C3\A9vrier\00\00\00", [11 x i8] c"mars\00\00\00\00\00\00\00", [11 x i8] c"Avril\00\00\00\00\00\00", [11 x i8] c"Mai\00\00\00\00\00\00\00\00", [11 x i8] c"Juin\00\00\00\00\00\00\00", [11 x i8] c"Juillet\00\00\00\00", [11 x i8] c"Ao\C3\BBt\00\00\00\00\00\00", [11 x i8] c"Septembre\00\00", [11 x i8] c"Octobre\00\00\00\00", [11 x i8] c"Novembre\00\00\00", [11 x i8] c"Decembre\00\00\00"], [36 x [4 x i8]] [[4 x i8] c"Jan\00", [4 x i8] c"Feb\00", [4 x i8] c"Mar\00", [4 x i8] c"Apr\00", [4 x i8] c"May\00", [4 x i8] c"Jun\00", [4 x i8] c"Jul\00", [4 x i8] c"Aug\00", [4 x i8] c"Sep\00", [4 x i8] c"Oct\00", [4 x i8] c"Nov\00", [4 x i8] c"Dec\00", [4 x i8] c"Jan\00", [4 x i8] c"Feb\00", [4 x i8] c"Mrz\00", [4 x i8] c"Apr\00", [4 x i8] c"Mai\00", [4 x i8] c"Jun\00", [4 x i8] c"Jul\00", [4 x i8] c"Aug\00", [4 x i8] c"Sep\00", [4 x i8] c"Okt\00", [4 x i8] c"Nov\00", [4 x i8] c"Dez\00", [4 x i8] c"Jan\00", [4 x i8] c"Fev\00", [4 x i8] c"Mar\00", [4 x i8] c"Avr\00", [4 x i8] c"Mai\00", [4 x i8] c"Jun\00", [4 x i8] c"Jul\00", [4 x i8] c"Aou\00", [4 x i8] c"Sep\00", [4 x i8] c"Oct\00", [4 x i8] c"Nov\00", [4 x i8] c"Dec\00"], [48 x [4 x i8]] [[4 x i8] c"N\00\00\00", [4 x i8] c"NNE\00", [4 x i8] c"NE\00\00", [4 x i8] c"ENE\00", [4 x i8] c"E\00\00\00", [4 x i8] c"ESE\00", [4 x i8] c"SE\00\00", [4 x i8] c"SSE\00", [4 x i8] c"S\00\00\00", [4 x i8] c"SSW\00", [4 x i8] c"SW\00\00", [4 x i8] c"WSW\00", [4 x i8] c"W\00\00\00", [4 x i8] c"WNW\00", [4 x i8] c"NW\00\00", [4 x i8] c"NNW\00", [4 x i8] c"N\00\00\00", [4 x i8] c"NNO\00", [4 x i8] c"NO\00\00", [4 x i8] c"ONO\00", [4 x i8] c"O\00\00\00", [4 x i8] c"OSO\00", [4 x i8] c"SO\00\00", [4 x i8] c"SSO\00", [4 x i8] c"S\00\00\00", [4 x i8] c"SSW\00", [4 x i8] c"SW\00\00", [4 x i8] c"WSW\00", [4 x i8] c"W\00\00\00", [4 x i8] c"WNW\00", [4 x i8] c"NW\00\00", [4 x i8] c"NNW\00", [4 x i8] c"N\00\00\00", [4 x i8] c"NNO\00", [4 x i8] c"NO\00\00", [4 x i8] c"ONO\00", [4 x i8] c"O\00\00\00", [4 x i8] c"OSO\00", [4 x i8] c"SO\00\00", [4 x i8] c"SSO\00", [4 x i8] c"S\00\00\00", [4 x i8] c"SSW\00", [4 x i8] c"SW\00\00", [4 x i8] c"WSW\00", [4 x i8] c"W\00\00\00", [4 x i8] c"WNW\00", [4 x i8] c"NW\00\00", [4 x i8] c"NNW\00"] } - +@x = global %CONSTANTS_LANGUAGE { i16 1, i16 3, [21 x [11 x i8]] [[11 x i8] c"Monday\00\00\00\00\00", [11 x i8] c"Tuesday\00\00\00\00", [11 x i8] c"Wednesday\00\00", [11 x i8] c"Thursday\00\00\00", [11 x i8] c"Friday\00\00\00\00\00", [11 x i8] c"Saturday\00\00\00", [11 x i8] c"Sunday\00\00\00\00\00", [11 x i8] c"Montag\00\00\00\00\00", [11 x i8] c"Dienstag\00\00\00", [11 x i8] c"Mittwoch\00\00\00", [11 x i8] c"Donnerstag\00", [11 x i8] c"Freitag\00\00\00\00", [11 x i8] c"Samstag\00\00\00\00", [11 x i8] c"Sonntag\00\00\00\00", [11 x i8] c"Lundi\00\00\00\00\00\00", [11 x i8] c"Mardi\00\00\00\00\00\00", [11 x i8] c"Mercredi\00\00\00", [11 x i8] c"Jeudi\00\00\00\00\00\00", [11 x i8] c"Vendredi\00\00\00", [11 x i8] c"Samedi\00\00\00\00\00", [11 x i8] c"Dimanche\00\00\00"], [21 x [3 x i8]] [[3 x i8] c"Mo\00", [3 x i8] c"Tu\00", [3 x i8] c"We\00", [3 x i8] c"Th\00", [3 x i8] c"Fr\00", [3 x i8] c"Sa\00", [3 x i8] c"Su\00", [3 x i8] c"Mo\00", [3 x i8] c"Di\00", [3 x i8] c"Mi\00", [3 x i8] c"Do\00", [3 x i8] c"Fr\00", [3 x i8] c"Sa\00", [3 x i8] c"So\00", [3 x i8] c"Lu\00", [3 x i8] c"Ma\00", [3 x i8] c"Me\00", [3 x i8] c"Je\00", [3 x i8] c"Ve\00", [3 x i8] c"Sa\00", [3 x i8] c"Di\00"], [36 x [11 x i8]] [[11 x i8] c"January\00\00\00\00", [11 x i8] c"February\00\00\00", [11 x i8] c"March\00\00\00\00\00\00", [11 x i8] c"April\00\00\00\00\00\00", [11 x i8] c"May\00\00\00\00\00\00\00\00", [11 x i8] c"June\00\00\00\00\00\00\00", [11 x i8] c"July\00\00\00\00\00\00\00", [11 x i8] c"August\00\00\00\00\00", [11 x i8] c"September\00\00", [11 x i8] c"October\00\00\00\00", [11 x i8] c"November\00\00\00", [11 x i8] c"December\00\00\00", [11 x i8] c"Januar\00\00\00\00\00", [11 x i8] c"Februar\00\00\00\00", [11 x i8] c"M\C3\A4rz\00\00\00\00\00\00", [11 x i8] c"April\00\00\00\00\00\00", [11 x i8] c"Mai\00\00\00\00\00\00\00\00", [11 x i8] c"Juni\00\00\00\00\00\00\00", [11 x i8] c"Juli\00\00\00\00\00\00\00", [11 x i8] c"August\00\00\00\00\00", [11 x i8] c"September\00\00", [11 x i8] c"Oktober\00\00\00\00", [11 x i8] c"November\00\00\00", [11 x i8] c"Dezember\00\00\00", [11 x i8] c"Janvier\00\00\00\00", [11 x i8] c"F\C3\A9vrier\00\00\00", [11 x i8] c"mars\00\00\00\00\00\00\00", [11 x i8] c"Avril\00\00\00\00\00\00", [11 x i8] c"Mai\00\00\00\00\00\00\00\00", [11 x i8] c"Juin\00\00\00\00\00\00\00", [11 x i8] c"Juillet\00\00\00\00", [11 x i8] c"Ao\C3\BBt\00\00\00\00\00\00", [11 x i8] c"Septembre\00\00", [11 x i8] c"Octobre\00\00\00\00", [11 x i8] c"Novembre\00\00\00", [11 x i8] c"Decembre\00\00\00"], [36 x [4 x i8]] [[4 x i8] c"Jan\00", [4 x i8] c"Feb\00", [4 x i8] c"Mar\00", [4 x i8] c"Apr\00", [4 x i8] c"May\00", [4 x i8] c"Jun\00", [4 x i8] c"Jul\00", [4 x i8] c"Aug\00", [4 x i8] c"Sep\00", [4 x i8] c"Oct\00", [4 x i8] c"Nov\00", [4 x i8] c"Dec\00", [4 x i8] c"Jan\00", [4 x i8] c"Feb\00", [4 x i8] c"Mrz\00", [4 x i8] c"Apr\00", [4 x i8] c"Mai\00", [4 x i8] c"Jun\00", [4 x i8] c"Jul\00", [4 x i8] c"Aug\00", [4 x i8] c"Sep\00", [4 x i8] c"Okt\00", [4 x i8] c"Nov\00", [4 x i8] c"Dez\00", [4 x i8] c"Jan\00", [4 x i8] c"Fev\00", [4 x i8] c"Mar\00", [4 x i8] c"Avr\00", [4 x i8] c"Mai\00", [4 x i8] c"Jun\00", [4 x i8] c"Jul\00", [4 x i8] c"Aou\00", [4 x i8] c"Sep\00", [4 x i8] c"Oct\00", [4 x i8] c"Nov\00", [4 x i8] c"Dec\00"], [48 x [4 x i8]] [[4 x i8] c"N\00\00\00", [4 x i8] c"NNE\00", [4 x i8] c"NE\00\00", [4 x i8] c"ENE\00", [4 x i8] c"E\00\00\00", [4 x i8] c"ESE\00", [4 x i8] c"SE\00\00", [4 x i8] c"SSE\00", [4 x i8] c"S\00\00\00", [4 x i8] c"SSW\00", [4 x i8] c"SW\00\00", [4 x i8] c"WSW\00", [4 x i8] c"W\00\00\00", [4 x i8] c"WNW\00", [4 x i8] c"NW\00\00", [4 x i8] c"NNW\00", [4 x i8] c"N\00\00\00", [4 x i8] c"NNO\00", [4 x i8] c"NO\00\00", [4 x i8] c"ONO\00", [4 x i8] c"O\00\00\00", [4 x i8] c"OSO\00", [4 x i8] c"SO\00\00", [4 x i8] c"SSO\00", [4 x i8] c"S\00\00\00", [4 x i8] c"SSW\00", [4 x i8] c"SW\00\00", [4 x i8] c"WSW\00", [4 x i8] c"W\00\00\00", [4 x i8] c"WNW\00", [4 x i8] c"NW\00\00", [4 x i8] c"NNW\00", [4 x i8] c"N\00\00\00", [4 x i8] c"NNO\00", [4 x i8] c"NO\00\00", [4 x i8] c"ONO\00", [4 x i8] c"O\00\00\00", [4 x i8] c"OSO\00", [4 x i8] c"SO\00\00", [4 x i8] c"SSO\00", [4 x i8] c"S\00\00\00", [4 x i8] c"SSW\00", [4 x i8] c"SW\00\00", [4 x i8] c"WSW\00", [4 x i8] c"W\00\00\00", [4 x i8] c"WNW\00", [4 x i8] c"NW\00\00", [4 x i8] c"NNW\00"] }, section "var-$RUSTY$x:r7i16i16as8u11as8u3as8u11as8u4as8u4" +@__CONSTANTS_LANGUAGE__init = unnamed_addr constant %CONSTANTS_LANGUAGE { i16 1, i16 3, [21 x [11 x i8]] [[11 x i8] c"Monday\00\00\00\00\00", [11 x i8] c"Tuesday\00\00\00\00", [11 x i8] c"Wednesday\00\00", [11 x i8] c"Thursday\00\00\00", [11 x i8] c"Friday\00\00\00\00\00", [11 x i8] c"Saturday\00\00\00", [11 x i8] c"Sunday\00\00\00\00\00", [11 x i8] c"Montag\00\00\00\00\00", [11 x i8] c"Dienstag\00\00\00", [11 x i8] c"Mittwoch\00\00\00", [11 x i8] c"Donnerstag\00", [11 x i8] c"Freitag\00\00\00\00", [11 x i8] c"Samstag\00\00\00\00", [11 x i8] c"Sonntag\00\00\00\00", [11 x i8] c"Lundi\00\00\00\00\00\00", [11 x i8] c"Mardi\00\00\00\00\00\00", [11 x i8] c"Mercredi\00\00\00", [11 x i8] c"Jeudi\00\00\00\00\00\00", [11 x i8] c"Vendredi\00\00\00", [11 x i8] c"Samedi\00\00\00\00\00", [11 x i8] c"Dimanche\00\00\00"], [21 x [3 x i8]] [[3 x i8] c"Mo\00", [3 x i8] c"Tu\00", [3 x i8] c"We\00", [3 x i8] c"Th\00", [3 x i8] c"Fr\00", [3 x i8] c"Sa\00", [3 x i8] c"Su\00", [3 x i8] c"Mo\00", [3 x i8] c"Di\00", [3 x i8] c"Mi\00", [3 x i8] c"Do\00", [3 x i8] c"Fr\00", [3 x i8] c"Sa\00", [3 x i8] c"So\00", [3 x i8] c"Lu\00", [3 x i8] c"Ma\00", [3 x i8] c"Me\00", [3 x i8] c"Je\00", [3 x i8] c"Ve\00", [3 x i8] c"Sa\00", [3 x i8] c"Di\00"], [36 x [11 x i8]] [[11 x i8] c"January\00\00\00\00", [11 x i8] c"February\00\00\00", [11 x i8] c"March\00\00\00\00\00\00", [11 x i8] c"April\00\00\00\00\00\00", [11 x i8] c"May\00\00\00\00\00\00\00\00", [11 x i8] c"June\00\00\00\00\00\00\00", [11 x i8] c"July\00\00\00\00\00\00\00", [11 x i8] c"August\00\00\00\00\00", [11 x i8] c"September\00\00", [11 x i8] c"October\00\00\00\00", [11 x i8] c"November\00\00\00", [11 x i8] c"December\00\00\00", [11 x i8] c"Januar\00\00\00\00\00", [11 x i8] c"Februar\00\00\00\00", [11 x i8] c"M\C3\A4rz\00\00\00\00\00\00", [11 x i8] c"April\00\00\00\00\00\00", [11 x i8] c"Mai\00\00\00\00\00\00\00\00", [11 x i8] c"Juni\00\00\00\00\00\00\00", [11 x i8] c"Juli\00\00\00\00\00\00\00", [11 x i8] c"August\00\00\00\00\00", [11 x i8] c"September\00\00", [11 x i8] c"Oktober\00\00\00\00", [11 x i8] c"November\00\00\00", [11 x i8] c"Dezember\00\00\00", [11 x i8] c"Janvier\00\00\00\00", [11 x i8] c"F\C3\A9vrier\00\00\00", [11 x i8] c"mars\00\00\00\00\00\00\00", [11 x i8] c"Avril\00\00\00\00\00\00", [11 x i8] c"Mai\00\00\00\00\00\00\00\00", [11 x i8] c"Juin\00\00\00\00\00\00\00", [11 x i8] c"Juillet\00\00\00\00", [11 x i8] c"Ao\C3\BBt\00\00\00\00\00\00", [11 x i8] c"Septembre\00\00", [11 x i8] c"Octobre\00\00\00\00", [11 x i8] c"Novembre\00\00\00", [11 x i8] c"Decembre\00\00\00"], [36 x [4 x i8]] [[4 x i8] c"Jan\00", [4 x i8] c"Feb\00", [4 x i8] c"Mar\00", [4 x i8] c"Apr\00", [4 x i8] c"May\00", [4 x i8] c"Jun\00", [4 x i8] c"Jul\00", [4 x i8] c"Aug\00", [4 x i8] c"Sep\00", [4 x i8] c"Oct\00", [4 x i8] c"Nov\00", [4 x i8] c"Dec\00", [4 x i8] c"Jan\00", [4 x i8] c"Feb\00", [4 x i8] c"Mrz\00", [4 x i8] c"Apr\00", [4 x i8] c"Mai\00", [4 x i8] c"Jun\00", [4 x i8] c"Jul\00", [4 x i8] c"Aug\00", [4 x i8] c"Sep\00", [4 x i8] c"Okt\00", [4 x i8] c"Nov\00", [4 x i8] c"Dez\00", [4 x i8] c"Jan\00", [4 x i8] c"Fev\00", [4 x i8] c"Mar\00", [4 x i8] c"Avr\00", [4 x i8] c"Mai\00", [4 x i8] c"Jun\00", [4 x i8] c"Jul\00", [4 x i8] c"Aou\00", [4 x i8] c"Sep\00", [4 x i8] c"Oct\00", [4 x i8] c"Nov\00", [4 x i8] c"Dec\00"], [48 x [4 x i8]] [[4 x i8] c"N\00\00\00", [4 x i8] c"NNE\00", [4 x i8] c"NE\00\00", [4 x i8] c"ENE\00", [4 x i8] c"E\00\00\00", [4 x i8] c"ESE\00", [4 x i8] c"SE\00\00", [4 x i8] c"SSE\00", [4 x i8] c"S\00\00\00", [4 x i8] c"SSW\00", [4 x i8] c"SW\00\00", [4 x i8] c"WSW\00", [4 x i8] c"W\00\00\00", [4 x i8] c"WNW\00", [4 x i8] c"NW\00\00", [4 x i8] c"NNW\00", [4 x i8] c"N\00\00\00", [4 x i8] c"NNO\00", [4 x i8] c"NO\00\00", [4 x i8] c"ONO\00", [4 x i8] c"O\00\00\00", [4 x i8] c"OSO\00", [4 x i8] c"SO\00\00", [4 x i8] c"SSO\00", [4 x i8] c"S\00\00\00", [4 x i8] c"SSW\00", [4 x i8] c"SW\00\00", [4 x i8] c"WSW\00", [4 x i8] c"W\00\00\00", [4 x i8] c"WNW\00", [4 x i8] c"NW\00\00", [4 x i8] c"NNW\00", [4 x i8] c"N\00\00\00", [4 x i8] c"NNO\00", [4 x i8] c"NO\00\00", [4 x i8] c"ONO\00", [4 x i8] c"O\00\00\00", [4 x i8] c"OSO\00", [4 x i8] c"SO\00\00", [4 x i8] c"SSO\00", [4 x i8] c"S\00\00\00", [4 x i8] c"SSW\00", [4 x i8] c"SW\00\00", [4 x i8] c"WSW\00", [4 x i8] c"W\00\00\00", [4 x i8] c"WNW\00", [4 x i8] c"NW\00\00", [4 x i8] c"NNW\00"] }, section "var-$RUSTY$__CONSTANTS_LANGUAGE__init:r7i16i16as8u11as8u3as8u11as8u4as8u4" diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__string_tests__program_string_output.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__string_tests__program_string_output.snap index a85faa2de55..3968ed43062 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__string_tests__program_string_output.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__string_tests__program_string_output.snap @@ -8,12 +8,12 @@ source_filename = "main" %prog = type { [81 x i8], [81 x i16] } %main = type { [7 x i8], [8 x i16] } -@prog_instance = global %prog zeroinitializer -@main_instance = global %main zeroinitializer +@prog_instance = global %prog zeroinitializer, section "var-$RUSTY$prog_instance:r2s8u81s16u81" +@main_instance = global %main zeroinitializer, section "var-$RUSTY$main_instance:r2s8u7s16u8" @utf08_literal_0 = private unnamed_addr constant [7 x i8] c"string\00" @utf16_literal_0 = private unnamed_addr constant [8 x i16] [i16 119, i16 115, i16 116, i16 114, i16 105, i16 110, i16 103, i16 0] -define void @prog(%prog* %0) section "fn-prog:v[s8u81][s16u81]" { +define void @prog(%prog* %0) section "fn-$RUSTY$prog:v[s8u81][s16u81]" { entry: %output1 = getelementptr inbounds %prog, %prog* %0, i32 0, i32 0 %output2 = getelementptr inbounds %prog, %prog* %0, i32 0, i32 1 @@ -24,7 +24,7 @@ entry: ret void } -define void @main(%main* %0) section "fn-main:v" { +define void @main(%main* %0) section "fn-$RUSTY$main:v" { entry: %x = getelementptr inbounds %main, %main* %0, i32 0, i32 0 %y = getelementptr inbounds %main, %main* %0, i32 0, i32 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__string_tests__program_with_casted_string_assignment.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__string_tests__program_with_casted_string_assignment.snap index 3a57950c3bb..3f2af07b08b 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__string_tests__program_with_casted_string_assignment.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__string_tests__program_with_casted_string_assignment.snap @@ -7,13 +7,13 @@ source_filename = "main" %prg = type { [81 x i8], [81 x i16] } -@prg_instance = global %prg zeroinitializer +@prg_instance = global %prg zeroinitializer, section "var-$RUSTY$prg_instance:r2s8u81s16u81" @utf08_literal_0 = private unnamed_addr constant [12 x i8] c"im a genius\00" @utf08_literal_1 = private unnamed_addr constant [18 x i8] c"im a utf16 genius\00" @utf16_literal_0 = private unnamed_addr constant [12 x i16] [i16 105, i16 109, i16 32, i16 97, i16 32, i16 103, i16 101, i16 110, i16 105, i16 117, i16 115, i16 0] @utf16_literal_1 = private unnamed_addr constant [18 x i16] [i16 105, i16 109, i16 32, i16 97, i16 32, i16 117, i16 116, i16 102, i16 49, i16 54, i16 32, i16 103, i16 101, i16 110, i16 105, i16 117, i16 115, i16 0] -define void @prg(%prg* %0) section "fn-prg:v" { +define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: %y = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 %z = getelementptr inbounds %prg, %prg* %0, i32 0, i32 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__string_tests__program_with_string_type_assignment.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__string_tests__program_with_string_type_assignment.snap index bef912eb1d3..73237fe8e02 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__string_tests__program_with_string_type_assignment.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__string_tests__program_with_string_type_assignment.snap @@ -7,14 +7,14 @@ source_filename = "main" %prg = type { [81 x i8], [100 x i8], [100 x i16] } -@prg_instance = global %prg { [81 x i8] zeroinitializer, [100 x i8] c"abc\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00", [100 x i16] [i16 97, i16 98, i16 99, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0] } -@__MyString__init = unnamed_addr constant [100 x i8] c"abc\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00" -@__MyWString__init = unnamed_addr constant [100 x i16] [i16 97, i16 98, i16 99, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0] +@prg_instance = global %prg { [81 x i8] zeroinitializer, [100 x i8] c"abc\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00", [100 x i16] [i16 97, i16 98, i16 99, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0] }, section "var-$RUSTY$prg_instance:r3s8u81s8u100s16u100" +@__MyString__init = unnamed_addr constant [100 x i8] c"abc\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00", section "var-$RUSTY$__MyString__init:s8u100" +@__MyWString__init = unnamed_addr constant [100 x i16] [i16 97, i16 98, i16 99, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0], section "var-$RUSTY$__MyWString__init:s16u100" @utf08_literal_0 = private unnamed_addr constant [12 x i8] c"im a genius\00" @utf08_literal_1 = private unnamed_addr constant [17 x i8] c"im also a genius\00" @utf16_literal_0 = private unnamed_addr constant [17 x i16] [i16 105, i16 109, i16 32, i16 97, i16 108, i16 115, i16 111, i16 32, i16 97, i16 32, i16 103, i16 101, i16 110, i16 105, i16 117, i16 115, i16 0] -define void @prg(%prg* %0) section "fn-prg:v" { +define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: %y = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 %z = getelementptr inbounds %prg, %prg* %0, i32 0, i32 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__string_tests__simple_string_test.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__string_tests__simple_string_test.snap index 8b1a844a790..942e6e48077 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__string_tests__simple_string_test.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__string_tests__simple_string_test.snap @@ -1,11 +1,9 @@ --- source: src/codegen/tests/string_tests.rs expression: result - --- ; ModuleID = 'main' source_filename = "main" -@str = global [21 x i8] zeroinitializer -@wstr = global [21 x i16] zeroinitializer - +@str = global [21 x i8] zeroinitializer, section "var-$RUSTY$str:s8u21" +@wstr = global [21 x i16] zeroinitializer, section "var-$RUSTY$wstr:s16u21" diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__string_tests__string_function_parameters.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__string_tests__string_function_parameters.snap index 29b9c8ae6a4..763d82a4f85 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__string_tests__string_function_parameters.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__string_tests__string_function_parameters.snap @@ -7,11 +7,11 @@ source_filename = "main" %prg = type { [11 x i8], [81 x i8] } -@prg_instance = global %prg { [11 x i8] c"hello\00\00\00\00\00\00", [81 x i8] zeroinitializer } +@prg_instance = global %prg { [11 x i8] c"hello\00\00\00\00\00\00", [81 x i8] zeroinitializer }, section "var-$RUSTY$prg_instance:r2s8u11s8u81" @__prg.s__init = unnamed_addr constant [11 x i8] c"hello\00\00\00\00\00\00" @utf08_literal_0 = private unnamed_addr constant [6 x i8] c"hello\00" -define i16 @foo(i8* %0) section "fn-foo:i16[s8u81]" { +define i16 @foo(i8* %0) section "fn-$RUSTY$foo:i16[s8u81]" { entry: %foo = alloca i16, align 2 %s = alloca [81 x i8], align 1 @@ -27,7 +27,7 @@ buffer_block: ; No predecessors! ret i16 %foo_ret1 } -define void @prg(%prg* %0) section "fn-prg:v" { +define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: %s = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 %a = getelementptr inbounds %prg, %prg* %0, i32 0, i32 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__string_tests__using_a_constant_var_string_should_be_memcpyable.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__string_tests__using_a_constant_var_string_should_be_memcpyable.snap index 16bcbdf9adc..b12538dbe8d 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__string_tests__using_a_constant_var_string_should_be_memcpyable.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__string_tests__using_a_constant_var_string_should_be_memcpyable.snap @@ -8,7 +8,7 @@ source_filename = "main" @__FSTRING_TO_DT.ignore__init = unnamed_addr constant [2 x i8] c"*\00" @__FSTRING_TO_DT.fchar__init = unnamed_addr constant [2 x i8] c"#\00" -define i8 @STRING_EQUAL(i8* %0, i8* %1) section "fn-STRING_EQUAL:u8[ps8u1025][ps8u1025]" { +define i8 @STRING_EQUAL(i8* %0, i8* %1) section "fn-$RUSTY$STRING_EQUAL:u8[ps8u1025][ps8u1025]" { entry: %STRING_EQUAL = alloca i8, align 1 %op1 = alloca i8*, align 8 @@ -20,7 +20,7 @@ entry: ret i8 %STRING_EQUAL_ret } -define i64 @FSTRING_TO_DT() section "fn-FSTRING_TO_DT:v" { +define i64 @FSTRING_TO_DT() section "fn-$RUSTY$FSTRING_TO_DT:i64" { entry: %FSTRING_TO_DT = alloca i64, align 8 %ignore = alloca [2 x i8], align 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__string_tests__using_a_constant_var_string_should_be_memcpyable_nonref.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__string_tests__using_a_constant_var_string_should_be_memcpyable_nonref.snap index 4c7455e8c09..e9582efb1b9 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__string_tests__using_a_constant_var_string_should_be_memcpyable_nonref.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__string_tests__using_a_constant_var_string_should_be_memcpyable_nonref.snap @@ -8,7 +8,7 @@ source_filename = "main" @__FSTRING_TO_DT.ignore__init = unnamed_addr constant [2 x i8] c"*\00" @__FSTRING_TO_DT.fchar__init = unnamed_addr constant [2 x i8] c"#\00" -define i8 @STRING_EQUAL(i8* %0, i8* %1) section "fn-STRING_EQUAL:u8[s8u1025][s8u1025]" { +define i8 @STRING_EQUAL(i8* %0, i8* %1) section "fn-$RUSTY$STRING_EQUAL:u8[s8u1025][s8u1025]" { entry: %STRING_EQUAL = alloca i8, align 1 %op1 = alloca [1025 x i8], align 1 @@ -24,7 +24,7 @@ entry: ret i8 %STRING_EQUAL_ret } -define i64 @FSTRING_TO_DT() section "fn-FSTRING_TO_DT:v" { +define i64 @FSTRING_TO_DT() section "fn-$RUSTY$FSTRING_TO_DT:i64" { entry: %FSTRING_TO_DT = alloca i64, align 8 %ignore = alloca [2 x i8], align 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__string_tests__variable_length_strings_can_be_created.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__string_tests__variable_length_strings_can_be_created.snap index 3f72b2b1ffa..f8a29a88a09 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__string_tests__variable_length_strings_can_be_created.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__string_tests__variable_length_strings_can_be_created.snap @@ -7,13 +7,13 @@ source_filename = "main" %prg = type { [16 x i8], [4 x i8], [16 x i16], [4 x i16] } -@prg_instance = global %prg { [16 x i8] zeroinitializer, [4 x i8] c"xyz\00", [16 x i16] zeroinitializer, [4 x i16] [i16 120, i16 121, i16 122, i16 0] } +@prg_instance = global %prg { [16 x i8] zeroinitializer, [4 x i8] c"xyz\00", [16 x i16] zeroinitializer, [4 x i16] [i16 120, i16 121, i16 122, i16 0] }, section "var-$RUSTY$prg_instance:r4s8u16s8u4s16u16s16u4" @__prg.z__init = unnamed_addr constant [4 x i8] c"xyz\00" @__prg.wz__init = unnamed_addr constant [4 x i16] [i16 120, i16 121, i16 122, i16 0] @utf08_literal_0 = private unnamed_addr constant [12 x i8] c"im a genius\00" @utf16_literal_0 = private unnamed_addr constant [12 x i16] [i16 105, i16 109, i16 32, i16 97, i16 32, i16 103, i16 101, i16 110, i16 105, i16 117, i16 115, i16 0] -define void @prg(%prg* %0) section "fn-prg:v" { +define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: %y = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 %z = getelementptr inbounds %prg, %prg* %0, i32 0, i32 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__string_tests__variable_length_strings_using_constants_can_be_created.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__string_tests__variable_length_strings_using_constants_can_be_created.snap index 28e7166105c..c66d927edb0 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__string_tests__variable_length_strings_using_constants_can_be_created.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__string_tests__variable_length_strings_using_constants_can_be_created.snap @@ -7,15 +7,15 @@ source_filename = "main" %prg = type { [16 x i8], [4 x i8], [31 x i16], [7 x i16] } -@LONG_STRING = unnamed_addr constant i16 15 -@SHORT_STRING = unnamed_addr constant i16 3 -@prg_instance = global %prg { [16 x i8] zeroinitializer, [4 x i8] c"xyz\00", [31 x i16] zeroinitializer, [7 x i16] [i16 120, i16 121, i16 122, i16 0, i16 0, i16 0, i16 0] } +@LONG_STRING = unnamed_addr constant i16 15, section "var-$RUSTY$LONG_STRING:i16" +@SHORT_STRING = unnamed_addr constant i16 3, section "var-$RUSTY$SHORT_STRING:i16" +@prg_instance = global %prg { [16 x i8] zeroinitializer, [4 x i8] c"xyz\00", [31 x i16] zeroinitializer, [7 x i16] [i16 120, i16 121, i16 122, i16 0, i16 0, i16 0, i16 0] }, section "var-$RUSTY$prg_instance:r4vvvv" @__prg.z__init = unnamed_addr constant [4 x i8] c"xyz\00" @__prg.wz__init = unnamed_addr constant [7 x i16] [i16 120, i16 121, i16 122, i16 0, i16 0, i16 0, i16 0] @utf08_literal_0 = private unnamed_addr constant [12 x i8] c"im a genius\00" @utf16_literal_0 = private unnamed_addr constant [12 x i16] [i16 105, i16 109, i16 32, i16 97, i16 32, i16 103, i16 101, i16 110, i16 105, i16 117, i16 115, i16 0] -define void @prg(%prg* %0) section "fn-prg:v" { +define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: %y = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 %z = getelementptr inbounds %prg, %prg* %0, i32 0, i32 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__string_tests__variable_string_assignment_test.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__string_tests__variable_string_assignment_test.snap index a9d938e4994..160ce6ed308 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__string_tests__variable_string_assignment_test.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__string_tests__variable_string_assignment_test.snap @@ -7,10 +7,10 @@ source_filename = "main" %prg = type { [16 x i8], [31 x i8] } -@prg_instance = global %prg { [16 x i8] zeroinitializer, [31 x i8] c"xyz\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00" } +@prg_instance = global %prg { [16 x i8] zeroinitializer, [31 x i8] c"xyz\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00" }, section "var-$RUSTY$prg_instance:r2s8u16s8u31" @__prg.z__init = unnamed_addr constant [31 x i8] c"xyz\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00" -define void @prg(%prg* %0) section "fn-prg:v" { +define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: %y = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 %z = getelementptr inbounds %prg, %prg* %0, i32 0, i32 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__string_tests__vartmp_string_init_test.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__string_tests__vartmp_string_init_test.snap index 4fec55113e8..b18d8db47c2 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__string_tests__vartmp_string_init_test.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__string_tests__vartmp_string_init_test.snap @@ -7,10 +7,10 @@ source_filename = "main" %prg = type {} -@prg_instance = global %prg zeroinitializer +@prg_instance = global %prg zeroinitializer, section "var-$RUSTY$prg_instance:r2s8u16s8u31" @__prg.z__init = unnamed_addr constant [31 x i8] c"xyz\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00" -define void @prg(%prg* %0) section "fn-prg:v" { +define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: %y = alloca [16 x i8], align 1 %z = alloca [31 x i8], align 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__typesystem_test__aliased_datatypes_respect_conversion_rules.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__typesystem_test__aliased_datatypes_respect_conversion_rules.snap index d5c05a45978..c5e96b18bdb 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__typesystem_test__aliased_datatypes_respect_conversion_rules.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__typesystem_test__aliased_datatypes_respect_conversion_rules.snap @@ -7,9 +7,9 @@ source_filename = "main" %prg = type { i8, i32, i32 } -@prg_instance = global %prg zeroinitializer +@prg_instance = global %prg zeroinitializer, section "var-$RUSTY$prg_instance:r3i8i32i32" -define void @prg(%prg* %0) section "fn-prg:v" { +define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: %b = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 %c = getelementptr inbounds %prg, %prg* %0, i32 0, i32 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__typesystem_test__datatypes_larger_than_int_promote_the_second_operand.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__typesystem_test__datatypes_larger_than_int_promote_the_second_operand.snap index 404b889c93b..aeb30559df0 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__typesystem_test__datatypes_larger_than_int_promote_the_second_operand.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__typesystem_test__datatypes_larger_than_int_promote_the_second_operand.snap @@ -7,9 +7,9 @@ source_filename = "main" %prg = type { i32, i64, i64 } -@prg_instance = global %prg zeroinitializer +@prg_instance = global %prg zeroinitializer, section "var-$RUSTY$prg_instance:r3i32i64i64" -define void @prg(%prg* %0) section "fn-prg:v" { +define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: %b = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 %c = getelementptr inbounds %prg, %prg* %0, i32 0, i32 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__typesystem_test__datatypes_smaller_than_dint_promoted_to_dint.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__typesystem_test__datatypes_smaller_than_dint_promoted_to_dint.snap index a339a3e731c..9217183a402 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__typesystem_test__datatypes_smaller_than_dint_promoted_to_dint.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__typesystem_test__datatypes_smaller_than_dint_promoted_to_dint.snap @@ -7,9 +7,9 @@ source_filename = "main" %prg = type { i8, i32, i32 } -@prg_instance = global %prg zeroinitializer +@prg_instance = global %prg zeroinitializer, section "var-$RUSTY$prg_instance:r3i8i32i32" -define void @prg(%prg* %0) section "fn-prg:v" { +define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: %b = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 %c = getelementptr inbounds %prg, %prg* %0, i32 0, i32 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__typesystem_test__even_all_sint_expressions_fallback_to_dint.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__typesystem_test__even_all_sint_expressions_fallback_to_dint.snap index 61e0e8aa0be..be13838b668 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__typesystem_test__even_all_sint_expressions_fallback_to_dint.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__typesystem_test__even_all_sint_expressions_fallback_to_dint.snap @@ -7,9 +7,9 @@ source_filename = "main" %prg = type { i8, i8, i8 } -@prg_instance = global %prg zeroinitializer +@prg_instance = global %prg zeroinitializer, section "var-$RUSTY$prg_instance:r3i8i8i8" -define void @prg(%prg* %0) section "fn-prg:v" { +define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: %b = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 %c = getelementptr inbounds %prg, %prg* %0, i32 0, i32 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__typesystem_test__float_and_double_mix_converted_to_double.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__typesystem_test__float_and_double_mix_converted_to_double.snap index 86ba11023ff..3645170b4a1 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__typesystem_test__float_and_double_mix_converted_to_double.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__typesystem_test__float_and_double_mix_converted_to_double.snap @@ -7,9 +7,9 @@ source_filename = "main" %prg = type { float, double, double } -@prg_instance = global %prg zeroinitializer +@prg_instance = global %prg zeroinitializer, section "var-$RUSTY$prg_instance:r3f32f64f64" -define void @prg(%prg* %0) section "fn-prg:v" { +define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: %a = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 %b = getelementptr inbounds %prg, %prg* %0, i32 0, i32 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__typesystem_test__float_assigned_to_int_is_cast.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__typesystem_test__float_assigned_to_int_is_cast.snap index dc8cee115c1..1cc04585f94 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__typesystem_test__float_assigned_to_int_is_cast.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__typesystem_test__float_assigned_to_int_is_cast.snap @@ -7,9 +7,9 @@ source_filename = "main" %prg = type { i16, i16, float } -@prg_instance = global %prg zeroinitializer +@prg_instance = global %prg zeroinitializer, section "var-$RUSTY$prg_instance:r3i16u16f32" -define void @prg(%prg* %0) section "fn-prg:v" { +define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: %a = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 %b = getelementptr inbounds %prg, %prg* %0, i32 0, i32 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__typesystem_test__float_assinged_to_double_to_double.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__typesystem_test__float_assinged_to_double_to_double.snap index 93ff27bfd5f..6f9cd627e60 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__typesystem_test__float_assinged_to_double_to_double.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__typesystem_test__float_assinged_to_double_to_double.snap @@ -7,9 +7,9 @@ source_filename = "main" %prg = type { float, double } -@prg_instance = global %prg zeroinitializer +@prg_instance = global %prg zeroinitializer, section "var-$RUSTY$prg_instance:r2f32f64" -define void @prg(%prg* %0) section "fn-prg:v" { +define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: %a = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 %b = getelementptr inbounds %prg, %prg* %0, i32 0, i32 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__typesystem_test__int_assigned_to_float_is_cast.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__typesystem_test__int_assigned_to_float_is_cast.snap index f46afe08414..a0d78252fef 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__typesystem_test__int_assigned_to_float_is_cast.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__typesystem_test__int_assigned_to_float_is_cast.snap @@ -7,9 +7,9 @@ source_filename = "main" %prg = type { i16, i16, float } -@prg_instance = global %prg zeroinitializer +@prg_instance = global %prg zeroinitializer, section "var-$RUSTY$prg_instance:r3i16u16f32" -define void @prg(%prg* %0) section "fn-prg:v" { +define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: %a = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 %b = getelementptr inbounds %prg, %prg* %0, i32 0, i32 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__typesystem_test__int_bigger_than_byte_promoted_on_compare_statement.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__typesystem_test__int_bigger_than_byte_promoted_on_compare_statement.snap index 261e31be4a6..41368ecbee1 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__typesystem_test__int_bigger_than_byte_promoted_on_compare_statement.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__typesystem_test__int_bigger_than_byte_promoted_on_compare_statement.snap @@ -7,9 +7,9 @@ source_filename = "main" %prg = type { i8, i64 } -@prg_instance = global %prg zeroinitializer +@prg_instance = global %prg zeroinitializer, section "var-$RUSTY$prg_instance:r2u8i64" -define void @prg(%prg* %0) section "fn-prg:v" { +define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: %a = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 %b = getelementptr inbounds %prg, %prg* %0, i32 0, i32 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__typesystem_test__int_bigger_than_float_converted_to_double.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__typesystem_test__int_bigger_than_float_converted_to_double.snap index 7f2f3d41147..5e02bd0f58c 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__typesystem_test__int_bigger_than_float_converted_to_double.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__typesystem_test__int_bigger_than_float_converted_to_double.snap @@ -7,9 +7,9 @@ source_filename = "main" %prg = type { float, i64 } -@prg_instance = global %prg zeroinitializer +@prg_instance = global %prg zeroinitializer, section "var-$RUSTY$prg_instance:r2f32i64" -define void @prg(%prg* %0) section "fn-prg:v" { +define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: %a = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 %b = getelementptr inbounds %prg, %prg* %0, i32 0, i32 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__typesystem_test__int_smaller_or_equal_to_float_converted_to_float.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__typesystem_test__int_smaller_or_equal_to_float_converted_to_float.snap index 70ec2025271..abcb8aca8a7 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__typesystem_test__int_smaller_or_equal_to_float_converted_to_float.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__typesystem_test__int_smaller_or_equal_to_float_converted_to_float.snap @@ -7,9 +7,9 @@ source_filename = "main" %prg = type { float, i16, float } -@prg_instance = global %prg zeroinitializer +@prg_instance = global %prg zeroinitializer, section "var-$RUSTY$prg_instance:r3f32i16f32" -define void @prg(%prg* %0) section "fn-prg:v" { +define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: %a = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 %b = getelementptr inbounds %prg, %prg* %0, i32 0, i32 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__typesystem_test__numerical_promotion_for_variadic_functions_without_declaration.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__typesystem_test__numerical_promotion_for_variadic_functions_without_declaration.snap index 6c790a5b78b..a6c9934fbf1 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__typesystem_test__numerical_promotion_for_variadic_functions_without_declaration.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__typesystem_test__numerical_promotion_for_variadic_functions_without_declaration.snap @@ -7,12 +7,12 @@ source_filename = "main" %main = type {} -@main_instance = global %main zeroinitializer +@main_instance = global %main zeroinitializer, section "var-$RUSTY$main_instance:r4s8u81f32f64i16" @__main.s__init = unnamed_addr constant [81 x i8] c"\0A numbers: %f %f %f %d \0A \0A\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00" -declare i32 @printf(i8*, ...) section "fn-printf:i32[ps8u81]" +declare i32 @printf(i8*, ...) section "fn-$RUSTY$printf:i32[ps8u81]" -define void @main(%main* %0) section "fn-main:v" { +define void @main(%main* %0) section "fn-$RUSTY$main:v" { entry: %s = alloca [81 x i8], align 1 %float = alloca float, align 4 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__typesystem_test__small_int_varargs_get_promoted_while_32bit_and_higher_keep_their_type.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__typesystem_test__small_int_varargs_get_promoted_while_32bit_and_higher_keep_their_type.snap index 6c986be051c..367285edf78 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__typesystem_test__small_int_varargs_get_promoted_while_32bit_and_higher_keep_their_type.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__typesystem_test__small_int_varargs_get_promoted_while_32bit_and_higher_keep_their_type.snap @@ -8,9 +8,9 @@ source_filename = "main" @utf08_literal_0 = private unnamed_addr constant [26 x i8] c"(d) result : %d %d %d %u\0A\00" @utf08_literal_1 = private unnamed_addr constant [27 x i8] c"(hd) result : %hd %hd %hd\0A\00" -declare i32 @printf(i8*, ...) section "fn-printf:i32[ps8u81]" +declare i32 @printf(i8*, ...) section "fn-$RUSTY$printf:i32[ps8u81]" -define i32 @main() section "fn-main:i32" { +define i32 @main() section "fn-$RUSTY$main:i32" { entry: %main = alloca i32, align 4 %out1 = alloca i16, align 2 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__typesystem_test__unsingned_datatypes_smaller_than_dint_promoted_to_dint.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__typesystem_test__unsingned_datatypes_smaller_than_dint_promoted_to_dint.snap index d7d78e7b45e..f7c53cabc40 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__typesystem_test__unsingned_datatypes_smaller_than_dint_promoted_to_dint.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__typesystem_test__unsingned_datatypes_smaller_than_dint_promoted_to_dint.snap @@ -7,9 +7,9 @@ source_filename = "main" %prg = type { i8, i32, i32 } -@prg_instance = global %prg zeroinitializer +@prg_instance = global %prg zeroinitializer, section "var-$RUSTY$prg_instance:r3u8i32i32" -define void @prg(%prg* %0) section "fn-prg:v" { +define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: %b = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 %c = getelementptr inbounds %prg, %prg* %0, i32 0, i32 1 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__vla_tests__consecutive_calls_with_differently_sized_arrays.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__vla_tests__consecutive_calls_with_differently_sized_arrays.snap index 4681fafeb19..7517e8f8193 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__vla_tests__consecutive_calls_with_differently_sized_arrays.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__vla_tests__consecutive_calls_with_differently_sized_arrays.snap @@ -7,9 +7,9 @@ source_filename = "main" %__foo_vla = type { i16*, [4 x i32] } -@____foo_vla__init = unnamed_addr constant %__foo_vla zeroinitializer +@____foo_vla__init = unnamed_addr constant %__foo_vla zeroinitializer, section "var-$RUSTY$____foo_vla__init:r2pai16ai32" -define i16 @foo(%__foo_vla* %0) section "fn-foo:i16[v]" { +define i16 @foo(%__foo_vla* %0) section "fn-$RUSTY$foo:i16[r2pai16ai32]" { entry: %foo = alloca i16, align 2 %vla = alloca %__foo_vla, align 8 @@ -57,7 +57,7 @@ entry: ret i16 %foo_ret } -define i32 @main() section "fn-main:i32" { +define i32 @main() section "fn-$RUSTY$main:i32" { entry: %main = alloca i32, align 4 %arr = alloca [60 x i16], align 2 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__vla_tests__global_variable_passed_to_function_as_vla.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__vla_tests__global_variable_passed_to_function_as_vla.snap index 71d8b1c3389..188e363617b 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__vla_tests__global_variable_passed_to_function_as_vla.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__vla_tests__global_variable_passed_to_function_as_vla.snap @@ -7,10 +7,10 @@ source_filename = "main" %__foo_vla = type { i16*, [2 x i32] } -@arr = global [2 x i16] zeroinitializer -@____foo_vla__init = unnamed_addr constant %__foo_vla zeroinitializer +@arr = global [2 x i16] zeroinitializer, section "var-$RUSTY$arr:ai16" +@____foo_vla__init = unnamed_addr constant %__foo_vla zeroinitializer, section "var-$RUSTY$____foo_vla__init:r2pai16ai32" -define i16 @foo(%__foo_vla* %0) section "fn-foo:i16[v]" { +define i16 @foo(%__foo_vla* %0) section "fn-$RUSTY$foo:i16[r2pai16ai32]" { entry: %foo = alloca i16, align 2 %vla = alloca %__foo_vla, align 8 @@ -32,7 +32,7 @@ entry: ret i16 %foo_ret } -define i32 @main() section "fn-main:i32" { +define i32 @main() section "fn-$RUSTY$main:i32" { entry: %main = alloca i32, align 4 store i32 0, i32* %main, align 4 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__vla_tests__internal_vla_struct_is_generated_for_call_statements.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__vla_tests__internal_vla_struct_is_generated_for_call_statements.snap index 2c464533af1..d7cf5af6d39 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__vla_tests__internal_vla_struct_is_generated_for_call_statements.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__vla_tests__internal_vla_struct_is_generated_for_call_statements.snap @@ -7,9 +7,9 @@ source_filename = "main" %__foo_vla = type { i16*, [2 x i32] } -@____foo_vla__init = unnamed_addr constant %__foo_vla zeroinitializer +@____foo_vla__init = unnamed_addr constant %__foo_vla zeroinitializer, section "var-$RUSTY$____foo_vla__init:r2pai16ai32" -define void @foo(%__foo_vla* %0) section "fn-foo:v[v]" { +define void @foo(%__foo_vla* %0) section "fn-$RUSTY$foo:v[r2pai16ai32]" { entry: %vla = alloca %__foo_vla, align 8 %1 = bitcast %__foo_vla* %vla to i8* @@ -18,7 +18,7 @@ entry: ret void } -define void @bar() section "fn-bar:v" { +define void @bar() section "fn-$RUSTY$bar:v" { entry: %arr = alloca [2 x i16], align 2 %0 = bitcast [2 x i16]* %arr to i8* diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__vla_tests__multi_dimensional_vla.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__vla_tests__multi_dimensional_vla.snap index 339ee6d6d3e..2d4e774ca82 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__vla_tests__multi_dimensional_vla.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__vla_tests__multi_dimensional_vla.snap @@ -7,9 +7,9 @@ source_filename = "main" %__foo_vla = type { i16*, [4 x i32] } -@____foo_vla__init = unnamed_addr constant %__foo_vla zeroinitializer +@____foo_vla__init = unnamed_addr constant %__foo_vla zeroinitializer, section "var-$RUSTY$____foo_vla__init:r2pai16ai32" -define i16 @foo(%__foo_vla* %0) section "fn-foo:i16[v]" { +define i16 @foo(%__foo_vla* %0) section "fn-$RUSTY$foo:i16[r2pai16ai32]" { entry: %foo = alloca i16, align 2 %vla = alloca %__foo_vla, align 8 @@ -57,7 +57,7 @@ entry: ret i16 %foo_ret } -define i32 @main() section "fn-main:i32" { +define i32 @main() section "fn-$RUSTY$main:i32" { entry: %main = alloca i32, align 4 %arr = alloca [20 x i16], align 2 diff --git a/src/codegen/tests/snapshots/rusty__codegen__tests__vla_tests__vla_read_access.snap b/src/codegen/tests/snapshots/rusty__codegen__tests__vla_tests__vla_read_access.snap index a804f6e0897..8ec1aaee735 100644 --- a/src/codegen/tests/snapshots/rusty__codegen__tests__vla_tests__vla_read_access.snap +++ b/src/codegen/tests/snapshots/rusty__codegen__tests__vla_tests__vla_read_access.snap @@ -7,9 +7,9 @@ source_filename = "main" %__foo_vla = type { i16*, [2 x i32] } -@____foo_vla__init = unnamed_addr constant %__foo_vla zeroinitializer +@____foo_vla__init = unnamed_addr constant %__foo_vla zeroinitializer, section "var-$RUSTY$____foo_vla__init:r2pai16ai32" -define i16 @foo(%__foo_vla* %0) section "fn-foo:i16[v]" { +define i16 @foo(%__foo_vla* %0) section "fn-$RUSTY$foo:i16[r2pai16ai32]" { entry: %foo = alloca i16, align 2 %vla = alloca %__foo_vla, align 8 @@ -32,7 +32,7 @@ entry: ret i16 %foo_ret } -define i32 @main() section "fn-main:i32" { +define i32 @main() section "fn-$RUSTY$main:i32" { entry: %main = alloca i32, align 4 %arr = alloca [2 x i16], align 2 diff --git a/src/codegen/tests/statement_codegen_test.rs b/src/codegen/tests/statement_codegen_test.rs index b4dd2e88cab..5b627712f30 100644 --- a/src/codegen/tests/statement_codegen_test.rs +++ b/src/codegen/tests/statement_codegen_test.rs @@ -1,3 +1,5 @@ +use insta::assert_snapshot; + // Copyright (c) 2020 Ghaith Hachem and Mathias Rieder use crate::test_utils::tests::codegen; @@ -184,3 +186,184 @@ fn floating_point_type_casting() { insta::assert_snapshot!(result); } + +#[test] +fn ref_assignment() { + let result = codegen( + r#" + FUNCTION main + VAR + a : REF_TO DINT; + b : DINT; + END_VAR + a REF= b; + END_PROGRAM + "#, + ); + + insta::assert_snapshot!(result, @r###" + ; ModuleID = 'main' + source_filename = "main" + + define void @main() section "fn-$RUSTY$main:v" { + entry: + %a = alloca i32*, align 8 + %b = alloca i32, align 4 + store i32* null, i32** %a, align 8 + store i32 0, i32* %b, align 4 + store i32* %b, i32** %a, align 8 + ret void + } + "###); +} + +#[test] +fn reference_to_assignment() { + let auto_deref = codegen( + r#" + FUNCTION main + VAR + a : REFERENCE TO DINT; + END_VAR + a := 5; + END_FUNCTION + "#, + ); + + let manual_deref = codegen( + r#" + FUNCTION main + VAR + a : REF_TO DINT; + END_VAR + a^ := 5; + END_FUNCTION + "#, + ); + + // We want to assert that `a := 5` and `a^ := 5` yield identical IR + assert_eq!(auto_deref, manual_deref); + + insta::assert_snapshot!(auto_deref, @r###" + ; ModuleID = 'main' + source_filename = "main" + + define void @main() section "fn-$RUSTY$main:v" { + entry: + %a = alloca i32*, align 8 + store i32* null, i32** %a, align 8 + %deref = load i32*, i32** %a, align 8 + store i32 5, i32* %deref, align 4 + ret void + } + "###); +} + +#[test] +fn reference_to_string_assignment() { + let auto_deref = codegen( + r#" + FUNCTION main + VAR + a : REFERENCE TO STRING; + END_VAR + + a := 'hello'; + END_FUNCTION + "#, + ); + + let manual_deref = codegen( + r#" + FUNCTION main + VAR + a : REF_TO STRING; + END_VAR + + a^ := 'hello'; + END_FUNCTION + "#, + ); + + // We want to assert that `a := 'hello'` and `a^ := 'hello'` yield identical IR + assert_eq!(auto_deref, manual_deref); + + insta::assert_snapshot!(auto_deref, @r###" + ; ModuleID = 'main' + source_filename = "main" + + @utf08_literal_0 = private unnamed_addr constant [6 x i8] c"hello\00" + + define void @main() section "fn-$RUSTY$main:v" { + entry: + %a = alloca [81 x i8]*, align 8 + store [81 x i8]* null, [81 x i8]** %a, align 8 + %deref = load [81 x i8]*, [81 x i8]** %a, align 8 + %0 = bitcast [81 x i8]* %deref to i8* + call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %0, i8* align 1 getelementptr inbounds ([6 x i8], [6 x i8]* @utf08_literal_0, i32 0, i32 0), i32 6, i1 false) + ret void + } + + ; Function Attrs: argmemonly nofree nounwind willreturn + declare void @llvm.memcpy.p0i8.p0i8.i32(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i32, i1 immarg) #0 + + attributes #0 = { argmemonly nofree nounwind willreturn } + "###); +} + +#[test] +#[ignore = "Not working because of REF(...) initializer; should be resolved with https://github.com/PLC-lang/rusty/pull/1259"] +fn alias_dint() { + let content = codegen( + r#" + FUNCTION main + VAR + foo AT bar : DINT; + bar : DINT; + END_VAR + END_FUNCTION + "#, + ); + + assert_snapshot!(content, @r""); +} + +#[test] +#[ignore = "Not working because of REF(...) initializer; should be resolved with https://github.com/PLC-lang/rusty/pull/1259"] +fn alias_string() { + let content = codegen( + r#" + FUNCTION main + VAR + foo AT bar : STRING; + bar : STRING; + END_VAR + END_FUNCTION + "#, + ); + + assert_snapshot!(content, @r""); +} + +#[test] +#[ignore = "Not working because of REF(...) initializer; should be resolved with https://github.com/PLC-lang/rusty/pull/1259"] +fn alias_struct() { + let content = codegen( + r#" + TYPE Node : STRUCT + id : DINT; + child : REF_TO Node; + parent : REF_TO Node; + END_STRUCT END_TYPE + + FUNCTION main + VAR + foo AT bar : STRING; + bar : STRING; + END_VAR + END_FUNCTION + "#, + ); + + assert_snapshot!(content, @r""); +} diff --git a/src/index.rs b/src/index.rs index 0370ce073a5..474217b6620 100644 --- a/src/index.rs +++ b/src/index.rs @@ -347,6 +347,12 @@ pub enum VariableType { Return, } +impl VariableType { + pub fn is_output(&self) -> bool { + matches!(self, VariableType::Output) + } +} + impl std::fmt::Display for VariableType { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { @@ -1124,6 +1130,7 @@ impl Index { if segments.is_empty() { return None; } + //For the first element, if the context does not contain that element, it is possible that the element is also a global variable let init = match context { Some(context) => self @@ -1199,6 +1206,10 @@ impl Index { .collect::>() } + pub fn has_variadic_parameter(&self, pou_name: &str) -> bool { + self.get_pou_members(pou_name).iter().any(|member| member.is_parameter() && member.is_variadic()) + } + /// returns some if the current index is a VAR_INPUT, VAR_IN_OUT or VAR_OUTPUT that is not a variadic argument /// In other words it returns some if the member variable at `index` of the given container is a possible parameter in /// the call to it diff --git a/src/index/tests/index_tests.rs b/src/index/tests/index_tests.rs index b9dc72dc62f..7b1d2e4d081 100644 --- a/src/index/tests/index_tests.rs +++ b/src/index/tests/index_tests.rs @@ -1,7 +1,8 @@ // Copyright (c) 2020 Ghaith Hachem and Mathias Rieder use insta::assert_debug_snapshot; use plc_ast::ast::{ - pre_process, AstFactory, DataType, GenericBinding, LinkageType, Operator, TypeNature, UserTypeDeclaration, + pre_process, AstFactory, AutoDerefType, DataType, GenericBinding, LinkageType, Operator, TypeNature, + UserTypeDeclaration, }; use plc_ast::provider::IdProvider; use plc_source::source_location::{SourceLocation, SourceLocationFactory}; @@ -1252,7 +1253,7 @@ fn pointer_and_in_out_pointer_should_not_conflict() { &DataTypeInformation::Pointer { name: "__main_x".to_string(), inner_type_name: "INT".to_string(), - auto_deref: false, + auto_deref: None, } ); @@ -1263,7 +1264,7 @@ fn pointer_and_in_out_pointer_should_not_conflict() { &DataTypeInformation::Pointer { name: "__auto_pointer_to_INT".to_string(), inner_type_name: "INT".to_string(), - auto_deref: true, + auto_deref: Some(AutoDerefType::Default), } ); } @@ -1302,7 +1303,7 @@ fn pointer_and_in_out_pointer_should_not_conflict_2() { &DataTypeInformation::Pointer { name: "__main_x".to_string(), inner_type_name: "INT".to_string(), - auto_deref: false, + auto_deref: None, } ); @@ -1313,7 +1314,7 @@ fn pointer_and_in_out_pointer_should_not_conflict_2() { &DataTypeInformation::Pointer { name: "__auto_pointer_to_INT".to_string(), inner_type_name: "INT".to_string(), - auto_deref: true, + auto_deref: Some(AutoDerefType::Default), } ); } diff --git a/src/index/tests/snapshots/rusty__index__tests__index_tests__pre_processing_generates_inline_pointer_to_pointer-2.snap b/src/index/tests/snapshots/rusty__index__tests__index_tests__pre_processing_generates_inline_pointer_to_pointer-2.snap index 16bd9f94819..dd220acec73 100644 --- a/src/index/tests/snapshots/rusty__index__tests__index_tests__pre_processing_generates_inline_pointer_to_pointer-2.snap +++ b/src/index/tests/snapshots/rusty__index__tests__index_tests__pre_processing_generates_inline_pointer_to_pointer-2.snap @@ -10,6 +10,7 @@ UserTypeDeclaration { referenced_type: DataTypeReference { referenced_type: "__foo_inline_pointer_", }, + auto_deref: None, }, initializer: None, scope: Some( diff --git a/src/index/tests/snapshots/rusty__index__tests__index_tests__pre_processing_generates_inline_pointer_to_pointer.snap b/src/index/tests/snapshots/rusty__index__tests__index_tests__pre_processing_generates_inline_pointer_to_pointer.snap index 493df6f2fd8..3ce97d31658 100644 --- a/src/index/tests/snapshots/rusty__index__tests__index_tests__pre_processing_generates_inline_pointer_to_pointer.snap +++ b/src/index/tests/snapshots/rusty__index__tests__index_tests__pre_processing_generates_inline_pointer_to_pointer.snap @@ -10,6 +10,7 @@ UserTypeDeclaration { referenced_type: DataTypeReference { referenced_type: "INT", }, + auto_deref: None, }, initializer: None, scope: Some( diff --git a/src/index/tests/snapshots/rusty__index__tests__index_tests__pre_processing_generates_inline_pointers.snap b/src/index/tests/snapshots/rusty__index__tests__index_tests__pre_processing_generates_inline_pointers.snap index e603f07e5d0..582c409f4e3 100644 --- a/src/index/tests/snapshots/rusty__index__tests__index_tests__pre_processing_generates_inline_pointers.snap +++ b/src/index/tests/snapshots/rusty__index__tests__index_tests__pre_processing_generates_inline_pointers.snap @@ -10,6 +10,7 @@ UserTypeDeclaration { referenced_type: DataTypeReference { referenced_type: "INT", }, + auto_deref: None, }, initializer: None, scope: Some( diff --git a/src/index/tests/snapshots/rusty__index__tests__index_tests__pre_processing_generates_pointer_to_pointer_type-2.snap b/src/index/tests/snapshots/rusty__index__tests__index_tests__pre_processing_generates_pointer_to_pointer_type-2.snap index df5d0ae77af..b88ea5be2b0 100644 --- a/src/index/tests/snapshots/rusty__index__tests__index_tests__pre_processing_generates_pointer_to_pointer_type-2.snap +++ b/src/index/tests/snapshots/rusty__index__tests__index_tests__pre_processing_generates_pointer_to_pointer_type-2.snap @@ -10,6 +10,7 @@ UserTypeDeclaration { referenced_type: DataTypeReference { referenced_type: "__pointer_to_pointer", }, + auto_deref: None, }, initializer: None, scope: None, diff --git a/src/index/tests/snapshots/rusty__index__tests__index_tests__pre_processing_generates_pointer_to_pointer_type.snap b/src/index/tests/snapshots/rusty__index__tests__index_tests__pre_processing_generates_pointer_to_pointer_type.snap index f5332a5730d..bbcd573ad6b 100644 --- a/src/index/tests/snapshots/rusty__index__tests__index_tests__pre_processing_generates_pointer_to_pointer_type.snap +++ b/src/index/tests/snapshots/rusty__index__tests__index_tests__pre_processing_generates_pointer_to_pointer_type.snap @@ -10,6 +10,7 @@ UserTypeDeclaration { referenced_type: DataTypeReference { referenced_type: "INT", }, + auto_deref: None, }, initializer: None, scope: None, diff --git a/src/index/visitor.rs b/src/index/visitor.rs index cff5e49e478..04f146031e6 100644 --- a/src/index/visitor.rs +++ b/src/index/visitor.rs @@ -3,9 +3,9 @@ use super::{HardwareBinding, PouIndexEntry, VariableIndexEntry, VariableType}; use crate::index::{ArgumentType, Index, MemberInfo}; use crate::typesystem::{self, *}; use plc_ast::ast::{ - self, ArgumentProperty, Assignment, AstFactory, AstNode, AstStatement, CompilationUnit, DataType, - DataTypeDeclaration, Implementation, Pou, PouType, RangeStatement, TypeNature, UserTypeDeclaration, - Variable, VariableBlock, VariableBlockType, + self, ArgumentProperty, Assignment, AstFactory, AstNode, AstStatement, AutoDerefType, CompilationUnit, + DataType, DataTypeDeclaration, Implementation, Pou, PouType, RangeStatement, TypeNature, + UserTypeDeclaration, Variable, VariableBlock, VariableBlockType, }; use plc_ast::literals::AstLiteral; use plc_diagnostics::diagnostics::Diagnostic; @@ -272,7 +272,7 @@ fn register_byref_pointer_type_for(index: &mut Index, inner_type_name: &str) -> information: DataTypeInformation::Pointer { name: type_name.clone(), inner_type_name: inner_type_name.to_string(), - auto_deref: true, + auto_deref: Some(AutoDerefType::Default), }, nature: TypeNature::Any, location: SourceLocation::internal(), @@ -400,12 +400,12 @@ fn visit_data_type(index: &mut Index, type_declaration: &UserTypeDeclaration) { DataType::ArrayType { name: Some(name), bounds, referenced_type, .. } => { visit_array(bounds, index, scope, referenced_type, name, type_declaration); } - DataType::PointerType { name: Some(name), referenced_type, .. } => { + DataType::PointerType { name: Some(name), referenced_type, auto_deref: kind } => { let inner_type_name = referenced_type.get_name().expect("named datatype"); let information = DataTypeInformation::Pointer { name: name.clone(), inner_type_name: inner_type_name.into(), - auto_deref: false, + auto_deref: *kind, }; let init = index.get_mut_const_expressions().maybe_add_constant_expression( @@ -572,6 +572,7 @@ fn visit_variable_length_array( referenced_type: dummy_array_name, location: SourceLocation::undefined(), }), + auto_deref: None, }, location: SourceLocation::undefined(), scope: None, diff --git a/src/lexer/tokens.rs b/src/lexer/tokens.rs index 02baa2a7e16..d7c72a53944 100644 --- a/src/lexer/tokens.rs +++ b/src/lexer/tokens.rs @@ -159,6 +159,9 @@ pub enum Token { #[token("=>")] KeywordOutputAssignment, + #[token("REF=", ignore(case))] + KeywordReferenceAssignment, + #[token("(")] KeywordParensOpen, @@ -252,6 +255,9 @@ pub enum Token { #[token("REFTO", ignore(case))] KeywordRef, + #[token("REFERENCE TO", ignore(case))] + KeywordReferenceTo, + #[token("ARRAY", ignore(case))] KeywordArray, diff --git a/src/parser.rs b/src/parser.rs index 385322fd281..eae1b9f5778 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -4,8 +4,8 @@ use std::ops::Range; use plc_ast::{ ast::{ - AccessModifier, ArgumentProperty, AstFactory, AstNode, AstStatement, CompilationUnit, DataType, - DataTypeDeclaration, DirectAccessType, GenericBinding, HardwareAccessType, Implementation, + AccessModifier, ArgumentProperty, AstFactory, AstNode, AstStatement, AutoDerefType, CompilationUnit, + DataType, DataTypeDeclaration, DirectAccessType, GenericBinding, HardwareAccessType, Implementation, LinkageType, PolymorphismMode, Pou, PouType, ReferenceAccess, ReferenceExpr, TypeNature, UserTypeDeclaration, Variable, VariableBlock, VariableBlockType, }, @@ -23,7 +23,10 @@ use plc_util::convention::qualified_name; use crate::{ expect_token, - lexer::{self, ParseSession, Token, Token::*}, + lexer::{ + self, ParseSession, + Token::{self, *}, + }, typesystem::DINT_TYPE, }; @@ -676,9 +679,9 @@ fn parse_data_type_definition( if expect_keyword_to(lexer).is_some() { lexer.advance(); } - parse_pointer_definition(lexer, name, start_pos) + parse_pointer_definition(lexer, name, start_pos, None) } else if lexer.try_consume(&KeywordRef) { - parse_pointer_definition(lexer, name, lexer.last_range.start) + parse_pointer_definition(lexer, name, lexer.last_range.start, None) } else if lexer.try_consume(&KeywordParensOpen) { //enum without datatype parse_enum_type_definition(lexer, name) @@ -701,11 +704,12 @@ fn parse_pointer_definition( lexer: &mut ParseSession, name: Option, start_pos: usize, + auto_deref: Option, ) -> Option<(DataTypeDeclaration, Option)> { parse_data_type_definition(lexer, None).map(|(decl, initializer)| { ( DataTypeDeclaration::DataTypeDefinition { - data_type: DataType::PointerType { name, referenced_type: Box::new(decl) }, + data_type: DataType::PointerType { name, referenced_type: Box::new(decl), auto_deref }, location: lexer.source_range_factory.create_range(start_pos..lexer.last_range.end), scope: lexer.scope.clone(), }, @@ -733,7 +737,11 @@ fn parse_type_reference_type_definition( }; let initial_value = - if lexer.try_consume(&KeywordAssignment) { Some(parse_expression(lexer)) } else { None }; + if lexer.try_consume(&KeywordAssignment) || lexer.try_consume(&KeywordReferenceAssignment) { + Some(parse_expression(lexer)) + } else { + None + }; let end = lexer.last_range.end; if name.is_some() || bounds.is_some() { @@ -1064,6 +1072,37 @@ fn parse_variable_list(lexer: &mut ParseSession) -> Vec { variables } +fn parse_aliasing(lexer: &mut ParseSession, names: &(String, Range)) -> Option { + let reference = parse_reference(lexer); + if !lexer.try_consume(&KeywordColon) { + lexer.accept_diagnostic(Diagnostic::missing_token( + format!("{KeywordColon:?}").as_str(), + lexer.location(), + )); + } + + let start = &lexer.location().get_span().to_range().unwrap_or(lexer.last_range.clone()).start; + let datatype = parse_pointer_definition(lexer, None, *start, Some(AutoDerefType::Alias)); + if !lexer.try_consume(&KeywordSemicolon) { + lexer.accept_diagnostic(Diagnostic::missing_token( + format!("{KeywordSemicolon:?}").as_str(), + lexer.location(), + )); + } + + if let Some((data_type, _)) = datatype { + return Some(Variable { + name: names.0.clone(), + data_type_declaration: data_type, + location: lexer.source_range_factory.create_range(names.1.clone()), + initializer: Some(reference), + address: None, + }); + } + + None +} + fn parse_variable_line(lexer: &mut ParseSession) -> Vec { // read in a comma separated list of variable names let mut var_names: Vec<(String, Range)> = vec![]; @@ -1086,16 +1125,27 @@ fn parse_variable_line(lexer: &mut ParseSession) -> Vec { } //See if there's an AT keyword - let address = if lexer.try_consume(&KeywordAt) { - //Look for a hardware address - if let HardwareAccess((direction, access_type)) = lexer.token { - parse_hardware_access(lexer, direction, access_type) - } else { - lexer.accept_diagnostic(Diagnostic::missing_token("Hardware Access", lexer.location())); - None + let mut address: Option = None; + if lexer.try_consume(&KeywordAt) { + match lexer.token { + HardwareAccess((direction, access_type)) => { + address = parse_hardware_access(lexer, direction, access_type) + } + + Identifier => { + return match parse_aliasing(lexer, &var_names[0]) { + Some(aliased_variable) => vec![aliased_variable], + None => vec![], + }; + } + + _ => { + lexer.accept_diagnostic(Diagnostic::missing_token( + "hardware access or identifier", + lexer.location(), + )); + } } - } else { - None }; // colon has to come before the data type @@ -1108,7 +1158,16 @@ fn parse_variable_line(lexer: &mut ParseSession) -> Vec { // create variables with the same data type for each of the names let mut variables = vec![]; - if let Some((data_type, initializer)) = parse_full_data_type_definition(lexer, None) { + + let parse_definition_opt = if lexer.try_consume(&KeywordReferenceTo) { + parse_pointer_definition(lexer, None, lexer.last_range.start, Some(AutoDerefType::Reference)) + } else { + parse_full_data_type_definition(lexer, None) + }; + + lexer.try_consume(&KeywordSemicolon); + + if let Some((data_type, initializer)) = parse_definition_opt { for (name, range) in var_names { variables.push(Variable { name, @@ -1119,6 +1178,7 @@ fn parse_variable_line(lexer: &mut ParseSession) -> Vec { }); } } + variables } diff --git a/src/parser/expressions_parser.rs b/src/parser/expressions_parser.rs index 798de928135..ac41e0223fe 100644 --- a/src/parser/expressions_parser.rs +++ b/src/parser/expressions_parser.rs @@ -213,17 +213,21 @@ fn parse_leaf_expression(lexer: &mut ParseSession) -> AstNode { }; match literal_parse_result { - Some(statement) => { - if lexer.token == KeywordAssignment { + Some(statement) => match lexer.token { + KeywordAssignment => { lexer.advance(); AstFactory::create_assignment(statement, parse_range_statement(lexer), lexer.next_id()) - } else if lexer.token == KeywordOutputAssignment { + } + KeywordOutputAssignment => { lexer.advance(); AstFactory::create_output_assignment(statement, parse_range_statement(lexer), lexer.next_id()) - } else { - statement } - } + KeywordReferenceAssignment => { + lexer.advance(); + AstFactory::create_ref_assignment(statement, parse_range_statement(lexer), lexer.next_id()) + } + _ => statement, + }, None => { let statement = AstFactory::create_empty_statement( lexer.diagnostics.last().map_or(SourceLocation::undefined(), |d| d.get_location()), @@ -312,7 +316,7 @@ fn parse_atomic_leaf_expression(lexer: &mut ParseSession<'_>) -> Option } fn parse_identifier(lexer: &mut ParseSession<'_>) -> AstNode { - AstFactory::create_identifier(&lexer.slice_and_advance(), &lexer.last_location(), lexer.next_id()) + AstFactory::create_identifier(&lexer.slice_and_advance(), lexer.last_location(), lexer.next_id()) } fn parse_vla_range(lexer: &mut ParseSession) -> Option { @@ -477,7 +481,7 @@ fn parse_direct_access(lexer: &mut ParseSession, access: DirectAccessType) -> Op Identifier => { let location = lexer.location(); Some(AstFactory::create_member_reference( - AstFactory::create_identifier(lexer.slice_and_advance().as_str(), &location, lexer.next_id()), + AstFactory::create_identifier(lexer.slice_and_advance().as_str(), location, lexer.next_id()), None, lexer.next_id(), )) diff --git a/src/parser/tests.rs b/src/parser/tests.rs index 8ee0e295b62..5d3b2f9800d 100644 --- a/src/parser/tests.rs +++ b/src/parser/tests.rs @@ -5,6 +5,7 @@ use plc_ast::{ use plc_source::source_location::SourceLocation; // Copyright (c) 2020 Ghaith Hachem and Mathias Rieder +mod ast_visitor_tests; mod class_parser_tests; mod container_parser_tests; mod control_parser_tests; @@ -22,7 +23,7 @@ mod variable_parser_tests; /// helper function to create references pub fn ref_to(name: &str) -> AstNode { AstFactory::create_member_reference( - AstFactory::create_identifier(name, &SourceLocation::undefined(), 0), + AstFactory::create_identifier(name, SourceLocation::undefined(), 0), None, 0, ) diff --git a/src/parser/tests/ast_visitor_tests.rs b/src/parser/tests/ast_visitor_tests.rs new file mode 100644 index 00000000000..c97533c520d --- /dev/null +++ b/src/parser/tests/ast_visitor_tests.rs @@ -0,0 +1,628 @@ +use plc_ast::{ + ast::LinkageType, + provider::IdProvider, + visitor::{AstVisitor, Walker}, +}; +use plc_source::source_location::SourceLocationFactory; + +use crate::{lexer, parser}; + +/// This is a simple visitor that collects all identifiers and literals in a given body +/// It is used by unit tests, to easily see if all identifiers (even the deeply nested ones) were visited +/// and therefore that all subtrees of the AST were visited. +/// +/// e.g. if we have a source code like this: +/// ``` +/// PROGRAM prg +/// foo (a := b, c => 4); +/// END_PROGRAM +/// ``` +/// The visitor should collect the following identifiers/literals: "foo", "a", "b", "c" and "4" +#[derive(Default)] +struct IdentifierCollector { + identifiers: Vec, +} + +impl AstVisitor for IdentifierCollector { + fn visit_identifier(&mut self, stmt: &str, _node: &plc_ast::ast::AstNode) { + self.identifiers.push(stmt.to_string()); + } + + fn visit_literal(&mut self, stmt: &plc_ast::literals::AstLiteral, _node: &plc_ast::ast::AstNode) { + self.identifiers.push(stmt.get_literal_value()); + } +} + +/// Helper function to create a vector of strings with all characters in the range from start to end +fn get_character_range(start: char, end: char) -> Vec { + (start as u8..=end as u8).map(|c| c as char).map(|c| c.to_string()).collect() +} + +/// Helper function to collect all identifiers in a given source code +/// using the IdentifierCollector visitor +fn collect_identifiers(src: &str) -> IdentifierCollector { + let mut visitor = IdentifierCollector::default(); + visit(src, &mut visitor); + visitor.identifiers.sort(); + visitor +} + +/// Helper function to visit a given source code with a given visitor +fn visit(src: &str, visitor: &mut impl AstVisitor) { + let id_provider = IdProvider::default(); + let (compilation_unit, _) = parser::parse( + lexer::lex_with_ids(src, id_provider.clone(), SourceLocationFactory::internal(src)), + LinkageType::Internal, + "test.st", + ); + + visitor.visit_compilation_unit(&compilation_unit) +} + +#[test] +fn test_visit_arithmetic_expressions() { + // GIVEN a source code with arithmetic expressions + // WHEN we visit all nodes in the AST + let visitor = collect_identifiers( + " + PROGRAM prg + a; + b; + c := NOT d; + e := f MOD g; + h := (i / j / k - (l + m)) * n; + END_PROGRAM", + ); + // THEN we expect to also visit subexpressions in binary and unary expressions + assert_eq!(get_character_range('a', 'n'), visitor.identifiers); +} + +#[test] +fn test_visit_expression_list() { + // GIVEN a source code with an expression list + // WHEN we visit all nodes in the AST + let visitor = collect_identifiers( + " + PROGRAM prg + a,b,c; + END_PROGRAM", + ); + // THEN we expect to visit all identifiers in the expression list + assert_eq!(get_character_range('a', 'c'), visitor.identifiers); +} + +#[test] +fn test_if_statement() { + // GIVEN a source code with an if statement + // WHEN we visit all nodes in the AST + let visitor = collect_identifiers( + " + PROGRAM prg + IF a THEN + b := c; + ELSIF d THEN + e := f; + ELSE + g := h; + END_IF; + END_PROGRAM", + ); + // THEN we expect to visit the condition, the body, the elseif condition and body and the else body + assert_eq!(get_character_range('a', 'h'), visitor.identifiers); +} + +#[test] +fn test_visit_for_loop_statement() { + // GIVEN a source code with a for loop statement + // WHEN we visit all nodes in the AST + let visitor = collect_identifiers( + " + PROGRAM prg + FOR a := b TO c BY d DO + e; + f; + END_FOR; + END_PROGRAM", + ); + // THEN we expect to visit the loop variable, the start, end and step expressions and the loop body + assert_eq!(get_character_range('a', 'f'), visitor.identifiers); +} + +#[test] +fn test_visit_while_loop_statement() { + // GIVEN a source code with a while loop statement + // WHEN we visit all nodes in the AST + let visitor = collect_identifiers( + " + PROGRAM prg + WHILE a < b DO + c; + d; + END_WHILE; + END_PROGRAM", + ); + // THEN we expect to visit the condition and the loop body + assert_eq!(get_character_range('a', 'd'), visitor.identifiers); +} +#[test] +fn test_visit_repeat_loop_statement() { + // GIVEN a source code with a repeat loop statement + // WHEN we visit all nodes in the AST + let visitor = collect_identifiers( + " + PROGRAM prg + REPEAT + a; + b; + UNTIL c > d; + END_PROGRAM", + ); + // THEN we expect to visit the loop body and the condition + assert_eq!(get_character_range('a', 'd'), visitor.identifiers); +} + +#[test] +fn test_visit_case_statement() { + // GIVEN a source code with a case statement + + let visitor = collect_identifiers( + " + PROGRAM prg + CASE a OF + b: + c; + d; + e, f: + g; + h; + ELSE + i; + j; + END_CASE; + END_PROGRAM", + ); + // THEN we expect to visit the case expression, the case labels, their bodies and the else body + assert_eq!(get_character_range('a', 'j'), visitor.identifiers); +} + +#[test] +fn test_visit_multiplied_statement() { + // GIVEN a source code with a multiplied statement + // WHEN we visit all nodes in the AST + let visitor = collect_identifiers( + " + PROGRAM prg + 3(a+b); + END_PROGRAM", + ); + // THEN we expect to visit the multiplied expression and its subexpressions + assert_eq!(get_character_range('a', 'b'), visitor.identifiers); +} + +#[test] +fn test_visist_array_expressions() { + // GIVEN a source code with array expressions + // WHEN we visit all nodes in the AST + let visitor = collect_identifiers( + " + PROGRAM prg + a[b]; + c[d,e+f]; + g[h+i][j+k]; + END_PROGRAM", + ); + // THEN we expect to visit the array expressions and the array-accessor expressions + assert_eq!(get_character_range('a', 'k'), visitor.identifiers); +} + +#[test] +fn test_visit_range_statement() { + // GIVEN a source code with range statements + // WHEN we visit all nodes in the AST + let visitor = collect_identifiers( + " + PROGRAM prg + a..b; + END_PROGRAM", + ); + // THEN we expect to visit the start and end expressions of the range + assert_eq!(get_character_range('a', 'b'), visitor.identifiers); +} + +#[test] +fn test_visit_assignment_expressions() { + // GIVEN a source code with assignment expressions + // WHEN we visit all nodes in the AST + let visitor = collect_identifiers( + " + PROGRAM prg + a := b; + c => d; + e =>; + END_PROGRAM", + ); + // THEN we expect to visit the left and right side of the assignment expressions + assert_eq!(get_character_range('a', 'e'), visitor.identifiers); +} + +#[test] +fn test_visit_direct_access_statement_expressions() { + // GIVEN a source code with direct access expressions + // WHEN we visit all nodes in the AST + let visitor = collect_identifiers( + " + PROGRAM prg + %IW1.2.3; + %MD4; + END_PROGRAM", + ); + // THEN we expect to visit all segments of the direct access + assert_eq!(get_character_range('1', '4'), visitor.identifiers); +} + +#[test] +fn test_visit_call_statements() { + // GIVEN a source code with call statements + // WHEN we visit all nodes in the AST + let visitor = collect_identifiers( + " + PROGRAM prg + a(); + b(c,d); + e(f:=(g), h=>i); + END_PROGRAM", + ); + // THEN we expect to visit the function name and all arguments + assert_eq!(get_character_range('a', 'i'), visitor.identifiers); +} + +#[test] +fn test_visit_return_statement() { + // GIVEN a source code with a return statement + // WHEN we visit all nodes in the AST + let visitor = collect_identifiers( + " + FUNCTION prg : INT + RETURN a + b; + END_PROGRAM", + ); + // THEN we expect to visit the return expression + assert_eq!(get_character_range('a', 'b'), visitor.identifiers); +} + +#[test] +fn test_visit_into_var_global() { + // GIVEN a source code with a var_global section + // WHEN we visit all nodes in the AST + let visitor = collect_identifiers( + " + VAR_GLOBAL + a : INT := c; + c : INT := d; + END_VAR", + ); + // THEN we expect to visit all initializers (variable names are no AstStatements!) + assert_eq!(get_character_range('c', 'd'), visitor.identifiers); +} + +#[test] +fn test_visit_data_type_declaration() { + // GIVEN a visitor that collects variables, enum elements and range expressions + struct FieldCollector { + fields: Vec, + } + + // This is a simple visitor that collects all field names in a datatype + impl AstVisitor for FieldCollector { + fn visit_variable(&mut self, variable: &plc_ast::ast::Variable) { + self.fields.push(variable.name.clone()); + variable.walk(self); + } + + fn visit_enum_element(&mut self, element: &plc_ast::ast::AstNode) { + if let Some(name) = element.get_flat_reference_name() { + self.fields.push(name.to_string()); + } + element.walk(self); + } + + fn visit_range_statement( + &mut self, + stmt: &plc_ast::ast::RangeStatement, + _node: &plc_ast::ast::AstNode, + ) { + if let Some((start, end)) = + stmt.start.get_flat_reference_name().zip(stmt.end.get_flat_reference_name()) + { + self.fields.push(start.to_string()); + self.fields.push(end.to_string()); + } + stmt.walk(self); + } + } + let mut visitor = FieldCollector { fields: vec![] }; + // WHEN we visit a source code with a complex datatype + visit( + " + TYPE myStruct: STRUCT + a, b, c: DINT; + s: STRING; + e: (enum1, enum2, enum3); + END_STRUCT; + END_TYPE + + TYPE MyEnum: (myEnum1, myEnum2, myEnum3); + END_TYPE + + TYPE MySubRange: INT(max..min); END_TYPE + + TYPE MyArray: ARRAY[start..end] OF INT; END_TYPE + ", + &mut visitor, + ); + + visitor.fields.sort(); + // THEN we expect to visit all fields, enum elements and range expressions + assert_eq!( + vec![ + "a", "b", "c", "e", "end", "enum1", "enum2", "enum3", "max", "min", "myEnum1", "myEnum2", + "myEnum3", "s", "start" + ], + visitor.fields + ); +} + +#[test] +fn test_count_assignments() { + // GIVEN a visitor that counts assignments + struct AssignmentCounter { + count: usize, + } + + impl AstVisitor for AssignmentCounter { + fn visit_assignment(&mut self, stmt: &plc_ast::ast::Assignment, _node: &plc_ast::ast::AstNode) { + self.count += 1; + stmt.walk(self) + } + + fn visit_output_assignment( + &mut self, + stmt: &plc_ast::ast::Assignment, + _node: &plc_ast::ast::AstNode, + ) { + self.count += 1; + stmt.walk(self) + } + } + + let id_provider = IdProvider::default(); + let (compilation_unit, _) = parser::parse( + lexer::lex_with_ids( + " + PROGRAM prg + a := b; + c => d; + e := f; + foo(a := baz(x := 2, z => 3)); + END_PROGRAM", + id_provider.clone(), + SourceLocationFactory::internal(""), + ), + LinkageType::Internal, + "test.st", + ); + + let mut visitor = AssignmentCounter { count: 0 }; + // WHEN we visit a source code with assignments + for st in &compilation_unit.implementations[0].statements { + visitor.visit(st); + } + // THEN we expect to visit all assignments + assert_eq!(6, visitor.count); +} + +#[test] +fn test_visit_datatype_initializers_statement() { + // GIVEN a source code with datatype initializers + // WHEN we visit all nodes in the AST + let visitor = collect_identifiers( + " + TYPE MyStruct: STRUCT + field1: DINT := a; + field2: DINT := (b + c); + field3: ARRAY[1..3] OF DINT := 4(d); + field4: ARRAY[4..7] OF DINT := (e, f, g, h); + field5: (i := j, k := l) := m; + + END_STRUCT + END_TYPE", + ); + // THEN we expect to visit all initializers and enum elements + let mut expected = ["1", "3", "4", "7"].iter().map(|c| c.to_string()).collect::>(); + + expected.extend(get_character_range('a', 'm')); + assert_eq!(expected, visitor.identifiers); +} + +#[test] +fn test_visit_array_declaration_statement() { + // GIVEN a source code with array declarations + // WHEN we visit all nodes in the AST + let visitor = collect_identifiers( + " + TYPE MyArray: ARRAY[(a+b)..(c+d)] OF INT; END_TYPE", + ); + // THEN we expect to visit the start and end expressions of the array + assert_eq!(get_character_range('a', 'd'), visitor.identifiers); +} + +#[test] +fn test_visit_qualified_expressions() { + // GIVEN a source code with qualified expressions + // WHEN we visit all nodes in the AST + let visitor = collect_identifiers( + " + PROGRAM prg + a.b; + c.d^.e; + f.g[h].i; + END_PROGRAM", + ); + // THEN we expect to visit all segments in the qualified expressions + assert_eq!(get_character_range('a', 'i'), visitor.identifiers); +} + +#[test] +fn test_visit_variable_block() { + // GIVEN a source code with a variable block + // WHEN we visit all nodes in the AST + let visitor = collect_identifiers( + " + PROGRAM prg + VAR_INPUT + a : INT := X; + END_VAR + VAR_OUTPUT + b : INT := Y; + END_VAR + VAR CONSTANT + c : INT + END_VAR + END_PROGRAM", + ); + // THEN we expect to visit all variables and their initializers + assert_eq!(get_character_range('X', 'Y'), visitor.identifiers); +} + +#[test] +fn test_visit_continue_exit() { + // THIS test is mainly here to cover the default visit implementation of Continue, Exit and EmptyStatement + let visitor = collect_identifiers( + " + PROGRAM prg + CONTINUE; + EXIT; + ; + END_PROGRAM", + ); + assert_eq!(0, visitor.identifiers.len()); +} + +#[test] +fn test_visit_default_value() { + // GIVEN a Visitor that visits default values + struct DefaultValueCollector { + visited: bool, + } + + // This is a simple visitor that collects all field names in a datatype + impl AstVisitor for DefaultValueCollector { + fn visit_default_value(&mut self, _stmt: &plc_ast::ast::DefaultValue, _node: &plc_ast::ast::AstNode) { + self.visited = true; + } + } + + let mut visitor = DefaultValueCollector { visited: false }; + // WHEN we visit a source code with a default value + visit( + " + VAR_GLOBAL CONSTANT + a : INT; + END_VAR + ", + &mut visitor, + ); + // THEN we expect to visit the default value + assert!(visitor.visited); +} + +#[test] +fn test_visit_direct_access() { + // GIVEN a Visitor that visits direct accesses + struct Visited { + visited: bool, + } + + impl AstVisitor for Visited { + fn visit_direct_access(&mut self, _stmt: &plc_ast::ast::DirectAccess, _node: &plc_ast::ast::AstNode) { + self.visited = true; + } + } + + let mut visitor = Visited { visited: false }; + // WHEN we visit a source code with a direct access + visit( + " + PROGRAM prg + x.1; + ", + &mut visitor, + ); + // THEN we expect to visit the direct access + assert!(visitor.visited); + + let v = collect_identifiers( + " + PROGRAM prg + x.1; + ", + ); + assert_eq!(vec!["1", "x"], v.identifiers); +} + +#[test] +fn test_invalid_case_condition() { + // this tests ensures that we visit "invalid" statements. (see parser's behavior in parse_statement) + struct Visited { + visited: bool, + } + + impl AstVisitor for Visited { + fn visit_case_condition(&mut self, _child: &plc_ast::ast::AstNode, _node: &plc_ast::ast::AstNode) { + self.visited = true; + } + } + + let mut visitor = Visited { visited: false }; + + visit( + " + PROGRAM prg + x: + ", + &mut visitor, + ); + assert!(visitor.visited); +} + +#[test] +fn test_visit_string_declaration() { + // GIVEN a source code with a string declaration + // WHEN we visit all nodes in the AST + let visitor = collect_identifiers( + " + PROGRAM prg + VAR + str: STRING(X); + END_VAR + ", + ); + // THEN we expect to visit the string length + assert_eq!(vec!["X"], visitor.identifiers); +} + +#[test] +fn test_visit_pointer_declaration() { + // GIVEN a source code with a pointer declaration + // WHEN we visit all nodes in the AST + let visitor = collect_identifiers( + " + PROGRAM prg + VAR + str: POINTER TO ARRAY[a..b] OF INT := c; + END_VAR + ", + ); + // THEN we expect to visit the pointer type and the initializer + assert_eq!(get_character_range('a', 'c'), visitor.identifiers); +} diff --git a/src/parser/tests/expressions_parser_tests.rs b/src/parser/tests/expressions_parser_tests.rs index 7eec8b4575f..72f4edde749 100644 --- a/src/parser/tests/expressions_parser_tests.rs +++ b/src/parser/tests/expressions_parser_tests.rs @@ -734,7 +734,7 @@ fn literal_real_test() { fn cast(data_type: &str, value: AstNode) -> AstNode { AstFactory::create_cast_statement( AstFactory::create_member_reference( - AstFactory::create_identifier(data_type, &SourceLocation::undefined(), 0), + AstFactory::create_identifier(data_type, SourceLocation::undefined(), 0), None, 0, ), diff --git a/src/parser/tests/parse_errors/parse_error_statements_tests.rs b/src/parser/tests/parse_errors/parse_error_statements_tests.rs index ca29b7abba2..65d2419ec02 100644 --- a/src/parser/tests/parse_errors/parse_error_statements_tests.rs +++ b/src/parser/tests/parse_errors/parse_error_statements_tests.rs @@ -1128,6 +1128,7 @@ fn pointer_type_without_to_test() { referenced_type: "INT".to_string(), location: SourceLocation::undefined(), }), + auto_deref: None, }, location: SourceLocation::undefined(), initializer: None, @@ -1154,6 +1155,7 @@ fn pointer_type_with_wrong_keyword_to_test() { referenced_type: "tu".to_string(), location: SourceLocation::undefined(), }), + auto_deref: None, }, location: SourceLocation::undefined(), initializer: None, diff --git a/src/parser/tests/snapshots/rusty__parser__tests__type_parser_tests__global_pointer_declaration-2.snap b/src/parser/tests/snapshots/rusty__parser__tests__type_parser_tests__global_pointer_declaration-2.snap index f430f662933..670cab7d36f 100644 --- a/src/parser/tests/snapshots/rusty__parser__tests__type_parser_tests__global_pointer_declaration-2.snap +++ b/src/parser/tests/snapshots/rusty__parser__tests__type_parser_tests__global_pointer_declaration-2.snap @@ -10,6 +10,7 @@ Variable { referenced_type: DataTypeReference { referenced_type: "INT", }, + auto_deref: None, }, }, } diff --git a/src/parser/tests/snapshots/rusty__parser__tests__type_parser_tests__global_pointer_declaration.snap b/src/parser/tests/snapshots/rusty__parser__tests__type_parser_tests__global_pointer_declaration.snap index f7426bc0ee3..01eb109c7bc 100644 --- a/src/parser/tests/snapshots/rusty__parser__tests__type_parser_tests__global_pointer_declaration.snap +++ b/src/parser/tests/snapshots/rusty__parser__tests__type_parser_tests__global_pointer_declaration.snap @@ -10,6 +10,7 @@ Variable { referenced_type: DataTypeReference { referenced_type: "INT", }, + auto_deref: None, }, }, } diff --git a/src/parser/tests/snapshots/rusty__parser__tests__type_parser_tests__pointer_type_test.snap b/src/parser/tests/snapshots/rusty__parser__tests__type_parser_tests__pointer_type_test.snap index 1bd1d207dec..03c86b8ad31 100644 --- a/src/parser/tests/snapshots/rusty__parser__tests__type_parser_tests__pointer_type_test.snap +++ b/src/parser/tests/snapshots/rusty__parser__tests__type_parser_tests__pointer_type_test.snap @@ -10,6 +10,7 @@ UserTypeDeclaration { referenced_type: DataTypeReference { referenced_type: "INT", }, + auto_deref: None, }, initializer: None, scope: None, diff --git a/src/parser/tests/snapshots/rusty__parser__tests__type_parser_tests__ref_type_test.snap b/src/parser/tests/snapshots/rusty__parser__tests__type_parser_tests__ref_type_test.snap index 9402582b6ee..366d52a65bb 100644 --- a/src/parser/tests/snapshots/rusty__parser__tests__type_parser_tests__ref_type_test.snap +++ b/src/parser/tests/snapshots/rusty__parser__tests__type_parser_tests__ref_type_test.snap @@ -10,6 +10,7 @@ UserTypeDeclaration { referenced_type: DataTypeReference { referenced_type: "INT", }, + auto_deref: None, }, initializer: None, scope: None, diff --git a/src/parser/tests/statement_parser_tests.rs b/src/parser/tests/statement_parser_tests.rs index ffddd7578f6..81d2848f38b 100644 --- a/src/parser/tests/statement_parser_tests.rs +++ b/src/parser/tests/statement_parser_tests.rs @@ -38,7 +38,7 @@ fn empty_statements_are_parsed_before_a_statement() { empty_stmt(), empty_stmt(), AstFactory::create_member_reference( - AstFactory::create_identifier("x", &SourceLocation::undefined(), 0), + AstFactory::create_identifier("x", SourceLocation::undefined(), 0), None, 0 ), @@ -59,7 +59,7 @@ fn empty_statements_are_ignored_after_a_statement() { let expected_ast = format!( "{:#?}", AstFactory::create_member_reference( - AstFactory::create_identifier("x", &SourceLocation::undefined(), 0), + AstFactory::create_identifier("x", SourceLocation::undefined(), 0), None, 0 ) @@ -262,3 +262,126 @@ fn empty_parameter_assignments_in_call_statement() { let ast_string = format!("{:#?}", &result); insta::assert_snapshot!(ast_string); } + +#[test] +fn ref_assignment() { + let result = &parse("PROGRAM main x REF= y END_PROGRAM").0.implementations[0]; + insta::assert_debug_snapshot!(result.statements, @r###" + [ + ReferenceAssignment { + left: ReferenceExpr { + kind: Member( + Identifier { + name: "x", + }, + ), + base: None, + }, + right: ReferenceExpr { + kind: Member( + Identifier { + name: "y", + }, + ), + base: None, + }, + }, + ] + "###) +} + +#[test] +fn reference_to_declaration() { + let (result, diagnostics) = parse( + r" + FUNCTION foo + VAR + bar : DINT; + baz : REFERENCE TO DINT; + qux : DINT; + END_VAR + END_FUNCTION + ", + ); + + assert!(diagnostics.is_empty()); + insta::assert_debug_snapshot!(result.units[0].variable_blocks[0], @r###" + VariableBlock { + variables: [ + Variable { + name: "bar", + data_type: DataTypeReference { + referenced_type: "DINT", + }, + }, + Variable { + name: "baz", + data_type: DataTypeDefinition { + data_type: PointerType { + name: None, + referenced_type: DataTypeReference { + referenced_type: "DINT", + }, + auto_deref: Some( + Reference, + ), + }, + }, + }, + Variable { + name: "qux", + data_type: DataTypeReference { + referenced_type: "DINT", + }, + }, + ], + variable_block_type: Local, + } + "###); +} + +#[test] +fn aliasing_dint_variable() { + let (result, diagnostics) = parse( + " + FUNCTION main + VAR + a AT b : DINT; // equivalent to `a : REFERENCE TO DINT REF= b` + END_VAR + END_FUNCTION + ", + ); + + assert_eq!(diagnostics, vec![]); + insta::assert_debug_snapshot!(result.units[0].variable_blocks[0], @r###" + VariableBlock { + variables: [ + Variable { + name: "a", + data_type: DataTypeDefinition { + data_type: PointerType { + name: None, + referenced_type: DataTypeReference { + referenced_type: "DINT", + }, + auto_deref: Some( + Alias, + ), + }, + }, + initializer: Some( + ReferenceExpr { + kind: Member( + Identifier { + name: "b", + }, + ), + base: None, + }, + ), + }, + ], + variable_block_type: Local, + } + "###); +} diff --git a/src/resolver.rs b/src/resolver.rs index 3e6a29dcf82..21ca9b9f926 100644 --- a/src/resolver.rs +++ b/src/resolver.rs @@ -10,10 +10,9 @@ use std::hash::Hash; use plc_ast::{ ast::{ - self, flatten_expression_list, Assignment, AstFactory, AstId, AstNode, AstStatement, - BinaryExpression, CastStatement, CompilationUnit, DataType, DataTypeDeclaration, DirectAccessType, - JumpStatement, Operator, Pou, ReferenceAccess, ReferenceExpr, TypeNature, UserTypeDeclaration, - Variable, + self, flatten_expression_list, Assignment, AstFactory, AstId, AstNode, AstStatement, AutoDerefType, + BinaryExpression, CompilationUnit, DataType, DataTypeDeclaration, DirectAccessType, JumpStatement, + Operator, Pou, ReferenceAccess, ReferenceExpr, TypeNature, UserTypeDeclaration, Variable, }, control_statements::{AstControlStatement, ReturnStatement}, literals::{Array, AstLiteral, StringValue}, @@ -392,8 +391,8 @@ pub enum StatementAnnotation { constant: bool, /// denotes the variable type of this variable, hence whether it is an input, output, etc. argument_type: ArgumentType, - /// denotes whether this variable-reference should be automatically dereferenced when accessed - is_auto_deref: bool, + /// denotes wheter this variable has the auto-deref trait and if so what type + auto_deref: Option, }, /// a reference to a function Function { @@ -434,6 +433,14 @@ impl StatementAnnotation { } } + pub fn is_alias(&self) -> bool { + matches!(self, StatementAnnotation::Variable { auto_deref: Some(AutoDerefType::Alias), .. }) + } + + pub fn is_auto_deref(&self) -> bool { + matches!(self, StatementAnnotation::Variable { auto_deref: Some(_), .. }) + } + pub fn data_type(type_name: &str) -> Self { StatementAnnotation::Type { type_name: type_name.into() } } @@ -546,7 +553,10 @@ pub trait AnnotationMap { fn get_qualified_name(&self, s: &AstNode) -> Option<&str> { match self.get(s) { - Some(StatementAnnotation::Function { qualified_name, .. }) => Some(qualified_name.as_str()), + Some(StatementAnnotation::Function { qualified_name, .. }) + | Some(StatementAnnotation::Variable { qualified_name, .. }) + | Some(StatementAnnotation::Program { qualified_name, .. }) => Some(qualified_name.as_str()), + _ => self.get_call_name(s), } } @@ -699,7 +709,7 @@ impl AnnotationMap for AnnotationMapImpl { } } -#[derive(Default)] +#[derive(Default, Debug)] pub struct StringLiterals { pub utf08: FxHashSet, pub utf16: FxHashSet, @@ -1012,19 +1022,64 @@ impl<'i> TypeAnnotator<'i> { fn type_hint_for_variable_initializer( &mut self, initializer: &AstNode, - ty: &typesystem::DataType, + variable_ty: &typesystem::DataType, ctx: &VisitorContext, ) { if let AstStatement::ParenExpression(expr) = &initializer.stmt { - self.type_hint_for_variable_initializer(expr, ty, ctx); + self.type_hint_for_variable_initializer(expr, variable_ty, ctx); self.inherit_annotations(initializer, expr); return; } - self.annotation_map.annotate_type_hint(initializer, StatementAnnotation::value(ty.get_name())); - self.update_expected_types(ty, initializer); + self.replace_reference_pointer_initializer(variable_ty, initializer, ctx); - self.type_hint_for_array_of_structs(ty, initializer, ctx); + self.annotation_map.annotate_type_hint(initializer, StatementAnnotation::value(&variable_ty.name)); + self.update_expected_types(variable_ty, initializer); + + self.type_hint_for_array_of_structs(variable_ty, initializer, ctx); + } + + /// Wraps the initializer of a reference- or alias-pointer in a `REF` function call. + /// + /// Initializers already wrapped in a `REF` (or similiar) function call are however excluded, as we do + /// not want something like `REF(REF(...))`. + fn replace_reference_pointer_initializer( + &mut self, + variable_ty: &typesystem::DataType, + initializer: &AstNode, + ctx: &VisitorContext, + ) { + let variable_is_auto_deref_pointer = { + variable_ty.get_type_information().is_alias() + || variable_ty.get_type_information().is_reference_to() + }; + + let initializer_is_not_wrapped_in_ref_call = { + !(initializer.is_call() + && self.annotation_map.get_type(initializer, self.index).is_some_and(|opt| opt.is_pointer())) + }; + + if variable_is_auto_deref_pointer && initializer_is_not_wrapped_in_ref_call { + debug_assert!(builtins::get_builtin("REF").is_some(), "REF must exist for this use-case"); + + let mut id_provider = ctx.id_provider.clone(); + let location = &initializer.location; + + let ref_ident = AstFactory::create_identifier("REF", location, id_provider.next_id()); + let fn_name = AstFactory::create_member_reference(ref_ident, None, id_provider.next_id()); + let fn_arg = initializer; + self.visit_statement(ctx, &fn_name); + self.visit_statement(ctx, fn_arg); + + let fn_call = AstFactory::create_call_statement( + fn_name, + Some(fn_arg.clone()), + id_provider.next_id(), + location, + ); + self.visit_statement(ctx, &fn_call); + self.annotate(initializer, StatementAnnotation::ReplacementAst { statement: fn_call }); + } } fn type_hint_for_array_of_structs( @@ -1417,7 +1472,7 @@ impl<'i> TypeAnnotator<'i> { AstStatement::RangeStatement(data, ..) => { visit_all_statements!(self, ctx, &data.start, &data.end); } - AstStatement::Assignment(data, ..) => { + AstStatement::Assignment(data, ..) | AstStatement::RefAssignment(data, ..) => { self.visit_statement(&ctx.enter_control(), &data.right); if let Some(lhs) = ctx.lhs { //special context for left hand side @@ -1442,57 +1497,6 @@ impl<'i> TypeAnnotator<'i> { AstStatement::CallStatement(..) => { self.visit_call_statement(statement, ctx); } - AstStatement::CastStatement(CastStatement { target, type_name }, ..) => { - //see if this type really exists - let data_type = self.index.find_effective_type_info(type_name); - let statement_to_annotation = if let Some(DataTypeInformation::Enum { name, .. }) = data_type - { - //enum cast - self.visit_statement(&ctx.with_qualifier(name.to_string()), target); - //use the type of the target - let type_name = self.annotation_map.get_type_or_void(target, self.index).get_name(); - vec![(statement, type_name.to_string())] - } else if let Some(t) = data_type { - // special handling for unlucky casted-strings where caste-type does not match the literal encoding - // ´STRING#"abc"´ or ´WSTRING#'abc'´ - match (t, target.as_ref().get_stmt()) { - ( - DataTypeInformation::String { encoding: StringEncoding::Utf8, .. }, - AstStatement::Literal(AstLiteral::String(StringValue { - value, - is_wide: is_wide @ true, - })), - ) - | ( - DataTypeInformation::String { encoding: StringEncoding::Utf16, .. }, - AstStatement::Literal(AstLiteral::String(StringValue { - value, - is_wide: is_wide @ false, - })), - ) => { - // visit the target-statement as if the programmer used the correct quotes to prevent - // a utf16 literal-global-variable that needs to be casted back to utf8 or vice versa - self.visit_statement( - ctx, - &AstNode::new_literal( - AstLiteral::new_string(value.clone(), !is_wide), - target.get_id(), - target.get_location(), - ), - ); - } - _ => {} - } - vec![(statement, t.get_name().to_string()), (target, t.get_name().to_string())] - } else { - //unknown type? what should we do here? - self.visit_statement(ctx, target); - vec![] - }; - for (stmt, annotation) in statement_to_annotation { - self.annotate(stmt, StatementAnnotation::value(annotation)); - } - } AstStatement::ReferenceExpr(data, ..) => { self.visit_reference_expr(&data.access, data.base.as_deref(), statement, ctx); } @@ -1592,7 +1596,7 @@ impl<'i> TypeAnnotator<'i> { } } (ReferenceAccess::Deref, _) => { - if let Some(DataTypeInformation::Pointer { inner_type_name, auto_deref: false, .. }) = base + if let Some(DataTypeInformation::Pointer { inner_type_name, auto_deref: None, .. }) = base .map(|base| self.annotation_map.get_type_or_void(base, self.index)) .map(|it| it.get_type_information()) { @@ -1677,7 +1681,7 @@ impl<'i> TypeAnnotator<'i> { else { unreachable!("expected a vla reference, but got {statement:#?}"); }; - if let DataTypeInformation::Pointer { inner_type_name, .. } = &self + if let DataTypeInformation::Pointer { inner_type_name, auto_deref: kind, .. } = &self .index .get_effective_type_or_void_by_name( members.first().expect("internal VLA struct ALWAYS has this member").get_type_name(), @@ -1712,7 +1716,7 @@ impl<'i> TypeAnnotator<'i> { qualified_name: qualified_name.to_string(), constant: false, argument_type, - is_auto_deref: false, + auto_deref: *kind, }; self.annotation_map.annotate_type_hint(statement, hint_annotation) } @@ -1798,7 +1802,12 @@ impl<'i> TypeAnnotator<'i> { } pub(crate) fn annotate_parameters(&mut self, p: &AstNode, type_name: &str) { - if !matches!(p.get_stmt(), AstStatement::Assignment(..) | AstStatement::OutputAssignment(..)) { + if !matches!( + p.get_stmt(), + AstStatement::Assignment(..) + | AstStatement::OutputAssignment(..) + | AstStatement::RefAssignment(..) + ) { if let Some(effective_member_type) = self.index.find_effective_type_by_name(type_name) { //update the type hint self.annotation_map @@ -1918,10 +1927,10 @@ pub(crate) fn add_pointer_type(index: &mut Index, inner_type_name: String) -> St name: new_type_name.clone(), initial_value: None, nature: TypeNature::Any, - information: crate::typesystem::DataTypeInformation::Pointer { - auto_deref: false, - inner_type_name, + information: DataTypeInformation::Pointer { name: new_type_name.clone(), + inner_type_name, + auto_deref: None, }, location: SourceLocation::internal(), }); @@ -1957,22 +1966,21 @@ fn to_variable_annotation( index: &Index, constant_override: bool, ) -> StatementAnnotation { - const AUTO_DEREF: bool = true; - const NO_DEREF: bool = false; let v_type = index.get_effective_type_or_void_by_name(v.get_type_name()); //see if this is an auto-deref variable - let (effective_type_name, is_auto_deref) = match (v_type.get_type_information(), v.is_return()) { + let (effective_type_name, kind) = match (v_type.get_type_information(), v.is_return()) { (_, true) if v_type.is_aggregate_type() => { // treat a return-aggregate variable like an auto-deref pointer since it got // passed by-ref - (v_type.get_name().to_string(), AUTO_DEREF) + let kind = v_type.get_type_information().get_auto_deref_type().unwrap_or(AutoDerefType::Default); + (v_type.get_name().to_string(), Some(kind)) } - (DataTypeInformation::Pointer { inner_type_name, auto_deref: true, .. }, _) => { + (DataTypeInformation::Pointer { inner_type_name, auto_deref: Some(deref), .. }, _) => { // real auto-deref pointer - (inner_type_name.clone(), AUTO_DEREF) + (inner_type_name.clone(), Some(*deref)) } - _ => (v_type.get_name().to_string(), NO_DEREF), + _ => (v_type.get_name().to_string(), None), }; StatementAnnotation::Variable { @@ -1980,7 +1988,7 @@ fn to_variable_annotation( resulting_type: effective_type_name, constant: v.is_constant() || constant_override, argument_type: v.get_declaration_type(), - is_auto_deref, + auto_deref: kind, } } diff --git a/src/resolver/generics.rs b/src/resolver/generics.rs index 7cea4931422..509c321ab11 100644 --- a/src/resolver/generics.rs +++ b/src/resolver/generics.rs @@ -201,14 +201,17 @@ impl<'i> TypeAnnotator<'i> { .unwrap_or_else(|| member_name) .to_string() } - Some(DataTypeInformation::Pointer { name, inner_type_name, auto_deref: true }) => { + Some(DataTypeInformation::Pointer { name, inner_type_name, auto_deref: Some(kind), .. }) => { // This is an auto deref pointer (VAR_IN_OUT or VAR_INPUT {ref}) that points to a // generic. We first resolve the generic type, then create a new pointer type of // the combination let inner_type_name = self.find_or_create_datatype(inner_type_name, generics); let name = format!("{name}__{inner_type_name}"); // TODO: Naming convention (see plc_util/src/convention.rs) - let new_type_info = - DataTypeInformation::Pointer { name: name.clone(), inner_type_name, auto_deref: true }; + let new_type_info = DataTypeInformation::Pointer { + name: name.clone(), + inner_type_name, + auto_deref: Some(*kind), + }; // Registers a new pointer type to the index self.annotation_map.new_index.register_type(DataType { @@ -440,7 +443,7 @@ pub fn generic_name_resolver( .fold(qualified_name.to_string(), |accum, s| format!("{accum}__{s}")) // TODO: Naming convention (see plc_util/src/convention.rs) } -/// This method returns the qualified name, but has the same signature as the generic resover to be used in builtins +/// This method returns the qualified name, but has the same signature as the generic resolver to be used in builtins pub fn no_generic_name_resolver( qualified_name: &str, _: &[GenericBinding], diff --git a/src/resolver/tests.rs b/src/resolver/tests.rs index 15f0039de29..0813304d6bd 100644 --- a/src/resolver/tests.rs +++ b/src/resolver/tests.rs @@ -1,4 +1,5 @@ mod const_resolver_tests; +mod lowering; mod resolve_control_statments; mod resolve_expressions_tests; mod resolve_generic_calls; diff --git a/src/resolver/tests/lowering.rs b/src/resolver/tests/lowering.rs new file mode 100644 index 00000000000..ca69f098048 --- /dev/null +++ b/src/resolver/tests/lowering.rs @@ -0,0 +1,240 @@ +//! Contains tests related to lowering, i.e. (for now) anything that uses the `ReplacementAst`. + +use insta::assert_debug_snapshot; +use plc_ast::provider::IdProvider; + +use crate::{ + resolver::AnnotationMap, + test_utils::tests::{annotate_with_ids, index_with_ids}, +}; + +#[test] +fn initializer_with_ref_call_annotated_as_pointer() { + let id_provider = IdProvider::default(); + let (unit, mut index) = index_with_ids( + " + FUNCTION main + VAR + foo : DINT; + bar : REFERENCE TO DINT := REF(foo); + END_VAR + END_FUNCTION + ", + id_provider.clone(), + ); + + let annotations = annotate_with_ids(&unit, &mut index, id_provider); + let initializer_bar = unit.units[0].variable_blocks[0].variables[1].initializer.as_ref().unwrap(); + let initializer_bar_annotation = annotations.get(initializer_bar).unwrap(); + + assert_debug_snapshot!((initializer_bar, initializer_bar_annotation), @r###" + ( + CallStatement { + operator: ReferenceExpr { + kind: Member( + Identifier { + name: "REF", + }, + ), + base: None, + }, + parameters: Some( + ReferenceExpr { + kind: Member( + Identifier { + name: "foo", + }, + ), + base: None, + }, + ), + }, + Value { + resulting_type: "__POINTER_TO_DINT", + }, + ) + "###); +} + +#[test] +fn initializer_with_refassignment_annotated_with_replacementast() { + let id_provider = IdProvider::default(); + let (unit, mut index) = index_with_ids( + " + FUNCTION main + VAR + foo : DINT; + bar : REFERENCE TO DINT REF= foo; + END_VAR + END_FUNCTION + ", + id_provider.clone(), + ); + + let annotations = annotate_with_ids(&unit, &mut index, id_provider); + let initializer_bar = unit.units[0].variable_blocks[0].variables[1].initializer.as_ref().unwrap(); + let initializer_bar_annotation = annotations.get(initializer_bar).unwrap(); + + assert_debug_snapshot!((initializer_bar, initializer_bar_annotation), @r###" + ( + ReferenceExpr { + kind: Member( + Identifier { + name: "foo", + }, + ), + base: None, + }, + ReplacementAst { + statement: CallStatement { + operator: ReferenceExpr { + kind: Member( + Identifier { + name: "REF", + }, + ), + base: None, + }, + parameters: Some( + ReferenceExpr { + kind: Member( + Identifier { + name: "foo", + }, + ), + base: None, + }, + ), + }, + }, + ) + "###); +} + +#[test] +fn initializer_of_alias_annotated_with_replacementast() { + let id_provider = IdProvider::default(); + let (unit, mut index) = index_with_ids( + " + FUNCTION main + VAR + foo : DINT; + bar AT foo : DINT; + END_VAR + END_FUNCTION + ", + id_provider.clone(), + ); + + let annotations = annotate_with_ids(&unit, &mut index, id_provider); + let initializer_bar = unit.units[0].variable_blocks[0].variables[1].initializer.as_ref().unwrap(); + let initializer_bar_annotation = annotations.get(initializer_bar).unwrap(); + + assert_debug_snapshot!((initializer_bar, initializer_bar_annotation), @r###" + ( + ReferenceExpr { + kind: Member( + Identifier { + name: "foo", + }, + ), + base: None, + }, + ReplacementAst { + statement: CallStatement { + operator: ReferenceExpr { + kind: Member( + Identifier { + name: "REF", + }, + ), + base: None, + }, + parameters: Some( + ReferenceExpr { + kind: Member( + Identifier { + name: "foo", + }, + ), + base: None, + }, + ), + }, + }, + ) + "###); +} + +#[test] +fn initializer_of_alias_annotated_with_replacementast_array() { + let id_provider = IdProvider::default(); + let (unit, mut index) = index_with_ids( + " + FUNCTION main + VAR + foo : ARRAY[1..5] OF DINT; + bar AT foo[1] : DINT; + END_VAR + END_FUNCTION + ", + id_provider.clone(), + ); + + let annotations = annotate_with_ids(&unit, &mut index, id_provider); + let initializer_bar = unit.units[0].variable_blocks[0].variables[1].initializer.as_ref().unwrap(); + let initializer_bar_annotation = annotations.get(initializer_bar).unwrap(); + + assert_debug_snapshot!((initializer_bar, initializer_bar_annotation), @r###" + ( + ReferenceExpr { + kind: Index( + LiteralInteger { + value: 1, + }, + ), + base: Some( + ReferenceExpr { + kind: Member( + Identifier { + name: "foo", + }, + ), + base: None, + }, + ), + }, + ReplacementAst { + statement: CallStatement { + operator: ReferenceExpr { + kind: Member( + Identifier { + name: "REF", + }, + ), + base: None, + }, + parameters: Some( + ReferenceExpr { + kind: Index( + LiteralInteger { + value: 1, + }, + ), + base: Some( + ReferenceExpr { + kind: Member( + Identifier { + name: "foo", + }, + ), + base: None, + }, + ), + }, + ), + }, + }, + ) + "###); +} diff --git a/src/resolver/tests/resolve_expressions_tests.rs b/src/resolver/tests/resolve_expressions_tests.rs index 44d1537f19c..10c9a14479d 100644 --- a/src/resolver/tests/resolve_expressions_tests.rs +++ b/src/resolver/tests/resolve_expressions_tests.rs @@ -162,7 +162,7 @@ fn cast_expressions_of_enum_with_resolves_types() { qualified_name: "MyEnum.a".to_string(), constant: true, argument_type: ArgumentType::ByVal(VariableType::Global), - is_auto_deref: false + auto_deref: None, }) ); @@ -178,7 +178,7 @@ fn cast_expressions_of_enum_with_resolves_types() { qualified_name: "MyEnum.b".to_string(), constant: true, argument_type: ArgumentType::ByVal(VariableType::Global), - is_auto_deref: false + auto_deref: None, }) ); } @@ -1311,8 +1311,8 @@ fn function_expression_resolves_to_the_function_itself_not_its_return_type() { qualified_name: "foo.foo".into(), resulting_type: "INT".into(), constant: false, - is_auto_deref: false, argument_type: ArgumentType::ByVal(VariableType::Return), + auto_deref: None, }), foo_annotation ); @@ -1572,8 +1572,8 @@ fn qualified_expressions_dont_fallback_to_globals() { qualified_name: "MyStruct.y".into(), resulting_type: "INT".into(), constant: false, - is_auto_deref: false, argument_type: ArgumentType::ByVal(VariableType::Input), + auto_deref: None, }), annotations.get(&statements[1]) ); @@ -1813,8 +1813,8 @@ fn method_references_are_resolved() { qualified_name: "cls.foo.foo".into(), resulting_type: "INT".into(), constant: false, - is_auto_deref: false, argument_type: ArgumentType::ByVal(VariableType::Return), + auto_deref: None, }), annotation ); @@ -2448,7 +2448,7 @@ fn struct_member_explicit_initialization_test() { qualified_name: "myStruct.var1".to_string(), constant: false, argument_type: ArgumentType::ByVal(VariableType::Input), - is_auto_deref: false + auto_deref: None, }), annotations.get(left) ); @@ -2462,7 +2462,7 @@ fn struct_member_explicit_initialization_test() { qualified_name: "myStruct.var2".to_string(), constant: false, argument_type: ArgumentType::ByVal(VariableType::Input), - is_auto_deref: false + auto_deref: None, }), annotations.get(left) ); @@ -2942,8 +2942,8 @@ fn action_body_gets_resolved() { qualified_name: "prg.x".to_string(), resulting_type: "DINT".to_string(), constant: false, - is_auto_deref: false, argument_type: ArgumentType::ByVal(VariableType::Local), + auto_deref: None, }), a ); @@ -3385,9 +3385,9 @@ fn address_of_is_annotated_correctly() { if let Some(&StatementAnnotation::Value { resulting_type }) = annotations.get(s).as_ref() { assert_eq!( Some(&DataTypeInformation::Pointer { - auto_deref: false, inner_type_name: "INT".to_string(), name: "__POINTER_TO_INT".to_string(), + auto_deref: None, }), index.find_effective_type_info(resulting_type), ); @@ -3468,7 +3468,7 @@ fn call_explicit_parameter_name_is_resolved() { qualified_name: "fb.b".to_string(), constant: false, argument_type: ArgumentType::ByVal(VariableType::Input), - is_auto_deref: false + auto_deref: None, }), annotations.get(b.as_ref()) ); @@ -3479,7 +3479,7 @@ fn call_explicit_parameter_name_is_resolved() { qualified_name: "fb.a".to_string(), constant: false, argument_type: ArgumentType::ByVal(VariableType::Input), - is_auto_deref: false + auto_deref: None, }), annotations.get(a) ); @@ -3701,7 +3701,7 @@ fn function_block_initialization_test() { qualified_name: "TON.PT".into(), constant: false, argument_type: ArgumentType::ByVal(VariableType::Input), - is_auto_deref: false + auto_deref: None, } ) } else { @@ -3836,7 +3836,7 @@ fn resolve_return_variable_in_nested_call() { qualified_name: "main.main".to_string(), constant: false, argument_type: ArgumentType::ByVal(VariableType::Return), - is_auto_deref: false + auto_deref: None, } ) } @@ -5080,7 +5080,7 @@ fn annotate_variable_in_parent_class() { qualified_name: "cls1.LIGHT".to_string(), constant: false, argument_type: ArgumentType::ByVal(VariableType::Local,), - is_auto_deref: false, + auto_deref: None, }, annotation.unwrap() ); @@ -5095,7 +5095,7 @@ fn annotate_variable_in_parent_class() { qualified_name: "cls2.Light2".to_string(), constant: false, argument_type: ArgumentType::ByVal(VariableType::Local,), - is_auto_deref: false, + auto_deref: None, }, annotation.unwrap() ); @@ -5133,7 +5133,7 @@ fn annotate_variable_in_grandparent_class() { qualified_name: "cls0.LIGHT".to_string(), constant: false, argument_type: ArgumentType::ByVal(VariableType::Local,), - is_auto_deref: false, + auto_deref: None, }, annotation.unwrap() ); @@ -5178,7 +5178,7 @@ fn annotate_variable_in_field() { qualified_name: "cls0.LIGHT".to_string(), constant: false, argument_type: ArgumentType::ByVal(VariableType::Local,), - is_auto_deref: false, + auto_deref: None, }, annotation.unwrap() ); @@ -5235,7 +5235,7 @@ fn annotate_method_in_super() { qualified_name: "cls0.LIGHT".to_string(), constant: false, argument_type: ArgumentType::ByVal(VariableType::Local,), - is_auto_deref: false, + auto_deref: None, }, annotation.unwrap() ); @@ -5250,7 +5250,7 @@ fn annotate_method_in_super() { qualified_name: "cls1.LIGHT1".to_string(), constant: false, argument_type: ArgumentType::ByVal(VariableType::Local,), - is_auto_deref: false, + auto_deref: None, }, annotation.unwrap() ); @@ -5265,7 +5265,7 @@ fn annotate_method_in_super() { qualified_name: "cls0.LIGHT".to_string(), constant: false, argument_type: ArgumentType::ByVal(VariableType::Local,), - is_auto_deref: false, + auto_deref: None, }, annotation.unwrap() ); @@ -5280,7 +5280,7 @@ fn annotate_method_in_super() { qualified_name: "cls1.LIGHT1".to_string(), constant: false, argument_type: ArgumentType::ByVal(VariableType::Local,), - is_auto_deref: false, + auto_deref: None, }, annotation.unwrap() ); @@ -5295,7 +5295,7 @@ fn annotate_method_in_super() { qualified_name: "cls2.LIGHT2".to_string(), constant: false, argument_type: ArgumentType::ByVal(VariableType::Local,), - is_auto_deref: false, + auto_deref: None, }, annotation.unwrap() ); diff --git a/src/resolver/tests/resolve_generic_calls.rs b/src/resolver/tests/resolve_generic_calls.rs index 706f8e525c1..f517aa5157a 100644 --- a/src/resolver/tests/resolve_generic_calls.rs +++ b/src/resolver/tests/resolve_generic_calls.rs @@ -716,7 +716,7 @@ fn auto_pointer_of_generic_resolved() { let member = index.find_member("LEFT_EXT__DINT", "IN").unwrap(); let dt = index.find_effective_type_info(&member.data_type_name).unwrap(); - if let DataTypeInformation::Pointer { inner_type_name, auto_deref: true, .. } = dt { + if let DataTypeInformation::Pointer { inner_type_name, auto_deref: Some(_), .. } = dt { assert_eq!(inner_type_name, "DINT") } else { panic!("Expecting a pointer to dint, found {dt:?}") @@ -767,7 +767,7 @@ fn string_ref_as_generic_resolved() { let member = index.find_member("LEFT_EXT__STRING", "IN").unwrap(); let dt = index.find_effective_type_info(&member.data_type_name).unwrap(); - if let DataTypeInformation::Pointer { inner_type_name, auto_deref: true, .. } = dt { + if let DataTypeInformation::Pointer { inner_type_name, auto_deref: Some(_), .. } = dt { assert_eq!(inner_type_name, STRING_TYPE) } else { panic!("Expecting auto deref pointer to string, found {dt:?}") diff --git a/src/resolver/tests/resolve_literals_tests.rs b/src/resolver/tests/resolve_literals_tests.rs index 559da46845b..30636c1c701 100644 --- a/src/resolver/tests/resolve_literals_tests.rs +++ b/src/resolver/tests/resolve_literals_tests.rs @@ -312,7 +312,7 @@ fn enum_literals_target_are_annotated() { qualified_name: "Color.Red".into(), constant: true, argument_type: ArgumentType::ByVal(crate::index::VariableType::Global), - is_auto_deref: false + auto_deref: None, }), annotations.get(target) ); diff --git a/src/resolver/tests/snapshots/rusty__resolver__tests__const_resolver_tests__const_enum_variable_default_value_compile_time_evaluation.snap b/src/resolver/tests/snapshots/rusty__resolver__tests__const_resolver_tests__const_enum_variable_default_value_compile_time_evaluation.snap index 001b53a48de..eb2eab72b70 100644 --- a/src/resolver/tests/snapshots/rusty__resolver__tests__const_resolver_tests__const_enum_variable_default_value_compile_time_evaluation.snap +++ b/src/resolver/tests/snapshots/rusty__resolver__tests__const_resolver_tests__const_enum_variable_default_value_compile_time_evaluation.snap @@ -5,8 +5,8 @@ expression: ir ; ModuleID = 'main' source_filename = "main" -@me = unnamed_addr constant i32 3 -@THREE = unnamed_addr constant i16 3 -@MyEnum.a = unnamed_addr constant i32 3 -@MyEnum.b = unnamed_addr constant i32 4 -@MyEnum.c = unnamed_addr constant i32 5 +@me = unnamed_addr constant i32 3, section "var-$RUSTY$me:e3i32" +@THREE = unnamed_addr constant i16 3, section "var-$RUSTY$THREE:i16" +@MyEnum.a = unnamed_addr constant i32 3, section "var-$RUSTY$a:e3i32" +@MyEnum.b = unnamed_addr constant i32 4, section "var-$RUSTY$b:e3i32" +@MyEnum.c = unnamed_addr constant i32 5, section "var-$RUSTY$c:e3i32" diff --git a/src/resolver/tests/snapshots/rusty__resolver__tests__const_resolver_tests__const_variables_default_value_compile_time_evaluation.snap b/src/resolver/tests/snapshots/rusty__resolver__tests__const_resolver_tests__const_variables_default_value_compile_time_evaluation.snap index 1ac4ac6da76..15c2095dad0 100644 --- a/src/resolver/tests/snapshots/rusty__resolver__tests__const_resolver_tests__const_variables_default_value_compile_time_evaluation.snap +++ b/src/resolver/tests/snapshots/rusty__resolver__tests__const_resolver_tests__const_variables_default_value_compile_time_evaluation.snap @@ -5,12 +5,12 @@ expression: ir ; ModuleID = 'main' source_filename = "main" -@false_bool = unnamed_addr constant i8 0 -@zero_int = unnamed_addr constant i16 0 -@zero_real = unnamed_addr constant double 0.000000e+00 -@empty_string = unnamed_addr constant [81 x i8] zeroinitializer -@null_ptr = unnamed_addr constant i16* null -@zero_enum = unnamed_addr constant i32 0 -@myEnum.a = unnamed_addr constant i32 0 -@myEnum.b = unnamed_addr constant i32 1 -@myEnum.c = unnamed_addr constant i32 2 +@false_bool = unnamed_addr constant i8 0, section "var-$RUSTY$false_bool:u8" +@zero_int = unnamed_addr constant i16 0, section "var-$RUSTY$zero_int:i16" +@zero_real = unnamed_addr constant double 0.000000e+00, section "var-$RUSTY$zero_real:f64" +@empty_string = unnamed_addr constant [81 x i8] zeroinitializer, section "var-$RUSTY$empty_string:s8u81" +@null_ptr = unnamed_addr constant i16* null, section "var-$RUSTY$null_ptr:pi16" +@zero_enum = unnamed_addr constant i32 0, section "var-$RUSTY$zero_enum:e3i32" +@myEnum.a = unnamed_addr constant i32 0, section "var-$RUSTY$a:e3i32" +@myEnum.b = unnamed_addr constant i32 1, section "var-$RUSTY$b:e3i32" +@myEnum.c = unnamed_addr constant i32 2, section "var-$RUSTY$c:e3i32" diff --git a/src/resolver/tests/snapshots/rusty__resolver__tests__const_resolver_tests__default_values_are_transitive_for_range_types.snap b/src/resolver/tests/snapshots/rusty__resolver__tests__const_resolver_tests__default_values_are_transitive_for_range_types.snap index f702fd1b496..810a15dd212 100644 --- a/src/resolver/tests/snapshots/rusty__resolver__tests__const_resolver_tests__default_values_are_transitive_for_range_types.snap +++ b/src/resolver/tests/snapshots/rusty__resolver__tests__const_resolver_tests__default_values_are_transitive_for_range_types.snap @@ -5,9 +5,8 @@ expression: src ; ModuleID = 'main' source_filename = "main" -@a = global i16 7 -@b = global i16 7 -@aa = unnamed_addr constant i16 7 -@bb = unnamed_addr constant i16 7 -@cc = unnamed_addr constant i16 14 - +@a = global i16 7, section "var-$RUSTY$a:i16" +@b = global i16 7, section "var-$RUSTY$b:i16" +@aa = unnamed_addr constant i16 7, section "var-$RUSTY$aa:i16" +@bb = unnamed_addr constant i16 7, section "var-$RUSTY$bb:i16" +@cc = unnamed_addr constant i16 14, section "var-$RUSTY$cc:i16" diff --git a/src/test_utils.rs b/src/test_utils.rs index f7631b06c50..6b153a4c4e0 100644 --- a/src/test_utils.rs +++ b/src/test_utils.rs @@ -1,7 +1,7 @@ #[cfg(test)] pub mod tests { - use std::{path::PathBuf, str::FromStr}; + use std::{path::PathBuf, str::FromStr, sync::Mutex}; use plc_ast::{ ast::{pre_process, CompilationUnit, LinkageType}, @@ -161,19 +161,23 @@ pub mod tests { &context, path.as_deref(), "main", + None, crate::OptimizationLevel::None, debug_level, ); let annotations = AstAnnotations::new(annotations, id_provider.next_id()); + + let got_layout = Mutex::new(None); + let llvm_index = code_generator - .generate_llvm_index(&context, &annotations, &literals, &dependencies, &index) + .generate_llvm_index(&context, &annotations, &literals, &dependencies, &index, &got_layout) .map_err(|err| { reporter.handle(&[err]); reporter.buffer().unwrap() })?; code_generator - .generate(&context, &unit, &annotations, &index, &llvm_index) + .generate(&context, &unit, &annotations, &index, llvm_index) .map(|module| module.persist_to_string()) .map_err(|err| { reporter.handle(&[err]); @@ -232,18 +236,22 @@ pub mod tests { context, path.as_deref(), &unit.file_name, + None, crate::OptimizationLevel::None, debug_level, ); + let got_layout = Mutex::new(None); + let llvm_index = code_generator.generate_llvm_index( context, &annotations, &literals, &dependencies, &index, + &got_layout, )?; - code_generator.generate(context, &unit, &annotations, &index, &llvm_index) + code_generator.generate(context, &unit, &annotations, &index, llvm_index) }) .collect::, Diagnostic>>() } diff --git a/src/tests/adr/annotated_ast_adr.rs b/src/tests/adr/annotated_ast_adr.rs index bdfc003e7cb..6bc6ffa1f0d 100644 --- a/src/tests/adr/annotated_ast_adr.rs +++ b/src/tests/adr/annotated_ast_adr.rs @@ -49,7 +49,7 @@ fn references_to_variables_are_annotated() { qualified_name: "prg.a".into(), constant: false, argument_type: ArgumentType::ByVal(VariableType::Local), - is_auto_deref: false + auto_deref: None, } ); @@ -61,7 +61,7 @@ fn references_to_variables_are_annotated() { qualified_name: "gX".into(), constant: true, argument_type: ArgumentType::ByVal(VariableType::Global), - is_auto_deref: false + auto_deref: None, } ); } @@ -104,8 +104,8 @@ fn different_types_of_annotations() { qualified_name: "POINT.x".into(), // the qualified name of the target element resulting_type: "SINT".into(), // the variable's type constant: false, // whether this variable is a constant or not - is_auto_deref: false, // whether this pointerType should be automatically dereferenced argument_type: ArgumentType::ByVal(VariableType::Input), // the type of declaration + auto_deref: None, }) ); @@ -153,8 +153,8 @@ fn different_types_of_annotations() { qualified_name: "Main.in".into(), resulting_type: "INT".into(), constant: false, - is_auto_deref: false, argument_type: ArgumentType::ByVal(VariableType::Input), + auto_deref: None, }) ); @@ -165,8 +165,8 @@ fn different_types_of_annotations() { qualified_name: "Main.in".into(), resulting_type: "INT".into(), constant: false, - is_auto_deref: false, argument_type: ArgumentType::ByVal(VariableType::Input), + auto_deref: None, }) ); } diff --git a/src/tests/adr/arrays_adr.rs b/src/tests/adr/arrays_adr.rs index f2bcd2359a6..e5a95bcc6b0 100644 --- a/src/tests/adr/arrays_adr.rs +++ b/src/tests/adr/arrays_adr.rs @@ -18,7 +18,7 @@ fn declaring_an_array() { ; ModuleID = 'main' source_filename = "main" - @d = global [10 x i32] zeroinitializer + @d = global [10 x i32] zeroinitializer, section "var-$RUSTY$d:ai32" "###); } @@ -40,8 +40,8 @@ fn initializing_an_array() { ; ModuleID = 'main' source_filename = "main" - @d = global [10 x i32] [i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9] - @__Data__init = unnamed_addr constant [10 x i32] [i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9] + @d = global [10 x i32] [i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9], section "var-$RUSTY$d:ai32" + @__Data__init = unnamed_addr constant [10 x i32] [i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9], section "var-$RUSTY$__Data__init:ai32" "###); } @@ -70,10 +70,10 @@ fn assigning_full_arrays() { %prg = type { [10 x i32], [10 x i32] } - @prg_instance = global %prg { [10 x i32] [i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9], [10 x i32] [i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9] } - @__Data__init = unnamed_addr constant [10 x i32] [i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9] + @prg_instance = global %prg { [10 x i32] [i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9], [10 x i32] [i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9] }, section "var-$RUSTY$prg_instance:r2ai32ai32" + @__Data__init = unnamed_addr constant [10 x i32] [i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9], section "var-$RUSTY$__Data__init:ai32" - define void @prg(%prg* %0) section "fn-prg:v" { + define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: %a = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 %b = getelementptr inbounds %prg, %prg* %0, i32 0, i32 1 @@ -122,11 +122,11 @@ fn accessing_array_elements() { %prg = type { [10 x i32], [3 x i32] } - @prg_instance = global %prg { [10 x i32] [i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9], [3 x i32] [i32 3, i32 4, i32 5] } - @__Data__init = unnamed_addr constant [10 x i32] [i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9] + @prg_instance = global %prg { [10 x i32] [i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9], [3 x i32] [i32 3, i32 4, i32 5] }, section "var-$RUSTY$prg_instance:r2ai32ai32" + @__Data__init = unnamed_addr constant [10 x i32] [i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9], section "var-$RUSTY$__Data__init:ai32" @__prg.b__init = unnamed_addr constant [3 x i32] [i32 3, i32 4, i32 5] - define void @prg(%prg* %0) section "fn-prg:v" { + define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: %a = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 %b = getelementptr inbounds %prg, %prg* %0, i32 0, i32 1 diff --git a/src/tests/adr/enum_adr.rs b/src/tests/adr/enum_adr.rs index 6cca156de81..aa7af6da0fb 100644 --- a/src/tests/adr/enum_adr.rs +++ b/src/tests/adr/enum_adr.rs @@ -22,10 +22,10 @@ fn enums_generate_a_global_constants_for_each_element() { ; ModuleID = 'main' source_filename = "main" - @myColor = global i32 0 - @Color.red = unnamed_addr constant i32 0 - @Color.yellow = unnamed_addr constant i32 1 - @Color.green = unnamed_addr constant i32 2 + @myColor = global i32 0, section "var-$RUSTY$myColor:e3i32" + @Color.red = unnamed_addr constant i32 0, section "var-$RUSTY$red:e3i32" + @Color.yellow = unnamed_addr constant i32 1, section "var-$RUSTY$yellow:e3i32" + @Color.green = unnamed_addr constant i32 2, section "var-$RUSTY$green:e3i32" "###); } @@ -52,16 +52,16 @@ fn enums_constants_are_automatically_numbered_or_user_defined() { ; ModuleID = 'main' source_filename = "main" - @myColor = global i32 0 - @myState = global i8 0 - @Color.red = unnamed_addr constant i32 1 - @Color.yellow = unnamed_addr constant i32 2 - @Color.green = unnamed_addr constant i32 4 - @Color.blue = unnamed_addr constant i32 8 - @State.open = unnamed_addr constant i8 1 - @State.closed = unnamed_addr constant i8 4 - @State.idle = unnamed_addr constant i8 5 - @State.running = unnamed_addr constant i8 6 + @myColor = global i32 0, section "var-$RUSTY$myColor:e4i32" + @myState = global i8 0, section "var-$RUSTY$myState:e4u8" + @Color.red = unnamed_addr constant i32 1, section "var-$RUSTY$red:e4i32" + @Color.yellow = unnamed_addr constant i32 2, section "var-$RUSTY$yellow:e4i32" + @Color.green = unnamed_addr constant i32 4, section "var-$RUSTY$green:e4i32" + @Color.blue = unnamed_addr constant i32 8, section "var-$RUSTY$blue:e4i32" + @State.open = unnamed_addr constant i8 1, section "var-$RUSTY$open:e4u8" + @State.closed = unnamed_addr constant i8 4, section "var-$RUSTY$closed:e4u8" + @State.idle = unnamed_addr constant i8 5, section "var-$RUSTY$idle:e4u8" + @State.running = unnamed_addr constant i8 6, section "var-$RUSTY$running:e4u8" "###); } @@ -80,14 +80,14 @@ fn inline_declaration_of_enum_types() { ; ModuleID = 'main' source_filename = "main" - @frontColor = global i32 0 - @backColor = global i32 0 - @__global_frontColor.red = unnamed_addr constant i32 0 - @__global_frontColor.green = unnamed_addr constant i32 1 - @__global_frontColor.yellow = unnamed_addr constant i32 2 - @__global_backColor.red = unnamed_addr constant i32 0 - @__global_backColor.green = unnamed_addr constant i32 1 - @__global_backColor.yellow = unnamed_addr constant i32 2 + @frontColor = global i32 0, section "var-$RUSTY$frontColor:e3i32" + @backColor = global i32 0, section "var-$RUSTY$backColor:e3i32" + @__global_frontColor.red = unnamed_addr constant i32 0, section "var-$RUSTY$red:e3i32" + @__global_frontColor.green = unnamed_addr constant i32 1, section "var-$RUSTY$green:e3i32" + @__global_frontColor.yellow = unnamed_addr constant i32 2, section "var-$RUSTY$yellow:e3i32" + @__global_backColor.red = unnamed_addr constant i32 0, section "var-$RUSTY$red:e3i32" + @__global_backColor.green = unnamed_addr constant i32 1, section "var-$RUSTY$green:e3i32" + @__global_backColor.yellow = unnamed_addr constant i32 2, section "var-$RUSTY$yellow:e3i32" "###); } @@ -121,15 +121,15 @@ fn using_enums() { %prg = type { i32, i32, i32 } - @prg_instance = global %prg zeroinitializer - @ProcessState.open = unnamed_addr constant i32 1 - @ProcessState.closed = unnamed_addr constant i32 4 - @ProcessState.idle = unnamed_addr constant i32 5 - @ProcessState.running = unnamed_addr constant i32 6 - @Door.open = unnamed_addr constant i32 8 - @Door.closed = unnamed_addr constant i32 16 + @prg_instance = global %prg zeroinitializer, section "var-$RUSTY$prg_instance:r3i32i32i32" + @ProcessState.open = unnamed_addr constant i32 1, section "var-$RUSTY$open:e4i32" + @ProcessState.closed = unnamed_addr constant i32 4, section "var-$RUSTY$closed:e4i32" + @ProcessState.idle = unnamed_addr constant i32 5, section "var-$RUSTY$idle:e4i32" + @ProcessState.running = unnamed_addr constant i32 6, section "var-$RUSTY$running:e4i32" + @Door.open = unnamed_addr constant i32 8, section "var-$RUSTY$open:e2i32" + @Door.closed = unnamed_addr constant i32 16, section "var-$RUSTY$closed:e2i32" - define void @prg(%prg* %0) section "fn-prg:v" { + define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: %x = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 %y = getelementptr inbounds %prg, %prg* %0, i32 0, i32 1 diff --git a/src/tests/adr/pou_adr.rs b/src/tests/adr/pou_adr.rs index 78e8f1359d7..2fbde24ad63 100644 --- a/src/tests/adr/pou_adr.rs +++ b/src/tests/adr/pou_adr.rs @@ -233,9 +233,9 @@ fn codegen_of_a_program_pou() { %main_prg = type { i16, i16*, i16, i16 } - @main_prg_instance = global %main_prg zeroinitializer + @main_prg_instance = global %main_prg zeroinitializer, section "var-$RUSTY$main_prg_instance:r5i16pi16i16i16i16" - define void @main_prg(%main_prg* %0) section "fn-main_prg:v[i16][pi16][i16]" { + define void @main_prg(%main_prg* %0) section "fn-$RUSTY$main_prg:v[i16][pi16][i16]" { entry: %i = getelementptr inbounds %main_prg, %main_prg* %0, i32 0, i32 0 %io = getelementptr inbounds %main_prg, %main_prg* %0, i32 0, i32 1 @@ -271,9 +271,9 @@ fn calling_a_program() { %main_prg = type { i16, i16*, i16, i16 } - @main_prg_instance = global %main_prg zeroinitializer + @main_prg_instance = global %main_prg zeroinitializer, section "var-$RUSTY$main_prg_instance:r5i16pi16i16i16i16" - define i16 @foo() section "fn-foo:i16" { + define i16 @foo() section "fn-$RUSTY$foo:i16" { entry: %foo = alloca i16, align 2 %x = alloca i16, align 2 @@ -290,7 +290,7 @@ fn calling_a_program() { ret i16 %foo_ret } - define void @main_prg(%main_prg* %0) section "fn-main_prg:v[i16][pi16][i16]" { + define void @main_prg(%main_prg* %0) section "fn-$RUSTY$main_prg:v[i16][pi16][i16]" { entry: %i = getelementptr inbounds %main_prg, %main_prg* %0, i32 0, i32 0 %io = getelementptr inbounds %main_prg, %main_prg* %0, i32 0, i32 1 @@ -335,9 +335,9 @@ fn function_blocks_get_a_method_with_a_self_parameter() { %main_fb = type { i16, i16*, i16, i16 } - @__main_fb__init = unnamed_addr constant %main_fb { i16 6, i16* null, i16 0, i16 1 } + @__main_fb__init = unnamed_addr constant %main_fb { i16 6, i16* null, i16 0, i16 1 }, section "var-$RUSTY$__main_fb__init:r5i16pi16i16i16i16" - define void @main_fb(%main_fb* %0) section "fn-main_fb:v[i16][pi16][i16]" { + define void @main_fb(%main_fb* %0) section "fn-$RUSTY$main_fb:v[i16][pi16][i16]" { entry: %i = getelementptr inbounds %main_fb, %main_fb* %0, i32 0, i32 0 %io = getelementptr inbounds %main_fb, %main_fb* %0, i32 0, i32 1 @@ -375,10 +375,10 @@ fn calling_a_function_block() { %foo = type { i16, i16, %main_fb } %main_fb = type { i16, i16*, i16, i16 } - @foo_instance = global %foo { i16 0, i16 0, %main_fb { i16 6, i16* null, i16 0, i16 1 } } - @__main_fb__init = unnamed_addr constant %main_fb { i16 6, i16* null, i16 0, i16 1 } + @foo_instance = global %foo { i16 0, i16 0, %main_fb { i16 6, i16* null, i16 0, i16 1 } }, section "var-$RUSTY$foo_instance:r3i16i16r5i16pi16i16i16i16" + @__main_fb__init = unnamed_addr constant %main_fb { i16 6, i16* null, i16 0, i16 1 }, section "var-$RUSTY$__main_fb__init:r5i16pi16i16i16i16" - define void @foo(%foo* %0) section "fn-foo:v" { + define void @foo(%foo* %0) section "fn-$RUSTY$foo:v" { entry: %x = getelementptr inbounds %foo, %foo* %0, i32 0, i32 0 %y = getelementptr inbounds %foo, %foo* %0, i32 0, i32 1 @@ -394,7 +394,7 @@ fn calling_a_function_block() { ret void } - define void @main_fb(%main_fb* %0) section "fn-main_fb:v[i16][pi16][i16]" { + define void @main_fb(%main_fb* %0) section "fn-$RUSTY$main_fb:v[i16][pi16][i16]" { entry: %i = getelementptr inbounds %main_fb, %main_fb* %0, i32 0, i32 0 %io = getelementptr inbounds %main_fb, %main_fb* %0, i32 0, i32 1 @@ -431,7 +431,7 @@ fn function_get_a_method_with_by_ref_parameters() { ; ModuleID = 'main' source_filename = "main" - define i32 @main_fun(i16 %0, i8* %1, i64* %2) section "fn-main_fun:i32[i16][pi8][pi64]" { + define i32 @main_fun(i16 %0, i8* %1, i64* %2) section "fn-$RUSTY$main_fun:i32[i16][pi8][pi64]" { entry: %main_fun = alloca i32, align 4 %i = alloca i16, align 2 @@ -475,9 +475,9 @@ fn calling_a_function() { %prg = type { i16, i8 } - @prg_instance = global %prg zeroinitializer + @prg_instance = global %prg zeroinitializer, section "var-$RUSTY$prg_instance:r2i16i8" - define void @prg(%prg* %0) section "fn-prg:v" { + define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: %x = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 %z = getelementptr inbounds %prg, %prg* %0, i32 0, i32 1 @@ -487,7 +487,7 @@ fn calling_a_function() { ret void } - define i32 @main_fun(i16 %0, i8* %1, i64* %2) section "fn-main_fun:i32[i16][pi8][pi64]" { + define i32 @main_fun(i16 %0, i8* %1, i64* %2) section "fn-$RUSTY$main_fun:i32[i16][pi8][pi64]" { entry: %main_fun = alloca i32, align 4 %i = alloca i16, align 2 @@ -537,10 +537,10 @@ fn return_a_complex_type_from_function() { %prg = type { [81 x i8] } - @prg_instance = global %prg zeroinitializer + @prg_instance = global %prg zeroinitializer, section "var-$RUSTY$prg_instance:r1s8u81" @utf08_literal_0 = private unnamed_addr constant [13 x i8] c"hello world!\00" - define void @foo([81 x i8]* %0) section "fn-foo:s8u81" { + define void @foo([81 x i8]* %0) section "fn-$RUSTY$foo:s8u81" { entry: %foo = alloca [81 x i8]*, align 8 store [81 x i8]* %0, [81 x i8]** %foo, align 8 @@ -553,7 +553,7 @@ fn return_a_complex_type_from_function() { ret void } - define void @prg(%prg* %0) section "fn-prg:v" { + define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: %s = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 %1 = alloca [81 x i8], align 1 @@ -620,10 +620,10 @@ fn passing_aggregate_types_to_functions_by_value() { %myStruct = type { i32, i32, i32, [81 x i8] } %main = type { [81 x i8], [81 x i16], [30000 x i32], %myStruct } - @__myStruct__init = unnamed_addr constant %myStruct zeroinitializer - @main_instance = global %main zeroinitializer + @__myStruct__init = unnamed_addr constant %myStruct zeroinitializer, section "var-$RUSTY$__myStruct__init:r4i32i32i32s8u81" + @main_instance = global %main zeroinitializer, section "var-$RUSTY$main_instance:r4s8u81s16u81ai32r4i32i32i32s8u81" - define void @foo(i8* %0, i16* %1, i32* %2, %myStruct* %3) section "fn-foo:v[s8u81][s16u81][v][v]" { + define void @foo(i8* %0, i16* %1, i32* %2, %myStruct* %3) section "fn-$RUSTY$foo:v[s8u81][s16u81][ai32][r4i32i32i32s8u81]" { entry: %s = alloca [81 x i8], align 1 %bitcast = bitcast [81 x i8]* %s to i8* @@ -648,7 +648,7 @@ fn passing_aggregate_types_to_functions_by_value() { ret void } - define void @main(%main* %0) section "fn-main:v" { + define void @main(%main* %0) section "fn-$RUSTY$main:v" { entry: %string1 = getelementptr inbounds %main, %main* %0, i32 0, i32 0 %string2 = getelementptr inbounds %main, %main* %0, i32 0, i32 1 @@ -705,9 +705,9 @@ fn passing_by_ref_to_functions() { %main = type { [81 x i8], [81 x i8] } - @main_instance = global %main zeroinitializer + @main_instance = global %main zeroinitializer, section "var-$RUSTY$main_instance:r2s8u81s8u81" - define i8 @StrEqual(i8* %0, i8* %1) section "fn-StrEqual:u8[ps8u81][ps8u81]" { + define i8 @StrEqual(i8* %0, i8* %1) section "fn-$RUSTY$StrEqual:u8[ps8u81][ps8u81]" { entry: %StrEqual = alloca i8, align 1 %o1 = alloca i8*, align 8 @@ -719,7 +719,7 @@ fn passing_by_ref_to_functions() { ret i8 %StrEqual_ret } - define void @main(%main* %0) section "fn-main:v" { + define void @main(%main* %0) section "fn-$RUSTY$main:v" { entry: %str1 = getelementptr inbounds %main, %main* %0, i32 0, i32 0 %str2 = getelementptr inbounds %main, %main* %0, i32 0, i32 1 diff --git a/src/tests/adr/strings_adr.rs b/src/tests/adr/strings_adr.rs index 6a8d00c4844..33dc2b22d25 100644 --- a/src/tests/adr/strings_adr.rs +++ b/src/tests/adr/strings_adr.rs @@ -18,8 +18,8 @@ fn declaring_a_string() { ; ModuleID = 'main' source_filename = "main" - @myUtf8 = global [21 x i8] zeroinitializer - @myUtf16 = global [21 x i16] zeroinitializer + @myUtf8 = global [21 x i8] zeroinitializer, section "var-$RUSTY$myUtf8:s8u21" + @myUtf16 = global [21 x i16] zeroinitializer, section "var-$RUSTY$myUtf16:s16u21" "###); } @@ -41,8 +41,8 @@ fn strings_are_terminated_with_0byte() { ; ModuleID = 'main' source_filename = "main" - @myUtf8 = global [6 x i8] c"Hello\00" - @myUtf16 = global [6 x i16] [i16 87, i16 111, i16 114, i16 108, i16 100, i16 0] + @myUtf8 = global [6 x i8] c"Hello\00", section "var-$RUSTY$myUtf8:s8u6" + @myUtf16 = global [6 x i16] [i16 87, i16 111, i16 114, i16 108, i16 100, i16 0], section "var-$RUSTY$myUtf16:s16u6" "###); } @@ -68,9 +68,9 @@ fn assigning_strings() { %prg = type { [11 x i8], [11 x i8] } - @prg_instance = global %prg zeroinitializer + @prg_instance = global %prg zeroinitializer, section "var-$RUSTY$prg_instance:r2s8u11s8u11" - define void @prg(%prg* %0) section "fn-prg:v" { + define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: %a = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 %b = getelementptr inbounds %prg, %prg* %0, i32 0, i32 1 @@ -109,11 +109,11 @@ fn assigning_string_literals() { %prg = type { [11 x i8], [11 x i8] } - @prg_instance = global %prg zeroinitializer + @prg_instance = global %prg zeroinitializer, section "var-$RUSTY$prg_instance:r2s8u11s8u11" @utf08_literal_0 = private unnamed_addr constant [6 x i8] c"hello\00" @utf08_literal_1 = private unnamed_addr constant [6 x i8] c"world\00" - define void @prg(%prg* %0) section "fn-prg:v" { + define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: %a = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 %b = getelementptr inbounds %prg, %prg* %0, i32 0, i32 1 diff --git a/src/tests/adr/structs_adr.rs b/src/tests/adr/structs_adr.rs index fd1e456a681..23f2b550bf3 100644 --- a/src/tests/adr/structs_adr.rs +++ b/src/tests/adr/structs_adr.rs @@ -24,7 +24,7 @@ fn declaring_a_struct() { %Person = type { [81 x i8], [81 x i8], i16, i8 } - @__Person__init = unnamed_addr constant %Person zeroinitializer + @__Person__init = unnamed_addr constant %Person zeroinitializer, section "var-$RUSTY$__Person__init:r4s8u81s8u81i16u8" "###); } @@ -54,8 +54,8 @@ fn default_values_of_a_struct() { %Person = type { [6 x i8], [6 x i8], i16, i8 } - @p = global %Person { [6 x i8] c"Jane\00\00", [6 x i8] c"Row\00\00\00", i16 1988, i8 0 } - @__Person__init = unnamed_addr constant %Person { [6 x i8] c"Jane\00\00", [6 x i8] c"Row\00\00\00", i16 1988, i8 0 } + @p = global %Person { [6 x i8] c"Jane\00\00", [6 x i8] c"Row\00\00\00", i16 1988, i8 0 }, section "var-$RUSTY$p:r4s8u6s8u6i16u8" + @__Person__init = unnamed_addr constant %Person { [6 x i8] c"Jane\00\00", [6 x i8] c"Row\00\00\00", i16 1988, i8 0 }, section "var-$RUSTY$__Person__init:r4s8u6s8u6i16u8" "###); } @@ -97,13 +97,13 @@ fn initializing_a_struct() { %Rect = type { %Point, %Point } %Point = type { i16, i16 } - @prg_instance = global %prg { %Rect { %Point { i16 1, i16 5 }, %Point { i16 10, i16 15 } }, %Rect { %Point { i16 4, i16 6 }, %Point { i16 16, i16 22 } } } - @__Rect__init = unnamed_addr constant %Rect zeroinitializer - @__Point__init = unnamed_addr constant %Point zeroinitializer + @prg_instance = global %prg { %Rect { %Point { i16 1, i16 5 }, %Point { i16 10, i16 15 } }, %Rect { %Point { i16 4, i16 6 }, %Point { i16 16, i16 22 } } }, section "var-$RUSTY$prg_instance:r2r2r2i16i16r2i16i16r2r2i16i16r2i16i16" + @__Rect__init = unnamed_addr constant %Rect zeroinitializer, section "var-$RUSTY$__Rect__init:r2r2i16i16r2i16i16" + @__Point__init = unnamed_addr constant %Point zeroinitializer, section "var-$RUSTY$__Point__init:r2i16i16" @__prg.rect1__init = unnamed_addr constant %Rect { %Point { i16 1, i16 5 }, %Point { i16 10, i16 15 } } @__prg.rect2__init = unnamed_addr constant %Rect { %Point { i16 4, i16 6 }, %Point { i16 16, i16 22 } } - define void @prg(%prg* %0) section "fn-prg:v" { + define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: %rect1 = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 %rect2 = getelementptr inbounds %prg, %prg* %0, i32 0, i32 1 @@ -143,10 +143,10 @@ fn assigning_structs() { %prg = type { %Point, %Point } %Point = type { i16, i16 } - @prg_instance = global %prg zeroinitializer - @__Point__init = unnamed_addr constant %Point zeroinitializer + @prg_instance = global %prg zeroinitializer, section "var-$RUSTY$prg_instance:r2r2i16i16r2i16i16" + @__Point__init = unnamed_addr constant %Point zeroinitializer, section "var-$RUSTY$__Point__init:r2i16i16" - define void @prg(%prg* %0) section "fn-prg:v" { + define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: %p1 = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 %p2 = getelementptr inbounds %prg, %prg* %0, i32 0, i32 1 @@ -200,11 +200,11 @@ fn accessing_struct_members() { %Rect = type { %Point, %Point } %Point = type { i16, i16 } - @prg_instance = global %prg zeroinitializer - @__Rect__init = unnamed_addr constant %Rect zeroinitializer - @__Point__init = unnamed_addr constant %Point zeroinitializer + @prg_instance = global %prg zeroinitializer, section "var-$RUSTY$prg_instance:r2r2r2i16i16r2i16i16r2r2i16i16r2i16i16" + @__Rect__init = unnamed_addr constant %Rect zeroinitializer, section "var-$RUSTY$__Rect__init:r2r2i16i16r2i16i16" + @__Point__init = unnamed_addr constant %Point zeroinitializer, section "var-$RUSTY$__Point__init:r2i16i16" - define void @prg(%prg* %0) section "fn-prg:v" { + define void @prg(%prg* %0) section "fn-$RUSTY$prg:v" { entry: %rect1 = getelementptr inbounds %prg, %prg* %0, i32 0, i32 0 %rect2 = getelementptr inbounds %prg, %prg* %0, i32 0, i32 1 diff --git a/src/tests/adr/vla_adr.rs b/src/tests/adr/vla_adr.rs index a4b2d6430b0..38d3a8eb83c 100644 --- a/src/tests/adr/vla_adr.rs +++ b/src/tests/adr/vla_adr.rs @@ -103,7 +103,7 @@ fn representation() { information: Pointer { name: "__ptr_to___arr_vla_1_dint", inner_type_name: "__arr_vla_1_dint", - auto_deref: false, + auto_deref: None, }, nature: Any, location: SourceLocation { @@ -316,9 +316,9 @@ fn pass() { %__foo_arr = type { i32*, [2 x i32] } - @____foo_arr__init = unnamed_addr constant %__foo_arr zeroinitializer + @____foo_arr__init = unnamed_addr constant %__foo_arr zeroinitializer, section "var-$RUSTY$____foo_arr__init:r2pai32ai32" - define i32 @main() section "fn-main:i32" { + define i32 @main() section "fn-$RUSTY$main:i32" { entry: %main = alloca i32, align 4 %local = alloca [6 x i32], align 4 @@ -340,7 +340,7 @@ fn pass() { ret i32 %main_ret } - define i32 @foo(%__foo_arr* %0) section "fn-foo:i32[pv]" { + define i32 @foo(%__foo_arr* %0) section "fn-$RUSTY$foo:i32[pr2pai32ai32]" { entry: %foo = alloca i32, align 4 %arr = alloca %__foo_arr*, align 8 @@ -382,9 +382,9 @@ fn access() { %__foo_arr = type { i32*, [2 x i32] } - @____foo_arr__init = unnamed_addr constant %__foo_arr zeroinitializer + @____foo_arr__init = unnamed_addr constant %__foo_arr zeroinitializer, section "var-$RUSTY$____foo_arr__init:r2pai32ai32" - define i32 @foo(%__foo_arr* %0) section "fn-foo:i32[pv]" { + define i32 @foo(%__foo_arr* %0) section "fn-$RUSTY$foo:i32[pr2pai32ai32]" { entry: %foo = alloca i32, align 4 %arr = alloca %__foo_arr*, align 8 @@ -440,9 +440,9 @@ fn multi_dimensional() { %__foo_arr = type { i32*, [4 x i32] } - @____foo_arr__init = unnamed_addr constant %__foo_arr zeroinitializer + @____foo_arr__init = unnamed_addr constant %__foo_arr zeroinitializer, section "var-$RUSTY$____foo_arr__init:r2pai32ai32" - define i32 @foo(%__foo_arr* %0) section "fn-foo:i32[pv]" { + define i32 @foo(%__foo_arr* %0) section "fn-$RUSTY$foo:i32[pr2pai32ai32]" { entry: %foo = alloca i32, align 4 %arr = alloca %__foo_arr*, align 8 diff --git a/src/typesystem.rs b/src/typesystem.rs index eaead481135..b915271d7dd 100644 --- a/src/typesystem.rs +++ b/src/typesystem.rs @@ -6,7 +6,7 @@ use std::{ }; use plc_ast::{ - ast::{AstNode, Operator, PouType, TypeNature}, + ast::{AstNode, AutoDerefType, Operator, PouType, TypeNature}, literals::{AstLiteral, StringValue}, }; use plc_source::source_location::SourceLocation; @@ -96,7 +96,7 @@ mod tests; #[derive(Debug, Clone)] pub struct DataType { pub name: String, - /// the initial value defined on the TYPE-declration + /// the initial value defined on the TYPE-declaration pub initial_value: Option, pub information: DataTypeInformation, pub nature: TypeNature, @@ -390,7 +390,7 @@ pub enum DataTypeInformation { Pointer { name: TypeId, inner_type_name: TypeId, - auto_deref: bool, + auto_deref: Option, }, Integer { name: TypeId, @@ -443,6 +443,13 @@ impl DataTypeInformation { } } + pub fn get_inner_name(&self) -> &str { + match self { + DataTypeInformation::Pointer { inner_type_name, .. } => inner_type_name, + _ => self.get_name(), + } + } + pub fn is_void(&self) -> bool { matches!(self, DataTypeInformation::Void) } @@ -559,6 +566,20 @@ impl DataTypeInformation { } } + /// Returns true if the variable was declared as `REFERENCE TO`, e.g. `foo : REFERENCE TO DINT`. + pub fn is_reference_to(&self) -> bool { + matches!(self, DataTypeInformation::Pointer { auto_deref: Some(AutoDerefType::Reference), .. }) + } + + /// Returns true if the variable was declared as `REFERENCE TO`, e.g. `foo : REFERENCE TO DINT`. + pub fn is_alias(&self) -> bool { + matches!(self, DataTypeInformation::Pointer { auto_deref: Some(AutoDerefType::Alias), .. }) + } + + pub fn is_auto_deref(&self) -> bool { + matches!(self, DataTypeInformation::Pointer { auto_deref: Some(_), .. }) + } + pub fn is_aggregate(&self) -> bool { matches!( self, @@ -568,6 +589,14 @@ impl DataTypeInformation { ) } + pub fn get_auto_deref_type(&self) -> Option { + if let DataTypeInformation::Pointer { auto_deref: kind, .. } = self { + return *kind; + } + + None + } + pub fn is_date_or_time_type(&self) -> bool { matches!(self.get_name(), DATE_TYPE | DATE_AND_TIME_TYPE | TIME_OF_DAY_TYPE | TIME_TYPE) } diff --git a/src/validation/array.rs b/src/validation/array.rs index f87e7a367c9..596dc3ff0b4 100644 --- a/src/validation/array.rs +++ b/src/validation/array.rs @@ -194,7 +194,7 @@ impl<'a> StatementWrapper<'a> { where T: AnnotationMap, { - match self { + let ty = match self { StatementWrapper::Statement(statement) => { let AstNode { stmt: AstStatement::Assignment(data), .. } = statement else { return None }; context.annotations.get_type(&data.left, context.index).map(|it| it.get_type_information()) @@ -204,6 +204,11 @@ impl<'a> StatementWrapper<'a> { .data_type_declaration .get_referenced_type() .and_then(|it| context.index.find_effective_type_info(&it)), + }?; + + match ty { + DataTypeInformation::Pointer { .. } => Some(context.index.find_elementary_pointer_type(ty)), + _ => Some(ty), } } } diff --git a/src/validation/statement.rs b/src/validation/statement.rs index 4e6d8af18c3..8c2aa880093 100644 --- a/src/validation/statement.rs +++ b/src/validation/statement.rs @@ -1,6 +1,7 @@ use rustc_hash::{FxHashMap, FxHashSet}; use std::mem::discriminant; +use plc_ast::ast::Assignment; use plc_ast::control_statements::ForLoopStatement; use plc_ast::{ ast::{ @@ -13,7 +14,9 @@ use plc_ast::{ use plc_diagnostics::diagnostics::Diagnostic; use plc_source::source_location::SourceLocation; +use super::{array::validate_array_assignment, ValidationContext, Validator, Validators}; use crate::index::ImplementationType; +use crate::typesystem::VOID_TYPE; use crate::validation::statement::helper::{get_datatype_name_or_slice, get_literal_int_or_const_expr_value}; use crate::{ builtins::{self, BuiltIn}, @@ -26,8 +29,6 @@ use crate::{ }, }; -use super::{array::validate_array_assignment, ValidationContext, Validator, Validators}; - macro_rules! visit_all_statements { ($validator:expr, $context:expr, $last:expr ) => { visit_statement($validator, $last, $context); @@ -58,18 +59,6 @@ pub fn visit_statement( AstStatement::Literal(AstLiteral::Array(Array { elements: Some(elements) })) => { visit_statement(validator, elements.as_ref(), context); } - AstStatement::CastStatement(data) => { - if let AstStatement::Literal(literal) = data.target.get_stmt() { - validate_cast_literal( - validator, - literal, - statement, - &data.type_name, - &statement.get_location(), - context, - ); - } - } AstStatement::MultipliedStatement(data) => { visit_statement(validator, &data.element, context); } @@ -97,14 +86,22 @@ pub fn visit_statement( visit_statement(validator, &data.left, context); visit_statement(validator, &data.right, context); - validate_assignment(validator, &data.right, Some(&data.left), &statement.get_location(), context); + validate_assignment(validator, &data.right, Some(&data.left), &statement.location, context); validate_array_assignment(validator, context, statement); } AstStatement::OutputAssignment(data) => { visit_statement(validator, &data.left, context); visit_statement(validator, &data.right, context); - validate_assignment(validator, &data.right, Some(&data.left), &statement.get_location(), context); + validate_assignment(validator, &data.right, Some(&data.left), &statement.location, context); + } + AstStatement::RefAssignment(data) => { + visit_statement(validator, &data.left, context); + visit_statement(validator, &data.right, context); + + validate_ref_assignment(context, validator, data, &statement.location); + validate_alias_assignment(validator, context, statement); + validate_array_assignment(validator, context, statement); } AstStatement::CallStatement(data) => { validate_call(validator, &data.operator, data.parameters.as_deref(), &context.set_is_call()); @@ -774,6 +771,99 @@ fn validate_call_by_ref(validator: &mut Validator, param: &VariableIndexEntry, a } } +pub fn validate_pointer_assignment( + context: &ValidationContext, + validator: &mut Validator, + type_lhs: &DataType, + type_rhs: &DataType, + assignment_location: &SourceLocation, +) where + T: AnnotationMap, +{ + let type_info_lhs = context.index.find_elementary_pointer_type(type_lhs.get_type_information()); + let type_info_rhs = context.index.find_elementary_pointer_type(type_rhs.get_type_information()); + + if type_info_lhs.is_array() && type_info_rhs.is_array() { + let len_lhs = type_info_lhs.get_array_length(context.index).unwrap_or_default(); + let len_rhs = type_info_rhs.get_array_length(context.index).unwrap_or_default(); + + let inner_ty_name_lhs = type_info_lhs.get_inner_array_type_name().unwrap_or(VOID_TYPE); + let inner_ty_name_rhs = type_info_rhs.get_inner_array_type_name().unwrap_or(VOID_TYPE); + let inner_ty_lhs = context.index.find_effective_type_by_name(inner_ty_name_lhs); + let inner_ty_rhs = context.index.find_effective_type_by_name(inner_ty_name_rhs); + + if len_lhs != len_rhs || inner_ty_lhs != inner_ty_rhs { + validator.push_diagnostic(Diagnostic::invalid_assignment( + &get_datatype_name_or_slice(validator.context, type_rhs), + &get_datatype_name_or_slice(validator.context, type_lhs), + assignment_location, + )); + } + } else if type_info_lhs != type_info_rhs { + let type_name_lhs = get_datatype_name_or_slice(validator.context, type_lhs); + let type_name_rhs = get_datatype_name_or_slice(validator.context, type_rhs); + + validator.push_diagnostic(Diagnostic::invalid_assignment( + &type_name_rhs, + &type_name_lhs, + assignment_location, + )); + } +} + +/// Checks if `REF=` assignments are correct, specifically if the left-hand side is a reference declared +/// as `REFERENCE TO` and the right hand side is a lvalue of the same type that is being referenced. +fn validate_ref_assignment( + context: &ValidationContext, + validator: &mut Validator, + assignment: &Assignment, + assignment_location: &SourceLocation, +) { + let annotation_lhs = context.annotations.get(&assignment.left); + let type_lhs = context.annotations.get_type_or_void(&assignment.left, context.index); + let type_rhs = context.annotations.get_type_or_void(&assignment.right, context.index); + + // Assert that the right-hand side is a reference + if !assignment.right.is_reference() { + validator.push_diagnostic( + Diagnostic::new("Invalid assignment, expected a reference") + .with_location(&assignment.right.location) + .with_error_code("E098"), + ); + } + + // Assert that the left-hand side is a valid pointer-reference + if !type_lhs.is_pointer() && !annotation_lhs.is_some_and(|opt| opt.is_auto_deref()) { + validator.push_diagnostic( + Diagnostic::new("Invalid assignment, expected a pointer reference") + .with_location(&assignment.left.location) + .with_error_code("E098"), + ) + } + + validate_pointer_assignment(context, validator, type_lhs, type_rhs, assignment_location); +} + +/// Returns a diagnostic if an alias declared variables address is re-assigned in the POU body. +fn validate_alias_assignment( + validator: &mut Validator, + context: &ValidationContext, + ref_assignment: &AstNode, +) { + if let AstStatement::RefAssignment(Assignment { left, .. }) = ref_assignment.get_stmt() { + if context.annotations.get(left).is_some_and(|opt| opt.is_alias()) { + validator.push_diagnostic( + Diagnostic::new(format!( + "{} is an immutable alias variable, can not change the address", + validator.context.slice(&left.location) + )) + .with_location(&ref_assignment.location) + .with_error_code("E100"), + ) + } + } +} + fn validate_assignment( validator: &mut Validator, right: &AstNode, @@ -839,7 +929,7 @@ fn validate_assignment( if let (Some(right_type), Some(left_type)) = (right_type, left_type) { // implicit call parameter assignments are annotated to auto_deref pointers for ´ByRef` parameters // we need the inner type - let left_type = if let DataTypeInformation::Pointer { inner_type_name, auto_deref: true, .. } = + let left_type = if let DataTypeInformation::Pointer { inner_type_name, auto_deref: Some(_), .. } = left_type.get_type_information() { context.index.get_effective_type_or_void_by_name(inner_type_name) @@ -868,11 +958,7 @@ fn validate_assignment( .with_location(location), ); } else { - validator.push_diagnostic(Diagnostic::invalid_assignment( - &get_datatype_name_or_slice(validator.context, right_type), - &get_datatype_name_or_slice(validator.context, left_type), - location.clone(), - )); + validate_pointer_assignment(context, validator, left_type, right_type, location); } } else { validate_assignment_type_sizes(validator, left_type, right, context) @@ -1067,7 +1153,7 @@ fn is_invalid_pointer_assignment( return !typesystem::is_same_type_class(left_type, right_type, index); } //check if Datatype can hold a Pointer (u64) - else if right_type.is_pointer() + else if (right_type.is_pointer() && !right_type.is_auto_deref()) && !left_type.is_pointer() && left_type.get_size_in_bits(index) < POINTER_SIZE { @@ -1131,7 +1217,7 @@ fn is_aggregate_type_missmatch(left_type: &DataType, right_type: &DataType, inde fn validate_call( validator: &mut Validator, operator: &AstNode, - parameters: Option<&AstNode>, + operator_arguments: Option<&AstNode>, context: &ValidationContext, ) { // visit called pou @@ -1140,20 +1226,24 @@ fn validate_call( if let Some(pou) = context.find_pou(operator) { // additional validation for builtin calls if necessary if let Some(validation) = builtins::get_builtin(pou.get_name()).and_then(BuiltIn::get_validation) { - validation(validator, operator, parameters, context.annotations, context.index) + validation(validator, operator, operator_arguments, context.annotations, context.index) } - let declared_parameters = context.index.get_declared_parameters(pou.get_name()); - let passed_parameters = parameters.map(flatten_expression_list).unwrap_or_default(); + let arguments = operator_arguments.map(flatten_expression_list).unwrap_or_default(); + let parameters = context.index.get_declared_parameters(pou.get_name()); + + if builtins::get_builtin(pou.get_name()).is_none() { + validate_argument_count(context, validator, pou, &arguments, &operator.location); + } - let mut are_implicit_parameters = true; + let mut arguments_are_implicit = true; let mut variable_location_in_parent = vec![]; // validate parameters - for (i, param) in passed_parameters.iter().enumerate() { - match get_implicit_call_parameter(param, &declared_parameters, i) { + for (i, param) in arguments.iter().enumerate() { + match get_implicit_call_parameter(param, ¶meters, i) { Ok((parameter_location_in_parent, right, is_implicit)) => { - let left = declared_parameters.get(parameter_location_in_parent); + let left = parameters.get(parameter_location_in_parent); if let Some(left) = left { validate_call_by_ref(validator, left, param); // 'parameter location in parent' and 'variable location in parent' are not the same (e.g VAR blocks are not counted as param). @@ -1167,11 +1257,11 @@ fn validate_call( validate_assignment(validator, right, None, ¶m.get_location(), context); } - // mixing implicit and explicit parameters is not allowed - // allways compare to the first passed parameter + // mixing implicit and explicit arguments is not allowed + // allways compare to the first argument if i == 0 { - are_implicit_parameters = is_implicit; - } else if are_implicit_parameters != is_implicit { + arguments_are_implicit = is_implicit; + } else if arguments_are_implicit != is_implicit { validator.push_diagnostic( Diagnostic::new("Cannot mix implicit and explicit call parameters!") .with_error_code("E031") @@ -1202,7 +1292,7 @@ fn validate_call( return; } let declared_in_out_params: Vec<&&VariableIndexEntry> = - declared_parameters.iter().filter(|p| VariableType::InOut == p.get_variable_type()).collect(); + parameters.iter().filter(|p| VariableType::InOut == p.get_variable_type()).collect(); // if the called pou has declared inouts, we need to make sure that these were passed to the pou call if !declared_in_out_params.is_empty() { @@ -1220,7 +1310,7 @@ fn validate_call( } } else { // POU could not be found, we can still partially validate the passed parameters - if let Some(s) = parameters.as_ref() { + if let Some(s) = operator_arguments.as_ref() { visit_statement(validator, s, context); } } @@ -1484,7 +1574,44 @@ fn validate_assignment_type_sizes( }); } -mod helper { +/// Validates if a POU call has the correct number of arguments. Specifically, for functions, +/// the argument count must be equal to the required count unless the interface is variadic, +/// in which case the argument count may be greater than or equal to the required count. For stateful +/// POUs, the argument count can be less than or equal to the required count since VAR_INPUT and +/// VAR_OUTPUT arguments are optional. +fn validate_argument_count( + context: &ValidationContext, + validator: &mut Validator, + pou: &PouIndexEntry, + arguments: &[&AstNode], + operator_location: &SourceLocation, +) { + let parameters = context.index.get_declared_parameters(pou.get_name()); + let has_variadic_parameter = context.index.has_variadic_parameter(pou.get_name()); + + let argument_count_is_incorrect = match pou { + PouIndexEntry::Function { .. } => { + !((has_variadic_parameter && arguments.len() >= parameters.len()) + || (arguments.len() == parameters.len())) + } + + PouIndexEntry::Program { .. } | PouIndexEntry::FunctionBlock { .. } => { + arguments.len() > parameters.len() && !has_variadic_parameter + } + + _ => false, + }; + + if argument_count_is_incorrect { + validator.push_diagnostic(Diagnostic::invalid_argument_count( + parameters.len(), + arguments.len(), + operator_location, + )); + } +} + +pub(crate) mod helper { use std::ops::Range; use plc_ast::ast::{AstNode, DirectAccessType}; @@ -1522,7 +1649,7 @@ mod helper { pub fn get_datatype_name_or_slice(context: &GlobalContext, dt: &DataType) -> String { if dt.is_internal() { - return dt.get_type_information().get_name().to_string(); + return dt.get_type_information().get_inner_name().to_string(); } context.slice(&dt.location) diff --git a/src/validation/tests/assignment_validation_tests.rs b/src/validation/tests/assignment_validation_tests.rs index 40da9e7fc42..ddf4ce82f63 100644 --- a/src/validation/tests/assignment_validation_tests.rs +++ b/src/validation/tests/assignment_validation_tests.rs @@ -1,6 +1,6 @@ -use insta::assert_snapshot; +use insta::{assert_debug_snapshot, assert_snapshot}; -use crate::test_utils::tests::parse_and_validate_buffered; +use crate::test_utils::tests::{parse_and_validate, parse_and_validate_buffered}; #[test] fn constant_assignment_validation() { @@ -1217,3 +1217,365 @@ fn void_assignment_validation() { "###) } + +#[test] +fn ref_assignments() { + let diagnostics = parse_and_validate_buffered( + " + FUNCTION main + VAR + localINT : INT; + localDINT : DINT; + localSTRING : STRING; + + localRefTo : REF_TO DINT; + localReferenceTo : REFERENCE TO DINT; + END_VAR + + localRefTo REF= localDINT; + localReferenceTo REF= localDINT; + + // The following are invalid + 1 REF= localDINT; + localINT REF= localDINT; + localRefTo REF= 1; + localReferenceTo REF= 1; + + localReferenceTo REF= localINT; + localReferenceTo REF= localSTRING; + localReferenceTo REF= 'howdy'; + END_FUNCTION + ", + ); + + assert_snapshot!(diagnostics, @r###" + error[E098]: Invalid assignment, expected a pointer reference + ┌─ :16:13 + │ + 16 │ 1 REF= localDINT; + │ ^ Invalid assignment, expected a pointer reference + + error[E098]: Invalid assignment, expected a pointer reference + ┌─ :17:13 + │ + 17 │ localINT REF= localDINT; + │ ^^^^^^^^ Invalid assignment, expected a pointer reference + + error[E037]: Invalid assignment: cannot assign 'DINT' to 'INT' + ┌─ :17:13 + │ + 17 │ localINT REF= localDINT; + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign 'DINT' to 'INT' + + error[E098]: Invalid assignment, expected a reference + ┌─ :18:38 + │ + 18 │ localRefTo REF= 1; + │ ^ Invalid assignment, expected a reference + + error[E098]: Invalid assignment, expected a reference + ┌─ :19:38 + │ + 19 │ localReferenceTo REF= 1; + │ ^ Invalid assignment, expected a reference + + error[E037]: Invalid assignment: cannot assign 'INT' to 'DINT' + ┌─ :21:13 + │ + 21 │ localReferenceTo REF= localINT; + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign 'INT' to 'DINT' + + error[E037]: Invalid assignment: cannot assign 'STRING' to 'DINT' + ┌─ :22:13 + │ + 22 │ localReferenceTo REF= localSTRING; + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign 'STRING' to 'DINT' + + error[E098]: Invalid assignment, expected a reference + ┌─ :23:38 + │ + 23 │ localReferenceTo REF= 'howdy'; + │ ^^^^^^^ Invalid assignment, expected a reference + + error[E037]: Invalid assignment: cannot assign 'STRING' to 'DINT' + ┌─ :23:13 + │ + 23 │ localReferenceTo REF= 'howdy'; + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign 'STRING' to 'DINT' + + "###); +} + +#[test] +fn ref_assignment_with_global_local_variables_and_aliased_types() { + let diagnostics = parse_and_validate_buffered( + " + VAR_GLOBAL + fooGlobal : DINT; + END_VAR + + FUNCTION main + VAR + fooLocal : DINT; + referenceToFooFirstOfHisName : REFERENCE TO DINT; + referenceToFooSecondOfHisName : REFERENCE TO DINT; + referenceToAlias : REFERENCE TO AliasedDINT; + + intLocal : INT; + stringLocal : STRING; + + // Invalid, types should be referenced rather than literals or variables + invalidA : REFERENCE TO fooLocal; + invalidB : REFERENCE TO fooGlobal; + invalidC : REFERENCE TO DINT := 5; + END_VAR + + referenceToFooFirstOfHisName REF= fooLocal; + referenceToFooFirstOfHisName REF= fooGlobal; + referenceToFooFirstOfHisName REF= referenceToFooFirstOfHisName; // Valid, albeit questionable + referenceToFooFirstOfHisName REF= referenceToFooSecondOfHisName; + + // Invalid, type mismatch + referenceToFooFirstOfHisName REF= intLocal; + referenceToFooFirstOfHisName REF= stringLocal; + END_FUNCTION + ", + ); + + assert_snapshot!(diagnostics, @r###" + error[E099]: REFERENCE TO variables can not reference other variables + ┌─ :17:28 + │ + 17 │ invalidA : REFERENCE TO fooLocal; + │ ^^^^^^^^^^^^^^^^^^^^^ REFERENCE TO variables can not reference other variables + + error[E099]: REFERENCE TO variables can not reference other variables + ┌─ :18:28 + │ + 18 │ invalidB : REFERENCE TO fooGlobal; + │ ^^^^^^^^^^^^^^^^^^^^^^ REFERENCE TO variables can not reference other variables + + error[E037]: Invalid assignment: cannot assign 'INT' to 'DINT' + ┌─ :28:13 + │ + 28 │ referenceToFooFirstOfHisName REF= intLocal; + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign 'INT' to 'DINT' + + error[E037]: Invalid assignment: cannot assign 'STRING' to 'DINT' + ┌─ :29:13 + │ + 29 │ referenceToFooFirstOfHisName REF= stringLocal; + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign 'STRING' to 'DINT' + + "###); +} + +#[test] +fn ref_assignment_with_reference_to_array_variable() { + let diagnostics = parse_and_validate_buffered( + " + FUNCTION main + VAR + arrSTRING : ARRAY[1..6] OF STRING; + arrDINT : ARRAY[1..5] OF DINT; + arrReferenceDINT : REFERENCE TO ARRAY[1..5] OF DINT; + END_VAR + + arrReferenceDINT REF= arrDINT; + arrReferenceDINT REF= arrSTRING; + END_FUNCTION + ", + ); + + assert_snapshot!(diagnostics, @r###" + error[E037]: Invalid assignment: cannot assign 'ARRAY[1..6] OF STRING' to 'REFERENCE TO ARRAY[1..5] OF DINT' + ┌─ :10:13 + │ + 10 │ arrReferenceDINT REF= arrSTRING; + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign 'ARRAY[1..6] OF STRING' to 'REFERENCE TO ARRAY[1..5] OF DINT' + + "###); +} + +#[test] +fn ref_assignment_with_reference_to_string_variable() { + let diagnostics = parse_and_validate_buffered( + " + FUNCTION main + VAR + localCHAR : CHAR; + localSTRING : STRING; + localWSTRING : WSTRING; + referenceToString : REFERENCE TO STRING; + END_VAR + + referenceToString REF= localCHAR; + referenceToString REF= localSTRING; + referenceToString REF= localWSTRING; + END_FUNCTION + ", + ); + + assert_snapshot!(diagnostics, @r###" + error[E037]: Invalid assignment: cannot assign 'CHAR' to 'STRING' + ┌─ :10:13 + │ + 10 │ referenceToString REF= localCHAR; + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign 'CHAR' to 'STRING' + + error[E037]: Invalid assignment: cannot assign 'WSTRING' to 'STRING' + ┌─ :12:13 + │ + 12 │ referenceToString REF= localWSTRING; + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign 'WSTRING' to 'STRING' + + "###); +} + +// TODO(volsa): Improve the error messages here; these are the default messages returned by the parser +// without any modifications. +#[test] +fn invalid_reference_to_declaration() { + let diagnostics = parse_and_validate_buffered( + r" + FUNCTION foo + VAR + bar : ARRAY[1..5] OF REFERENCE TO DINT; + baz : REFERENCE TO REFERENCE TO DINT; + qux : REF_TO REFERENCE TO DINT; + END_VAR + END_FUNCTION + ", + ); + + insta::assert_snapshot!(diagnostics, @r###" + error[E007]: Unexpected token: expected DataTypeDefinition but found KeywordReferenceTo + ┌─ :4:38 + │ + 4 │ bar : ARRAY[1..5] OF REFERENCE TO DINT; + │ ^^^^^^^^^^^^ Unexpected token: expected DataTypeDefinition but found KeywordReferenceTo + + error[E007]: Unexpected token: expected KeywordSemicolon but found 'REFERENCE TO DINT' + ┌─ :4:38 + │ + 4 │ bar : ARRAY[1..5] OF REFERENCE TO DINT; + │ ^^^^^^^^^^^^^^^^^ Unexpected token: expected KeywordSemicolon but found 'REFERENCE TO DINT' + + error[E007]: Unexpected token: expected DataTypeDefinition but found KeywordReferenceTo + ┌─ :5:36 + │ + 5 │ baz : REFERENCE TO REFERENCE TO DINT; + │ ^^^^^^^^^^^^ Unexpected token: expected DataTypeDefinition but found KeywordReferenceTo + + error[E007]: Unexpected token: expected KeywordEndVar but found 'REFERENCE TO DINT; + qux : REF_TO REFERENCE TO DINT;' + ┌─ :5:36 + │ + 5 │ baz : REFERENCE TO REFERENCE TO DINT; + │ ╭────────────────────────────────────^ + 6 │ │ qux : REF_TO REFERENCE TO DINT; + │ ╰───────────────────────────────────────────────^ Unexpected token: expected KeywordEndVar but found 'REFERENCE TO DINT; + qux : REF_TO REFERENCE TO DINT;' + + "###); +} + +#[test] +fn alias_variable_type_check() { + let diagnostics = parse_and_validate( + r" + FUNCTION foo + VAR + dintVar : DINT; + sintVar : SINT; + stringVar : STRING; + arrayDintVar : ARRAY[1..5] OF DINT; + + dintVarRefA AT dintVar : DINT; // Valid + dintVarRefB AT sintVar : DINT; // Invalid + dintVarRefC AT stringVar : DINT; // Invalid + dintVarRefD AT arrayDintVar : DINT; // Invalid + + sintVarRefA AT dintVar : SINT; // Invalid + sintVarRefB AT sintVar : SINT; // Valid + sintVarRefC AT stringVar : SINT; // Invalid + sintVarRefD AT arrayDintVar : SINT; // Invalid + + stringVarRefA AT dintVar : STRING; // Invalid + stringVarRefB AT sintVar : STRING; // Invalid + stringVarRefC AT stringVar : STRING; // Valid + stringVarRefD AT arrayDintVar : STRING; // Invalid + + arrayDintVarRefA AT dintVar : ARRAY[1..5] OF DINT; // Invalid + arrayDintVarRefB AT sintVar : ARRAY[1..5] OF DINT; // Invalid + arrayDintVarRefC AT stringVar : ARRAY[1..5] OF DINT; // Invalid + arrayDintVarRefD AT arrayDintVar : ARRAY[1..5] OF DINT; // Valid + END_VAR + END_FUNCTION + ", + ); + + // Note: This assertion must fail once init functions are implemented and can then also be deleted + assert!(diagnostics.iter().any(|diagnostics| diagnostics.get_error_code() == "E033")); + + // TODO: Use parse_and_validate_buffered once above assertion is deleted + let diagnostics_messages_without_const_error = diagnostics + .iter() + .filter(|diagnostic| diagnostic.get_error_code() != "E033") + .map(|diagnostic| diagnostic.get_message()) + .collect::>(); + + assert_eq!(diagnostics_messages_without_const_error.len(), 12); + assert_debug_snapshot!(diagnostics_messages_without_const_error, @r###" + [ + "Invalid assignment: cannot assign 'SINT' to 'DINT'", + "Invalid assignment: cannot assign 'STRING' to 'DINT'", + "Invalid assignment: cannot assign '__foo_arrayDintVar' to 'DINT'", + "Invalid assignment: cannot assign 'DINT' to 'SINT'", + "Invalid assignment: cannot assign 'STRING' to 'SINT'", + "Invalid assignment: cannot assign '__foo_arrayDintVar' to 'SINT'", + "Invalid assignment: cannot assign 'DINT' to 'STRING'", + "Invalid assignment: cannot assign 'SINT' to 'STRING'", + "Invalid assignment: cannot assign '__foo_arrayDintVar' to 'STRING'", + "Invalid assignment: cannot assign 'DINT' to 'ARRAY[1..5] OF DINT'", + "Invalid assignment: cannot assign 'SINT' to 'ARRAY[1..5] OF DINT'", + "Invalid assignment: cannot assign 'STRING' to 'ARRAY[1..5] OF DINT'", + ] + "###); +} + +#[test] +fn reassignment_of_alias_variables_is_disallowed() { + let diagnostics = parse_and_validate( + r" + FUNCTION main + VAR + foo AT bar : DINT; + bar : DINT; + baz : DINT; + END_VAR + + foo := bar; // Valid, the dereferenced value of `foo` is being changed + foo := baz; // Valid, same reason as above + foo REF= bar; // Invalid, the address of `foo` is being changed + END_FUNCTION + ", + ); + + // Note: This assertion must fail once init functions are implemented and can then also be deleted + assert!(diagnostics.iter().any(|diagnostics| diagnostics.get_error_code() == "E033")); + + // TODO: Use parse_and_validate_buffered once above assertion is deleted + let diagnostics_messages_without_const_error = diagnostics + .iter() + .filter(|diagnostic| diagnostic.get_error_code() != "E033") + .map(|diagnostic| diagnostic.get_message()) + .collect::>(); + + assert_eq!(diagnostics_messages_without_const_error.len(), 1); + assert_debug_snapshot!(diagnostics_messages_without_const_error, @r###" + [ + "foo is an immutable alias variable, can not change the address", + ] + "###); +} diff --git a/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__pointer_assignment_validation.snap b/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__pointer_assignment_validation.snap index 3318e16d805..812104a4a62 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__pointer_assignment_validation.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__pointer_assignment_validation.snap @@ -26,11 +26,11 @@ error[E037]: Invalid assignment: cannot assign 'REF_TO INT' to 'WORD' 29 │ v_word := v_ptr_int; // INVALID │ ^^^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign 'REF_TO INT' to 'WORD' -warning[E090]: Pointers REF_TO INT and __POINTER_TO_REAL have different types +warning[E090]: Pointers REF_TO INT and REAL have different types ┌─ :31:5 │ 31 │ v_ptr_int := REF(v_real); // INVALID -> TODO: should be valid - │ ^^^^^^^^^^^^^^^^^^^^^^^^ Pointers REF_TO INT and __POINTER_TO_REAL have different types + │ ^^^^^^^^^^^^^^^^^^^^^^^^ Pointers REF_TO INT and REAL have different types warning[E067]: Implicit downcast from 'REAL' to 'INT'. ┌─ :32:19 @@ -62,11 +62,11 @@ warning[E067]: Implicit downcast from 'WORD' to 'INT'. 40 │ v_ptr_int^ := v_word; // valid │ ^^^^^^ Implicit downcast from 'WORD' to 'INT'. -warning[E090]: Pointers REF_TO INT and __POINTER_TO_STRING have different types +warning[E090]: Pointers REF_TO INT and STRING have different types ┌─ :41:5 │ 41 │ v_ptr_int := REF(v_string); // INVALID - │ ^^^^^^^^^^^^^^^^^^^^^^^^^^ Pointers REF_TO INT and __POINTER_TO_STRING have different types + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^ Pointers REF_TO INT and STRING have different types error[E037]: Invalid assignment: cannot assign 'STRING' to 'INT' ┌─ :42:5 diff --git a/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__struct_assignment_validation.snap b/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__struct_assignment_validation.snap index 8e77f342fee..1eeb0996e84 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__struct_assignment_validation.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__assignment_validation_tests__struct_assignment_validation.snap @@ -32,20 +32,20 @@ error[E037]: Invalid assignment: cannot assign 'STRUCT2' to 'STRUCT1' 56 │ myFB(var_inout_struct1 := v_struct2); // INVALID │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Invalid assignment: cannot assign 'STRUCT2' to 'STRUCT1' -warning[E090]: Pointers REF_TO STRUCT1 and __POINTER_TO_REAL have different types +warning[E090]: Pointers REF_TO STRUCT1 and REAL have different types ┌─ :66:5 │ 66 │ v_ref_to_struct1 := REF(v_real); // INVALID - │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Pointers REF_TO STRUCT1 and __POINTER_TO_REAL have different types + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Pointers REF_TO STRUCT1 and REAL have different types -warning[E090]: Pointers REF_TO STRUCT1 and __POINTER_TO_STRING have different types +warning[E090]: Pointers REF_TO STRUCT1 and STRING have different types ┌─ :67:5 │ 67 │ v_ref_to_struct1 := REF(v_string); // INVALID - │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Pointers REF_TO STRUCT1 and __POINTER_TO_STRING have different types + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Pointers REF_TO STRUCT1 and STRING have different types -warning[E090]: Pointers REF_TO STRUCT1 and __POINTER_TO_CHAR have different types +warning[E090]: Pointers REF_TO STRUCT1 and CHAR have different types ┌─ :68:5 │ 68 │ v_ref_to_struct1 := REF(v_char); // INVALID - │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Pointers REF_TO STRUCT1 and __POINTER_TO_CHAR have different types + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Pointers REF_TO STRUCT1 and CHAR have different types diff --git a/src/validation/tests/snapshots/rusty__validation__tests__builtin_validation_tests__arithmetic_builtins_called_with_invalid_param_count.snap b/src/validation/tests/snapshots/rusty__validation__tests__builtin_validation_tests__arithmetic_builtins_called_with_invalid_param_count.snap index 118b7272712..f32c66c15d0 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__builtin_validation_tests__arithmetic_builtins_called_with_invalid_param_count.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__builtin_validation_tests__arithmetic_builtins_called_with_invalid_param_count.snap @@ -2,11 +2,11 @@ source: src/validation/tests/builtin_validation_tests.rs expression: "&diagnostics" --- -error[E032]: Invalid parameter count. Received 0 parameters while 2 parameters were expected. +error[E032]: this POU takes 2 arguments but 0 arguments were supplied ┌─ :7:13 │ 7 │ ADD(); - │ ^^^ Invalid parameter count. Received 0 parameters while 2 parameters were expected. + │ ^^^ this POU takes 2 arguments but 0 arguments were supplied error[E064]: Could not resolve generic type T with ANY_NUMBER ┌─ :7:13 @@ -14,22 +14,20 @@ error[E064]: Could not resolve generic type T with ANY_NUMBER 7 │ ADD(); │ ^^^^^^ Could not resolve generic type T with ANY_NUMBER -error[E032]: Invalid parameter count. Received 1 parameters while 2 parameters were expected. +error[E032]: this POU takes 2 arguments but 1 argument was supplied ┌─ :8:13 │ 8 │ MUL(x1); - │ ^^^ Invalid parameter count. Received 1 parameters while 2 parameters were expected. + │ ^^^ this POU takes 2 arguments but 1 argument was supplied -error[E032]: Invalid parameter count. Received 4 parameters while 2 parameters were expected. +error[E032]: this POU takes 2 arguments but 4 arguments were supplied ┌─ :9:13 │ 9 │ DIV(x2, x2, x1, x2); // DIV and SUB are not extensible - │ ^^^ Invalid parameter count. Received 4 parameters while 2 parameters were expected. + │ ^^^ this POU takes 2 arguments but 4 arguments were supplied -error[E032]: Invalid parameter count. Received 4 parameters while 2 parameters were expected. +error[E032]: this POU takes 2 arguments but 4 arguments were supplied ┌─ :10:13 │ 10 │ SUB(x2, x2, x1, x2); - │ ^^^ Invalid parameter count. Received 4 parameters while 2 parameters were expected. - - + │ ^^^ this POU takes 2 arguments but 4 arguments were supplied diff --git a/src/validation/tests/snapshots/rusty__validation__tests__builtin_validation_tests__comparison_builtins_called_with_invalid_param_count.snap b/src/validation/tests/snapshots/rusty__validation__tests__builtin_validation_tests__comparison_builtins_called_with_invalid_param_count.snap index cafd37f35ca..5eb779a4d07 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__builtin_validation_tests__comparison_builtins_called_with_invalid_param_count.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__builtin_validation_tests__comparison_builtins_called_with_invalid_param_count.snap @@ -2,22 +2,20 @@ source: src/validation/tests/builtin_validation_tests.rs expression: "&diagnostics" --- -error[E032]: Invalid parameter count. Received 0 parameters while 2 parameters were expected. +error[E032]: this POU takes 2 arguments but 0 arguments were supplied ┌─ :7:13 │ 7 │ EQ(); - │ ^^ Invalid parameter count. Received 0 parameters while 2 parameters were expected. + │ ^^ this POU takes 2 arguments but 0 arguments were supplied -error[E032]: Invalid parameter count. Received 1 parameters while 2 parameters were expected. +error[E032]: this POU takes 2 arguments but 1 argument was supplied ┌─ :8:13 │ 8 │ GT(x1); - │ ^^ Invalid parameter count. Received 1 parameters while 2 parameters were expected. + │ ^^ this POU takes 2 arguments but 1 argument was supplied -error[E032]: Invalid parameter count. Received 4 parameters while 2 parameters were expected. +error[E032]: this POU takes 2 arguments but 4 arguments were supplied ┌─ :10:13 │ 10 │ NE(x2, x2, x1, x2); // NE is not extensible - │ ^^ Invalid parameter count. Received 4 parameters while 2 parameters were expected. - - + │ ^^ this POU takes 2 arguments but 4 arguments were supplied diff --git a/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__ref_builtin_function_reports_invalid_param_count.snap b/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__ref_builtin_function_reports_invalid_param_count.snap index f30dceb1b44..02950337cbe 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__ref_builtin_function_reports_invalid_param_count.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__ref_builtin_function_reports_invalid_param_count.snap @@ -2,16 +2,14 @@ source: src/validation/tests/statement_validation_tests.rs expression: diagnostics --- -error[E032]: Invalid parameter count. Received 0 parameters while 1 parameters were expected. +error[E032]: this POU takes 1 argument but 0 arguments were supplied ┌─ :7:13 │ 7 │ REF(); - │ ^^^ Invalid parameter count. Received 0 parameters while 1 parameters were expected. + │ ^^^ this POU takes 1 argument but 0 arguments were supplied -error[E032]: Invalid parameter count. Received 4 parameters while 1 parameters were expected. +error[E032]: this POU takes 1 argument but 4 arguments were supplied ┌─ :8:13 │ 8 │ REF(x, 1, 2, 'abc'); - │ ^^^ Invalid parameter count. Received 4 parameters while 1 parameters were expected. - - + │ ^^^ this POU takes 1 argument but 4 arguments were supplied diff --git a/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__reference_to_reference_assignments_in_function_arguments.snap b/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__reference_to_reference_assignments_in_function_arguments.snap index 46c02e259f3..35513a3c8eb 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__reference_to_reference_assignments_in_function_arguments.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__statement_validation_tests__reference_to_reference_assignments_in_function_arguments.snap @@ -2,20 +2,20 @@ source: src/validation/tests/statement_validation_tests.rs expression: "&diagnostics" --- -warning[E090]: Pointers REF_TO STRUCT_params and __POINTER_TO_INT have different types +warning[E090]: Pointers REF_TO STRUCT_params and INT have different types ┌─ :47:13 │ 47 │ input1 := REF(global4), - │ ^^^^^^^^^^^^^^^^^^^^^^ Pointers REF_TO STRUCT_params and __POINTER_TO_INT have different types + │ ^^^^^^^^^^^^^^^^^^^^^^ Pointers REF_TO STRUCT_params and INT have different types -warning[E090]: Pointers REF_TO STRUCT_params and __POINTER_TO_REAL have different types +warning[E090]: Pointers REF_TO STRUCT_params and REAL have different types ┌─ :48:13 │ 48 │ input2 := REF(global5), - │ ^^^^^^^^^^^^^^^^^^^^^^ Pointers REF_TO STRUCT_params and __POINTER_TO_REAL have different types + │ ^^^^^^^^^^^^^^^^^^^^^^ Pointers REF_TO STRUCT_params and REAL have different types -warning[E090]: Pointers REF_TO STRUCT_params and __POINTER_TO_STRING have different types +warning[E090]: Pointers REF_TO STRUCT_params and STRING have different types ┌─ :49:13 │ 49 │ input3 := REF(global6), - │ ^^^^^^^^^^^^^^^^^^^^^^ Pointers REF_TO STRUCT_params and __POINTER_TO_STRING have different types + │ ^^^^^^^^^^^^^^^^^^^^^^ Pointers REF_TO STRUCT_params and STRING have different types diff --git a/src/validation/tests/snapshots/rusty__validation__tests__variable_length_array_test__builtins__builtins_called_with_invalid_number_of_params.snap b/src/validation/tests/snapshots/rusty__validation__tests__variable_length_array_test__builtins__builtins_called_with_invalid_number_of_params.snap index 61e2cbe5231..d2c0b22a832 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__variable_length_array_test__builtins__builtins_called_with_invalid_number_of_params.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__variable_length_array_test__builtins__builtins_called_with_invalid_number_of_params.snap @@ -2,23 +2,23 @@ source: src/validation/tests/variable_length_array_test.rs expression: diagnostics --- -error[E032]: Invalid parameter count. Received 0 parameters while 2 parameters were expected. +error[E032]: this POU takes 2 arguments but 0 arguments were supplied ┌─ :13:13 │ 13 │ LOWER_BOUND(); - │ ^^^^^^^^^^^ Invalid parameter count. Received 0 parameters while 2 parameters were expected. + │ ^^^^^^^^^^^ this POU takes 2 arguments but 0 arguments were supplied -error[E032]: Invalid parameter count. Received 1 parameters while 2 parameters were expected. +error[E032]: this POU takes 2 arguments but 1 argument was supplied ┌─ :14:13 │ 14 │ LOWER_BOUND(vla); - │ ^^^^^^^^^^^ Invalid parameter count. Received 1 parameters while 2 parameters were expected. + │ ^^^^^^^^^^^ this POU takes 2 arguments but 1 argument was supplied -error[E032]: Invalid parameter count. Received 1 parameters while 2 parameters were expected. +error[E032]: this POU takes 2 arguments but 1 argument was supplied ┌─ :15:13 │ 15 │ LOWER_BOUND(1); - │ ^^^^^^^^^^^ Invalid parameter count. Received 1 parameters while 2 parameters were expected. + │ ^^^^^^^^^^^ this POU takes 2 arguments but 1 argument was supplied error[E031]: Expected a reference for parameter arr because their type is InOut ┌─ :15:25 @@ -32,29 +32,29 @@ error[E037]: Invalid assignment: cannot assign 'DINT' to 'VARIABLE LENGTH ARRAY' 15 │ LOWER_BOUND(1); │ ^ Invalid assignment: cannot assign 'DINT' to 'VARIABLE LENGTH ARRAY' -error[E032]: Invalid parameter count. Received 4 parameters while 2 parameters were expected. +error[E032]: this POU takes 2 arguments but 4 arguments were supplied ┌─ :16:13 │ 16 │ LOWER_BOUND(vla, 1, 2, 3); - │ ^^^^^^^^^^^ Invalid parameter count. Received 4 parameters while 2 parameters were expected. + │ ^^^^^^^^^^^ this POU takes 2 arguments but 4 arguments were supplied -error[E032]: Invalid parameter count. Received 0 parameters while 2 parameters were expected. +error[E032]: this POU takes 2 arguments but 0 arguments were supplied ┌─ :18:13 │ 18 │ UPPER_BOUND(); - │ ^^^^^^^^^^^ Invalid parameter count. Received 0 parameters while 2 parameters were expected. + │ ^^^^^^^^^^^ this POU takes 2 arguments but 0 arguments were supplied -error[E032]: Invalid parameter count. Received 1 parameters while 2 parameters were expected. +error[E032]: this POU takes 2 arguments but 1 argument was supplied ┌─ :19:13 │ 19 │ UPPER_BOUND(vla); - │ ^^^^^^^^^^^ Invalid parameter count. Received 1 parameters while 2 parameters were expected. + │ ^^^^^^^^^^^ this POU takes 2 arguments but 1 argument was supplied -error[E032]: Invalid parameter count. Received 1 parameters while 2 parameters were expected. +error[E032]: this POU takes 2 arguments but 1 argument was supplied ┌─ :20:13 │ 20 │ UPPER_BOUND(1); - │ ^^^^^^^^^^^ Invalid parameter count. Received 1 parameters while 2 parameters were expected. + │ ^^^^^^^^^^^ this POU takes 2 arguments but 1 argument was supplied error[E031]: Expected a reference for parameter arr because their type is InOut ┌─ :20:25 @@ -68,10 +68,8 @@ error[E037]: Invalid assignment: cannot assign 'DINT' to 'VARIABLE LENGTH ARRAY' 20 │ UPPER_BOUND(1); │ ^ Invalid assignment: cannot assign 'DINT' to 'VARIABLE LENGTH ARRAY' -error[E032]: Invalid parameter count. Received 4 parameters while 2 parameters were expected. +error[E032]: this POU takes 2 arguments but 4 arguments were supplied ┌─ :21:13 │ 21 │ UPPER_BOUND(vla, 1, 2, 3); - │ ^^^^^^^^^^^ Invalid parameter count. Received 4 parameters while 2 parameters were expected. - - + │ ^^^^^^^^^^^ this POU takes 2 arguments but 4 arguments were supplied diff --git a/src/validation/tests/snapshots/rusty__validation__tests__variable_validation_tests__constant_fb_instances_are_illegal.snap b/src/validation/tests/snapshots/rusty__validation__tests__variable_validation_tests__constant_fb_instances_are_illegal.snap index 52d6277b77b..a6062071b64 100644 --- a/src/validation/tests/snapshots/rusty__validation__tests__variable_validation_tests__constant_fb_instances_are_illegal.snap +++ b/src/validation/tests/snapshots/rusty__validation__tests__variable_validation_tests__constant_fb_instances_are_illegal.snap @@ -2,16 +2,14 @@ source: src/validation/tests/variable_validation_tests.rs expression: "&diagnostics" --- -error[E035]: Invalid constant y - Functionblock- and Class-instances cannot be delcared constant +error[E035]: Invalid constant y, FUNCTION_BLOCK- and CLASS-instances cannot be declared constant ┌─ :15:13 │ 15 │ y : MyFb; - │ ^ Invalid constant y - Functionblock- and Class-instances cannot be delcared constant + │ ^ Invalid constant y, FUNCTION_BLOCK- and CLASS-instances cannot be declared constant -error[E035]: Invalid constant z - Functionblock- and Class-instances cannot be delcared constant +error[E035]: Invalid constant z, FUNCTION_BLOCK- and CLASS-instances cannot be declared constant ┌─ :16:13 │ 16 │ z : cls; - │ ^ Invalid constant z - Functionblock- and Class-instances cannot be delcared constant - - + │ ^ Invalid constant z, FUNCTION_BLOCK- and CLASS-instances cannot be declared constant diff --git a/src/validation/tests/statement_validation_tests.rs b/src/validation/tests/statement_validation_tests.rs index fe186996be8..e2cc050b354 100644 --- a/src/validation/tests/statement_validation_tests.rs +++ b/src/validation/tests/statement_validation_tests.rs @@ -1667,3 +1667,157 @@ fn action_assignment_attempt_does_not_report_missing_parentheses() { "###); } + +#[test] +fn incorrect_argument_count_stateless_pous() { + let diagnostics = parse_and_validate_buffered( + " + FUNCTION main : DINT + fn_with_one_parameter(); + fn_with_one_parameter(1, 2); + + fn_with_two_parameters(1); + fn_with_two_parameters(1, 2, 3); + + fn_with_one_variadic_parameter(); + fn_with_one_variadic_parameter(1); + fn_with_one_variadic_parameter(1, 2); + fn_with_one_variadic_parameter(1, 2, 3); + END_FUNCTION + + FUNCTION fn_with_one_parameter + VAR_INPUT + in_one : DINT; + END_VAR + END_FUNCTION + + FUNCTION fn_with_two_parameters + VAR_INPUT + in_one : DINT; + END_VAR + + VAR_OUTPUT + out_two : DINT; + END_VAR + END_FUNCTION + + FUNCTION fn_with_one_variadic_parameter + VAR_INPUT + vararg: DINT...; + END_VAR + END_FUNCTION + ", + ); + + assert_snapshot!(diagnostics, @r###" + error[E032]: this POU takes 1 argument but 0 arguments were supplied + ┌─ :3:13 + │ + 3 │ fn_with_one_parameter(); + │ ^^^^^^^^^^^^^^^^^^^^^ this POU takes 1 argument but 0 arguments were supplied + + error[E032]: this POU takes 1 argument but 2 arguments were supplied + ┌─ :4:13 + │ + 4 │ fn_with_one_parameter(1, 2); + │ ^^^^^^^^^^^^^^^^^^^^^ this POU takes 1 argument but 2 arguments were supplied + + error[E032]: this POU takes 2 arguments but 1 argument was supplied + ┌─ :6:13 + │ + 6 │ fn_with_two_parameters(1); + │ ^^^^^^^^^^^^^^^^^^^^^^ this POU takes 2 arguments but 1 argument was supplied + + error[E032]: this POU takes 2 arguments but 3 arguments were supplied + ┌─ :7:13 + │ + 7 │ fn_with_two_parameters(1, 2, 3); + │ ^^^^^^^^^^^^^^^^^^^^^^ this POU takes 2 arguments but 3 arguments were supplied + + error[E031]: Expected a reference for parameter out_two because their type is Output + ┌─ :7:39 + │ + 7 │ fn_with_two_parameters(1, 2, 3); + │ ^ Expected a reference for parameter out_two because their type is Output + + "###); +} + +#[test] +fn incorrect_argument_count_stateful_pous() { + let source = r" + FUNCTION main : DINT + VAR + one_instance : fn_with_one_parameter; + two_instance : fn_with_two_parameters; + END_VAR + + one_instance(); + one_instance(1, 2); + + two_instance(1); + two_instance(1, 2, 3); + END_FUNCTION + + fn_with_one_parameter + VAR_INPUT + in_one : DINT; + END_VAR + END_ + + fn_with_two_parameters + VAR_INPUT + in_one : DINT; + END_VAR + + VAR_OUTPUT + out_two : DINT; + END_VAR + END_ + + "; + + let diagnostics = parse_and_validate_buffered(&source.replace("", "FUNCTION_BLOCK")); + assert_snapshot!(diagnostics, @r###" + error[E032]: this POU takes 1 argument but 2 arguments were supplied + ┌─ :9:13 + │ + 9 │ one_instance(1, 2); + │ ^^^^^^^^^^^^ this POU takes 1 argument but 2 arguments were supplied + + error[E032]: this POU takes 2 arguments but 3 arguments were supplied + ┌─ :12:13 + │ + 12 │ two_instance(1, 2, 3); + │ ^^^^^^^^^^^^ this POU takes 2 arguments but 3 arguments were supplied + + error[E031]: Expected a reference for parameter out_two because their type is Output + ┌─ :12:29 + │ + 12 │ two_instance(1, 2, 3); + │ ^ Expected a reference for parameter out_two because their type is Output + + "###); + + let diagnostics = parse_and_validate_buffered(&source.replace("", "PROGRAM")); + assert_snapshot!(diagnostics, @r###" + error[E032]: this POU takes 1 argument but 2 arguments were supplied + ┌─ :9:13 + │ + 9 │ one_instance(1, 2); + │ ^^^^^^^^^^^^ this POU takes 1 argument but 2 arguments were supplied + + error[E032]: this POU takes 2 arguments but 3 arguments were supplied + ┌─ :12:13 + │ + 12 │ two_instance(1, 2, 3); + │ ^^^^^^^^^^^^ this POU takes 2 arguments but 3 arguments were supplied + + error[E031]: Expected a reference for parameter out_two because their type is Output + ┌─ :12:29 + │ + 12 │ two_instance(1, 2, 3); + │ ^ Expected a reference for parameter out_two because their type is Output + + "###); +} diff --git a/src/validation/variable.rs b/src/validation/variable.rs index f841b0001fe..174454483af 100644 --- a/src/validation/variable.rs +++ b/src/validation/variable.rs @@ -1,15 +1,15 @@ use plc_ast::ast::{ArgumentProperty, Pou, PouType, Variable, VariableBlock, VariableBlockType}; use plc_diagnostics::diagnostics::Diagnostic; -use crate::typesystem::DataTypeInformation; -use crate::{index::const_expressions::ConstExpression, resolver::AnnotationMap}; - use super::{ array::validate_array_assignment, - statement::{validate_enum_variant_assignment, visit_statement}, + statement::{validate_enum_variant_assignment, validate_pointer_assignment, visit_statement}, types::{data_type_is_fb_or_class_instance, visit_data_type_declaration}, ValidationContext, Validator, Validators, }; +use crate::index::VariableIndexEntry; +use crate::typesystem::DataTypeInformation; +use crate::{index::const_expressions::ConstExpression, resolver::AnnotationMap}; pub fn visit_variable_block( validator: &mut Validator, @@ -143,6 +143,8 @@ fn validate_variable( validate_array_ranges(validator, variable, context); if let Some(v_entry) = context.index.find_variable(context.qualifier, &[&variable.name]) { + validate_reference_to_declaration(validator, context, variable, v_entry); + if let Some(initializer) = &variable.initializer { // Assume `foo : ARRAY[1..5] OF DINT := [...]`, here the first function call validates the // assignment as a whole whereas the second function call (`visit_statement`) validates the @@ -198,7 +200,7 @@ fn validate_variable( { validator.push_diagnostic( Diagnostic::new(format!( - "Invalid constant {} - Functionblock- and Class-instances cannot be delcared constant", + "Invalid constant {}, FUNCTION_BLOCK- and CLASS-instances cannot be declared constant", v_entry.get_name() )) .with_error_code("E035") @@ -208,6 +210,47 @@ fn validate_variable( } } +/// Returns a diagnostic if a `REFERENCE TO` variable is incorrectly declared. +fn validate_reference_to_declaration( + validator: &mut Validator, + context: &ValidationContext, + variable: &Variable, + variable_entry: &VariableIndexEntry, +) { + let Some(variable_ty) = context.index.find_effective_type_by_name(variable_entry.get_type_name()) else { + return; + }; + + if !variable_ty.get_type_information().is_reference_to() && !variable_ty.get_type_information().is_alias() + { + return; + } + + let Some(inner_ty_name) = variable_ty.get_type_information().get_inner_pointer_type_name() else { + unreachable!("`REFERENCE TO` is defined as a pointer, hence this must exist") + }; + + // Assert that the referenced type is no variable reference + let qualifier = context.qualifier.unwrap_or_default(); + let inner_ty_is_local_var = context.index.find_member(qualifier, inner_ty_name).is_some(); + let inner_ty_is_global_var = context.index.find_global_variable(inner_ty_name).is_some(); + + if inner_ty_is_local_var || inner_ty_is_global_var { + validator.push_diagnostic( + Diagnostic::new("REFERENCE TO variables can not reference other variables") + .with_location(&variable_ty.location) + .with_error_code("E099"), + ); + } + + if let Some(ref initializer) = variable.initializer { + let type_lhs = context.index.find_type(inner_ty_name).unwrap(); + let type_rhs = context.annotations.get_type(initializer, context.index).unwrap(); + + validate_pointer_assignment(context, validator, type_lhs, type_rhs, &initializer.location); + } +} + #[cfg(test)] mod variable_validator_tests { use insta::assert_snapshot; diff --git a/tests/correctness/bitaccess.rs b/tests/correctness/bitaccess.rs index 06d6e6728fc..a412bf4f6a9 100644 --- a/tests/correctness/bitaccess.rs +++ b/tests/correctness/bitaccess.rs @@ -1,5 +1,9 @@ // Copyright (c) 2020 Ghaith Hachem and Mathias Rieder +// TODO: Some of these tests are incorrect, because a `default()` call will override the values defined in the +// VAR block. Thus any tests relying on data initialized in the VAR block needs to be updated such that +// the initialization happens in the POU body. However, this won't be any issue once we convert to LIT. + use crate::*; use pretty_assertions::assert_eq; @@ -214,3 +218,125 @@ fn byteaccess_assignment_should_not_override_current_values() { let res: i32 = compile_and_run(prog, &mut crate::MainType::default); assert_eq!(res, 0b0000_0000_1100_0011_1010_1010_0101_0101); } + +#[test] +fn bitaccess_in_output_assignments_with_simple_expression() { + let prog = " + FUNCTION_BLOCK foo + VAR_OUTPUT + OUT_FALSE : BOOL; + OUT_TRUE : BOOL; + END_VAR + + OUT_TRUE := TRUE; + OUT_FALSE := FALSE; + END_FUNCTION_BLOCK + + FUNCTION main : DINT + VAR + a : BYTE; + END_VAR + + VAR_TEMP + foo_instance : foo; + END_VAR + + a := 2#1010_1010; + + // Invert these ~~bitc-~~bits + foo_instance(OUT_TRUE => a.0); + foo_instance(OUT_TRUE => a.2); + foo_instance(OUT_TRUE => a.4); + foo_instance(OUT_TRUE => a.6); + + foo_instance(OUT_FALSE => a.1); + foo_instance(OUT_FALSE => a.3); + foo_instance(OUT_FALSE => a.5); + foo_instance(OUT_FALSE => a.7); + + main := a; + END_FUNCTION"; + + let res: i32 = compile_and_run(prog, &mut crate::MainType::default()); + assert_eq!(res, 0b0101_0101); +} + +#[test] +fn bitaccess_in_output_assignment_with_complexish_expression() { + let prog = " + TYPE foo_struct : STRUCT + bar : bar_struct; + END_STRUCT END_TYPE + + TYPE bar_struct : STRUCT + baz : DINT; // 0000_0000_0000_0000_0000_0000_0000_0000 + END_STRUCT END_TYPE + + FUNCTION_BLOCK QUUX + VAR_OUTPUT + Q : BOOL; + END_VAR + + Q := TRUE; + END_FUNCTION_BLOCK + + FUNCTION main : DINT + VAR + foo : foo_struct; + f : QUUX; + END_VAR + + foo.bar.baz := 0; // ...just to be sure + + + // foo.bar.baz: 0000_0000_0000_0000_0000_0000_0000_0000 + f(Q => foo.bar.baz.%W1.%B1.%X3); // 0000_1000_0000_0000_0000_0000_0000_0000 + f(Q => foo.bar.baz.%W1.%B1.%X1); // 0000_1010_0000_0000_0000_0000_0000_0000 + main := foo.bar.baz; + END_FUNCTION + "; + + let res: i32 = compile_and_run(prog, &mut crate::MainType::default()); + assert_eq!(res, 0b0000_1010_0000_0000_0000_0000_0000_0000); +} + +#[test] +fn bitaccess_in_output_assignment_with_complexish_expression_implicit() { + let prog = " + TYPE foo_struct : STRUCT + bar : bar_struct; + END_STRUCT END_TYPE + + TYPE bar_struct : STRUCT + baz : DINT; // 0000_0000_0000_0000_0000_0000_0000_0000 + END_STRUCT END_TYPE + + FUNCTION_BLOCK QUUX + VAR_INPUT + x : DINT; + END_VAR + VAR_OUTPUT + Q : BOOL; + END_VAR + + Q := TRUE; + END_FUNCTION_BLOCK + + FUNCTION main : DINT + VAR + foo : foo_struct; + f : QUUX; + END_VAR + + foo.bar.baz := 0; // ...just to be sure + + // foo.bar.baz: 0000_0000_0000_0000_0000_0000_0000_0000 + f(x := 0, Q => foo.bar.baz.%W1.%B1.%X3); // 0000_1000_0000_0000_0000_0000_0000_0000 + f(0, foo.bar.baz.%W1.%B1.%X1); // 0000_1010_0000_0000_0000_0000_0000_0000 + main := foo.bar.baz; + END_FUNCTION + "; + + let res: i32 = compile_and_run(prog, &mut crate::MainType::default()); + assert_eq!(res, 0b0000_1010_0000_0000_0000_0000_0000_0000); +} diff --git a/tests/correctness/control_flow.rs b/tests/correctness/control_flow.rs index d84495f16a4..cef4a61aef1 100644 --- a/tests/correctness/control_flow.rs +++ b/tests/correctness/control_flow.rs @@ -483,6 +483,109 @@ fn for_loop_and_increment_10_times_skipping_1() { assert_eq!(res, 1005); } +#[test] +fn for_loop_does_not_execute_if_condition_is_not_met() { + let function = r#" + FUNCTION main : DINT + VAR + i, end, step, res: DINT; + END_VAR + end := -1; + step := -1; + res := 100; + + FOR i := end TO 0 BY step DO + res := i; + END_FOR + + main := res; + END_FUNCTION + "#; + + let res: i32 = compile_and_run(function.to_string(), &mut crate::MainType::default()); + assert_eq!(res, 100); +} + +#[test] +fn for_loop_step_changes_sign_in_loop_body() { + let function = r#" + FUNCTION main : DINT + VAR + i, step, temp, iteration: DINT; + END_VAR + step := 1; + iteration := 0; + + FOR i := 5 TO 10 BY step DO + temp := (step + 1) * -1 ; + IF i + temp > 0 THEN + step := temp; + ELSE + step := step + 3; + END_IF; + + // i: 5, 3, 4, 2, 3, 1, 2, 6, 1, 5, 12 + // step: -2, 1, -2, 1, -2, 1, 4, -5, 4, 7 + iteration := iteration + 1; + END_FOR + + main := iteration; + END_FUNCTION + "#; + + let res: i32 = compile_and_run(function.to_string(), &mut crate::MainType::default()); + assert_eq!(res, 10); +} + +#[test] +fn for_loop_step_and_counter_change_sign_in_loop_body() { + let function = r#" + FUNCTION main : DINT + VAR + i, step, temp, iteration: DINT; + END_VAR + step := 1; + iteration := 0; + + FOR i := 3 TO 10 BY step DO + step := (step + 1) * -2; + + // i: 3, -1, 5, -9, 17 + // step: -4, 5, -14, 26 + iteration := iteration + 1; + END_FOR + + main := iteration; + END_FUNCTION + "#; + + let res: i32 = compile_and_run(function.to_string(), &mut crate::MainType::default()); + assert_eq!(res, 4); +} + +#[test] +fn for_loop_statement_with_binary_expressions() { + let function = r#" + FUNCTION main : DINT + VAR + step: DINT := 1; + x, y, iteration : DINT; + z : DINT := 25; + END_VAR + // 1 TO 23 BY 3 + FOR x := y + 1 TO z - 2 BY step * 3 DO + // x: 1, 4, 7, 10, 13, 16, 19, 22 + iteration := iteration + 1; + END_FOR + + main := iteration; + END_FUNCTION + "#; + + let res: i32 = compile_and_run(function.to_string(), &mut crate::MainType::default()); + assert_eq!(res, 8); +} + #[test] fn while_loop_no_entry() { let function = r#" diff --git a/tests/integration/cfc/resolver_tests.rs b/tests/integration/cfc/resolver_tests.rs index f11c8667396..76165b9798f 100644 --- a/tests/integration/cfc/resolver_tests.rs +++ b/tests/integration/cfc/resolver_tests.rs @@ -98,7 +98,7 @@ fn function_block_calls_are_annotated_correctly() { argument_type: ByVal( Local, ), - is_auto_deref: false, + auto_deref: None, } "###); } diff --git a/tests/integration/cfc/snapshots/tests__integration__cfc__resolver_tests__action_variables_annotated-3.snap b/tests/integration/cfc/snapshots/tests__integration__cfc__resolver_tests__action_variables_annotated-3.snap index 5d463082182..ab63eb8fa6c 100644 --- a/tests/integration/cfc/snapshots/tests__integration__cfc__resolver_tests__action_variables_annotated-3.snap +++ b/tests/integration/cfc/snapshots/tests__integration__cfc__resolver_tests__action_variables_annotated-3.snap @@ -10,6 +10,6 @@ Some( argument_type: ByVal( Local, ), - is_auto_deref: false, + auto_deref: None, }, ) diff --git a/tests/integration/cfc/snapshots/tests__integration__cfc__resolver_tests__action_variables_annotated-4.snap b/tests/integration/cfc/snapshots/tests__integration__cfc__resolver_tests__action_variables_annotated-4.snap index 1cb6d633ba6..1c4ab20701f 100644 --- a/tests/integration/cfc/snapshots/tests__integration__cfc__resolver_tests__action_variables_annotated-4.snap +++ b/tests/integration/cfc/snapshots/tests__integration__cfc__resolver_tests__action_variables_annotated-4.snap @@ -10,6 +10,6 @@ Some( argument_type: ByVal( Local, ), - is_auto_deref: false, + auto_deref: None, }, ) diff --git a/tests/integration/snapshots/tests__integration__cfc__ir__actions_debug.snap b/tests/integration/snapshots/tests__integration__cfc__ir__actions_debug.snap index 9fdb73b521c..b12c6d93a50 100644 --- a/tests/integration/snapshots/tests__integration__cfc__ir__actions_debug.snap +++ b/tests/integration/snapshots/tests__integration__cfc__ir__actions_debug.snap @@ -4,9 +4,9 @@ expression: output_file_content_without_headers --- %main = type { i32, i32 } -@main_instance = global %main zeroinitializer, !dbg !0 +@main_instance = global %main zeroinitializer, section "var-$RUSTY$main_instance:r2i32i32", !dbg !0 -define void @main(%main* %0) section "fn-main:v" !dbg !12 { +define void @main(%main* %0) section "fn-$RUSTY$main:v" !dbg !12 { entry: call void @llvm.dbg.declare(metadata %main* %0, metadata !16, metadata !DIExpression()), !dbg !17 %a = getelementptr inbounds %main, %main* %0, i32 0, i32 0, !dbg !18 @@ -17,7 +17,7 @@ entry: ret void, !dbg !20 } -define void @main.newAction(%main* %0) section "fn-main.newAction:v" !dbg !21 { +define void @main.newAction(%main* %0) section "fn-$RUSTY$main.newAction:v" !dbg !21 { entry: call void @llvm.dbg.declare(metadata %main* %0, metadata !16, metadata !DIExpression()), !dbg !22 %a = getelementptr inbounds %main, %main* %0, i32 0, i32 0, !dbg !23 @@ -28,7 +28,7 @@ entry: ret void, !dbg !22 } -define void @main.newAction2(%main* %0) section "fn-main.newAction2:v" !dbg !24 { +define void @main.newAction2(%main* %0) section "fn-$RUSTY$main.newAction2:v" !dbg !24 { entry: call void @llvm.dbg.declare(metadata %main* %0, metadata !16, metadata !DIExpression()), !dbg !25 %a = getelementptr inbounds %main, %main* %0, i32 0, i32 0, !dbg !26 diff --git a/tests/integration/snapshots/tests__integration__cfc__ir__conditional_return.snap b/tests/integration/snapshots/tests__integration__cfc__ir__conditional_return.snap index 3f3583d9933..f9950133be4 100644 --- a/tests/integration/snapshots/tests__integration__cfc__ir__conditional_return.snap +++ b/tests/integration/snapshots/tests__integration__cfc__ir__conditional_return.snap @@ -4,9 +4,9 @@ expression: output_file_content_without_headers --- %conditional_return = type { i32 } -@__conditional_return__init = unnamed_addr constant %conditional_return zeroinitializer +@__conditional_return__init = unnamed_addr constant %conditional_return zeroinitializer, section "var-$RUSTY$__conditional_return__init:r1i32" -define void @conditional_return(%conditional_return* %0) section "fn-conditional_return:v[i32]" { +define void @conditional_return(%conditional_return* %0) section "fn-$RUSTY$conditional_return:v[i32]" { entry: %val = getelementptr inbounds %conditional_return, %conditional_return* %0, i32 0, i32 0 %load_val = load i32, i32* %val, align 4 diff --git a/tests/integration/snapshots/tests__integration__cfc__ir__conditional_return_debug.snap b/tests/integration/snapshots/tests__integration__cfc__ir__conditional_return_debug.snap index 0f4f5bb4d6c..25a2211efc9 100644 --- a/tests/integration/snapshots/tests__integration__cfc__ir__conditional_return_debug.snap +++ b/tests/integration/snapshots/tests__integration__cfc__ir__conditional_return_debug.snap @@ -2,7 +2,7 @@ source: tests/integration/cfc.rs expression: output_file_content_without_headers --- -define i32 @foo(i32 %0) section "fn-foo:i32[i32]" !dbg !4 { +define i32 @foo(i32 %0) section "fn-$RUSTY$foo:i32[i32]" !dbg !4 { entry: %foo = alloca i32, align 4, !dbg !9 %val = alloca i32, align 4, !dbg !9 diff --git a/tests/integration/snapshots/tests__integration__cfc__ir__conditional_return_evaluating_true.snap b/tests/integration/snapshots/tests__integration__cfc__ir__conditional_return_evaluating_true.snap index 6a8c2cfb273..1ecce88ccf9 100644 --- a/tests/integration/snapshots/tests__integration__cfc__ir__conditional_return_evaluating_true.snap +++ b/tests/integration/snapshots/tests__integration__cfc__ir__conditional_return_evaluating_true.snap @@ -4,9 +4,9 @@ expression: output_file_content_without_headers --- %conditional_return = type { i32 } -@__conditional_return__init = constant %conditional_return zeroinitializer +@__conditional_return__init = constant %conditional_return zeroinitializer, section "var-$RUSTY$__conditional_return__init:r1i32" -define i32 @main() section "fn-main:i32" { +define i32 @main() section "fn-$RUSTY$main:i32" { entry: %main = alloca i32, align 4 %my_val = alloca i32, align 4 @@ -29,7 +29,7 @@ entry: ; Function Attrs: argmemonly nofree nounwind willreturn declare void @llvm.memcpy.p0i8.p0i8.i64(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i64, i1 immarg) #0 -define void @conditional_return(%conditional_return* %0) section "fn-conditional_return:v[i32]" { +define void @conditional_return(%conditional_return* %0) section "fn-$RUSTY$conditional_return:v[i32]" { entry: %val = getelementptr inbounds %conditional_return, %conditional_return* %0, i32 0, i32 0 %load_val = load i32, i32* %val, align 4 diff --git a/tests/integration/snapshots/tests__integration__cfc__ir__conditional_return_evaluating_true_negated.snap b/tests/integration/snapshots/tests__integration__cfc__ir__conditional_return_evaluating_true_negated.snap index 168d2152543..46dee4354aa 100644 --- a/tests/integration/snapshots/tests__integration__cfc__ir__conditional_return_evaluating_true_negated.snap +++ b/tests/integration/snapshots/tests__integration__cfc__ir__conditional_return_evaluating_true_negated.snap @@ -4,9 +4,9 @@ expression: output_file_content_without_headers --- %conditional_return = type { i32 } -@__conditional_return__init = constant %conditional_return zeroinitializer +@__conditional_return__init = constant %conditional_return zeroinitializer, section "var-$RUSTY$__conditional_return__init:r1i32" -define i32 @main() section "fn-main:i32" { +define i32 @main() section "fn-$RUSTY$main:i32" { entry: %main = alloca i32, align 4 %my_val = alloca i32, align 4 @@ -29,7 +29,7 @@ entry: ; Function Attrs: argmemonly nofree nounwind willreturn declare void @llvm.memcpy.p0i8.p0i8.i64(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i64, i1 immarg) #0 -define void @conditional_return(%conditional_return* %0) section "fn-conditional_return:v[i32]" { +define void @conditional_return(%conditional_return* %0) section "fn-$RUSTY$conditional_return:v[i32]" { entry: %val = getelementptr inbounds %conditional_return, %conditional_return* %0, i32 0, i32 0 %load_val = load i32, i32* %val, align 4 diff --git a/tests/integration/snapshots/tests__integration__cfc__ir__jump_debug.snap b/tests/integration/snapshots/tests__integration__cfc__ir__jump_debug.snap index 85a459500a0..ea666e9a67b 100644 --- a/tests/integration/snapshots/tests__integration__cfc__ir__jump_debug.snap +++ b/tests/integration/snapshots/tests__integration__cfc__ir__jump_debug.snap @@ -4,9 +4,9 @@ expression: output_file_content_without_headers --- %foo = type { i32 } -@foo_instance = global %foo zeroinitializer, !dbg !0 +@foo_instance = global %foo zeroinitializer, section "var-$RUSTY$foo_instance:r1i32", !dbg !0 -define void @foo(%foo* %0) section "fn-foo:v" !dbg !11 { +define void @foo(%foo* %0) section "fn-$RUSTY$foo:v" !dbg !11 { entry: call void @llvm.dbg.declare(metadata %foo* %0, metadata !15, metadata !DIExpression()), !dbg !16 %val = getelementptr inbounds %foo, %foo* %0, i32 0, i32 0, !dbg !17 diff --git a/tests/integration/snapshots/tests__integration__cfc__ir__jump_to_label_with_false.snap b/tests/integration/snapshots/tests__integration__cfc__ir__jump_to_label_with_false.snap index 03bfcb1c79b..fd0716b3fcd 100644 --- a/tests/integration/snapshots/tests__integration__cfc__ir__jump_to_label_with_false.snap +++ b/tests/integration/snapshots/tests__integration__cfc__ir__jump_to_label_with_false.snap @@ -2,7 +2,7 @@ source: tests/integration/cfc.rs expression: output_file_content_without_headers --- -define i32 @main() section "fn-main:i32" { +define i32 @main() section "fn-$RUSTY$main:i32" { entry: %main = alloca i32, align 4 %x = alloca i8, align 1 diff --git a/tests/integration/snapshots/tests__integration__cfc__ir__jump_to_label_with_true.snap b/tests/integration/snapshots/tests__integration__cfc__ir__jump_to_label_with_true.snap index 4a7dd30341e..9e3f4c97b90 100644 --- a/tests/integration/snapshots/tests__integration__cfc__ir__jump_to_label_with_true.snap +++ b/tests/integration/snapshots/tests__integration__cfc__ir__jump_to_label_with_true.snap @@ -2,7 +2,7 @@ source: tests/integration/cfc.rs expression: output_file_content_without_headers --- -define i32 @main() section "fn-main:i32" { +define i32 @main() section "fn-$RUSTY$main:i32" { entry: %main = alloca i32, align 4 %x = alloca i8, align 1 diff --git a/tests/integration/snapshots/tests__integration__cfc__ir__sink_source_debug.snap b/tests/integration/snapshots/tests__integration__cfc__ir__sink_source_debug.snap index 3e6e525f301..79be9a600a3 100644 --- a/tests/integration/snapshots/tests__integration__cfc__ir__sink_source_debug.snap +++ b/tests/integration/snapshots/tests__integration__cfc__ir__sink_source_debug.snap @@ -4,9 +4,9 @@ expression: output_file_content_without_headers --- %main = type { i32 } -@main_instance = global %main zeroinitializer, !dbg !0 +@main_instance = global %main zeroinitializer, section "var-$RUSTY$main_instance:r1i32", !dbg !0 -define void @main(%main* %0) section "fn-main:v" !dbg !11 { +define void @main(%main* %0) section "fn-$RUSTY$main:v" !dbg !11 { entry: call void @llvm.dbg.declare(metadata %main* %0, metadata !15, metadata !DIExpression()), !dbg !16 %x = getelementptr inbounds %main, %main* %0, i32 0, i32 0, !dbg !17 diff --git a/tests/integration/snapshots/tests__integration__cfc__ir__variable_source_to_variable_and_block_sink.snap b/tests/integration/snapshots/tests__integration__cfc__ir__variable_source_to_variable_and_block_sink.snap index 707a4124b89..1dcbe82b60d 100644 --- a/tests/integration/snapshots/tests__integration__cfc__ir__variable_source_to_variable_and_block_sink.snap +++ b/tests/integration/snapshots/tests__integration__cfc__ir__variable_source_to_variable_and_block_sink.snap @@ -2,7 +2,7 @@ source: tests/integration/cfc.rs expression: output_file_content_without_headers --- -define i32 @main() section "fn-main:i32" { +define i32 @main() section "fn-$RUSTY$main:i32" { entry: %main = alloca i32, align 4 %value = alloca i32, align 4 @@ -15,7 +15,7 @@ entry: ret i32 %main_ret } -define i32 @myAdd(i32 %0, i32 %1) section "fn-myAdd:i32[i32][i32]" { +define i32 @myAdd(i32 %0, i32 %1) section "fn-$RUSTY$myAdd:i32[i32][i32]" { entry: %myAdd = alloca i32, align 4 %a = alloca i32, align 4 @@ -31,7 +31,7 @@ entry: ret i32 %myAdd_ret } -define i32 @myConnection(i32 %0) section "fn-myConnection:i32[i32]" { +define i32 @myConnection(i32 %0) section "fn-$RUSTY$myConnection:i32[i32]" { entry: %myConnection = alloca i32, align 4 %x = alloca i32, align 4 diff --git a/tests/integration/snapshots/tests__integration__command_line_compile__ir_generation_full_pass.snap b/tests/integration/snapshots/tests__integration__command_line_compile__ir_generation_full_pass.snap index 10c5e319f35..7d5863d39dd 100644 --- a/tests/integration/snapshots/tests__integration__command_line_compile__ir_generation_full_pass.snap +++ b/tests/integration/snapshots/tests__integration__command_line_compile__ir_generation_full_pass.snap @@ -2,4 +2,4 @@ source: tests/integration/command_line_compile.rs expression: content --- -define i32 @myFunc(i32 %0, i32 %1, i32 %2) section "fn-myFunc:i32[i32][i32][i32]" {entry: %myFunc = alloca i32, align 4 %a = alloca i32, align 4 store i32 %0, i32* %a, align 4 %b = alloca i32, align 4 store i32 %1, i32* %b, align 4 %c = alloca i32, align 4 store i32 %2, i32* %c, align 4 store i32 0, i32* %myFunc, align 4 %myFunc_ret = load i32, i32* %myFunc, align 4 ret i32 %myFunc_ret} +define i32 @myFunc(i32 %0, i32 %1, i32 %2) section "fn-$RUSTY$myFunc:i32[i32][i32][i32]" {entry: %myFunc = alloca i32, align 4 %a = alloca i32, align 4 store i32 %0, i32* %a, align 4 %b = alloca i32, align 4 store i32 %1, i32* %b, align 4 %c = alloca i32, align 4 store i32 %2, i32* %c, align 4 store i32 0, i32* %myFunc, align 4 %myFunc_ret = load i32, i32* %myFunc, align 4 ret i32 %myFunc_ret} diff --git a/tests/lit/lit.cfg b/tests/lit/lit.cfg new file mode 100644 index 00000000000..6b07c4aa42a --- /dev/null +++ b/tests/lit/lit.cfg @@ -0,0 +1,20 @@ +import lit.formats, os, os.path, sys, subprocess +srcDir = os.path.dirname(__file__) +config.test_format = lit.formats.ShTest(True) +config.pipefail = False +rustyRootDirectory = subprocess.check_output("dirname `cargo locate-project --message-format plain`", shell=True).decode("utf-8").strip() + +stdlibLocation = lit_config.params["LIB"] +compilerLocation = lit_config.params["COMPILER"] + +# ...to make the compile command more reable we build it over multiple lines +compile = f'{compilerLocation}' +compile = f'{compile} -o /tmp/%basename_t.out' +compile = f'{compile} -liec61131std -L{stdlibLocation}/lib -i "{stdlibLocation}/include/*.st"' +compile = f'{compile} -i {rustyRootDirectory}/tests/lit/util/*.pli' +compile = f'{compile} --linker=cc' +print(f'Compile command: {compile}') + +config.substitutions.append(('%COMPILE', f'{compile}')) +config.substitutions.append(('%RUN', f'LD_LIBRARY_PATH="{stdlibLocation}/lib" /tmp/%basename_t.out')) +config.substitutions.append(('%CHECK', f'FileCheck-14 --check-prefixes CHECK --allow-unused-prefixes --match-full-lines')) \ No newline at end of file diff --git a/tests/lit/multi/enum__month_to_int/month_to_int.st b/tests/lit/multi/enum__month_to_int/month_to_int.st new file mode 100644 index 00000000000..aeb9658971d --- /dev/null +++ b/tests/lit/multi/enum__month_to_int/month_to_int.st @@ -0,0 +1,26 @@ +FUNCTION main : DINT + printf('%d', month_to_int(MONTH#June)); +END_FUNCTION + + +FUNCTION month_to_int : INT + VAR_INPUT + month_var : MONTH; + END_VAR + + CASE month_var OF + MONTH.January: month_to_int := 1; + MONTH.February: month_to_int := 2; + MONTH.March: month_to_int := 3; + MONTH.April: month_to_int := 4; + MONTH.May: month_to_int := 5; + MONTH.June: month_to_int := 6; + MONTH.July: month_to_int := 7; + MONTH.August: month_to_int := 8; + MONTH.September: month_to_int := 9; + MONTH.October: month_to_int := 10; + MONTH.November: month_to_int := 11; + MONTH.December: month_to_int := 12; + else month_to_int := 0; + END_CASE; +END_FUNCTION diff --git a/tests/lit/multi/enum__month_to_int/month_to_int.test b/tests/lit/multi/enum__month_to_int/month_to_int.test new file mode 100644 index 00000000000..fe9a8d88f38 --- /dev/null +++ b/tests/lit/multi/enum__month_to_int/month_to_int.test @@ -0,0 +1,2 @@ +RUN: %COMPILE %S/month_to_int.st %S/months.dt && %RUN | %CHECK %s +CHECK:6 \ No newline at end of file diff --git a/tests/lit/multi/enum__month_to_int/months.dt b/tests/lit/multi/enum__month_to_int/months.dt new file mode 100644 index 00000000000..d1ff02e6020 --- /dev/null +++ b/tests/lit/multi/enum__month_to_int/months.dt @@ -0,0 +1,3 @@ +TYPE + MONTH: (January, February, March, April, May, June, July, August, September, October, November, December); +END_TYPE \ No newline at end of file diff --git a/tests/lit/multi/lit.local.cfg b/tests/lit/multi/lit.local.cfg new file mode 100644 index 00000000000..4b89c231b94 --- /dev/null +++ b/tests/lit/multi/lit.local.cfg @@ -0,0 +1 @@ +config.suffixes = ['.test'] \ No newline at end of file diff --git a/tests/lit/single/arithmetic/addition.st b/tests/lit/single/arithmetic/addition.st new file mode 100644 index 00000000000..79d620ec0e8 --- /dev/null +++ b/tests/lit/single/arithmetic/addition.st @@ -0,0 +1,12 @@ +// RUN: (%COMPILE %s && %RUN) | %CHECK %s +// CHECK: 10 +FUNCTION main + VAR + x : DINT; + y : DINT; + END_VAR + + x := 5; + y := 5; + printf('%d$N', x + y); +END_FUNCTION diff --git a/tests/lit/single/arithmetic/sqrt.st b/tests/lit/single/arithmetic/sqrt.st new file mode 100644 index 00000000000..5bedfc48fde --- /dev/null +++ b/tests/lit/single/arithmetic/sqrt.st @@ -0,0 +1,8 @@ +// RUN: (%COMPILE %s && %RUN) | %CHECK %s +// CHECK: 2 +FUNCTION main + VAR + res : LREAL; + END_VAR + printf('%d$N', REAL_TO_DINT(SQRT(4.0))); +END_FUNCTION diff --git a/tests/lit/single/lit.local.cfg b/tests/lit/single/lit.local.cfg new file mode 100644 index 00000000000..4b8df7dec5a --- /dev/null +++ b/tests/lit/single/lit.local.cfg @@ -0,0 +1,2 @@ +# Declare any *.st file as a standlone test file +config.suffixes = ['.st'] \ No newline at end of file diff --git a/tests/lit/single/pointer/alias_array.ignore b/tests/lit/single/pointer/alias_array.ignore new file mode 100644 index 00000000000..7cd997cb82e --- /dev/null +++ b/tests/lit/single/pointer/alias_array.ignore @@ -0,0 +1,14 @@ +// RUN: (%COMPILE %s && %RUN) | %CHECK %s +FUNCTION main: DINT + VAR + refArr AT arr : ARRAY[1..3] OF DINT; + arr : ARRAY[1..3] OF DINT; + END_VAR + + arr[1] := 3; + arr[2] := 2; + arr[3] := 1; + + // CHECK: 1, 2, 3 + printf('%d, %d, %d$N', refArr[3], refArr[2], refArr[1]); +END_FUNCTION \ No newline at end of file diff --git a/tests/lit/single/pointer/alias_autoderef.ignore b/tests/lit/single/pointer/alias_autoderef.ignore new file mode 100644 index 00000000000..eb9be37b0c5 --- /dev/null +++ b/tests/lit/single/pointer/alias_autoderef.ignore @@ -0,0 +1,13 @@ +// RUN: (%COMPILE %s && %RUN) | %CHECK %s +FUNCTION main: DINT + VAR + foo AT bar : DINT; + bar : DINT; + END_VAR + + bar := 1; + + // CHECK: 2 + bar := bar + foo; // bar + bar => 1 + 1 + printf('%d$N', foo); +END_FUNCTION \ No newline at end of file diff --git a/tests/lit/single/pointer/alias_struct.ignore b/tests/lit/single/pointer/alias_struct.ignore new file mode 100644 index 00000000000..c0c5f41512e --- /dev/null +++ b/tests/lit/single/pointer/alias_struct.ignore @@ -0,0 +1,22 @@ +// RUN: (%COMPILE %s && %RUN) | %CHECK %s +TYPE Transaction : STRUCT + id : DINT; + amount : DINT; + message : STRING; +END_STRUCT END_TYPE + +FUNCTION main : DINT + VAR + txn : Transaction := (id := 1, amount := 5, message := 'whats up'); + refTxn AT txn : Transaction; + END_VAR + + // CHECK: 1 + printf('%d$N', refTxn.id); + + // CHECK: 5 + printf('%d$N', refTxn.amount); + + // CHECK: whats up + printf('%s$N', REF(refTxn.message)); +END_FUNCTION \ No newline at end of file diff --git a/tests/lit/single/pointer/ref_assignment_operator.st b/tests/lit/single/pointer/ref_assignment_operator.st new file mode 100644 index 00000000000..72f5a9f97cb --- /dev/null +++ b/tests/lit/single/pointer/ref_assignment_operator.st @@ -0,0 +1,11 @@ +// RUN: (%COMPILE %s && %RUN) | %CHECK %s +FUNCTION main : DINT + VAR + a : REF_TO DINT; + b : DINT := 5; + END_VAR + a REF= b; + + // CHECK: 5 + printf('%d$N', a^); +END_FUNCTION \ No newline at end of file diff --git a/tests/lit/single/pointer/referenceto_variable_autoderef.st b/tests/lit/single/pointer/referenceto_variable_autoderef.st new file mode 100644 index 00000000000..400b2ffc569 --- /dev/null +++ b/tests/lit/single/pointer/referenceto_variable_autoderef.st @@ -0,0 +1,28 @@ +// RUN: (%COMPILE %s && %RUN) | %CHECK %s +FUNCTION main: DINT + VAR + foo : REFERENCE TO DINT; + bar : DINT; + baz : DINT; + qux : DINT; + END_VAR + + foo REF= bar; + bar := 1; + baz := 2; + qux := 2; + + // CHECK: 2 + bar := bar + foo; // bar + bar => 1 + 1 + printf('%d$N', foo); + + // CHECK: 4 + baz := baz + foo; // baz + foo => baz + bar => 2 + 2 + foo REF= baz; + printf('%d$N', foo); + + // CHECK: 6 + qux := qux + foo; // qux + foo => qux + baz => 2 + 4 + foo REF= qux; + printf('%d$N', foo); +END_FUNCTION \ No newline at end of file diff --git a/tests/lit/single/pointer/referenceto_variable_referencing_array.st b/tests/lit/single/pointer/referenceto_variable_referencing_array.st new file mode 100644 index 00000000000..f3e255a388f --- /dev/null +++ b/tests/lit/single/pointer/referenceto_variable_referencing_array.st @@ -0,0 +1,15 @@ +// RUN: (%COMPILE %s && %RUN) | %CHECK %s +FUNCTION main: DINT + VAR + arr : ARRAY[1..3] OF DINT; + refArr : REFERENCE TO ARRAY[1..3] OF DINT; + END_VAR + + refArr REF= arr; + arr[1] := 3; + arr[2] := 2; + arr[3] := 1; + + // CHECK: 1, 2, 3 + printf('%d, %d, %d$N', refArr[3], refArr[2], refArr[1]); +END_FUNCTION \ No newline at end of file diff --git a/tests/lit/single/pointer/referenceto_variable_referencing_itself.st b/tests/lit/single/pointer/referenceto_variable_referencing_itself.st new file mode 100644 index 00000000000..c108e8917e3 --- /dev/null +++ b/tests/lit/single/pointer/referenceto_variable_referencing_itself.st @@ -0,0 +1,17 @@ +// RUN: (%COMPILE %s && %RUN) | %CHECK %s +FUNCTION main : DINT + VAR + foo : REFERENCE TO DINT; + bar : REFERENCE TO DINT; + qux : DINT; + END_VAR + + foo REF= bar; + bar REF= qux; + + bar REF= bar; + qux := 5; + + // CHECK: 5 + printf('%d$N', bar); // bar (-> bar) -> qux +END_FUNCTION \ No newline at end of file diff --git a/tests/lit/single/pointer/referenceto_variable_referencing_other_referenceto_variable.st b/tests/lit/single/pointer/referenceto_variable_referencing_other_referenceto_variable.st new file mode 100644 index 00000000000..9b739965c9c --- /dev/null +++ b/tests/lit/single/pointer/referenceto_variable_referencing_other_referenceto_variable.st @@ -0,0 +1,15 @@ +// RUN: (%COMPILE %s && %RUN) | %CHECK %s +FUNCTION main : DINT + VAR + foo : REFERENCE TO DINT; + bar : REFERENCE TO DINT; + qux : DINT; + END_VAR + + bar REF= qux; + foo REF= bar; + qux := 5; + + // CHECK: 5 + printf('%d$N', foo); // foo -> bar -> qux +END_FUNCTION diff --git a/tests/lit/single/pointer/referenceto_variable_referencing_struct.st b/tests/lit/single/pointer/referenceto_variable_referencing_struct.st new file mode 100644 index 00000000000..77e6502ce36 --- /dev/null +++ b/tests/lit/single/pointer/referenceto_variable_referencing_struct.st @@ -0,0 +1,24 @@ +// RUN: (%COMPILE %s && %RUN) | %CHECK %s +TYPE Transaction : STRUCT + id : DINT; + amount : DINT; + message : STRING; +END_STRUCT END_TYPE + +FUNCTION main : DINT + VAR + txn : Transaction := (id := 1, amount := 5, message := 'whats up'); + refTxn : REFERENCE TO Transaction; + END_VAR + + refTxn REF= txn; + + // CHECK: 1 + printf('%d$N', refTxn.id); + + // CHECK: 5 + printf('%d$N', refTxn.amount); + + // CHECK: whats up + printf('%s$N', REF(refTxn.message)); +END_FUNCTION \ No newline at end of file diff --git a/tests/lit/util/printf.pli b/tests/lit/util/printf.pli new file mode 100644 index 00000000000..16036e0cf36 --- /dev/null +++ b/tests/lit/util/printf.pli @@ -0,0 +1,9 @@ +{external} +FUNCTION printf: DINT +VAR_INPUT {ref} + str : STRING; +END_VAR +VAR_INPUT + args: ...; +END_VAR +END_FUNCTION \ No newline at end of file