[llvm-bugs] [Bug 40737] New: X86 flag output parameters broken/incomplete, breaks compiling third party code
via llvm-bugs
llvm-bugs at lists.llvm.org
Fri Feb 15 00:44:45 PST 2019
https://bugs.llvm.org/show_bug.cgi?id=40737
Bug ID: 40737
Summary: X86 flag output parameters broken/incomplete, breaks
compiling third party code
Product: clang
Version: trunk
Hardware: PC
OS: All
Status: NEW
Severity: enhancement
Priority: P
Component: -New Bugs
Assignee: unassignedclangbugs at nondot.org
Reporter: martin at martin.st
CC: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org,
neeilans at live.com, richard-llvm at metafoo.co.uk
Created attachment 21483
--> https://bugs.llvm.org/attachment.cgi?id=21483&action=edit
Reproduction example
Since SVN r354053 ([X86] Add clang support for X86 flag output parameters.),
compiling of the mingw-w64 runtime is broken.
The issue seems to boil down to a construct like this:
/* GCC v6 added support for outputting flags. This allows better code to be
produced for a number of intrinsics. */
#ifndef __GCC_ASM_FLAG_OUTPUTS__
#define __buildbitscan(x, y, z) unsigned char x(unsigned int *Index, y Mask) \
{ \
y n; \
__asm__ (z \
: [Index] "=r" (n) \
: [Mask] "r" (Mask) \
: "cc"); \
*Index = n; \
return Mask!=0; \
}
#else
#define __buildbitscan(x, y, z) unsigned char x(unsigned int *Index, y Mask) \
{ \
y n; \
unsigned char old; \
__asm__ (z \
: "=@ccnz" (old), [Index] "=r" (n) \
: [Mask] "r" (Mask)); \
*Index = n; \
return old; \
}
#endif
__buildbitscan(_BitScanForward, unsigned int, "bsf{l %[Mask],%[Index] |
%[Index],%[Mask]}")
(The testcase is simplified from the original form from mingw-w64, making it
buildable for any target.)
Prior to this change, clang used the older form and everything assembled fine.
After this change, compilation now fails like this:
$ bin/clang -c test.c
clang-9: ../lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp:352: void
llvm::ScheduleDAGSDNodes::BuildSchedUnits(): Assertion `N->getNodeId() == -1 &&
"Node already inserted!"' failed.
Stack dump:
0. Program arguments: /home/martin/code/llvm-bisect/build/bin/clang-9 -cc1
-triple x86_64-unknown-linux-gnu -emit-obj -mrelax-all -disable-free
-main-file-name test.c -mrelocation-model static -mthread-model posix
-mdisable-fp-elim -fmath-errno -masm-verbose -mconstructor-aliases
-munwind-tables -fuse-init-array -target-cpu x86-64 -dwarf-column-info
-debugger-tuning=gdb -coverage-notes-file
/home/martin/code/llvm-bisect/build/test.gcno -resource-dir
/home/martin/code/llvm-bisect/build/lib/clang/9.0.0 -internal-isystem
/usr/local/include -internal-isystem
/home/martin/code/llvm-bisect/build/lib/clang/9.0.0/include
-internal-externc-isystem /usr/include/x86_64-linux-gnu
-internal-externc-isystem /include -internal-externc-isystem /usr/include
-fdebug-compilation-dir /home/martin/code/llvm-bisect/build -ferror-limit 19
-fmessage-length 207 -fobjc-runtime=gcc -fdiagnostics-show-option
-fcolor-diagnostics -o test.o -x c test.c -faddrsig
1. <eof> parser at end of file
2. Code generation
3. Running pass 'Function Pass Manager' on module 'test.c'.
4. Running pass 'X86 DAG->DAG Instruction Selection' on function
'@_BitScanForward'
#0 0x0000000001b6fb0a llvm::sys::PrintStackTrace(llvm::raw_ostream&)
(/home/martin/code/llvm-bisect/build/bin/clang-9+0x1b6fb0a)
#1 0x0000000001b6d8ac llvm::sys::RunSignalHandlers()
(/home/martin/code/llvm-bisect/build/bin/clang-9+0x1b6d8ac)
#2 0x0000000001b6da17 SignalHandler(int)
(/home/martin/code/llvm-bisect/build/bin/clang-9+0x1b6da17)
#3 0x00007fde9fe93390 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x11390)
#4 0x00007fde9ec05428 gsignal
/build/glibc-Cl5G7W/glibc-2.23/signal/../sysdeps/unix/sysv/linux/raise.c:54:0
#5 0x00007fde9ec0702a abort /build/glibc-Cl5G7W/glibc-2.23/stdlib/abort.c:91:0
#6 0x00007fde9ebfdbd7 __assert_fail_base
/build/glibc-Cl5G7W/glibc-2.23/assert/assert.c:92:0
#7 0x00007fde9ebfdc82 (/lib/x86_64-linux-gnu/libc.so.6+0x2dc82)
#8 0x000000000264e0c8 llvm::ScheduleDAGSDNodes::BuildSchedUnits()
(/home/martin/code/llvm-bisect/build/bin/clang-9+0x264e0c8)
#9 0x0000000002650831
llvm::ScheduleDAGSDNodes::BuildSchedGraph(llvm::AAResults*)
(/home/martin/code/llvm-bisect/build/bin/clang-9+0x2650831)
#10 0x00000000026450a8 (anonymous namespace)::ScheduleDAGRRList::Schedule()
(/home/martin/code/llvm-bisect/build/bin/clang-9+0x26450a8)
#11 0x00000000025bee2e llvm::SelectionDAGISel::CodeGenAndEmitDAG()
(/home/martin/code/llvm-bisect/build/bin/clang-9+0x25bee2e)
#12 0x00000000025c892b
llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&)
(/home/martin/code/llvm-bisect/build/bin/clang-9+0x25c892b)
#13 0x00000000025ca894
llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&)
(.part.899.constprop.925)
(/home/martin/code/llvm-bisect/build/bin/clang-9+0x25ca894)
#14 0x0000000000e00680 (anonymous
namespace)::X86DAGToDAGISel::runOnMachineFunction(llvm::MachineFunction&)
(/home/martin/code/llvm-bisect/build/bin/clang-9+0xe00680)
#15 0x00000000012b4691
llvm::MachineFunctionPass::runOnFunction(llvm::Function&)
(.part.37.constprop.38)
(/home/martin/code/llvm-bisect/build/bin/clang-9+0x12b4691)
#16 0x000000000166997c llvm::FPPassManager::runOnFunction(llvm::Function&)
(/home/martin/code/llvm-bisect/build/bin/clang-9+0x166997c)
#17 0x0000000001669b5c llvm::FPPassManager::runOnModule(llvm::Module&)
(/home/martin/code/llvm-bisect/build/bin/clang-9+0x1669b5c)
#18 0x000000000166ac79 llvm::legacy::PassManagerImpl::run(llvm::Module&)
(/home/martin/code/llvm-bisect/build/bin/clang-9+0x166ac79)
#19 0x0000000001d4feed (anonymous
namespace)::EmitAssemblyHelper::EmitAssembly(clang::BackendAction,
std::unique_ptr<llvm::raw_pwrite_stream,
std::default_delete<llvm::raw_pwrite_stream> >)
(/home/martin/code/llvm-bisect/build/bin/clang-9+0x1d4feed)
#20 0x0000000001d5187d clang::EmitBackendOutput(clang::DiagnosticsEngine&,
clang::HeaderSearchOptions const&, clang::CodeGenOptions const&,
clang::TargetOptions const&, clang::LangOptions const&, llvm::DataLayout
const&, llvm::Module*, clang::BackendAction,
std::unique_ptr<llvm::raw_pwrite_stream,
std::default_delete<llvm::raw_pwrite_stream> >)
(/home/martin/code/llvm-bisect/build/bin/clang-9+0x1d5187d)
#21 0x000000000269acc4
clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&)
(/home/martin/code/llvm-bisect/build/bin/clang-9+0x269acc4)
#22 0x0000000002f695d9 clang::ParseAST(clang::Sema&, bool, bool)
(/home/martin/code/llvm-bisect/build/bin/clang-9+0x2f695d9)
#23 0x000000000269a03f clang::CodeGenAction::ExecuteAction()
(/home/martin/code/llvm-bisect/build/bin/clang-9+0x269a03f)
#24 0x00000000021cba8e clang::FrontendAction::Execute()
(/home/martin/code/llvm-bisect/build/bin/clang-9+0x21cba8e)
#25 0x00000000021942b6
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/home/martin/code/llvm-bisect/build/bin/clang-9+0x21942b6)
#26 0x000000000226a4bd
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/home/martin/code/llvm-bisect/build/bin/clang-9+0x226a4bd)
#27 0x00000000009c6118 cc1_main(llvm::ArrayRef<char const*>, char const*,
void*) (/home/martin/code/llvm-bisect/build/bin/clang-9+0x9c6118)
#28 0x000000000094a4c9 main
(/home/martin/code/llvm-bisect/build/bin/clang-9+0x94a4c9)
#29 0x00007fde9ebf0830 __libc_start_main
/build/glibc-Cl5G7W/glibc-2.23/csu/../csu/libc-start.c:325:0
#30 0x00000000009c1fa9 _start
(/home/martin/code/llvm-bisect/build/bin/clang-9+0x9c1fa9)
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20190215/af214c46/attachment-0001.html>
More information about the llvm-bugs
mailing list