[llvm-dev] llc gives Segmentation fault at instruction selection in my own back end [was Re: Instruction selection gives "LLVM ERROR: Cannot select"]
RCU via llvm-dev
llvm-dev at lists.llvm.org
Sat Feb 6 11:31:08 PST 2016
Hello.
Just wanted to tell you that I found the bug in my back end.
Turned out that the problem was that I implemented just as a "return false" the method:
bool [MyTarget]DAGToDAGISel::selectIntAddrMSA(SDValue Addr, SDValue &Base,
SDValue &Offset) const {
Note that the Base and Offset arguments are references. And they have to get changed
- see the equivalent method in the Mips back end in MipsSEIselDAGToDAG.cpp.
So, these parameters were not set in my back end's selectIntAddrMSA() method and this
was upsetting the DoInstructionSelect().
I've spent quite a bit of time debugging llc to find the bug - it's not really
obvious to find.
Maybe somebody would be able to improve llc to prevent these kind of errors in the
future - I guess Base and Offset can be checked somewhere in the caller chain of
selectIntAddrMSA() and have an assert if it is not of the right value.
Can somebody help with this?
Best regards,
Alex
On 2/6/2016 1:37 AM, RCU wrote:
> Hello, Tim,
> I have attached the DOT file of the DAG before instruction selection starts.
>
> I found that the error with the NULL operand seems to be given by this code from
> lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp .
> 2737 case OPC_RecordNode: {
> 2738 // Remember this node, it may end up being an operand in the pattern.
> 2739 SDNode *Parent = nullptr;
> 2740 if (NodeStack.size() > 1)
> 2741 Parent = NodeStack[NodeStack.size()-2].getNode();
> 2742 RecordedNodes.push_back(std::make_pair(N, Parent));
> 2743 continue;
> 2744 }
>
> Thank you,
> Alex
>
> On 2/4/2016 7:57 PM, Tim Northover wrote:
>> Hi Alex,
>>
>> On 4 February 2016 at 03:19, RCU <alex.e.susu at gmail.com> wrote:
>>> But now I bumped into another serious problem: llc gives segmentation
>>> fault while doing instruction select on the store.
>>
>> Are you building with assertions enabled? You can get segfaults still,
>> but they're much rarer.
>>
>> Other than that, I'm afraid I don't know what the problem is. If
>> you've got custom C++ to handle stores in some way, that would be the
>> first place to look. It seems to be happening while creating a node,
>> so it's obviously also worth investigating where Ops comes from there.
>>
>>> I can provide the entire DOT output with -view-isel-dags
>>
>> I'd certainly be willing to look at that file for anything malformed or odd.
>>
>> Cheers.
>>
>> Tim.
>>
More information about the llvm-dev
mailing list