CompilerTestCodeGenFloatingPointEnvironment fails on ARM64x when run under x64 emulation
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 72/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Quiet
- Tech stack
- cpp
- Domain
- compilers, testing-qa
Research direction
Start in tools/clang/unittests/HLSL/CompilerTest.cpp at CompilerTest::CodeGenFloatingPointEnvironment and review its existing Win32 guards. Run the test under x64 emulation on Windows ARM64 and verify that runtime detection skips only that case while preserving compatibility on older Windows versions and other platforms.
Written by the indexing model from the issue text.
Description
Description
CodeGenFloatingPointEnvironment is a win32 only test as guarded by defines here:
https://github.com/microsoft/DirectXShaderCompiler/blob/c1104ee6ff393378f9d75f3326d5c56fac8e95b7/tools/clang/unittests/HLSL/CompilerTest.cpp#L4405
This doesn't appropriately guard against running the x64 version of this test on an ARM64 machine though.
So, this test fails in arm64x pipelines when targeting x64.
StartGroup: CompilerTest::CodeGenFloatingPointEnvironment
Verify: IsTrue(_controlfp_s(&fpOriginal, 0, 0) == 0)
Verify: IsTrue(_controlfp_s(&fpSavedState, 0, 0) == 0)
Verify: IsTrue(_controlfp_s(&newValue, fpTestState, fpTestMask) == 0)
Verify: IsTrue(_controlfp_s(&fpBeforeCompile, 0, 0) == 0)
Error: Verify: AreEqual((fpBeforeCompile & fpTestMask), fpTestState) - Values (34079263, 34079255) [File: C:\__w\1\s\DirectXShaderCompiler\tools\clang\unittests\HLSL\CompilerTest.cpp,
Function: CompilerTest::CodeGenFloatingPointEnvironment, Line: 4377]
EndGroup: CompilerTest::CodeGenFloatingPointEnvironment [Failed]
Environment
- DXC version: 1.9.2607
- Host Operating System: Windows ARM64
How to fix
We will need to add runtime detection to skip this test. Copilot had a few suggestions that wouldn't work. And then arrived at this, which I think will work. But we'll want to verify it.
https://learn.microsoft.com/en-us/windows/win32/api/wow64apiset/nf-wow64apiset-iswow64process2
static bool IsX64EmulatedOnArm64() {
using Fn = BOOL(WINAPI *)(HANDLE, USHORT *, USHORT *);
auto fn = reinterpret_cast<Fn>(GetProcAddress(
GetModuleHandleW(L"kernel32.dll"), "IsWow64Process2"));
if (!fn)
return false;
USHORT processMachine = 0;
USHORT nativeMachine = 0;
return fn(GetCurrentProcess(), &processMachine, &nativeMachine) &&
processMachine == IMAGE_FILE_MACHINE_AMD64 &&
nativeMachine == IMAGE_FILE_MACHINE_ARM64;
}
Dynamic lookup preserves compatibility with Windows versions predating IsWow64Process2 . This detects the exact failing case: x64 TAEF running through emulation on ARM64.
- Dominant language
- C++
- Stars
- 3.7k
- Forks
- 900
- Avg merge
- 2d 14h
- Merged PRs (30d)
- 39
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from microsoft/DirectXShaderCompiler
-
bug needs-triage spirv
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
microsoft/DirectXShaderCompiler#8831 ·
-
bug needs-triage spirv
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
microsoft/DirectXShaderCompiler#8829 ·
-
bug needs-triage spirv
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
microsoft/DirectXShaderCompiler#8828 ·
-
bug needs-triage spirv
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
microsoft/DirectXShaderCompiler#8827 ·
-
bug needs-triage spirv
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
microsoft/DirectXShaderCompiler#8826 ·
All issues in microsoft/DirectXShaderCompiler
Similar issues
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
AXERA-TECH/ax-llm#77 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
-
bug-unconfirmed
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
NVIDIA/cuda-samples#453 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
infiniflow/infinity#3502 ·