This is an archive of the discontinued LLVM Phabricator instance.

[CodeGen] Enhance `MachineInstrSpan` to allow the end of MBB to be used.
ClosedPublic

Authored by hliao on Jul 5 2019, 12:18 PM.

Diff Detail

Repository
rL LLVM

Event Timeline

hliao created this revision.Jul 5 2019, 12:18 PM
arsenm accepted this revision.Jul 5 2019, 12:24 PM

LGTM

This revision is now accepted and ready to land.Jul 5 2019, 12:24 PM
This revision was automatically updated to reflect the committed changes.
dstenb added a subscriber: dstenb.Jul 9 2019, 7:26 AM

The tests introduced in this commit currently fail when running UBSan, due to invoking getRegInfo() with RegInfo being null:

[ RUN      ] MachineInstrSpan.DistanceBegin
/b/sanitizer-x86_64-linux-fast/build/llvm/include/llvm/CodeGen/MachineFunction.h:474:46: runtime error: reference binding to null pointer of type 'llvm::MachineRegisterInfo'
    #0 0x1bed93c in getRegInfo /b/sanitizer-x86_64-linux-fast/build/llvm/include/llvm/CodeGen/MachineFunction.h:474:39
    #1 0x1bed93c in llvm::ilist_traits<llvm::MachineInstr>::addNodeToList(llvm::MachineInstr*) /b/sanitizer-x86_64-linux-fast/build/llvm/lib/CodeGen/MachineBasicBlock.cpp:111
    #2 0x48939c in llvm::iplist_impl<llvm::simple_ilist<llvm::MachineInstr, llvm::ilist_sentinel_tracking<true> >, llvm::ilist_traits<llvm::MachineInstr> >::insert(llvm::ilist_iterator<llvm::ilist_detail::node_options<llvm::MachineInstr, true, true, void>, false, false>, llvm::MachineInstr*) /b/sanitizer-x86_64-linux-fast/build/llvm/include/llvm/ADT/ilist.h:227:11
    #3 0x488e2a in llvm::MachineBasicBlock::insert(llvm::MachineInstrBundleIterator<llvm::MachineInstr, false>, llvm::MachineInstr*) /b/sanitizer-x86_64-linux-fast/build/llvm/include/llvm/CodeGen/MachineBasicBlock.h:627:18
    #4 0x488a93 in (anonymous namespace)::MachineInstrSpan_DistanceBegin_Test::TestBody() /b/sanitizer-x86_64-linux-fast/build/llvm/unittests/CodeGen/MachineInstrTest.cpp:289:8
    #5 0x2506006 in testing::Test::Run() /b/sanitizer-x86_64-linux-fast/build/llvm/utils/unittest/googletest/src/gtest.cc:2474:5
    #6 0x2506cf3 in testing::TestInfo::Run() /b/sanitizer-x86_64-linux-fast/build/llvm/utils/unittest/googletest/src/gtest.cc:2656:11
    #7 0x25076d2 in testing::TestCase::Run() /b/sanitizer-x86_64-linux-fast/build/llvm/utils/unittest/googletest/src/gtest.cc:2774:28
    #8 0x250ee02 in testing::internal::UnitTestImpl::RunAllTests() /b/sanitizer-x86_64-linux-fast/build/llvm/utils/unittest/googletest/src/gtest.cc:4649:43
    #9 0x250e846 in testing::UnitTest::Run() /b/sanitizer-x86_64-linux-fast/build/llvm/utils/unittest/googletest/src/gtest.cc:4257:10
    #10 0x492765 in RUN_ALL_TESTS /b/sanitizer-x86_64-linux-fast/build/llvm/utils/unittest/googletest/include/gtest/gtest.h:2233:46
    #11 0x492765 in main /b/sanitizer-x86_64-linux-fast/build/llvm/unittests/CodeGen/TargetOptionsTest.cpp:75
    #12 0x7f0cc584c2e0 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x202e0)
    #13 0x44d429 in _start (/b/sanitizer-x86_64-linux-fast/build/llvm_build_ubsan/unittests/CodeGen/CodeGenTests+0x44d429)

Log: http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/33393/steps/check-llvm%20ubsan/logs/stdio

Is someone looking into that? I did not find any indication of that on llvm-commits, llvm-dev, or in bugzilla, so I'm writing on this review just to make sure.

(I have not been able to run this myself, so I have not actually verified that the tests start breaking with rL365240 rather than some later commit.)