Page MenuHomePhabricator

[BitcodeReader] Fix DelayedShuffle handling for ConstantExpr shuffles.
ClosedPublic

Authored by efriedma on May 20 2020, 3:19 PM.

Details

Summary

The indexing was messed up, so the result was completely broken.

Shuffle constant exprs are rare in practice; without vscale types, constant folding generally elminates them. So sort of hard to trip over.

Fixes regression from D72467.

Diff Detail

Event Timeline

efriedma created this revision.May 20 2020, 3:19 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 20 2020, 3:19 PM
Herald added a subscriber: hiraditya. · View Herald Transcript
jdoerfert accepted this revision.Jun 2 2020, 2:46 PM

I'm not an expert in this but it looks reasonable and tested. LGTM

This revision is now accepted and ready to land.Jun 2 2020, 2:46 PM
This revision was automatically updated to reflect the committed changes.
This revision is now accepted and ready to land.Tue, Jun 23, 10:43 PM
hctim added a subscriber: hctim.Wed, Jun 24, 1:52 PM
hctim added a comment.Wed, Jun 24, 2:43 PM

Reverted in 10045cbe01928d9281723c640c03984d540f9012 to bring the ASan bots green again.

This revision was automatically updated to reflect the committed changes.

Still memory leaks: http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/43341

FAIL: LLVM :: Bitcode/vscale-shuffle.ll (6510 of 38183)
******************** TEST 'LLVM :: Bitcode/vscale-shuffle.ll' FAILED ********************
Script:
--
: 'RUN: at line 1';   /b/sanitizer-x86_64-linux-fast/build/llvm_build_asan/bin/llvm-as < /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/test/Bitcode/vscale-shuffle.ll | /b/sanitizer-x86_64-linux-fast/build/llvm_build_asan/bin/llvm-dis -disable-output
: 'RUN: at line 2';   /b/sanitizer-x86_64-linux-fast/build/llvm_build_asan/bin/verify-uselistorder < /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/test/Bitcode/vscale-shuffle.ll
--
Exit Code: 1

Command Output (stderr):
--

=================================================================
==42464==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 64 byte(s) in 1 object(s) allocated from:
    #0 0x4cbc2d in malloc /b/s/w/ir/cache/builder/src/third_party/llvm/compiler-rt/lib/asan/asan_malloc_linux.cpp:145:3
    #1 0xbeea32 in safe_malloc /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/include/llvm/Support/MemAlloc.h:26:18
    #2 0xbeea32 in llvm::SmallVectorBase<unsigned int>::grow_pod(void*, unsigned long, unsigned long) /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/lib/Support/SmallVector.cpp:68:15
    #3 0x8736f2 in grow_pod /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/include/llvm/ADT/SmallVector.h:119:11
    #4 0x8736f2 in grow /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/include/llvm/ADT/SmallVector.h:345:41
    #5 0x8736f2 in append<const int *, void> /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/include/llvm/ADT/SmallVector.h:436:13
    #6 0x8736f2 in assign<const int *, void> /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/include/llvm/ADT/SmallVector.h:472:5
    #7 0x8736f2 in llvm::ShuffleVectorConstantExpr::ShuffleVectorConstantExpr(llvm::Constant*, llvm::Constant*, llvm::ArrayRef<int>) /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/lib/IR/ConstantsContext.h:159:17
    #8 0x87136c in llvm::ConstantExprKeyType::create(llvm::Type*) const /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/lib/IR/ConstantsContext.h:582:18
    #9 0x84ec5c in create /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/lib/IR/ConstantsContext.h:672:31
    #10 0x84ec5c in llvm::ConstantUniqueMap<llvm::ConstantExpr>::getOrCreate(llvm::Type*, llvm::ConstantExprKeyType) /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/lib/IR/ConstantsContext.h:691:16
    #11 0x841827 in llvm::ConstantExpr::getShuffleVector(llvm::Constant*, llvm::Constant*, llvm::ArrayRef<int>, llvm::Type*) /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/lib/IR/Constants.cpp:2390:31
    #12 0x554a79 in llvm::LLParser::ParseValID(llvm::ValID&, llvm::LLParser::PerFunctionState*) /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/lib/AsmParser/LLParser.cpp:3717:24
    #13 0x59cb21 in llvm::LLParser::ParseValue(llvm::Type*, llvm::Value*&, llvm::LLParser::PerFunctionState*) /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/lib/AsmParser/LLParser.cpp:5395:10
    #14 0x56e78e in ParseValue /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/lib/AsmParser/LLParser.h:467:14
    #15 0x56e78e in llvm::LLParser::ParseParameterList(llvm::SmallVectorImpl<llvm::LLParser::ParamInfo>&, llvm::LLParser::PerFunctionState&, bool, bool) /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/lib/AsmParser/LLParser.cpp:2533:48
    #16 0x5b6b1e in llvm::LLParser::ParseCall(llvm::Instruction*&, llvm::LLParser::PerFunctionState&, llvm::CallInst::TailCallKind) /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/lib/AsmParser/LLParser.cpp:6911:7
    #17 0x59f3ea in llvm::LLParser::ParseInstruction(llvm::Instruction*&, llvm::BasicBlock*, llvm::LLParser::PerFunctionState&) /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/lib/AsmParser/LLParser.cpp
    #18 0x59e378 in llvm::LLParser::ParseBasicBlock(llvm::LLParser::PerFunctionState&) /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/lib/AsmParser/LLParser.cpp:5771:13
    #19 0x53c00d in llvm::LLParser::ParseFunctionBody(llvm::Function&) /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/lib/AsmParser/LLParser.cpp:5716:9
    #20 0x528efd in llvm::LLParser::ParseDefine() /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/lib/AsmParser/LLParser.cpp:529:10
    #21 0x521855 in llvm::LLParser::ParseTopLevelEntities() /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/lib/AsmParser/LLParser.cpp:347:33
    #22 0x521525 in llvm::LLParser::Run(bool, llvm::function_ref<llvm::Optional<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > (llvm::StringRef)>) /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/lib/AsmParser/LLParser.cpp:80:10
    #23 0x4fc6a4 in parseAssemblyInto(llvm::MemoryBufferRef, llvm::Module*, llvm::ModuleSummaryIndex*, llvm::SMDiagnostic&, llvm::SlotMapping*, bool, llvm::function_ref<llvm::Optional<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > (llvm::StringRef)>) /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/lib/AsmParser/Parser.cpp:36:8
    #24 0x4fd609 in parseAssemblyWithIndex(llvm::MemoryBufferRef, llvm::SMDiagnostic&, llvm::LLVMContext&, llvm::SlotMapping*, bool, llvm::function_ref<llvm::Optional<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > (llvm::StringRef)>) /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/lib/AsmParser/Parser.cpp:85:7
    #25 0x4fde4f in parseAssemblyFileWithIndex(llvm::StringRef, llvm::SMDiagnostic&, llvm::LLVMContext&, llvm::SlotMapping*, bool, llvm::function_ref<llvm::Optional<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > (llvm::StringRef)>) /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/lib/AsmParser/Parser.cpp:114:10
    #26 0x4fd92f in llvm::parseAssemblyFileWithIndex(llvm::StringRef, llvm::SMDiagnostic&, llvm::LLVMContext&, llvm::SlotMapping*, llvm::function_ref<llvm::Optional<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > (llvm::StringRef)>) /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/lib/AsmParser/Parser.cpp:123:10
    #27 0x4f88f4 in main /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/tools/llvm-as/llvm-as.cpp:134:22
    #28 0x7fd933d4509a in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2409a)

SUMMARY: AddressSanitizer: 64 byte(s) leaked in 1 allocation(s).

=================================================================
==42465==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 64 byte(s) in 1 object(s) allocated from:
    #0 0x4ab46d in malloc /b/s/w/ir/cache/builder/src/third_party/llvm/compiler-rt/lib/asan/asan_malloc_linux.cpp:145:3
    #1 0xa27f62 in safe_malloc /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/include/llvm/Support/MemAlloc.h:26:18
    #2 0xa27f62 in llvm::SmallVectorBase<unsigned int>::grow_pod(void*, unsigned long, unsigned long) /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/lib/Support/SmallVector.cpp:68:15
    #3 0x720ac2 in grow_pod /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/include/llvm/ADT/SmallVector.h:119:11
    #4 0x720ac2 in grow /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/include/llvm/ADT/SmallVector.h:345:41
    #5 0x720ac2 in append<const int *, void> /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/include/llvm/ADT/SmallVector.h:436:13
    #6 0x720ac2 in assign<const int *, void> /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/include/llvm/ADT/SmallVector.h:472:5
    #7 0x720ac2 in llvm::ShuffleVectorConstantExpr::ShuffleVectorConstantExpr(llvm::Constant*, llvm::Constant*, llvm::ArrayRef<int>) /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/lib/IR/ConstantsContext.h:159:17
    #8 0x71e73c in llvm::ConstantExprKeyType::create(llvm::Type*) const /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/lib/IR/ConstantsContext.h:582:18
    #9 0x6fc45c in create /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/lib/IR/ConstantsContext.h:672:31
    #10 0x6fc45c in llvm::ConstantUniqueMap<llvm::ConstantExpr>::getOrCreate(llvm::Type*, llvm::ConstantExprKeyType) /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/lib/IR/ConstantsContext.h:691:16
    #11 0x6ef607 in llvm::ConstantExpr::getShuffleVector(llvm::Constant*, llvm::Constant*, llvm::ArrayRef<int>, llvm::Type*) /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/lib/IR/Constants.cpp:2390:31
    #12 0x536cbf in (anonymous namespace)::BitcodeReader::parseConstants() /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/lib/Bitcode/Reader/BitcodeReader.cpp:2374:20
    #13 0x5086bc in (anonymous namespace)::BitcodeReader::parseFunctionBody(llvm::Function*) /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/lib/Bitcode/Reader/BitcodeReader.cpp:3822:25
    #14 0x4ffecb in (anonymous namespace)::BitcodeReader::materialize(llvm::GlobalValue*) /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/lib/Bitcode/Reader/BitcodeReader.cpp:5347:19
    #15 0x502606 in (anonymous namespace)::BitcodeReader::materializeModule() /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/lib/Bitcode/Reader/BitcodeReader.cpp:5405:21
    #16 0x845dc7 in llvm::Module::materializeAll() /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/lib/IR/Module.cpp:449:13
    #17 0x4d8ebe in main /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/tools/llvm-dis/llvm-dis.cpp:176:20
    #18 0x7ffb42ae009a in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2409a)

SUMMARY: AddressSanitizer: 64 byte(s) leaked in 1 allocation(s).

Should actually be fixed with 779e4d8