[LLVMdev] FW: Bug in SelectionDAG visitTargetIntrinsic

Villmow, Micah Micah.Villmow at amd.com
Tue Nov 6 13:45:04 PST 2012

From: Villmow, Micah
Sent: Tuesday, November 06, 2012 1:37 PM
To: 'llvm-dev at cs.uiuc.edu'
Cc: Guo, Xiaoyi
Subject: Bug in SelectionDAG visitTargetIntrinsic

We ran into a problem where specifying IntrNoMem was causing our instruction selection to fail with target specific intrinsics. After looking into the code and ISel debug it looks like tablegen and SelectionDAG are using different criteria to generate code for intrinsic_w_chain vs intrinsic_wo_chain.

In CodeGenDAGPatterns.cpp, tablegen decides based on whether IntrNoMem is set or not. However with SelectionDAG, whether to use a chain or not is determined by the call site attributes and not by the intrinsic.

So, we can get the situation where the call site has a different attribute than the intrinsic, and this causes selection dag to fail.

I believe that this is wrong and that whether a chain should be generated or not should come from only the intrinsic and not the call site. Since the mapping of call -> intrinsic is by function name only, it should not matter if the readnone attribute is set or not as that is irrelevant to the code generator. Only what is set in the tablegen definition should be determine how the intrinsic is generated.

So, I'm proposing the following patch. What this patch does is instead of relying on the call site to determine if a chain is required, use instead the read/write attributes of the intrinsic from the backend instead. There is not much documentation on target intrinsics and no other backend uses them in this manner.

This patch sound good?


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20121106/7e359891/attachment.html>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: target_intrinsic_incorrect_chain.txt
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20121106/7e359891/attachment.txt>

More information about the llvm-dev mailing list