JinGu Kang
2014-Jun-17 15:00 UTC
[LLVMdev] Question about 'DuplicateInstruction' function of TailDuplicatePass in CodeGen
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 -------------- next part -------------- Index: lib/CodeGen/TailDuplication.cpp ==================================================================--- lib/CodeGen/TailDuplication.cpp (revision 211103) +++ lib/CodeGen/TailDuplication.cpp (working copy) @@ -453,6 +453,11 @@ } } PredBB->insert(PredBB->instr_end(), NewMI); + + /// If there is bundled instruction in TailBB, + /// make bundled instruction in PredBB. + if (MI->isBundled() && MI->isInsideBundle()) + NewMI->bundleWithPred(); } /// UpdateSuccessorsPHIs - After FromBB is tail duplicated into its predecessor
jingu
2014-Jun-19 21:52 UTC
[LLVMdev] Question about 'DuplicateInstruction' function of TailDuplicatePass in CodeGen
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 > > >
Evan Cheng
2014-Jun-20 00:21 UTC
[LLVMdev] Question about 'DuplicateInstruction' function of TailDuplicatePass in CodeGen
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