This is an archive of the discontinued LLVM Phabricator instance.

AMDGPU/GlobalISel: Fully handle 0 dmask case during legalize
ClosedPublic

Authored by arsenm on Feb 6 2020, 6:59 AM.

Details

Summary

For normal loads, fully eliminate the load. For the TFE case, adjust
the dmask value in the instruction so the selector doesn't need to
handle it. For the TFE special case, I guess it would be possible to
replace the loaded data register with undef, but as-is this will start
treating it as a well defined value.

Diff Detail

Event Timeline

arsenm created this revision.Feb 6 2020, 6:59 AM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 6 2020, 6:59 AM
This revision is now accepted and ready to land.Mar 17 2020, 3:55 AM
vitalybuka reopened this revision.EditedMar 17 2020, 9:24 PM
vitalybuka added a subscriber: vitalybuka.

http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/39600

==60948==ERROR: AddressSanitizer: use-after-poison on address 0x6210004a8ce8 at pc 0x00000720aed7 bp 0x7ffc3bd86520 sp 0x7ffc3bd86518
READ of size 8 at 0x6210004a8ce8 thread T0
    #0 0x720aed6 in getOpcode /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/include/llvm/CodeGen/MachineInstr.h:430:39
    #1 0x720aed6 in createdOrChangedInstr /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/lib/CodeGen/GlobalISel/Legalizer.cpp:103:35
    #2 0x720aed6 in (anonymous namespace)::LegalizerWorkListManager::changedInstr(llvm::MachineInstr&) /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/lib/CodeGen/GlobalISel/Legalizer.cpp:139:5
    #3 0x18b2d2e in changedInstr /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/include/llvm/CodeGen/GlobalISel/GISelChangeObserver.h:97:10
    #4 0x18b2d2e in non-virtual thunk to llvm::GISelObserverWrapper::changedInstr(llvm::MachineInstr&) /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/include/llvm/CodeGen/GlobalISel/GISelChangeObserver.h
    #5 0x18a7562 in operator() /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/lib/Target/AMDGPU/AMDGPULegalizerInfo.cpp:3483:54
    #6 0x18a7562 in ~scope_exit /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/include/llvm/ADT/ScopeExit.h:45:7
    #7 0x18a7562 in llvm::AMDGPULegalizerInfo::legalizeImageIntrinsic(llvm::MachineInstr&, llvm::MachineIRBuilder&, llvm::GISelChangeObserver&, llvm::AMDGPU::ImageDimIntrinsicInfo const*) const /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/lib/Target/AMDGPU/AMDGPULegalizerInfo.cpp:3759:1
    #8 0x18ab5a8 in llvm::AMDGPULegalizerInfo::legalizeIntrinsic(llvm::MachineInstr&, llvm::MachineIRBuilder&, llvm::GISelChangeObserver&) const /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/lib/Target/AMDGPU/AMDGPULegalizerInfo.cpp:4048:14
    #9 0x721506c in llvm::LegalizerHelper::legalizeInstrStep(llvm::MachineInstr&) /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp:107:15
    #10 0x720358e in llvm::Legalizer::legalizeMachineFunction(llvm::MachineFunction&, llvm::LegalizerInfo const&, llvm::ArrayRef<llvm::GISelChangeObserver*>, llvm::MachineIRBuilder&) /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/lib/CodeGen/GlobalISel/Legalizer.cpp:207:25
    #11 0x7209280 in llvm::Legalizer::runOnMachineFunction(llvm::MachineFunction&) /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/lib/CodeGen/GlobalISel/Legalizer.cpp:312:21
    #12 0x45e42ad in llvm::MachineFunctionPass::runOnFunction(llvm::Function&) /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/lib/CodeGen/MachineFunctionPass.cpp:73:13
    #13 0x5165330 in llvm::FPPassManager::runOnFunction(llvm::Function&) /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1482:27
    #14 0x3ae6386 in RunPassOnSCC /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/lib/Analysis/CallGraphSCCPass.cpp:176:25
    #15 0x3ae6386 in RunAllPassesOnSCC /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/lib/Analysis/CallGraphSCCPass.cpp:441:16
    #16 0x3ae6386 in (anonymous namespace)::CGPassManager::runOnModule(llvm::Module&) /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/lib/Analysis/CallGraphSCCPass.cpp:497:18
This revision is now accepted and ready to land.Mar 17 2020, 9:24 PM
vitalybuka added inline comments.Mar 17 2020, 9:26 PM
llvm/lib/Target/AMDGPU/AMDGPULegalizerInfo.cpp
3190

I guess eraseFromParent conflicts with

auto ChangedInstr = make_scope_exit([&] { Observer.changedInstr(MI); });
arsenm closed this revision.Mar 18 2020, 7:10 AM

Please do not reopen revisions

Why?
I do that to help you to notice that is was reverted. It's trivial to close them whenever you want.