Closed llvmbot closed 5 years ago
https://reviews.llvm.org/D60811 Closed by commit rL358644: [PowerPC] Fix wrong ElemSIze when calling isConsecutiveLS() (Link:- https://reviews.llvm.org/rL358644)
The new patch for this bug is in https://reviews.llvm.org/D60811.
Hi @nemanjai,
I saw that this part of the code was introduced by you in commit - https://github.com/apple/swift-llvm/commit/502534bc2a23e0d8eab19ee77d7648dd65bf0667#diff-e9b0770875cf87fad4925f505fe401ae (https://reviews.llvm.org/D26023)
Can you please tell what this piece of code is doing and if at all the assert statement needs to be revisited?
Narrow down the error case
I have narrowed down the error case.
One can use llc simplify.ll
to reproduce the error.
Any updates on this one? Sorry for pushing this, but just wanted to mention that this is a blocker for our efforts on building Swift toolchain on ppc64le. Would highly appreciate an early resolution. Thanks in advance!
Hi, Sarvesh, I think there is a bug in below code.
for (int i = 1, e = N->getNumOperands(); i < e; ++i) {
// If any inputs are fp_round(extload), they all must be.
if (IsRoundOfExtLoad && N->getOperand(i).getOpcode() != ISD::FP_ROUND)
return SDValue();
SDValue NextInput = IsRoundOfExtLoad ? N->getOperand(i).getOperand(0) :
N->getOperand(i);
if (NextInput.getOpcode() != ISD::LOAD)
return SDValue();
SDValue PreviousInput =
IsRoundOfExtLoad ? N->getOperand(i-1).getOperand(0) : N->getOperand(i-1);
LoadSDNode *LD1 = dyn_cast<LoadSDNode>(PreviousInput);
LoadSDNode *LD2 = dyn_cast<LoadSDNode>(NextInput);
// If any inputs are fp_round(extload), they all must be.
if (IsRoundOfExtLoad && LD2->getExtensionType() != ISD::EXTLOAD)
return SDValue();
if (!isConsecutiveLS(LD2, LD1, ElemSize, 1, DAG))
InputsAreConsecutiveLoads = false;
if (!isConsecutiveLS(LD1, LD2, ElemSize, 1, DAG))
InputsAreReverseConsecutive = false;
// Exit early if the loads are neither consecutive nor reverse consecutive.
if (!InputsAreConsecutiveLoads && !InputsAreReverseConsecutive)
return SDValue();
}
assert(!(InputsAreConsecutiveLoads && InputsAreReverseConsecutive) &&
"The loads cannot be both consecutive and reverse consecutive.");
For below if statement, if InputsAreConsecutiveLoads = 0 and InputsAreReverseConsecutive = 0, it will return SDValue(). if (!InputsAreConsecutiveLoads && !InputsAreReverseConsecutive) return SDValue();
For below 3 situations, if-statement will not return SDValue(): InputsAreConsecutiveLoads = 0 and InputsAreReverseConsecutive = 1, InputsAreConsecutiveLoads = 1 and InputsAreReverseConsecutive = 0, InputsAreConsecutiveLoads = 1 and InputsAreReverseConsecutive = 1,
For below assert-statement: assert(!(InputsAreConsecutiveLoads && InputsAreReverseConsecutive) && "The loads cannot be both consecutive and reverse consecutive.");
If InputsAreConsecutiveLoads = 1 and InputsAreReverseConsecutive = 1, this assert condtion '!(InputsAreConsecutiveLoads && InputsAreReverseConsecutive)' will get false.
So I think the right assert statement should be: assert((InputsAreConsecutiveLoads || InputsAreReverseConsecutive) && "The loads cannot be both consecutive and reverse consecutive.");
关注IBM中国编译器开发团队 - 新浪微博: http://www.weibo.com/ibmcompiler | developerWorks: http://ibm.co/HK0GCx
This is a swift-related issue, report on their bugtrack.
This looks like an LLVM backend bug and, thus, should be tracked here.
Attaching the IR output of the failing command at https://bugs.swift.org/browse/SR-10176.
The failing command mentions this particular function literal in its stack dump:-
Running pass 'PowerPC DAG->DAG Pattern Instruction Selection' on function '@"$s22LanguageServerProtocol13HoverResponseV8contents5rangeAcA13MarkupContentV_SnyAA8PositionVGSgtcfC"' I could find "s22LanguageServerProtocol13HoverResponseV8contents5rangeAcA13MarkupContentV_SnyAA8PositionVGSgtcfC" function literal definition in the IR dump, however could not make much out of it.
Any help or any person you could point out to resolve this?
Please note that currently this is the only/final error we are facing now in our aim of building Apple Swift 5 toolchain on PPC64LE. Rest all issues have been resolved.
Just FYI, the toolchain builds to completion (thus confirming of no further failures) if we comment out the assert function which throws up this error - i.e. llvm/lib/Target/PowerPC/PPCISelLowering.cpp:12111: llvm::SDValue combineBVOfConsecutiveLoads(llvm::SDNode *, llvm::SelectionDAG &): Assertion `!(InputsAreConsecutiveLoads && InputsAreReverseConsecutive) && "The loads cannot be both consecutive and reverse consecutive."'
Please suggest.
Please ignore the previous comment. Looking at the assert, while trying a few things initially, I think I misread the assert in this case , the assert will hit only if the first condition is false which means both variables 'InputsAreConsecutiveLoads' and 'InputsAreReverseConsecutive' are true. :(
Investigated more on this and found that the following assert statement which throws up this error might be wrongly computed:- assert(!(InputsAreConsecutiveLoads && InputsAreReverseConsecutive) && "The loads cannot be both consecutive and reverse consecutive.");
Both variables 'InputsAreConsecutiveLoads' and 'InputsAreReverseConsecutive' are computed based on the return value from 'isConsecutiveLS' function. The 'isConsecutiveLS' function definition mentions in comments that it is "Like SelectionDAG::isConsecutiveLoad", which "Return true if LD is loading 'Bytes' bytes from a location that is 'Dist' units away from the location that the 'Base' load is loading from."
Based on this, both variables 'InputsAreConsecutiveLoads' and 'InputsAreReverseConsecutive' which are initialised to 'true', are set to 'false' if the return value of 'isConsecutiveLS' function is false i.e. if the loads are not consecutive or reverse consecutive respectively.
Further we do "Exit early if the loads are neither consecutive nor reverse consecutive.":- if (!InputsAreConsecutiveLoads && !InputsAreReverseConsecutive) return SDValue();
To summarise:- InputsAreConsecutiveLoads == true => Loads are consecutive InputsAreReverseConsecutive == true => Loads are reverse consecutive
InputsAreConsecutiveLoads == false => Loads are NOT consecutive InputsAreReverseConsecutive == false => Loads are NOT reverse consecutive
Based on this, the assert statement in question should have been the following:- assert((InputsAreConsecutiveLoads && InputsAreReverseConsecutive) && "The loads cannot be both consecutive and reverse consecutive.");
Please correct if I am missing anything.
Can some one please have a look and comment on this? This is blocking building Apple Swift 5 toolchain on PPC64LE.
Hi Davide,
I have already raised this on swift bugtracker:- https://bugs.swift.org/browse/SR-10059
I got the response from community members - "Looks like an LLVM bug to me."
Please suggest. Would appreciate a prompt response.
This is a swift-related issue, report on their bugtrack.
Extended Description
Facing the following error at step "--- Installing swiftpm ---" while building Apple Swift 5 toolchain on PowerPC64LE using the master branch(detailed log attached):-
--- Installing swiftpm ---
0 0x00000000152ebd28 PrintStackTraceSignalHandler(void*) (/home/sar/swift-source/swift-nightly-install/usr/bin/swift+0x152ebd28)
1 0x00000000152e8fc8 llvm::sys::RunSignalHandlers() (/home/sar/swift-source/swift-nightly-install/usr/bin/swift+0x152e8fc8)
2 0x00000000152ec3e8 SignalHandler(int) (/home/sar/swift-source/swift-nightly-install/usr/bin/swift+0x152ec3e8)
3 0x00003fff98e204d8 0x4d8 gsignal
4 0x00003fff98e204d8
5 0x00003fff98e204d8 abort (+0x4d8)
6 0x00003fff9879ec90 (/lib/powerpc64le-linux-gnu/libc.so.6+0x3ec90)
7 0x00003fff987a11f4 __assert_fail (/lib/powerpc64le-linux-gnu/libc.so.6+0x411f4)
8 0x00003fff987941c0 llvm::PPCTargetLowering::DAGCombineBuildVector(llvm::SDNode*, llvm::TargetLowering::DAGCombinerInfo&) const (/lib/powerpc64le-linux-gnu/libc.so.6+0x341c0)
9 0x00003fff987942b4 llvm::PPCTargetLowering::PerformDAGCombine(llvm::SDNode*, llvm::TargetLowering::DAGCombinerInfo&) const (/lib/powerpc64le-linux-gnu/libc.so.6+0x342b4)
10 0x0000000011c77228 (anonymous namespace)::DAGCombiner::combine(llvm::SDNode*) (/home/sar/swift-source/swift-nightly-install/usr/bin/swift+0x11c77228)
11 0x0000000011c78e98 llvm::SelectionDAG::Combine(llvm::CombineLevel, llvm::AAResults*, llvm::CodeGenOpt::Level) (/home/sar/swift-source/swift-nightly-install/usr/bin/swift+0x11c78e98)
12 0x0000000011f758f8 llvm::SelectionDAGISel::CodeGenAndEmitDAG() (/home/sar/swift-source/swift-nightly-install/usr/bin/swift+0x11f758f8)
13 0x0000000011f74130 llvm::SelectionDAGISel::SelectBasicBlock(llvm::ilist_iterator<llvm::ilist_detail::node_options<llvm::Instruction, true, false, void>, false, true>, llvm::ilist_iterator<llvm::ilist_detail::node_options<llvm::Instruction, true, false, void>, false, true>, bool&) (/home/sar/swift-source/swift-nightly-install/usr/bin/swift+0x11f74130)
14 0x00000000120fcffc llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) (/home/sar/swift-source/swift-nightly-install/usr/bin/swift+0x120fcffc)
15 0x00000000120fc7d8 llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) (/home/sar/swift-source/swift-nightly-install/usr/bin/swift+0x120fc7d8)
16 0x00000000120faf74 (anonymous namespace)::PPCDAGToDAGISel::runOnMachineFunction(llvm::MachineFunction&) (/home/sar/swift-source/swift-nightly-install/usr/bin/swift+0x120faf74)
17 0x00000000120f6c5c llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (/home/sar/swift-source/swift-nightly-install/usr/bin/swift+0x120f6c5c)
18 0x0000000011c0eea4 llvm::FPPassManager::runOnFunction(llvm::Function&) (/home/sar/swift-source/swift-nightly-install/usr/bin/swift+0x11c0eea4)
19 0x0000000012b079d4 llvm::FPPassManager::runOnModule(llvm::Module&) (/home/sar/swift-source/swift-nightly-install/usr/bin/swift+0x12b079d4)
20 0x00000000150f8180 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/home/sar/swift-source/swift-nightly-install/usr/bin/swift+0x150f8180)
21 0x00000000150f85c4 llvm::legacy::PassManager::run(llvm::Module&) (/home/sar/swift-source/swift-nightly-install/usr/bin/swift+0x150f85c4)
22 0x00000000150f8ca4 swift::performLLVM(swift::IRGenOptions&, swift::DiagnosticEngine, llvm::sys::SmartMutex , llvm::GlobalVariable, llvm::Module, llvm::TargetMachine, swift::version::Version const&, llvm::StringRef, swift::UnifiedStatsReporter) (/home/sar/swift-source/swift-nightly-install/usr/bin/swift+0x150f8ca4)
23 0x00000000150f9544 ThreadEntryPoint(swift::irgen::IRGenerator, llvm::sys::SmartMutex , int) (/home/sar/swift-source/swift-nightly-install/usr/bin/swift+0x150f9544)
24 0x000000001026eb5c std::thread::_Impl<std::_Bind_simple<void ( (swift::irgen::IRGenerator, llvm::sys::SmartMutex, int))(swift::irgen::IRGenerator, llvm::sys::SmartMutex*, int)> >::_M_run() (/home/sar/swift-source/swift-nightly-install/usr/bin/swift+0x1026eb5c)
25 0x0000000010274890 (/home/sar/swift-source/swift-nightly-install/usr/bin/swift+0x10274890)
26 0x00000000102764ac start_thread (/home/sar/swift-source/swift-nightly-install/usr/bin/swift+0x102764ac)
27 0x00003fff98a44974 clone (/usr/lib/powerpc64le-linux-gnu/libstdc++.so.6+0xe4974)
/home/sar/swift-source/swift-nightly-install/usr/bin/swift[0x152ebd28] /home/sar/swift-source/swift-nightly-install/usr/bin/swift[0x152e8fc8] /home/sar/swift-source/swift-nightly-install/usr/bin/swift[0x152ec3e8] [0x3fff98e204d8] /lib/powerpc64le-linux-gnu/libc.so.6(gsignal+0x40)[0x3fff9879ec90] /lib/powerpc64le-linux-gnu/libc.so.6(abort+0x2b4)[0x3fff987a11f4] /lib/powerpc64le-linux-gnu/libc.so.6(+0x341c0)[0x3fff987941c0] /lib/powerpc64le-linux-gnu/libc.so.6(__assert_fail+0x64)[0x3fff987942b4] /home/sar/swift-source/swift-nightly-install/usr/bin/swift[0x11c77228] /home/sar/swift-source/swift-nightly-install/usr/bin/swift[0x11c78e98] /home/sar/swift-source/swift-nightly-install/usr/bin/swift[0x11f758f8] /home/sar/swift-source/swift-nightly-install/usr/bin/swift[0x11f74130] /home/sar/swift-source/swift-nightly-install/usr/bin/swift[0x120fcffc] /home/sar/swift-source/swift-nightly-install/usr/bin/swift[0x120fc7d8] /home/sar/swift-source/swift-nightly-install/usr/bin/swift[0x120faf74] /home/sar/swift-source/swift-nightly-install/usr/bin/swift[0x120f6c5c] /home/sar/swift-source/swift-nightly-install/usr/bin/swift[0x11c0eea4] /home/sar/swift-source/swift-nightly-install/usr/bin/swift[0x12b079d4] /home/sar/swift-source/swift-nightly-install/usr/bin/swift[0x150f8180] /home/sar/swift-source/swift-nightly-install/usr/bin/swift[0x150f85c4] /home/sar/swift-source/swift-nightly-install/usr/bin/swift[0x150f8ca4] /home/sar/swift-source/swift-nightly-install/usr/bin/swift[0x150f9544] /home/sar/swift-source/swift-nightly-install/usr/bin/swift[0x1026eb5c] /home/sar/swift-source/swift-nightly-install/usr/bin/swift[0x10274890] /home/sar/swift-source/swift-nightly-install/usr/bin/swift[0x102764ac] /usr/lib/powerpc64le-linux-gnu/libstdc++.so.6(+0xe4974)[0x3fff98a44974] /lib/powerpc64le-linux-gnu/libpthread.so.0(+0x8040)[0x3fff98dd8040] /lib/powerpc64le-linux-gnu/libc.so.6(clone+0x98)[0x3fff98883bb0]