Justin Bogner de2bf130e3
[clang][DirectX] Specify element-aligned vectors in TargetInfo (#185954)
Add a bit to TargetInfo to specify that vectors are element-aligned
rather than naturally aligned. This is needed to match DirectX's Data
Layout in LLVM.

Note that this removes the `Opts.HLSL` early exit from
`checkDataLayoutConsistency` so that we actually get these checks when
compiling HLSL. This check looks like it was put there because of
similarity between OpenCL and HLSL, but it isn't actually necessary.

Resolves #123968
2026-03-13 16:35:39 -07:00

23 lines
1021 B
HLSL

// RUN: %clang_cc1 -finclude-default-header -triple dxil-pc-shadermodel6.3-compute -std=hlsl202x -emit-llvm -disable-llvm-passes -hlsl-entry main -o - %s | FileCheck %s
groupshared float4 SharedData;
// CHECK-LABEL: define hidden void @_Z3fn1RU3AS3Dv4_f(ptr addrspace(3) noundef align 4 dereferenceable(16) %Sh)
// CHECK: [[ShAddr:%.*]] = alloca ptr addrspace(3), align 4
// CHECK: [[Tmp:%.*]] = alloca <1 x float>, align 4
// CHECK: store ptr addrspace(3) %Sh, ptr [[ShAddr]], align 4
// CHECK: store <1 x float> splat (float 5.000000e+00), ptr [[Tmp]], align 4
// CHECK: [[A:%.*]] = load <1 x float>, ptr [[Tmp]], align 4
// CHECK: [[B:%.*]] = shufflevector <1 x float> [[A]], <1 x float> poison, <4 x i32> zeroinitializer
// CHECK: [[C:%.*]] = load ptr addrspace(3), ptr [[ShAddr]], align 4
// CHECK: store <4 x float> [[B]], ptr addrspace(3) [[C]], align 4
// CHECK: ret void
void fn1(groupshared float4 Sh) {
Sh = 5.0.xxxx;
}
[numthreads(4, 1, 1)]
void main(uint3 TID : SV_GroupThreadID) {
fn1(SharedData);
}