| 1 |
; RUN: llc -O0 -mtriple=spirv64-unknown-unknown %s -o - | FileCheck %s --check-prefixes=CHECK,CHECK-DEFAULT |
| 2 |
; RUN: llc -O0 -mtriple=spirv64-unknown-unknown --spirv-emit-op-names %s -o - | FileCheck %s --check-prefixes=CHECK,CHECK-ALL-NAMES |
| 3 |
; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv64-unknown-unknown %s -o - -filetype=obj | spirv-val %} |
| 4 |
|
| 5 |
; Verify that OpName is generated for Global Variables, Functions, Parameters, |
| 6 |
; Local Variables (Alloca), and Basic Blocks (Labels). |
| 7 |
; We preserve these names because they significantly improve the readability of |
| 8 |
; the generated SPIR-V binary and are unlikely to inhibit optimizations (like |
| 9 |
; Dead Code Elimination) since they define the interface or storage of the program. |
| 10 |
|
| 11 |
; 1. Global variables ("GlobalVar") |
| 12 |
; CHECK-DAG: OpName %[[#GlobalVar:]] "GlobalVar" |
| 13 |
|
| 14 |
; 2. Functions ("test_names") |
| 15 |
; CHECK-DAG: OpName %[[#Func:]] "test_names" |
| 16 |
|
| 17 |
; 3. Function parameters ("param") |
| 18 |
; CHECK-DAG: OpName %[[#Param:]] "param" |
| 19 |
|
| 20 |
; 4. Local variables (AllocaInst) ("localVar") |
| 21 |
; CHECK-DAG: OpName %[[#LocalVar:]] "localVar" |
| 22 |
|
| 23 |
; 5. Basic Blocks ("entry", "body") |
| 24 |
; CHECK-DAG: OpName %[[#Entry:]] "entry" |
| 25 |
; CHECK-DAG: OpName %[[#Body:]] "body" |
| 26 |
|
| 27 |
; Verify that OpName is NOT generated for intermediate instructions |
| 28 |
; (arithmetic, etc.) by default. This reduces file size and noise, and prevents |
| 29 |
; potential interference with optimizations. |
| 30 |
; With --spirv-emit-op-names, we expect them to be generated. |
| 31 |
|
| 32 |
; CHECK-DEFAULT-NOT: OpName %{{.*}} "add" |
| 33 |
; CHECK-DEFAULT-NOT: OpName %{{.*}} "sub" |
| 34 |
|
| 35 |
; CHECK-ALL-NAMES-DAG: OpName %{{.*}} "add" |
| 36 |
; CHECK-ALL-NAMES-DAG: OpName %{{.*}} "sub" |
| 37 |
|
| 38 |
@GlobalVar = global i32 0 |
| 39 |
|
| 40 |
define spir_func void @test_names(i32 %param) { |
| 41 |
entry: |
| 42 |
%localVar = alloca i32 |
| 43 |
br label %body |
| 44 |
|
| 45 |
body: |
| 46 |
%add = add i32 %param, 1 |
| 47 |
%sub = sub i32 %add, 1 |
| 48 |
store i32 %sub, ptr %localVar |
| 49 |
ret void |
| 50 |
} |