[LLVMdev] Question about 'DuplicateInstruction' function of TailDuplicatePass in CodeGen
JinGu Kang
jingu at codeplay.com
Fri Jun 20 08:21:55 PDT 2014
Hi Evan,
I appreciate your response.
I have added a target-specific codegen pass into 'addPostRegAlloc()' and
it makes instruction bundles. As I mentioned in my previous e-mail, the
problem I have is that the "TailDuplication" pass duplicates bundled
instructions to unbundled instructions.
The abstract shapes of predecessor and tail machine basic blocks are as
follows:
BB#Pred:
%R23<def> = MUL %R15<kill>, %R23<kill>
JUMP <BB#Tail>
Successors according to CFG: BB#Tail
...
BB#Tail:
%R30<def> = LOAD_SYMBOL<es:function_name>
JUMP_INDIRECT %R30
* Bundled instruction
* Bundled instruction
As you know, the "TailDuplication" pass tries to duplicate the
instructions from 'BB#Tail' to 'BB#Pred'. After duplicating the
instructions, the shape of 'BB#Pred" is as follows:
BB#Pred:
%R23<def> = MUL %R15<kill>, %R23<kill>
%R30<def> = LOAD_SYMBOL<es:function_name>
JUMP_INDIRECT %R30
Bundled instruction
Bundled instruction
I think that the default 'TargetInstrInfo::duplicate()' function does
not keep the BundledPred and BundledSucc flags, and thus the
'MachineBasicBlock::insert' function does not make bundled instructions.
I wanted to check whether the "TailDuplication" pass duplicates the
instruction bundles or not. In order to add support to duplicate
instruction bundles, do I need to target a specific hook of
'TargetInstrInfo::duplicate()' to set up the flags?
If you see any problems that I may overlooked, please let me know.
Thanks,
JinGu Kang
On 06/20/2014 01:21 AM, Evan Cheng wrote:
> I have a hard time following your description. I think you need to provide code snippets and illustrate the problem better.
>
> That said, I don't think your simple patch is safe. Tail duplication shouldn't partially duplicate a bundle. Either the entire bundle is duplicated or it should not be duplicated at all.
>
> Evan
>
> On Jun 19, 2014, at 2:52 PM, jingu <jingu at codeplay.com> wrote:
>
>> Hi all,
>>
>> Could someone comment about the email below please?
>>
>> In particular, are there any problems with creating a bundle while cloning, or are there any passes that depend on the instructions being unbundled?
>>
>> I am working on a new backend with LLVM. Your comments will be helpful for me to implement code.
>>
>> Thanks,
>> JinGu Kang
>>
>> On 2014-06-18 오전 12:00, JinGu Kang wrote:
>>> Hi all,
>>>
>>> I have faced a little bit of a strange transformation from the TailDuplicatePass In CodeGen. When the pass clones the contents of TailBB into PredBB, the bundled instructions in TailBB are not bundled in PredBB. I think the reason why it is not bundled is that the 'DuplicateInstruction' function does not set up the flag of the first instruction of the bundle in PredBB when it is cloned from TailBB. If the first instruction of the bundle is set up in PredBB, the 'MachineBasicBlock->insert()' function would automatically put the next instructions into the bundle. How do you feel about this?
>>>
>>> I did not find the API in order to make the first instruction of the bundle. I have added simple code to make bundled instructions from the 'DuplicateInstruction' function. As a reference, I have attached a simple patch. If there is something wrong, please let me know.
>>>
>>> Thanks,
>>> JinGu Kang
>>>
>>>
>>>
>> _______________________________________________
>> LLVM Developers mailing list
>> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
More information about the llvm-dev
mailing list