Preserve vec3 for HLSL by set -fpreserve-vec3-type.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
clang/lib/Driver/ToolChains/Clang.cpp | ||
---|---|---|
3524 ↗ | (On Diff #456559) | Preserving vec3 is required for HLSL correctness, this shouldn't be tied to the DXC driver mode. Instead, the option should be implied by the HLSL language mode. You should be able to add the following to the TableGen definition for the preserve-vec3-type flag: ImpliedByAnyOf<[hlsl.KeyPath]>; |
The test fails for -Asserts.
clang/test/CodeGenHLSL/float3.hlsl | ||
---|---|---|
4 | Also %a may be unnamed, like %0 |
clang/test/CodeGenHLSL/float3.hlsl | ||
---|---|---|
4 | Thanks for pointing this out. |
Fixed the %0 issue in https://github.com/llvm/llvm-project/commit/71fae33f5e7c1b11e32db695fd24dd50aead737c
It passed locally on build with -DLLVM_ENABLE_ASSERTIONS=ON
Is -DLLVM_ENABLE_ASSERTIONS=ON what you mean by -Asserts?
The fix looks good. Thanks.
Is -DLLVM_ENABLE_ASSERTIONS=ON what you mean by -Asserts?
Oh excuse me, "-Asserts" was an ancient term, "w/o assertsions" in the autoconf age.
An antonym was "+Asserts". it means LLVM_ENABLE_ASSERTIONS=ON
This test fails because the actual output has <3 x float>* rather than ptr. Could you please fix this test case?
Thanks for reporting the issue.
But I cannot repro the fail.
Do you mind sharing your cmake command?
Thanks for reporting the issue.
But I cannot repro the fail.
Do you mind sharing your cmake command?
Hmm, I'm just running the command in the test case:
clang --driver-mode=dxc -Tlib_6_7 -fcgl -Fo - clang/test/CodeGenHLSL/float3.hlsl | FileCheck clang/test/CodeGenHLSL/float3.hlsl
This is the output I got with clang --driver-mode=dxc -Tlib_6_7 -fcgl -Fo - clang/test/CodeGenHLSL/float3.hlsl
target datalayout = "e-m:e-p:32:32-i1:32-i8:8-i16:16-i32:32-i64:64-f16:16-f32:32-f64:64-n8:16:32:64" target triple = "dxil-unknown-shadermodel6.7-library" ; Function Attrs: noinline nounwind optnone define noundef <3 x float> @"?foo@@YAT?$__vector@M$02@__clang@@T12@@Z"(<3 x float> noundef %a) #0 { entry: %a.addr = alloca <3 x float>, align 16 store <3 x float> %a, ptr %a.addr, align 16 %0 = load <3 x float>, ptr %a.addr, align 16 ret <3 x float> %0 } attributes #0 = { noinline nounwind optnone "frame-pointer"="all" "min-legal-vector-width"="96" "no-trapping-math"="true" "stack-protector-buffer-size"="8" } !llvm.module.flags = !{!0, !1} !dx.valver = !{!2} !llvm.ident = !{!3} !0 = !{i32 1, !"wchar_size", i32 4} !1 = !{i32 7, !"frame-pointer", i32 2} !2 = !{i32 1, i32 7} !3 = !{!"clang version 16.0.0 (https://github.com/llvm/llvm-project c9d2b6b92d6c29d00f6adc0527cf2331dbaae31a)"}
Maybe you build clang with a different setting? What are the CMake options you're using?
Sorry for the delay and thank you for verifying. It turns out this is not due to a problem with the test itself, but rather a local problem with my compiler. No revision is necessary here, my apologies.
clang/test/CodeGenHLSL/float3.hlsl | ||
---|---|---|
1 | Does this need to use driver mode? That is odd for a code gen test. |
clang/test/CodeGenHLSL/float3.hlsl | ||
---|---|---|
1 | Nice catch. Thanks. |
Does this need to use driver mode? That is odd for a code gen test.