S. Bharadwaj Yadavalli f2650c54c9
[DirectX] Set Shader Flag DisableOptimizations (#126813)
- Set the shader flag `DisableOptimizations` based on `optnone`
attribute of shader entry functions.

- Add DXIL Metadata Analysis pass as pre-requisite for Shader Flags pass
to obtain entry function information collected therein.

- Named module metadata `dx.disable_optimizations` is intended to
indicate disabling optimizations (`-O0`) via commandline flag. However,
its intent is fulfilled by `optnone` attribute of shader entry functions as 
implemented in a recent change, and thus not needed. Delete
generation of named metadata and corresponding test file
`disable_opt.ll`.

- Add tests to verify correctness of setting shader flag.

Closes #112263
2025-02-12 16:45:01 -05:00

31 lines
1.2 KiB
LLVM

; RUN: not opt -S --passes="print-dx-shader-flags" 2>&1 %s | FileCheck %s
target triple = "dxilv1.3-pc-shadermodel6.3-library"
; All entry functions of a library shader need to either have optnone
; or not have the attribute
; CHECK: error:
; CHECK-SAME: in function entry_two
; CHECK-SAME: Inconsistent optnone attribute
; Function Attrs: convergent noinline norecurse optnone
define void @entry_one() #0 {
entry:
ret void
}
; Function Attrs: convergent noinline norecurse
define void @entry_two() #1 {
entry:
ret void
}
attributes #0 = { convergent noinline norecurse optnone "approx-func-fp-math"="true" "hlsl.numthreads"="1,1,1" "hlsl.shader"="compute" "no-infs-fp-math"="true" "no-nans-fp-math"="true" "no-signed-zeros-fp-math"="true" "no-trapping-math"="true" "stack-protector-buffer-size"="8" }
attributes #1 = { convergent noinline norecurse "approx-func-fp-math"="true" "hlsl.numthreads"="1,1,1" "hlsl.shader"="compute" "no-infs-fp-math"="true" "no-nans-fp-math"="true" "no-signed-zeros-fp-math"="true" "no-trapping-math"="true" "stack-protector-buffer-size"="8" }
!llvm.module.flags = !{!0, !1}
!dx.valver = !{!2}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 4, !"dx.disable_optimizations", i32 1}
!2 = !{i32 1, i32 8}