This is an archive of the discontinued LLVM Phabricator instance.

Changes for Installing SwiftPM for Apple Swift 5 Toolchain on PowerPC64LE
Needs ReviewPublic

Authored by sarveshtamba on Feb 27 2019, 4:08 AM.
This revision needs review, but there are no reviewers specified.

Details

Reviewers
None
Summary

This changes are required to fix the following error found while building Swift 5.0 toolchain:-

swift: /home/sar/swift-source/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."' failed.
Stack dump:
0. Running pass 'Function Pass Manager' on module '/home/sar/swift-source/build/buildbot_linux/sourcekitlsp-linux-powerpc64le/powerpc64le-unknown-linux/release/LanguageServerProtocol.build/CancelRequest.swift.o'.

  1. Running pass 'PowerPC DAG->DAG Pattern Instruction Selection' on function '@"$s22LanguageServerProtocol13HoverResponseV8contents5rangeAcA13MarkupContentV_SnyAA8PositionVGSgtcfC"' #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<false>*, 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<false>*, 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<false>*, int))(swift::irgen::IRGenerator*, llvm::sys::SmartMutex<false>*, 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]
<unknown>:0: error: unable to execute command: Aborted
<unknown>:0: error: compile command failed due to signal 6 (use -v to see invocation)
/home/sar/swift-source/swift-nightly-install/usr/bin/swift build --package-path /home/sar/swift-source/sourcekit-lsp --build-path /home/sar/swift-source/build/buildbot_linux/sourcekitlsp-linux-powerpc64le --configuration release --verbose -Xswiftc -enable-testing -Xcxx -I -Xcxx /home/sar/swift-source/swift-nightly-install/usr/lib/swift
Traceback (most recent call last):

File "/home/sar/swift-source/sourcekit-lsp/Utilities/build-script-helper.py", line 80, in <module>
  main()
File "/home/sar/swift-source/sourcekit-lsp/Utilities/build-script-helper.py", line 70, in main
  swiftpm('build', swift_exec, swiftpm_args)
File "/home/sar/swift-source/sourcekit-lsp/Utilities/build-script-helper.py", line 14, in swiftpm
  subprocess.check_call(cmd, env=env)
File "/usr/lib/python2.7/subprocess.py", line 541, in check_call
  raise CalledProcessError(retcode, cmd)

subprocess.CalledProcessError: Command '['/home/sar/swift-source/swift-nightly-install/usr/bin/swift', 'build', '--package-path', '/home/sar/swift-source/sourcekit-lsp', '--build-path', '/home/sar/swift-source/build/buildbot_linux/sourcekitlsp-linux-powerpc64le', '--configuration', 'release', '--verbose', '-Xswiftc', '-enable-testing', '-Xcxx', '-I', '-Xcxx', '/home/sar/swift-source/swift-nightly-install/usr/lib/swift']' returned non-zero exit status 1
Building the standard library for: swift-stdlib-linux-powerpc64le
Running Swift tests for: check-swift-all-linux-powerpc64le check-swift-all-optimize-linux-powerpc64le
./utils/build-script: fatal error: command terminated with a non-zero exit status 1, aborting
./utils/build-script: fatal error: command terminated with a non-zero exit status 1, aborting

Diff Detail

Repository
rL LLVM

Event Timeline

sarveshtamba created this revision.Feb 27 2019, 4:08 AM

Hi, Can someone please review this? Thanks!

The patch title doesn't seem related (or I don't understand how it's related) to the patch, and the patch description doesn't seem to detail how it relates to the code change.

And the code change doesn't seem to me like it could have any effect on semantics/fix any bug.

And the change has no test case.

Could you provide a test case and a more specific description of the issue and why this change is meaningful/fixes the issue?

This comment was removed by sarveshtamba.

Hi @dblaikie,

While building Apple Swift 5.0 toolchain on PowerPC64LE, we hit up on the following error(details in first comment) while going through the step "--- Installing swiftpm ---" i.e. installation of the swift package manager:-

		swift: /home/sar/swift-source/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."' failed.

The change fixes this issue by correctly calculating the PreviousInput and the NextInput.
Let me know if this is not the correct approach.

Are you sure you have the correct change here - this code review only shows "++i" changing to "i++" in a context where the value of cthe expression is discarded. In a valid C++ program there's no way I know of that this change could effect the behavior of the program.

Hi @dblaikie

Sorry for the delayed response.
Yes you are right, the submitted change would not effect the behavior of the program. I think I misread / misinterpreted the condition earlier, took it to be e = ++i, not realising its a simple for loop increment.
Also the error that's being thrown up might be intermittent, since when I made this change from ++i to i++, the build seemed to have passed, though now it fails again.

Following is the output of the successful build of Apple Swift 5 toolchain on PowerPC64LE:-

		"--- Creating installable package ---
		-- Package file: /home/sar/swift-source/swift-LOCAL-2019-02-26-a-linux.tar.gz --
		+ pushd /home/sar/swift-source/swift-nightly-install/
		~/swift-source/swift-nightly-install ~/swift-source/swift
		+ tar -c -z -f /home/sar/swift-source/swift-LOCAL-2019-02-26-a-linux.tar.gz --owner=0 --group=0 usr/
		+ popd
		~/swift-source/swift
		-- Test Installable Package --
		+ rm -rf /home/sar/swift-source/build/buildbot_linux/none-swift_package_sandbox_linux-powerpc64le
		+ mkdir -p /home/sar/swift-source/build/buildbot_linux/none-swift_package_sandbox_linux-powerpc64le
		+ pushd /home/sar/swift-source/build/buildbot_linux/none-swift_package_sandbox_linux-powerpc64le
		~/swift-source/build/buildbot_linux/none-swift_package_sandbox_linux-powerpc64le ~/swift-source/swift
		+ tar xzf /home/sar/swift-source/swift-LOCAL-2019-02-26-a-linux.tar.gz
		+ popd
		~/swift-source/swift
		+ pushd /home/sar/swift-source/swift-integration-tests
		~/swift-source/swift-integration-tests ~/swift-source/swift
		+ python /home/sar/swift-source/llvm/utils/lit/lit.py . -sv --param package-path=/home/sar/swift-source/build/buildbot_linux/none-swift_package_sandbox_linux-powerpc64le --param test-exec-root=/home/sar/swift-source/build/buildbot_linux/none-swift_package_sandbox_linux-powerpc64le/tests --param llvm-bin-dir=/home/sar/swift-source/build/buildbot_linux/llvm-linux-powerpc64le/bin
		lit.py: /home/sar/swift-source/swift-integration-tests/lit.cfg:131: note: testing package: '/home/sar/swift-source/build/buildbot_linux/none-swift_package_sandbox_linux-powerpc64le'
		lit.py: /home/sar/swift-source/swift-integration-tests/lit.cfg:143: note: testing using 'FileCheck': '/home/sar/swift-source/build/buildbot_linux/llvm-linux-powerpc64le/bin/FileCheck'
		lit.py: /home/sar/swift-source/swift-integration-tests/lit.cfg:144: note: testing using 'readelf': '/home/sar/swift-source/build/buildbot_linux/llvm-linux-powerpc64le/bin/llvm-readelf'
		lit.py: /home/sar/swift-source/swift-integration-tests/lit.cfg:165: note: testing using swift benchmarks at path: /home/sar/swift-source/swift/benchmark
		lit.py: /home/sar/swift-source/swift-integration-tests/lit.cfg:174: note: testing using 'swift': '/home/sar/swift-source/build/buildbot_linux/none-swift_package_sandbox_linux-powerpc64le/usr/bin/swift'
		lit.py: /home/sar/swift-source/swift-integration-tests/lit.cfg:179: note: testing using 'swiftc': '/home/sar/swift-source/build/buildbot_linux/none-swift_package_sandbox_linux-powerpc64le/usr/bin/swiftc'
		lit.py: /home/sar/swift-source/swift-integration-tests/lit.cfg:184: note: testing using 'lldb': /home/sar/swift-source/build/buildbot_linux/none-swift_package_sandbox_linux-powerpc64le/usr/bin/lldb
		lit.py: /home/sar/swift-source/swift-integration-tests/lit.cfg:189: note: testing using 'repl_swift': /home/sar/swift-source/build/buildbot_linux/none-swift_package_sandbox_linux-powerpc64le/usr/bin/repl_swift
		lit.py: /home/sar/swift-source/swift-integration-tests/lit.cfg:246: note: testing using 'sk-stress-test': /home/sar/swift-source/build/buildbot_linux/none-swift_package_sandbox_linux-powerpc64le/usr/bin/sk-stress-test
		lit.py: /home/sar/swift-source/swift-integration-tests/lit.cfg:247: note: testing using 'sk-swiftc-wrapper': /home/sar/swift-source/build/buildbot_linux/none-swift_package_sandbox_linux-powerpc64le/usr/bin/sk-swiftc-wrapper
		-- Testing: 27 tests, 8 threads --
		Testing: 0 .. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 90.. 
		Testing Time: 74.27s
		  Expected Passes    : 19
		  Unsupported Tests  : 8
		+ popd
		~/swift-source/swift
		Building the standard library for: swift-stdlib-linux-powerpc64le
		Running Swift tests for: check-swift-all-linux-powerpc64le check-swift-all-optimize-linux-powerpc64le"

Any thoughts/inputs on the possible causes?

Thanks!

Any thoughts/inputs on the possible causes?

Can't say I do, sorry - I know next to nothing about the LLVM backends, PPC, or Swift, unfortunately :/

@dblaikie, anyone you know who can help here?

Sorry, I don't know - I don't know much of anything about the Swift development process.

I have already raised the following issues:-
https://forums.swift.org/t/issues-at-step-installing-swiftpm-while-building-apple-swift-5-toolchain-on-powerpc64le/20802
https://bugs.swift.org/browse/SR-9976

jsji added a comment.Mar 14 2019, 11:27 AM

@dblaikie, anyone you know who can help here?

@sarveshtamba
Can you produce a reduced testcase that can show the problem?
Then I can find someone who can help to have a look.
Since this is an assert, I think it should not be too hard to create a reduce testcase using bugpoint.

@jsji can you please let me know how to produce a reduced testcase that can show the problem? Sorry, but I am quite new to this, any help would be greatly helpful.

lebedev.ri added inline comments.
lib/Target/PowerPC/PPCISelLowering.cpp
12081

Are you sure this is the right patch?
i is int, and this is only changing post-increment into pre-increment.
I really don't see how that could matter here, the return value of that increment operation is not used.

@lebedev.ri, no, as explained in above comments. Need some help in resolving this issue.

@jsji any inputs on how to produce a reduced testcase that can show the problem.

jsji added a comment.Mar 20 2019, 8:06 AM

I am not familiar with swift development process,
but looks like you should be able to dump LLVM IR passing -emit-ir -Xfrontend -disable-llvm-optzns according to https://github.com/apple/swift/blob/master/docs/DebuggingTheCompiler.rst#printing-the-intermediate-representations.
And you may try to reduce the SIL first using bug_reducer. https://github.com/apple/swift/blob/master/docs/DebuggingTheCompiler.rst#reducing-sil-test-cases-using-bug-reducer

jsji added a comment.Mar 21 2019, 6:59 AM

Thanks for filing the bug, but I think you still have to provide reduced testcase for further investigation.

This comment was removed by sarveshtamba.
This comment was removed by sarveshtamba.
HLJ2009 added a subscriber: HLJ2009.Apr 2 2019, 6:55 AM
HLJ2009 added inline comments.
lib/Target/PowerPC/PPCISelLowering.cpp
12106

Is this statement related to the assertion of the 12110 statement, is it necessary to guarantee here?