This is an archive of the discontinued LLVM Phabricator instance.

[SystemZ] Support the 'N' code for the odd register in inline-asm.
ClosedPublic

Authored by jonpa on Jul 6 2021, 10:36 AM.

Details

Summary

The odd register of a (128 bit) register pair is accessed with the 'N' code with an inline assembly operand.

Diff Detail

Event Timeline

jonpa created this revision.Jul 6 2021, 10:36 AM
jonpa requested review of this revision.Jul 6 2021, 10:36 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 6 2021, 10:36 AM
uweigand accepted this revision.Jul 6 2021, 10:41 AM

LGTM, thanks!

This revision is now accepted and ready to land.Jul 6 2021, 10:41 AM
This revision was landed with ongoing or failed builds.Jul 6 2021, 10:48 AM
This revision was automatically updated to reflect the committed changes.

I see the following crash when compiling the -next Linux kernel, which contains https://git.kernel.org/next/linux-next/c/4516f355c55f6da231c494c6d2be7d863d02f13c, which mentions this commit directly:

$ make -skj"$(nproc)" ARCH=s390 CC=clang CROSS_COMPILE=s390x-linux-gnu- O=build/s390 distclean defconfig drivers/s390/crypto/
clang-13: /home/nathan/cbl/github/tc-build/llvm-project/llvm/lib/CodeGen/MachineRegisterInfo.cpp:285: void llvm::MachineRegisterInfo::addRegOperandToUseList(llvm::MachineOperand *): Assertion `Last && "Inconsistent use list"' failed.
PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0.	Program arguments: /home/nathan/cbl/github/tc-build/build/llvm/stage1/bin/clang-13 -cc1 -triple s390x-unknown-linux-gnu -S -disable-free -main-file-name ap_queue.c -mrelocation-model pic -pic-level 2 -pic-is-pie -fno-delete-null-pointer-checks -fwarn-stack-size=2048 -mframe-pointer=none -relaxed-aliasing -fmath-errno -fno-rounding-math -no-integrated-as -mconstructor-aliases -target-cpu zEC12 -target-feature +soft-float -mbackchain -mpacked-stack -msoft-float -mfloat-abi soft -mllvm -treat-scalable-fixed-error-as-warning -debug-info-kind=limited -dwarf-version=4 -debugger-tuning=gdb -fcoverage-compilation-dir=/home/nathan/cbl/src/linux-next/build/s390 -nostdsysteminc -nobuiltininc -resource-dir /home/nathan/cbl/github/tc-build/build/llvm/stage1/lib/clang/13.0.0 -dependency-file drivers/s390/crypto/.ap_queue.o.d -MT drivers/s390/crypto/ap_queue.o -isystem /home/nathan/cbl/github/tc-build/build/llvm/stage1/lib/clang/13.0.0/include -include /home/nathan/cbl/src/linux-next/include/linux/compiler-version.h -include /home/nathan/cbl/src/linux-next/include/linux/kconfig.h -include /home/nathan/cbl/src/linux-next/include/linux/compiler_types.h -I /home/nathan/cbl/src/linux-next/arch/s390/include -I ./arch/s390/include/generated -I /home/nathan/cbl/src/linux-next/include -I ./include -I /home/nathan/cbl/src/linux-next/arch/s390/include/uapi -I ./arch/s390/include/generated/uapi -I /home/nathan/cbl/src/linux-next/include/uapi -I ./include/generated/uapi -D __KERNEL__ -D __PACK_STACK -D CONFIG_AS_CFI_VAL_OFFSET=1 -D CC_USING_NOP_MCOUNT -D CC_USING_FENTRY -I /home/nathan/cbl/src/linux-next/drivers/s390/crypto -I ./drivers/s390/crypto -D KBUILD_MODFILE=\"drivers/s390/crypto/ap\" -D KBUILD_BASENAME=\"ap_queue\" -D KBUILD_MODNAME=\"ap\" -D __KBUILD_MODNAME=kmod_ap -fmacro-prefix-map=/home/nathan/cbl/src/linux-next/= -O2 -Wall -Wundef -Werror=strict-prototypes -Wno-trigraphs -Werror=implicit-function-declaration -Werror=implicit-int -Werror=return-type -Wno-format-security -Werror=unknown-warning-option -Wno-sign-compare -Wno-frame-address -Wno-address-of-packed-member -Wframe-larger-than=2048 -Wno-format-invalid-specifier -Wno-gnu -Wno-unused-but-set-variable -Wno-unused-const-variable -Wdeclaration-after-statement -Wvla -Wno-pointer-sign -Wno-array-bounds -Werror=date-time -Werror=incompatible-pointer-types -Wno-initializer-overrides -Wno-format -Wno-sign-compare -Wno-format-zero-length -Wno-pointer-to-enum-cast -Wno-tautological-constant-out-of-range-compare -std=gnu89 -fno-dwarf-directory-asm -fdebug-compilation-dir=/home/nathan/cbl/src/linux-next/build/s390 -ferror-limit 19 -pg -mfentry -mnop-mcount -mrecord-mcount -fwrapv -fno-signed-char -fwchar-type=short -fno-signed-wchar -fgnuc-version=4.2.1 -fcolor-diagnostics -vectorize-loops -vectorize-slp -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/ap_queue-73312c.s -x c /home/nathan/cbl/src/linux-next/drivers/s390/crypto/ap_queue.c
1.	<eof> parser at end of file
2.	Code generation
3.	Running pass 'Function Pass Manager' on module '/home/nathan/cbl/src/linux-next/drivers/s390/crypto/ap_queue.c'.
4.	Running pass 'SystemZ Assembly Printer' on function '@ap_recv'
 #0 0x0000000002abf4c3 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/nathan/cbl/github/tc-build/build/llvm/stage1/bin/clang-13+0x2abf4c3)
 #1 0x0000000002abd30e llvm::sys::RunSignalHandlers() (/home/nathan/cbl/github/tc-build/build/llvm/stage1/bin/clang-13+0x2abd30e)
 #2 0x0000000002abf98a SignalHandler(int) Signals.cpp:0:0
 #3 0x00007f7231630870 __restore_rt sigaction.c:0:0
 #4 0x00007f72310ead22 raise (/usr/lib/libc.so.6+0x3cd22)
 #5 0x00007f72310d4862 abort (/usr/lib/libc.so.6+0x26862)
 #6 0x00007f72310d4747 _nl_load_domain.cold loadmsgcat.c:0:0
 #7 0x00007f72310e3616 (/usr/lib/libc.so.6+0x35616)
 #8 0x0000000001f95442 llvm::MachineRegisterInfo::addRegOperandToUseList(llvm::MachineOperand*) (/home/nathan/cbl/github/tc-build/build/llvm/stage1/bin/clang-13+0x1f95442)
 #9 0x000000000188a865 llvm::SystemZAsmPrinter::PrintAsmOperand(llvm::MachineInstr const*, unsigned int, char const*, llvm::raw_ostream&) SystemZAsmPrinter.cpp:0:0
#10 0x00000000037dffdb llvm::AsmPrinter::emitInlineAsm(llvm::MachineInstr const*) const (/home/nathan/cbl/github/tc-build/build/llvm/stage1/bin/clang-13+0x37dffdb)
#11 0x00000000037cd10e llvm::AsmPrinter::emitFunctionBody() (/home/nathan/cbl/github/tc-build/build/llvm/stage1/bin/clang-13+0x37cd10e)
#12 0x000000000188aac5 llvm::AsmPrinter::runOnMachineFunction(llvm::MachineFunction&) SystemZAsmPrinter.cpp:0:0
#13 0x0000000001f6553d llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (/home/nathan/cbl/github/tc-build/build/llvm/stage1/bin/clang-13+0x1f6553d)
#14 0x00000000023f62a8 llvm::FPPassManager::runOnFunction(llvm::Function&) (/home/nathan/cbl/github/tc-build/build/llvm/stage1/bin/clang-13+0x23f62a8)
#15 0x00000000023fe771 llvm::FPPassManager::runOnModule(llvm::Module&) (/home/nathan/cbl/github/tc-build/build/llvm/stage1/bin/clang-13+0x23fe771)
#16 0x00000000023f6da1 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/home/nathan/cbl/github/tc-build/build/llvm/stage1/bin/clang-13+0x23f6da1)
#17 0x00000000031aa4bf (anonymous namespace)::EmitAssemblyHelper::EmitAssemblyWithNewPassManager(clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream> >) BackendUtil.cpp:0:0
#18 0x00000000031a4c1c clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::StringRef, llvm::Module*, clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream> >) (/home/nathan/cbl/github/tc-build/build/llvm/stage1/bin/clang-13+0x31a4c1c)
#19 0x000000000363ed30 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) CodeGenAction.cpp:0:0
#20 0x0000000003d582f4 clang::ParseAST(clang::Sema&, bool, bool) (/home/nathan/cbl/github/tc-build/build/llvm/stage1/bin/clang-13+0x3d582f4)
#21 0x0000000003593240 clang::FrontendAction::Execute() (/home/nathan/cbl/github/tc-build/build/llvm/stage1/bin/clang-13+0x3593240)
#22 0x00000000035064ff clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/home/nathan/cbl/github/tc-build/build/llvm/stage1/bin/clang-13+0x35064ff)
#23 0x0000000003638db7 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/home/nathan/cbl/github/tc-build/build/llvm/stage1/bin/clang-13+0x3638db7)
#24 0x000000000187bc28 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/home/nathan/cbl/github/tc-build/build/llvm/stage1/bin/clang-13+0x187bc28)
#25 0x000000000187977d ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&) driver.cpp:0:0
#26 0x00000000018794dd main (/home/nathan/cbl/github/tc-build/build/llvm/stage1/bin/clang-13+0x18794dd)
#27 0x00007f72310d5b25 __libc_start_main (/usr/lib/libc.so.6+0x27b25)
#28 0x00000000018763ee _start (/home/nathan/cbl/github/tc-build/build/llvm/stage1/bin/clang-13+0x18763ee)
clang-13: error: unable to execute command: Aborted (core dumped)
clang-13: error: clang frontend command failed due to signal (use -v to see invocation)
ClangBuiltLinux clang version 13.0.0 (https://github.com/llvm/llvm-project a821df993def459009a0d8263af879fc35400a94)
Target: s390x-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/nathan/cbl/github/tc-build/build/llvm/stage1/bin
clang-13: note: diagnostic msg: 
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang-13: note: diagnostic msg: /tmp/ap_queue-12da73.c
clang-13: note: diagnostic msg: /tmp/ap_queue-12da73.sh
clang-13: note: diagnostic msg: 

********************
make[4]: *** [/home/nathan/cbl/src/linux-next/scripts/Makefile.build:272: drivers/s390/crypto/ap_queue.o] Error 254
make[4]: Target '__build' not remade because of errors.
make[3]: *** [/home/nathan/cbl/src/linux-next/scripts/Makefile.build:536: drivers/s390/crypto] Error 2
make[3]: Target '__build' not remade because of errors.
make[2]: *** [/home/nathan/cbl/src/linux-next/Makefile:1993: drivers/s390] Error 2
make[2]: Target 'drivers/s390/crypto/' not remade because of errors.
make[1]: *** [/home/nathan/cbl/src/linux-next/Makefile:358: __build_one_by_one] Error 2
make[1]: Target 'distclean' not remade because of errors.
make[1]: Target 'defconfig' not remade because of errors.
make[1]: Target 'drivers/s390/crypto/' not remade because of errors.
make: *** [Makefile:227: __sub-make] Error 2
make: Target 'distclean' not remade because of errors.
make: Target 'defconfig' not remade because of errors.
make: Target 'drivers/s390/crypto/' not remade because of errors.

cvise spits out:

$ cat ap_queue.i
__int128 ap_dqap_resgr0_rp2_0;
ap_dqap_resgr0() {
  asm("0:       ltgr    %N[rp2],%N[rp2]\n" : [rp2] "+&d"(ap_dqap_resgr0_rp2_0));
}

$ clang -O2 --target=s390x-linux-gnu -c -o /dev/null ap_queue.i
clang: /home/nathan/cbl/github/tc-build/llvm-project/llvm/lib/CodeGen/MachineRegisterInfo.cpp:285: void llvm::MachineRegisterInfo::addRegOperandToUseList(llvm::MachineOperand *): Assertion `Last && "Inconsistent use list"' failed.
...
jonpa added a comment.Jul 10 2021, 2:39 AM

Thank you for the bugreport and reduced test case!

Suggested bugfix: https://reviews.llvm.org/D105757.