This is an archive of the discontinued LLVM Phabricator instance.

[AMDGPU] Restore the s_memtime instruction in gfx1030
ClosedPublic

Authored by foad on Mar 4 2021, 2:59 AM.

Details

Summary

gfx1030 added a new way to implement readcyclecounter using the
SHADER_CYCLES hardware register, but the s_memtime instruction still
exists, so the MC layer should still accept it and the
llvm.amdgcn.s.memtime intrinsic should still work.

Diff Detail

Event Timeline

foad created this revision.Mar 4 2021, 2:59 AM
foad requested review of this revision.Mar 4 2021, 2:59 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 4 2021, 2:59 AM

It also needs clang change in the clang/lib/Basic/Targets/AMDGPU.cpp and clang tests.

foad updated this revision to Diff 328429.Mar 5 2021, 1:07 AM

Add clang changes.

Herald added a project: Restricted Project. · View Herald TranscriptMar 5 2021, 1:07 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
rampitec accepted this revision.Mar 5 2021, 11:02 AM

LGTM, thanks!

This revision is now accepted and ready to land.Mar 5 2021, 11:02 AM
This revision was landed with ongoing or failed builds.Mar 5 2021, 12:36 PM
This revision was automatically updated to reflect the committed changes.
hctim added a subscriber: hctim.Mar 5 2021, 4:48 PM

Hello, it looks like this change broke the MSan and ASan buildbots.

http://lab.llvm.org:8011/#/builders/5/builds/5327

FAIL: LLVM :: CodeGen/AMDGPU/GlobalISel/readcyclecounter.ll (39307 of 74613)
******************** TEST 'LLVM :: CodeGen/AMDGPU/GlobalISel/readcyclecounter.ll' FAILED ********************
Script:
--
: 'RUN: at line 2';   /b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/bin/llc -global-isel -march=amdgcn -mcpu=tonga -verify-machineinstrs < /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/test/CodeGen/AMDGPU/GlobalISel/../readcyclecounter.ll | /b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/bin/FileCheck -enable-var-scope -check-prefix=MEMTIME -check-prefix=SIVI -check-prefix=GCN /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/test/CodeGen/AMDGPU/GlobalISel/../readcyclecounter.ll
: 'RUN: at line 3';   /b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/bin/llc -global-isel -march=amdgcn -mcpu=gfx1010 -verify-machineinstrs < /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/test/CodeGen/AMDGPU/GlobalISel/../readcyclecounter.ll | /b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/bin/FileCheck -enable-var-scope -check-prefix=MEMTIME -check-prefix=GCN /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/test/CodeGen/AMDGPU/GlobalISel/../readcyclecounter.ll
--
Exit Code: 2
Command Output (stderr):
--
==75699==WARNING: MemorySanitizer: use-of-uninitialized-value
    #0 0x3518e32 in bool llvm::InstructionSelector::executeMatchTable<llvm::AMDGPUInstructionSelector const, llvm::PredicateBitsetImpl<62ul>, llvm::Optional<llvm::SmallVector<std::__1::function<void (llvm::MachineInstrBuilder&)>, 4u> > (llvm::AMDGPUInstructionSelector::*)(llvm::MachineOperand&) const, void (llvm::AMDGPUInstructionSelector::*)(llvm::MachineInstrBuilder&, llvm::MachineInstr const&, int) const>(llvm::AMDGPUInstructionSelector const&, llvm::SmallVector<llvm::MachineInstrBuilder, 4u>&, llvm::InstructionSelector::MatcherState&, llvm::InstructionSelector::ISelInfoTy<llvm::PredicateBitsetImpl<62ul>, llvm::Optional<llvm::SmallVector<std::__1::function<void (llvm::MachineInstrBuilder&)>, 4u> > (llvm::AMDGPUInstructionSelector::*)(llvm::MachineOperand&) const, void (llvm::AMDGPUInstructionSelector::*)(llvm::MachineInstrBuilder&, llvm::MachineInstr const&, int) const> const&, long const*, llvm::TargetInstrInfo const&, llvm::MachineRegisterInfo&, llvm::TargetRegisterInfo const&, llvm::RegisterBankInfo const&, llvm::PredicateBitsetImpl<62ul> const&, llvm::CodeGenCoverage&) const /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/include/llvm/CodeGen/GlobalISel/InstructionSelectorImpl.h:149:11
    #1 0x34fe428 in llvm::AMDGPUInstructionSelector::selectImpl(llvm::MachineInstr&, llvm::CodeGenCoverage&) const /b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/lib/Target/AMDGPU/AMDGPUGenGlobalISel.inc:1218:7
    #2 0x3557c75 in llvm::AMDGPUInstructionSelector::select(llvm::MachineInstr&) /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/lib/Target/AMDGPU/AMDGPUInstructionSelector.cpp
    #3 0xb45543c in llvm::InstructionSelect::runOnMachineFunction(llvm::MachineFunction&) /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/lib/CodeGen/GlobalISel/InstructionSelect.cpp:186:18
    #4 0x7327a1f in llvm::MachineFunctionPass::runOnFunction(llvm::Function&) /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/lib/CodeGen/MachineFunctionPass.cpp:72:13
    #5 0x826124c in llvm::FPPassManager::runOnFunction(llvm::Function&) /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1439:27
    #6 0x6482dab in RunPassOnSCC /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/lib/Analysis/CallGraphSCCPass.cpp:178:25
    #7 0x6482dab in RunAllPassesOnSCC /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/lib/Analysis/CallGraphSCCPass.cpp:476:9
    #8 0x6482dab in (anonymous namespace)::CGPassManager::runOnModule(llvm::Module&) /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/lib/Analysis/CallGraphSCCPass.cpp:541:18
    #9 0x8263b7a in runOnModule /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1554:27
    #10 0x8263b7a in llvm::legacy::PassManagerImpl::run(llvm::Module&) /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:542:44
    #11 0x8280619 in llvm::legacy::PassManager::run(llvm::Module&) /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1681:14
    #12 0x28f8ca2 in compileModule(char**, llvm::LLVMContext&) /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/tools/llc/llc.cpp:687:8
    #13 0x28f2b80 in main /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/tools/llc/llc.cpp:388:22
    #14 0x7f1559fb809a in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2409a)
    #15 0x2872809 in _start (/b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/bin/llc+0x2872809)
SUMMARY: MemorySanitizer: use-of-uninitialized-value /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/include/llvm/CodeGen/GlobalISel/InstructionSelectorImpl.h:149:11 in bool llvm::InstructionSelector::executeMatchTable<llvm::AMDGPUInstructionSelector const, llvm::PredicateBitsetImpl<62ul>, llvm::Optional<llvm::SmallVector<std::__1::function<void (llvm::MachineInstrBuilder&)>, 4u> > (llvm::AMDGPUInstructionSelector::*)(llvm::MachineOperand&) const, void (llvm::AMDGPUInstructionSelector::*)(llvm::MachineInstrBuilder&, llvm::MachineInstr const&, int) const>(llvm::AMDGPUInstructionSelector const&, llvm::SmallVector<llvm::MachineInstrBuilder, 4u>&, llvm::InstructionSelector::MatcherState&, llvm::InstructionSelector::ISelInfoTy<llvm::PredicateBitsetImpl<62ul>, llvm::Optional<llvm::SmallVector<std::__1::function<void (llvm::MachineInstrBuilder&)>, 4u> > (llvm::AMDGPUInstructionSelector::*)(llvm::MachineOperand&) const, void (llvm::AMDGPUInstructionSelector::*)(llvm::MachineInstrBuilder&, llvm::MachineInstr c
Exiting
FileCheck error: '<stdin>' is empty.
FileCheck command line:  /b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/bin/FileCheck -enable-var-scope -check-prefix=MEMTIME -check-prefix=SIVI -check-prefix=GCN /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/test/CodeGen/AMDGPU/GlobalISel/../readcyclecounter.ll
clang/test/CodeGenOpenCL/amdgpu-features.cl