This is an archive of the discontinued LLVM Phabricator instance.

[Attributor][Fix] Resolve various liveness issues
ClosedPublic

Authored by jdoerfert on Aug 3 2019, 11:55 AM.

Details

Summary

This contains various fixes:

  • Explicitly determine and return the next noreturn instruction.
  • If an invoke calls a noreturn function which is not nounwind we keep the unwind destination live. This also means we require an invoke. Though we can still add the unreachable to the normal destination block.
  • Check if the return instructions are dead after we look for calls to avoid triggering an optimistic fixpoint in the presence of assumed liveness information.
  • Make the interface work with "const" pointers.
  • Some simplifications

While additional tests are included, full coverage is achieved only with
D59978.

Event Timeline

jdoerfert created this revision.Aug 3 2019, 11:55 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 3 2019, 11:55 AM
sstefan1 accepted this revision.Aug 3 2019, 12:45 PM

LGTM.

llvm/lib/Transforms/IPO/Attributor.cpp
608

I run the clang-format and committed today, so this is not necessary.

https://reviews.llvm.org/rG7849e4163583288ea53837a4e463af472bfe5f02

This revision is now accepted and ready to land.Aug 3 2019, 12:45 PM
This revision was automatically updated to reflect the committed changes.
thakis added a subscriber: thakis.Aug 5 2019, 8:29 AM

msan reports an uninitialized read: http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/34088/steps/check-llvm%20msan/logs/stdio

FAIL: LLVM :: Transforms/FunctionAttrs/liveness.ll (26259 of 32933)
******************** TEST 'LLVM :: Transforms/FunctionAttrs/liveness.ll' FAILED ********************
Script:
--
: 'RUN: at line 1';   /b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/bin/opt -attributor --attributor-disable=false -S < /b/sanitizer-x86_64-linux-fast/build/llvm/test/Transforms/FunctionAttrs/liveness.ll | /b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/bin/FileCheck /b/sanitizer-x86_64-linux-fast/build/llvm/test/Transforms/FunctionAttrs/liveness.ll
--
Exit Code: 2

Command Output (stderr):
--
==43047==WARNING: MemorySanitizer: use-of-uninitialized-value
    #0 0xe558f2 in llvm::CallSiteBase<llvm::Function const, llvm::BasicBlock const, llvm::Value const, llvm::User const, llvm::Use const, llvm::Instruction const, llvm::CallInst const, llvm::InvokeInst const, llvm::CallBrInst const, llvm::Use const*>::get(llvm::Value const*) /b/sanitizer-x86_64-linux-fast/build/llvm/include/llvm/IR/CallSite.h:74:18
    #1 0x5652b4f in CallSiteBase /b/sanitizer-x86_64-linux-fast/build/llvm/include/llvm/IR/CallSite.h:66:46
    #2 0x5652b4f in ImmutableCallSite /b/sanitizer-x86_64-linux-fast/build/llvm/include/llvm/IR/CallSite.h:904
    #3 0x5652b4f in AAReturnedValuesImpl::checkForallReturnedValues(std::__1::function<bool (llvm::Value&, llvm::SmallPtrSetImpl<llvm::ReturnInst*> const&)>&) const /b/sanitizer-x86_64-linux-fast/build/llvm/lib/Transforms/IPO/Attributor.cpp:723
    #4 0x5651e4a in getAssumedUniqueReturnValue /b/sanitizer-x86_64-linux-fast/build/llvm/lib/Transforms/IPO/Attributor.cpp:705:8
    #5 0x5651e4a in AAReturnedValuesImpl::manifest(llvm::Attributor&) /b/sanitizer-x86_64-linux-fast/build/llvm/lib/Transforms/IPO/Attributor.cpp:649
    #6 0x566ed94 in llvm::Attributor::run() /b/sanitizer-x86_64-linux-fast/build/llvm/lib/Transforms/IPO/Attributor.cpp:2450:36
    #7 0x567d1d8 in runAttributorOnModule(llvm::Module&) /b/sanitizer-x86_64-linux-fast/build/llvm/lib/Transforms/IPO/Attributor.cpp:2687:12
    #8 0x5688e9c in (anonymous namespace)::AttributorLegacyPass::runOnModule(llvm::Module&) /b/sanitizer-x86_64-linux-fast/build/llvm/lib/Transforms/IPO/Attributor.cpp:2710:12
    #9 0x5420abd in runOnModule /b/sanitizer-x86_64-linux-fast/build/llvm/lib/IR/LegacyPassManager.cpp:1750:27
    #10 0x5420abd in llvm::legacy::PassManagerImpl::run(llvm::Module&) /b/sanitizer-x86_64-linux-fast/build/llvm/lib/IR/LegacyPassManager.cpp:1863
    #11 0x9d06a7 in main /b/sanitizer-x86_64-linux-fast/build/llvm/tools/opt/opt.cpp:892:12
    #12 0x7f4b2ca602e0 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x202e0)
    #13 0x907c59 in _start (/b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/bin/opt+0x907c59)

SUMMARY: MemorySanitizer: use-of-uninitialized-value /b/sanitizer-x86_64-linux-fast/build/llvm/include/llvm/IR/CallSite.h:74:18 in llvm::CallSiteBase<llvm::Function const, llvm::BasicBlock const, llvm::Value const, llvm::User const, llvm::Use const, llvm::Instruction const, llvm::CallInst const, llvm::InvokeInst const, llvm::CallBrInst const, llvm::Use const*>::get(llvm::Value const*)
Exiting

That run was at r367856 so it already had r367793 which maybe was supposed to fix this.

Please take a look!