In my upgrade process I get a memory-corruption in LLVM in a test-case (sadly I can’t provide this test-case)
I upgraded from 18.1.8 to 19.1.0 with only minor changes caused by my target - could be not enough changes.
The symptoms differ and are:
- a straight core dump without any error message:
| ^
| static
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
- or an assertion
| ^
| static
Assertion failed: (Sequence.size() - Noops == ScheduledNodes && "The number of nodes scheduled doesn't match the expected number!"), function VerifyScheduledSequence, file ScheduleDAGSDNodes.cpp, line 732.
- or another assertion
| ^
| static
Assertion failed: (Op.getValueType() != MVT::Other && Op.getValueType() != MVT::Glue && "Chain and glue operands should occur at end of operand list!"), function AddRegisterOperand, file InstrEmitter.cpp, line 325.
And maybe others.
When I run it in the debugger lldb I get:
1.
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x1)
frame #0: 0x00000001008d7310 clang`llvm::detail::PunnedPointer<llvm::SUnit*>::asInt(this=0x0000000000000001) const at PointerIntPair.h:41:5
38
39 constexpr intptr_t asInt() const {
40 intptr_t R = 0;
-> 41 std::memcpy(&R, Data, sizeof(R));
42 return R;
43 }
- or
* thread #1, queue = 'com.apple.main-thread', stop reason = hit program assert
frame #4: 0x00000001043b7df0 clang`llvm::InstrEmitter::AddRegisterOperand(this=0x000000016fdf6010, MIB=0x000000016fdf5a60, Op=SDValue @ 0x000000016fdf5430, IIOpNum=1, II=0x000000010a1156d8, VRBaseMap=0x000000016fdf5fe8, IsDebug=false, IsClone=false, IsCloned=false) at InstrEmitter.cpp:323:3
320 const MCInstrDesc *II,
321 DenseMap<SDValue, Register> &VRBaseMap,
322 bool IsDebug, bool IsClone, bool IsCloned) {
-> 323 assert(Op.getValueType() != MVT::Other &&
324 Op.getValueType() != MVT::Glue &&
325 "Chain and glue operands should occur at end of operand list!");
326 // Get/emit the operand.
- or
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=2, address=0xfffff0000)
frame #0: 0x0000000100d552f8 clang`llvm::SmallVectorTemplateBase<llvm::SDep, true>::push_back(this=0x0000000a3b4ccc78, Elt=llvm::SmallVectorTemplateBase<llvm::SDep, true>::ValueParamT @ 0x000000016fdf5f58) at SmallVector.h:577:5
574 public:
575 void push_back(ValueParamT Elt) {
576 const T *EltPtr = reserveForParamAndGetAddress(Elt);
-> 577 memcpy(reinterpret_cast<void *>(this->end()), EltPtr, sizeof(T));
578 this->set_size(this->size() + 1);
579 }
And maybe others.
I assume that quite some source code did go through the compiler and that is not a LLVM problem, but a missing initialisation from my side. Well, the different error messages point to missing initialisations.
I do use the option -verify-machineinstrs and I guess that the IR is correct.
Are there good guesses how I can track this down to the initial problem?