This is an archive of the discontinued LLVM Phabricator instance.

[HardwareLoops] Optimisation remarks
ClosedPublic

Authored by SjoerdMeijer on Oct 31 2019, 6:31 AM.

Details

Summary

I reverted this because of a PowerPC buildbot failure. I don't have access to the build/test logs anymore, and I can't reproduce this locally.
Could one of the PowerPC guys perhaps do a check-all with this patch?

Original review/patch here: https://reviews.llvm.org/D68579

Diff Detail

Event Timeline

SjoerdMeijer created this revision.Oct 31 2019, 6:31 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 31 2019, 6:31 AM
Herald added a subscriber: hiraditya. · View Herald Transcript

I will have a look

Many cases fail due to internal crash.

******************** TEST 'LLVM :: ExecutionEngine/OrcMCJIT/non-extern-addend.ll' FAILED ********************
Script:
--
: 'RUN: at line 1';   /home/czhengsz/llvm_new/llvm-project/llvm/build/bin/lli -jit-kind=orc-mcjit /home/czhengsz/llvm_new/llvm-project/llvm/test/ExecutionEngine/OrcMCJIT/non-extern-addend.ll > /dev/null
--
Exit Code: 134

Command Output (stderr):
--
Pass 'Hardware Loop Insertion' is not initialized.
Verify if there is a pass dependency cycle.
Required Passes:
        Natural Loop Information
        Dominator Tree Construction
        Scalar Evolution Analysis
        Assumption Cache Tracker
        Target Transform Information
lli: /home/czhengsz/llvm_new/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:695: void llvm::PMTopLevelManager::schedulePass(llvm::Pass*): Assertion `PI && "Expected required passes to be initialized"' failed.
Stack dump:
0.      Program arguments: /home/czhengsz/llvm_new/llvm-project/llvm/build/bin/lli -jit-kind=orc-mcjit /home/czhengsz/llvm_new/llvm-project/llvm/test/ExecutionEngine/OrcMCJIT/non-extern-addend.ll 
 #0 0x0000000010eb6848 llvm::sys::PrintStackTrace(llvm::raw_ostream&) (/home/czhengsz/llvm_new/llvm-project/llvm/build/bin/lli+0x10eb6848)
 #1 0x0000000010eb6970 PrintStackTraceSignalHandler(void*) (/home/czhengsz/llvm_new/llvm-project/llvm/build/bin/lli+0x10eb6970)
 #2 0x0000000010eb4404 llvm::sys::RunSignalHandlers() (/home/czhengsz/llvm_new/llvm-project/llvm/build/bin/lli+0x10eb4404)
 #3 0x0000000010eb45dc SignalHandler(int) (/home/czhengsz/llvm_new/llvm-project/llvm/build/bin/lli+0x10eb45dc)
 #4 0x00003fffa7f40478 (linux-vdso64.so.1+0x478)
 #5 0x00003fffa77de100 raise (/opt/at12.0/lib64/power8/libc.so.6+0x4e100)
 #6 0x00003fffa77b4598 abort (/opt/at12.0/lib64/power8/libc.so.6+0x24598)
 #7 0x00003fffa77cb624 (/opt/at12.0/lib64/power8/libc.so.6+0x3b624)
 #8 0x00003fffa77cb6c4 __assert_fail (/opt/at12.0/lib64/power8/libc.so.6+0x3b6c4)
 #9 0x0000000010841da0 llvm::PMTopLevelManager::schedulePass(llvm::Pass*) (.localalias.532) (/home/czhengsz/llvm_new/llvm-project/llvm/build/bin/lli+0x10841da0)
#10 0x00000000108421b0 llvm::legacy::PassManager::add(llvm::Pass*) (/home/czhengsz/llvm_new/llvm-project/llvm/build/bin/lli+0x108421b0)
#11 0x0000000010456500 llvm::TargetPassConfig::addPass(llvm::Pass*, bool, bool) (.localalias.227) (/home/czhengsz/llvm_new/llvm-project/llvm/build/bin/lli+0x10456500)
#12 0x0000000010fcad6c (anonymous namespace)::PPCPassConfig::addPreISel() (/home/czhengsz/llvm_new/llvm-project/llvm/build/bin/lli+0x10fcad6c)
#13 0x000000001045714c llvm::TargetPassConfig::addISelPrepare() (/home/czhengsz/llvm_new/llvm-project/llvm/build/bin/lli+0x1045714c)
#14 0x0000000010458f84 llvm::TargetPassConfig::addISelPasses() (/home/czhengsz/llvm_new/llvm-project/llvm/build/bin/lli+0x10458f84)
#15 0x0000000011226f94 addPassesToGenerateCode(llvm::LLVMTargetMachine&, llvm::legacy::PassManagerBase&, bool, llvm::MachineModuleInfoWrapperPass&) (/home/czhengsz/llvm_new/llvm-project/llvm/build/bin/lli+0x11226f94)
#16 0x000000001122a460 llvm::LLVMTargetMachine::addPassesToEmitMC(llvm::legacy::PassManagerBase&, llvm::MCContext*&, llvm::raw_pwrite_stream&, bool) (/home/czhengsz/llvm_new/llvm-project/llvm/build/bin/lli+0x1122a460)
#17 0x0000000010aeeeb4 llvm::orc::SimpleCompiler::operator()(llvm::Module&) (/home/czhengsz/llvm_new/llvm-project/llvm/build/bin/lli+0x10aeeeb4)
#18 0x0000000010ad93e4 llvm::Expected<unsigned long> llvm::unique_function<llvm::Expected<unsigned long> ()>::CallImpl<llvm::orc::LazyEmittingLayer<llvm::orc::LegacyIRCompileLayer<llvm::orc::LegacyRTDyldObjectLinkingLayer, llvm::orc::SimpleCompiler> >::EmissionDeferredModule::find(llvm::StringRef, bool, llvm::orc::LegacyIRCompileLayer<llvm::orc::LegacyRTDyldObjectLinkingLayer, llvm::orc::SimpleCompiler>&)::'lambda'()>(void*) (/home/czhengsz/llvm_new/llvm-project/llvm/build/bin/lli+0x10ad93e4)
#19 0x0000000010ad45dc llvm::JITSymbol::getAddress() (/home/czhengsz/llvm_new/llvm-project/llvm/build/bin/lli+0x10ad45dc)
#20 0x0000000010adbfa4 llvm::orc::OrcMCJITReplacement::getPointerToFunction(llvm::Function*) (/home/czhengsz/llvm_new/llvm-project/llvm/build/bin/lli+0x10adbfa4)
#21 0x00000000101ff694 main (/home/czhengsz/llvm_new/llvm-project/llvm/build/bin/lli+0x101ff694)
#22 0x00003fffa77b4bf8 (/opt/at12.0/lib64/power8/libc.so.6+0x24bf8)
#23 0x00003fffa77b4e04 __libc_start_main (/opt/at12.0/lib64/power8/libc.so.6+0x24e04)
/home/czhengsz/llvm_new/llvm-project/llvm/build/test/ExecutionEngine/OrcMCJIT/Output/non-extern-addend.ll.script: line 1: 132292 Aborted                 /home/czhengsz/llvm_new/llvm-project/llvm/build/bin/lli -jit-kind=orc-mcjit /home/czhengsz/llvm_new/llvm-project/llvm/test/ExecutionEngine/OrcMCJIT/non-extern-addend.ll > /dev/null

--

Many thanks!!!
Now I've got something to stare at. :-)

This is a pass manager's problem. By comparing the hardwareloop pass with other passes also using the optimisation remarks, I noticed a missing:

INITIALIZE_PASS_DEPENDENCY(OptimizationRemarkEmitterWrapperPass)

which I have now added. I am fairly confident that this will solve the problem, but as I haven't been able to reproduce locally, I am not entirely certain.
Could I ask for one more favour, would you be able to verify this? If this doesn't solve it, I need to see why I can't reproduce this, but that is a bit of bigger task which I'm obviously trying to avoid... :-/

Confirmed internal crash fixed with the dependancy decl change.

Now only one test case fail:

: 'RUN: at line 2';   /home/czhengsz/llvm_new/llvm-project/llvm/build/bin/llc -mtriple=thumbv8.1m.main-arm-none-eabi /home/czhengsz/llvm_new/llvm-project/llvm/test/Transforms/HardwareLoops/ARM/structure.ll -o - -pass-remarks-analysis=hardware-loops  2>&1 | /home/czhengsz/llvm_new/llvm-project/llvm/build/bin/FileCheck /home/czhengsz/llvm_new/llvm-project/llvm/test/Transforms/HardwareLoops/ARM/structure.ll --check-prefix=CHECK-LLC

--
Exit Code: 1

Command Output (stderr):
--
/home/czhengsz/llvm_new/llvm-project/llvm/test/Transforms/HardwareLoops/ARM/structure.ll:181:14: error: CHECK-LLC: expected string not found in input
; CHECK-LLC: remark: <unknown>:0:0: hardware-loop not created: loop is not a candidate
             ^
<stdin>:90:10: note: scanning from here
.LBB1_5: @ %while.end7
         ^

Strange thing is that it only fails on PowerPC but ok on ARM, this is a ARM case?

I think you can not mixup checking for remark and assembly both based on CHECK-LLC. All remarks will be put in the front of the output and after checking assembly with CHECK-LLC in func nested, there is no any remark logs after.

This is a pass manager's problem. By comparing the hardwareloop pass with other passes also using the optimisation remarks, I noticed a missing:

INITIALIZE_PASS_DEPENDENCY(OptimizationRemarkEmitterWrapperPass)

which I have now added. I am fairly confident that this will solve the problem, but as I haven't been able to reproduce locally, I am not entirely certain.
Could I ask for one more favour, would you be able to verify this? If this doesn't solve it, I need to see why I can't reproduce this, but that is a bit of bigger task which I'm obviously trying to avoid... :-/

I think the reason it crashs inside llc of PowerPC is HardwareLoop Pass becomes the first pass in PowerPC llc pipeline which uses analysis pass OptimizationRemarkEmitterWrapperPass after your change. But you don't register it by adding the dependancy marco.

I guess on ARM HardwareLoop Pass is not the first pass in llc pipeline so OptimizationRemarkEmitterWrapperPass should be registered before. So it is ok on ARM.

Many thanks again!

Yes, I guess it is platform dependent how output to stderr and stdout is 'interleaved', and I now remember having run into this before. So now I have just created a separate CHECK-REMARKS run line for this.

shchenz accepted this revision.Nov 4 2019, 6:01 PM

Verified we get a clean make check-llvm on PowerPC. I guess reason you delete the case test/Transforms/HardwareLoops/unconditional-latch.ll is this case becomes redudant after adding more checking in test/Transforms/HardwareLoops/ARM/structure.ll?
LGTM.

This revision is now accepted and ready to land.Nov 4 2019, 6:01 PM

I guess reason you delete the case test/Transforms/HardwareLoops/unconditional-latch.ll is this case becomes redudant after adding more checking in test/Transforms/HardwareLoops/ARM/structure.ll?

Yep, exactly that.

Thanks again for all your help.

This revision was automatically updated to reflect the committed changes.