[llvm-bugs] [Bug 44351] New: CodeGenPrepare: An asserting value handle still pointed to this value!

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Dec 19 16:25:16 PST 2019


https://bugs.llvm.org/show_bug.cgi?id=44351

            Bug ID: 44351
           Summary: CodeGenPrepare: An asserting value handle still
                    pointed to this value!
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Transformation Utilities
          Assignee: unassignedbugs at nondot.org
          Reporter: arichardson.kde at gmail.com
                CC: llvm-bugs at lists.llvm.org

I was trying to compile the FreeBSD kernel (RISC-V 64, but not sure that is the
cause) with the latest git HEAD of LLVM and encountered this assertion while
compiling if_malo_pci.c.

The following reduced test case (which can probably be reduced a bit further,
but this is what a sequence of creduce+bugpoint gave me):

```
; RUN: %clang_cc1 -triple riscv64-unknown-freebsd13.0 -relaxed-aliasing
-mcode-model medium -fno-split-dwarf-inlining -O2 -stack-protector 1
-fno-signed-char -fno-common -o - -S -x ir %s
; ModuleID =
'/local/scratch/alr48/cheri/build/llvm-project-build/regression-freebsd-kernel-reduce.test-reduce.test-reduce.test-reduce.test-reduce.ll-reduced-simplified.bc'
source_filename =
"/local/scratch/alr48/cheri/upstream-llvm-project/clang/test/CodeGen/regression-freebsd-kernel-reduce.test-reduce.test-reduce.test-reduce.test-reduce.ll"
target triple = "x86_64-unknown-linux-gnu"

%struct.ham = type { %struct.bar, %struct.snork.13*, [2 x %struct.spam*],
%struct.snork.13*, [1 x %struct.wombat.14*], [1 x i8*], i32 }
%struct.bar = type { %struct.wobble, %struct.ham.7*, %struct.bar*,
%struct.barney*, i64, %struct.snork.2*, i64, %struct.snork.2*, i8,
%struct.foo.3*, i16, %struct.wombat, %struct.wobble.6, %struct.ham.7*,
%struct.wobble.10, [1 x %struct.barney.8], %struct.wobble.10, i32,
%struct.blam, [4 x i8], %struct.zot, %struct.baz.12, i32 }
%struct.wobble = type { i8, i8*, i32, i32, i32, %struct.bar*,
%struct.wobble.10, %struct.wobble.10, %struct.wobble.10, %struct.wobble.10,
%struct.wobble.10, %struct.wobble.10, %struct.wobble.10, i64, i64, i32, i32,
i32, i32, i32, i32, i32, [2 x i8], i8, [6 x i8], i16, i16, i16, i16, i32, [128
x i8], [128 x i8], [128 x i8], %struct.spam*, %struct.spam*, %struct.spam*,
%struct.spam*, %struct.wibble*, %struct.spam*, %struct.spam*, i16,
%struct.bar.0*, %struct.wobble.1*, i32, i32, i32, i32, i16, i16, i16, i16, i8,
i32, i32, i32, i8, i32, i32, i32, [3 x i32], %struct.foo*, %struct.ham.7*, i8,
%struct.ham.7*, i8*, i32, %struct.baz*, void ()*, i32, void ()*, [7 x void
()*], void ()*, i32, i32*, i32, i32*, i32, void ()*, void ()*, void ()*, void
()*, void ()*, %struct.snork*, void ()*, void ()*, void ()*, void ()*, i8, void
()*, void ()*, void ()*, void ()*, void ()*, void ()*, void ()*, i32, i32*,
i32, i32*, i32, void ()*, void ()*, void ()*, i32, void ()*, void ()*, [7 x
i64] }
%struct.wibble = type {}
%struct.spam = type {}
%struct.bar.0 = type {}
%struct.wobble.1 = type {}
%struct.foo = type {}
%struct.baz = type {}
%struct.snork = type {}
%struct.barney = type opaque
%struct.snork.2 = type {}
%struct.foo.3 = type {}
%struct.wombat = type { i8, i8*, i64, i64, %struct.wobble.4, i32,
%struct.barney*, %struct.snork.5*, i8 }
%struct.wobble.4 = type { i64, i64 }
%struct.snork.5 = type {}
%struct.wobble.6 = type { %struct.ham.7*, %struct.ham.7* }
%struct.ham.7 = type opaque
%struct.barney.8 = type { %struct.wombat, [12 x i8], i32, i32, %struct.spam.9,
%struct.spam.9 }
%struct.spam.9 = type { %struct.foo.3*, %struct.foo.3* }
%struct.wobble.10 = type { %struct.spam.11, i16, void ()*, i8 }
%struct.spam.11 = type { %struct.wobble.10* }
%struct.blam = type { i16, i16, i8 }
%struct.zot = type { i8, i16, i16, i8, i8, [7 x i8] }
%struct.baz.12 = type { %struct.quux, i32, i32, i32, i32, i32, i32, i32, i32,
i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i8, [4 x
i32], [4 x i32] }
%struct.quux = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32,
i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32
}
%struct.snork.13 = type {}
%struct.wombat.14 = type {}
define i32 @widget() {
bb:
  %tmp3 = alloca i32
  %tmp4 = alloca %struct.ham*
  %tmp5 = call i8* @foo(%struct.ham.7* undef)
  %tmp6 = bitcast i8* %tmp5 to %struct.ham*
  store %struct.ham* %tmp6, %struct.ham** %tmp4
  %tmp7 = load %struct.ham*, %struct.ham** %tmp4
  %tmp8 = getelementptr %struct.ham, %struct.ham* %tmp7, i32 0, i32 4
  %tmp9 = getelementptr [1 x %struct.wombat.14*], [1 x %struct.wombat.14*]*
%tmp8, i64 0, i64 0
  %tmp = call i32 @snork(%struct.ham.7* undef, %struct.snork.13* undef,
%struct.wombat.14** %tmp9)
  %tmp10 = load %struct.ham*, %struct.ham** %tmp4
  %tmp11 = getelementptr %struct.ham, %struct.ham* %tmp10, i32 0, i32 6
  %tmp12 = load i32, i32* %tmp11
  %tmp13 = icmp eq i32 %tmp12, 0
  br i1 %tmp13, label %bb14, label %bb24

bb14:                                             ; preds = %bb
  %tmp15 = load %struct.ham*, %struct.ham** %tmp4
  %tmp16 = getelementptr %struct.ham, %struct.ham* %tmp15, i32 0, i32 4
  %tmp17 = getelementptr [1 x %struct.wombat.14*], [1 x %struct.wombat.14*]*
%tmp16, i64 0, i64 0
  %tmp18 = load %struct.wombat.14*, %struct.wombat.14** %tmp17
  %tmp19 = load %struct.ham*, %struct.ham** %tmp4
  %tmp20 = getelementptr %struct.ham, %struct.ham* %tmp19, i32 0, i32 5
  %tmp21 = getelementptr [1 x i8*], [1 x i8*]* %tmp20, i64 0, i64 0
  %tmp22 = load i8*, i8** %tmp21
  %tmp23 = call signext i32 @blam(%struct.ham.7* undef, %struct.wombat.14*
%tmp18, i8* %tmp22)
  br label %bb42

bb24:                                             ; preds = %bb
  store i32 0, i32* %tmp3
  br label %bb25

bb25:                                             ; preds = %bb28, %bb24
  %tmp26 = load i32, i32* %tmp3
  %tmp27 = icmp slt i32 %tmp26, 1
  br i1 %tmp27, label %bb28, label %bb42

bb28:                                             ; preds = %bb25
  %tmp29 = load %struct.ham*, %struct.ham** %tmp4
  %tmp30 = getelementptr %struct.ham, %struct.ham* %tmp29, i32 0, i32 4
  %tmp31 = load i32, i32* %tmp3
  %tmp32 = sext i32 %tmp31 to i64
  %tmp33 = getelementptr [1 x %struct.wombat.14*], [1 x %struct.wombat.14*]*
%tmp30, i64 0, i64 %tmp32
  %tmp34 = load %struct.wombat.14*, %struct.wombat.14** %tmp33
  %tmp35 = load %struct.ham*, %struct.ham** %tmp4
  %tmp36 = getelementptr %struct.ham, %struct.ham* %tmp35, i32 0, i32 5
  %tmp37 = getelementptr [1 x i8*], [1 x i8*]* %tmp36, i64 0, i64 0
  %tmp38 = load i8*, i8** %tmp37
  %tmp39 = call signext i32 @blam(%struct.ham.7* undef, %struct.wombat.14*
%tmp34, i8* %tmp38)
  %tmp40 = load i32, i32* %tmp3
  %tmp41 = add i32 %tmp40, 1
  store i32 %tmp41, i32* %tmp3
  br label %bb25

bb42:                                             ; preds = %bb25, %bb14
  ret i32 undef
}
declare i8* @foo(%struct.ham.7*)
declare i32 @snork(%struct.ham.7*, %struct.snork.13*, %struct.wombat.14**)
```


results in this backtrace:
```
While deleting: i8* %tmp11
An asserting value handle still pointed to this value!
UNREACHABLE executed at
/local/scratch/alr48/cheri/upstream-llvm-project/llvm/lib/IR/Value.cpp:917!
Stack dump:
0.      Program arguments:
/local/scratch/alr48/cheri/build/upstream-llvm-project-build/bin/clang -cc1
-internal-isystem
/local/scratch/alr48/cheri/build/upstream-llvm-project-build/lib/clang/10.0.0/include
-nostdsysteminc -triple riscv64-unknown-freebsd13.0 -relaxed-aliasing
-mcode-model medium -fno-split-dwarf-inlining -O2 -stack-protector 1
-fno-signed-char -fno-common -o - -S -x ir
/local/scratch/alr48/cheri/upstream-llvm-project/clang/test/CodeGen/regression-freebsd-kernel-reduce.test-reduce.test-reduce.test-reduce.test-reduce.test.ll
1.      Code generation
2.      Running pass 'Function Pass Manager' on module
'/local/scratch/alr48/cheri/upstream-llvm-project/clang/test/CodeGen/regression-freebsd-kernel-reduce.test-reduce.test-reduce.test-reduce.test-reduce.test.ll'.
3.      Running pass 'CodeGen Prepare' on function '@widget'
 #0 0x00000000048db954 llvm::sys::PrintStackTrace(llvm::raw_ostream&)
/local/scratch/alr48/cheri/upstream-llvm-project/llvm/lib/Support/Unix/Signals.inc:548:13
 #1 0x00000000048db954 PrintStackTraceSignalHandler(void*)
/local/scratch/alr48/cheri/upstream-llvm-project/llvm/lib/Support/Unix/Signals.inc:608:0
 #2 0x00000000048d960e llvm::sys::RunSignalHandlers()
/local/scratch/alr48/cheri/upstream-llvm-project/llvm/lib/Support/Signals.cpp:69:18
 #3 0x00000000048dbd6c SignalHandler(int)
/local/scratch/alr48/cheri/upstream-llvm-project/llvm/lib/Support/Unix/Signals.inc:380:3
 #4 0x00007f09370a8890 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x12890)
 #5 0x00007f0935b51e97 raise
/build/glibc-OTsEL5/glibc-2.27/signal/../sysdeps/unix/sysv/linux/raise.c:51:0
 #6 0x00007f0935b53801 abort /build/glibc-OTsEL5/glibc-2.27/stdlib/abort.c:81:0
 #7 0x0000000004865971
(/local/scratch/alr48/cheri/build/upstream-llvm-project-build/bin/clang+0x4865971)
 #8 0x00000000042318ae bool llvm::DenseMapBase<llvm::DenseMap<llvm::Value*,
llvm::ValueHandleBase*, llvm::DenseMapInfo<llvm::Value*>,
llvm::detail::DenseMapPair<llvm::Value*, llvm::ValueHandleBase*> >,
llvm::Value*, llvm::ValueHandleBase*, llvm::DenseMapInfo<llvm::Value*>,
llvm::detail::DenseMapPair<llvm::Value*, llvm::ValueHandleBase*>
>::LookupBucketFor<llvm::Value*>(llvm::Value* const&,
llvm::detail::DenseMapPair<llvm::Value*, llvm::ValueHandleBase*> const*&) const
/local/scratch/alr48/cheri/upstream-llvm-project/llvm/include/llvm/ADT/DenseMap.h:611:23
 #9 0x00000000042318ae bool llvm::DenseMapBase<llvm::DenseMap<llvm::Value*,
llvm::ValueHandleBase*, llvm::DenseMapInfo<llvm::Value*>,
llvm::detail::DenseMapPair<llvm::Value*, llvm::ValueHandleBase*> >,
llvm::Value*, llvm::ValueHandleBase*, llvm::DenseMapInfo<llvm::Value*>,
llvm::detail::DenseMapPair<llvm::Value*, llvm::ValueHandleBase*>
>::LookupBucketFor<llvm::Value*>(llvm::Value* const&,
llvm::detail::DenseMapPair<llvm::Value*, llvm::ValueHandleBase*>*&)
/local/scratch/alr48/cheri/upstream-llvm-project/llvm/include/llvm/ADT/DenseMap.h:632:0
#10 0x00000000042318ae llvm::DenseMapBase<llvm::DenseMap<llvm::Value*,
llvm::ValueHandleBase*, llvm::DenseMapInfo<llvm::Value*>,
llvm::detail::DenseMapPair<llvm::Value*, llvm::ValueHandleBase*> >,
llvm::Value*, llvm::ValueHandleBase*, llvm::DenseMapInfo<llvm::Value*>,
llvm::detail::DenseMapPair<llvm::Value*, llvm::ValueHandleBase*>
>::FindAndConstruct(llvm::Value* const&)
/local/scratch/alr48/cheri/upstream-llvm-project/llvm/include/llvm/ADT/DenseMap.h:293:0
#11 0x00000000042318ae llvm::DenseMapBase<llvm::DenseMap<llvm::Value*,
llvm::ValueHandleBase*, llvm::DenseMapInfo<llvm::Value*>,
llvm::detail::DenseMapPair<llvm::Value*, llvm::ValueHandleBase*> >,
llvm::Value*, llvm::ValueHandleBase*, llvm::DenseMapInfo<llvm::Value*>,
llvm::detail::DenseMapPair<llvm::Value*, llvm::ValueHandleBase*>
>::operator[](llvm::Value* const&)
/local/scratch/alr48/cheri/upstream-llvm-project/llvm/include/llvm/ADT/DenseMap.h:300:0
#12 0x00000000042318ae llvm::ValueHandleBase::ValueIsDeleted(llvm::Value*)
/local/scratch/alr48/cheri/upstream-llvm-project/llvm/lib/IR/Value.cpp:915:0
#13 0x0000000004231bf9 llvm::Value::isUsedByMetadata() const
/local/scratch/alr48/cheri/upstream-llvm-project/llvm/include/llvm/IR/Value.h:509:42
#14 0x0000000004231bf9 llvm::Value::~Value()
/local/scratch/alr48/cheri/upstream-llvm-project/llvm/lib/IR/Value.cpp:77:0
#15 0x0000000004231a40 llvm::Value::deleteValue()
/local/scratch/alr48/cheri/upstream-llvm-project/llvm/lib/IR/Value.cpp:0:3
#16 0x00000000041bb42b llvm::Instruction::eraseFromParent()
/local/scratch/alr48/cheri/upstream-llvm-project/llvm/lib/IR/Instruction.cpp:68:3
#17 0x00000000049356be llvm::SmallVectorBase::empty() const
/local/scratch/alr48/cheri/upstream-llvm-project/llvm/include/llvm/ADT/SmallVector.h:55:47
#18 0x00000000049356be
llvm::RecursivelyDeleteTriviallyDeadInstructions(llvm::SmallVectorImpl<llvm::Instruction*>&,
llvm::TargetLibraryInfo const*, llvm::MemorySSAUpdater*)
/local/scratch/alr48/cheri/upstream-llvm-project/llvm/lib/Transforms/Utils/Local.cpp:457:0
#19 0x000000000493509b llvm::SmallVectorTemplateCommon<llvm::Instruction*,
void>::isSmall() const
/local/scratch/alr48/cheri/upstream-llvm-project/llvm/include/llvm/ADT/SmallVector.h:103:33
#20 0x000000000493509b
llvm::SmallVectorImpl<llvm::Instruction*>::~SmallVectorImpl()
/local/scratch/alr48/cheri/upstream-llvm-project/llvm/include/llvm/ADT/SmallVector.h:335:0
#21 0x000000000493509b llvm::SmallVector<llvm::Instruction*,
16u>::~SmallVector()
/local/scratch/alr48/cheri/upstream-llvm-project/llvm/include/llvm/ADT/SmallVector.h:844:0
#22 0x000000000493509b
llvm::RecursivelyDeleteTriviallyDeadInstructions(llvm::Value*,
llvm::TargetLibraryInfo const*, llvm::MemorySSAUpdater*)
/local/scratch/alr48/cheri/upstream-llvm-project/llvm/lib/Transforms/Utils/Local.cpp:451:0
#23 0x0000000003d5a440 (anonymous
namespace)::CodeGenPrepare::optimizeMemoryInst(llvm::Instruction*,
llvm::Value*, llvm::Type*, unsigned int)
/local/scratch/alr48/cheri/upstream-llvm-project/llvm/lib/CodeGen/CodeGenPrepare.cpp:5134:20
#24 0x0000000003d51c81 (anonymous
namespace)::CodeGenPrepare::optimizeInst(llvm::Instruction*, bool&)
/local/scratch/alr48/cheri/upstream-llvm-project/llvm/lib/CodeGen/CodeGenPrepare.cpp:7098:16
#25 0x0000000003d47b95 (anonymous
namespace)::CodeGenPrepare::optimizeBlock(llvm::BasicBlock&, bool&)
/local/scratch/alr48/cheri/upstream-llvm-project/llvm/lib/CodeGen/CodeGenPrepare.cpp:7212:9
#26 0x0000000003d47b95 (anonymous
namespace)::CodeGenPrepare::runOnFunction(llvm::Function&)
/local/scratch/alr48/cheri/upstream-llvm-project/llvm/lib/CodeGen/CodeGenPrepare.cpp:488:0
#27 0x00000000041ec8f0 llvm::FPPassManager::runOnFunction(llvm::Function&)
/local/scratch/alr48/cheri/upstream-llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1481:27
#28 0x00000000041ecbe8 llvm::FPPassManager::runOnModule(llvm::Module&)
/local/scratch/alr48/cheri/upstream-llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1517:13
#29 0x00000000041ed25d (anonymous
namespace)::MPPassManager::runOnModule(llvm::Module&)
/local/scratch/alr48/cheri/upstream-llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1582:27
#30 0x00000000041ed25d llvm::legacy::PassManagerImpl::run(llvm::Module&)
/local/scratch/alr48/cheri/upstream-llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1694:0
#31 0x0000000004ac275a llvm::TimeTraceScope::~TimeTraceScope()
/local/scratch/alr48/cheri/upstream-llvm-project/llvm/include/llvm/Support/TimeProfiler.h:78:9
#32 0x0000000004ac275a (anonymous
namespace)::EmitAssemblyHelper::EmitAssembly(clang::BackendAction,
std::unique_ptr<llvm::raw_pwrite_stream,
std::default_delete<llvm::raw_pwrite_stream> >)
/local/scratch/alr48/cheri/upstream-llvm-project/clang/lib/CodeGen/BackendUtil.cpp:909:0
#33 0x0000000004ac275a clang::EmitBackendOutput(clang::DiagnosticsEngine&,
clang::HeaderSearchOptions const&, clang::CodeGenOptions const&,
clang::TargetOptions const&, clang::LangOptions const&, llvm::DataLayout
const&, llvm::Module*, clang::BackendAction,
std::unique_ptr<llvm::raw_pwrite_stream,
std::default_delete<llvm::raw_pwrite_stream> >)
/local/scratch/alr48/cheri/upstream-llvm-project/clang/lib/CodeGen/BackendUtil.cpp:1537:0
#34 0x0000000005207cf8 std::unique_ptr<llvm::raw_pwrite_stream,
std::default_delete<llvm::raw_pwrite_stream> >::~unique_ptr()
/usr/bin/../lib/gcc/x86_64-linux-gnu/7.4.0/../../../../include/c++/7.4.0/bits/unique_ptr.h:267:6
#35 0x0000000005207cf8 clang::CodeGenAction::ExecuteAction()
/local/scratch/alr48/cheri/upstream-llvm-project/clang/lib/CodeGen/CodeGenAction.cpp:1106:0
#36 0x0000000005152100 clang::FrontendAction::Execute()
/local/scratch/alr48/cheri/upstream-llvm-project/clang/lib/Frontend/FrontendAction.cpp:940:10
#37 0x00000000050ac864 llvm::Error::getPtr() const
/local/scratch/alr48/cheri/upstream-llvm-project/llvm/include/llvm/Support/Error.h:273:42
#38 0x00000000050ac864 llvm::Error::operator bool()
/local/scratch/alr48/cheri/upstream-llvm-project/llvm/include/llvm/Support/Error.h:236:0
#39 0x00000000050ac864
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
/local/scratch/alr48/cheri/upstream-llvm-project/clang/lib/Frontend/CompilerInstance.cpp:965:0
#40 0x0000000005202d5f
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
/local/scratch/alr48/cheri/upstream-llvm-project/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:290:25
#41 0x0000000002be21f2 cc1_main(llvm::ArrayRef<char const*>, char const*,
void*)
/local/scratch/alr48/cheri/upstream-llvm-project/clang/tools/driver/cc1_main.cpp:250:15
#42 0x0000000002bdfdd7 ExecuteCC1Tool(llvm::ArrayRef<char const*>,
llvm::StringRef)
/local/scratch/alr48/cheri/upstream-llvm-project/clang/tools/driver/driver.cpp:309:12
#43 0x0000000002bdfdd7 main
/local/scratch/alr48/cheri/upstream-llvm-project/clang/tools/driver/driver.cpp:382:0
#44 0x00007f0935b34b97 __libc_start_main
/build/glibc-OTsEL5/glibc-2.27/csu/../csu/libc-start.c:344:0
#45 0x0000000002bdd02a _start
(/local/scratch/alr48/cheri/build/upstream-llvm-project-build/bin/clang+0x2bdd02a)
/local/scratch/alr48/cheri/build/upstream-llvm-project-build/tools/clang/test/CodeGen/Output/regression-freebsd-kernel-reduce.test-reduce.test-reduce.test-reduce.test-reduce.test.ll.script:
line 1: 56146 Aborted                 (core dumped)
/local/scratch/alr48/cheri/build/upstream-llvm-project-build/bin/clang -cc1
-internal-isystem
/local/scratch/alr48/cheri/build/upstream-llvm-project-build/lib/clang/10.0.0/include
-nostdsysteminc -triple riscv64-unknown-freebsd13.0 -relaxed-aliasing
-mcode-model medium -fno-split-dwarf-inlining -O2 -stack-protector 1
-fno-signed-char -fno-common -o - -S -x ir
/local/scratch/alr48/cheri/upstream-llvm-project/clang/test/CodeGen/regression-freebsd-kernel-reduce.test-reduce.test-reduce.test-reduce.test-reduce.test.ll
```

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20191220/de59a0e8/attachment-0001.html>


More information about the llvm-bugs mailing list