Open rscottmanley opened 4 months ago
@llvm/issue-subscribers-flang-driver
Author: Scott Manley (rscottmanley)
godbolt link: https://godbolt.org/z/ex1Ejhjj6
backtrace:
'znver5' is not a recognized processor for this target (ignoring processor)
'znver5' is not a recognized processor for this target (ignoring processor)
'znver5' is not a recognized processor for this target (ignoring processor)
'znver5' is not a recognized processor for this target (ignoring processor)
'znver5' is not a recognized processor for this target (ignoring processor)
'znver5' is not a recognized processor for this target (ignoring processor)
LLVM ERROR: 64-bit code requested on a subtarget that doesn't support it!
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0. Program arguments: /opt/compiler-explorer/clang-llvmflang-trunk-20240702/bin/flang-new -fc1 -triple x86_64-unknown-linux-gnu -S -mrelocation-model pic -pic-level 2 -pic-is-pie -target-cpu znver5 -resource-dir /opt/compiler-explorer/clang-llvmflang-trunk-20240702/lib/clang/19 -mframe-pointer=all -o /app/output.s -x f95-cpp-input /app/example.f90
1. Running pass 'Function Pass Manager' on module 'FIRModule'.
2. Running pass 'Expand large div/rem' on function '@_QQmain'
#0 0x00000000034ddc68 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-llvmflang-trunk-20240702/bin/flang-new+0x34ddc68)
#1 0x00000000034db5ec SignalHandler(int) Signals.cpp:0:0
#2 0x0000719d39442520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#3 0x0000719d394969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
#4 0x0000719d39442476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
#5 0x0000719d394287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
#6 0x0000000001aebfac llvm::UniqueStringSaver::save(llvm::StringRef) (.cold) StringSaver.cpp:0:0
#7 0x00000000034360f8 (/opt/compiler-explorer/clang-llvmflang-trunk-20240702/bin/flang-new+0x34360f8)
#8 0x000000000331ee94 llvm::X86Subtarget::initSubtargetFeatures(llvm::StringRef, llvm::StringRef, llvm::StringRef) (/opt/compiler-explorer/clang-llvmflang-trunk-20240702/bin/flang-new+0x331ee94)
#9 0x000000000331f0a2 llvm::X86Subtarget::X86Subtarget(llvm::Triple const&, llvm::StringRef, llvm::StringRef, llvm::StringRef, llvm::X86TargetMachine const&, llvm::MaybeAlign, unsigned int, unsigned int) (/opt/compiler-explorer/clang-llvmflang-trunk-20240702/bin/flang-new+0x331f0a2)
#10 0x0000000003016a20 llvm::X86TargetMachine::getSubtargetImpl(llvm::Function const&) const (/opt/compiler-explorer/clang-llvmflang-trunk-20240702/bin/flang-new+0x3016a20)
#11 0x0000000005905c2c (anonymous namespace)::ExpandLargeDivRemLegacyPass::runOnFunction(llvm::Function&) ExpandLargeDivRem.cpp:0:0
#12 0x0000000007a192a2 llvm::FPPassManager::runOnFunction(llvm::Function&) (/opt/compiler-explorer/clang-llvmflang-trunk-20240702/bin/flang-new+0x7a192a2)
#13 0x0000000007a19421 llvm::FPPassManager::runOnModule(llvm::Module&) (/opt/compiler-explorer/clang-llvmflang-trunk-20240702/bin/flang-new+0x7a19421)
#14 0x0000000007a1b0d0 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/opt/compiler-explorer/clang-llvmflang-trunk-20240702/bin/flang-new+0x7a1b0d0)
#15 0x0000000003869e84 Fortran::frontend::CodeGenAction::executeAction() (/opt/compiler-explorer/clang-llvmflang-trunk-20240702/bin/flang-new+0x3869e84)
#16 0x0000000003534f5d Fortran::frontend::FrontendAction::execute() (/opt/compiler-explorer/clang-llvmflang-trunk-20240702/bin/flang-new+0x3534f5d)
#17 0x00000000035246f6 Fortran::frontend::CompilerInstance::executeAction(Fortran::frontend::FrontendAction&) (/opt/compiler-explorer/clang-llvmflang-trunk-20240702/bin/flang-new+0x35246f6)
#18 0x000000000353accd Fortran::frontend::executeCompilerInvocation(Fortran::frontend::CompilerInstance*) (/opt/compiler-explorer/clang-llvmflang-trunk-20240702/bin/flang-new+0x353accd)
#19 0x0000000001c3d758 fc1_main(llvm::ArrayRef<char const*>, char const*) (/opt/compiler-explorer/clang-llvmflang-trunk-20240702/bin/flang-new+0x1c3d758)
#20 0x0000000001b23a64 main (/opt/compiler-explorer/clang-llvmflang-trunk-20240702/bin/flang-new+0x1b23a64)
#21 0x0000719d39429d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#22 0x0000719d39429e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#23 0x0000000001c3c6be _start (/opt/compiler-explorer/clang-llvmflang-trunk-20240702/bin/flang-new+0x1c3c6be)
flang-new: error: unable to execute command: Aborted (core dumped)
flang-new: error: flang frontend command failed due to signal (use -v to see invocation)
flang-new version 19.0.0git (https://github.com/llvm/llvm-project.git fdd04e8c0c8bf19384901e8104f0643c4537ad73)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /opt/compiler-explorer/clang-llvmflang-trunk-20240702/bin
flang-new: note: diagnostic msg:
********************
PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
flang-new: note: diagnostic msg: /tmp/example-63841a
flang-new: note: diagnostic msg: /tmp/example-63841a.sh
flang-new: note: diagnostic msg:
********************
Compiler returned: 254
@llvm/issue-subscribers-bug
Author: Scott Manley (rscottmanley)
@llvm/issue-subscribers-backend-x86
Author: Scott Manley (rscottmanley)
Thanks for reporting - I confirm that I was able to reproduce this.
This is only affecting X86. When targeting AArch64, unsupported -march
flags are rejected here: https://github.com/llvm/llvm-project/blob/1ed84a862f9ce3c60251968f23a5405f06458975/clang/lib/Driver/ToolChains/Arch/AArch64.cpp#L232-L240
That's inside the clangDriver
that both Clang and Flang share (i.e. Clang and Flang behave consistently for AArch64). However, for X86, similar logic to reject unsupported -march
options, is implemented in clangBasic
in https://github.com/llvm/llvm-project/blob/1ed84a862f9ce3c60251968f23a5405f06458975/clang/lib/Basic/Targets.cpp#L777-L784
In Flang that logic is not used (Flang strives to minimise the dependency on clangBasic
and also does not re-use the TargetInfo logic from Clang).
While the output provide to the user is quite nice and very helpful, it is only available in Clang:
bin/clang --target=x86_64 -march=znver5 file.c -S -emit-llvm
error: unknown target CPU 'znver5'
note: valid target CPU values are: nocona, core2, penryn, bonnell, atom, silvermont, slm, goldmont, goldmont-plus, tremont, nehalem, corei7, westmere, sandybridge, corei7-avx, ivybridge, core-avx-i, haswell, core-avx2, broadwell, skylake, skylake-avx512, skx, cascadelake, cooperlake, cannonlake, icelake-client, rocketlake, icelake-server, tigerlake, sapphirerapids, alderlake, raptorlake, meteorlake, arrowlake, arrowlake-s, lunarlake, gracemont, pantherlake, sierraforest, grandridge, graniterapids, graniterapids-d, emeraldrapids, clearwaterforest, knl, knm, k8, athlon64, athlon-fx, opteron, k8-sse3, athlon64-sse3, opteron-sse3, amdfam10, barcelona, btver1, btver2, bdver1, bdver2, bdver3, bdver4, znver1, znver2, znver3, znver4, x86-64, x86-64-v2, x86-64-v3, x86-64-v4
I see two potential "quick" solutions:
clangDriver
), orclangDriver
, but will lead to some duplication).Another possibility that will require more work and consideration (but could be much more future-proof) - make Flang re-use Clang's TargetInfo
machinery.
Hope this helps.
CC @ganeshgit - the 19.x release is upcoming do you have a plan for znver5 support to match gcc?
https://discourse.llvm.org/t/llvm-19-release-schedule-and-planning/79828
With current sources, flang-new results in an ICE if you specify an unsupported cpu/arch on x86. I was able to replicate with trunk and 18.1.0