Skip to content

out and inout should always be references #5377

Closed as not planned
Closed as not planned

Description

@llvm-beanz

Description
All out and inout parameters should use reference types as their qual types in the AST.

DXC's ASTs currently model some types as pass-by-value even when they are out or inout, which makes the ASTs inaccurately reflect the program. In order to address issues with AST-based error and warning analysis and implement a correct calling convention for DXIL libraries we need to produce accurate ASTs.

Steps to Reproduce
Example shader

See the produced AST:

TranslationUnitDecl 0x55e2317384a0 <<invalid sloc>> <invalid sloc>
|-CXXRecordDecl 0x55e2317668c0 <<source>:1:1, line:3:1> line:1:8 referenced struct SomeStruct definition
| |-CXXRecordDecl 0x55e231766a00 <col:1, col:8> col:8 implicit struct SomeStruct
| `-FieldDecl 0x55e231766ac8 <line:2:3, col:7> col:7 SomeVal 'int'
|-FunctionDecl 0x55e2317741b0 <line:5:1, line:6:1> line:5:6 used Fn 'void (__restrict SomeStruct)'
| |-ParmVarDecl 0x55e231766b30 <col:9, col:26> col:26 S '__restrict SomeStruct'
| | `-HLSLInOutAttr 0x55e231766ba0 <col:9>
| `-CompoundStmt 0x55e2317742c8 <col:29, line:6:1>
`-FunctionDecl 0x55e231774300 <line:8:1, line:11:1> line:8:6 Fn2 'void ()'
  `-CompoundStmt 0x55e231774620 <col:12, line:11:1>
    |-DeclStmt 0x55e231774450 <line:9:3, col:15>
    | `-VarDecl 0x55e2317743e0 <col:3, col:14> col:14 used S 'SomeStruct'
    `-CallExpr 0x55e2317745c0 <line:10:3, col:7> 'void'
      |-ImplicitCastExpr 0x55e2317745a8 <col:3> 'void (*)(__restrict SomeStruct)' <FunctionToPointerDecay>
      | `-DeclRefExpr 0x55e231774528 <col:3> 'void (__restrict SomeStruct)' lvalue Function 0x55e2317741b0 'Fn' 'void (__restrict SomeStruct)'
      `-ImplicitCastExpr 0x55e231774608 <col:6> 'SomeStruct' <LValueToRValue>
        `-DeclRefExpr 0x55e2317744c0 <col:6> 'SomeStruct' lvalue Var 0x55e2317743e0 'S' 'SomeStruct'

FunctionDecl 0x55e2317741b0 <line:5:1, line:6:1> line:5:6 used Fn 'void (__restrict SomeStruct)' should have a reference parameter.

The argument copy semantics are also not represented in the AST, which will need to be fixed to address this.

Environment

  • DXC version: All versions of DXC
  • Host Operating System: All OS environments

Activity

  1. added
    bug
    needs-triage
    on Jun 29, 2023
  2. moved this from 🆕 New to 🏗 In progress in HLSL Roadmapon Jun 29, 2023
  3. llvm-beanz commented on Jun 29, 2023

    @llvm-beanz
    CollaboratorAuthor

    A draft PR for this is posted as #5249

  4. added this to the milestone on Sep 26, 2023
  5. removed this from the milestone on Mar 7, 2024
  6. llvm-beanz commented on Sep 16, 2024

    @llvm-beanz
    CollaboratorAuthor

    Closing as not planned. We have addressed this in Clang and will continue forward there.

  7. moved this from In progress to Done in HLSL Roadmapon Sep 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bugtech-debt

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions