[llvm-dev] [RFC] Interprocedural MIR-level outlining pass

Jessica Paquette via llvm-dev llvm-dev at lists.llvm.org
Mon Nov 14 14:36:38 PST 2016


Hi Violeta,

I think I've solved the problem you were having. I pushed the changes
to the git repo located at https://github.com/ornata/llvm. Sorry for
the delay!

If you're curious, the issue was in cloning instructions. The cloned
instructions created by CloneMachineInstr actually maintain references
back to the function you're cloning *from*. Since each outlined
function is cloned from some existing MachineFunction, when that
function is emitted and thrown out, certain outlined instructions are
deallocated. Thus, sometimes there's nothing there to print and so it
crashes and burns. The reason this never came up before was that in
the initial outliner implementation, LLVM didn't have
MachineModulePasses yet. As a preliminary solution, we just decided to
temporarily never throw out MachineFunctions. As a result, we never
tried to deallocate anything at all, so this problem never showed up!

Hopefully this resolves the issue on your end.

- Jessica

On Wed, Oct 19, 2016 at 10:46 AM, Violeta Vukobrat
<violeta.vukobrat at rt-rk.com> wrote:
> Hi Jessica,
>
>
> Did you have time to take a look at these questions maybe?
>
> Thank you,
>
>
> Violeta
>
>
>
> On 04.10.2016. 18:20, Violeta Vukobrat wrote:
>>
>> Hi Jessica,
>>
>> Thank you for your quick reply.
>>
>> I have a few more questions.
>>
>> 1. In the results section of your original post, I suppose that by 'llvm
>> test suite' you meant the SingleSource, MultiSource tests. Is that correct?
>>
>> 2. I am trying to run these tests with the -mno-red-zone option, however I
>> am running into issues, and I hope that you can help me.
>>
>> 2.1. The first problem is that I get a segfault when trying to e.g. create
>> an .o file. Example of building a test from the test-suite:
>>
>> clang++ -I<path-to-results-dir>/MultiSource/Benchmarks/Prolangs-C++/simul
>> -I<path-to-test-suite>/MultiSource/Benchmarks/Prolangs-C++/simul
>> -I<path-to-test-suite>/include -I../../../../include -D_GNU_SOURCE
>> -D__STDC_LIMIT_MACROS -DNDEBUG -DSMALL_PROBLEM_SIZE -O3 -mno-red-zone -mllvm
>> -enable-machine-outliner -m64 -fomit-frame-pointer -c
>> <path-to-test-suite>/MultiSource/Benchmarks/Prolangs-C++/simul/simulate.cpp
>> -o simulate.o
>>
>> The problem occurs in AsmPrinter::EmitFunctionBody(), during running 'X86
>> Assembly / Object Emitter' pass on an outlined function.
>> I haven't found what causes it, but the problematic bit seems to be the
>> value of MI in EmitFunctionBody() in lib/CodeGen/AsmPrinter/AsmPrinter.cpp
>> around line 854:
>>  ....
>>
>>     // Print a label for the basic block.
>>     EmitBasicBlockStart(MBB);
>>     for (auto &MI : MBB) {    <---- line 854
>>
>>       // Print the assembly for the instruction.
>>       if (!MI.isPosition() && !MI.isImplicitDef() && !MI.isKill() &&
>>           !MI.isDebugValue()) {
>> ....
>>
>> I haven't debugged this any further, so I don't really know what is the
>> cause of the problem here.
>> What makes it strange is that this segfault doesn't occur always (but does
>> majority of the times), and also, it doesn't always happen for the same
>> outlined function.
>> I was wondering if you have come across a similar issue?
>>
>>
>> 2.2. When I try to build a simple example with '-mno-red-zone' and
>> '-enable-machine-outliner' options, I get an 'undefined reference' to an
>> outlined function, e.g. "undefined reference to `l_OUTLINED_FUNCTION0'". The
>> .s file shows that the call that gets inserted is a call to
>> `l_OUTLINED_FUNCTION0', and the outlined function has the label with a
>> different prefix - `.LOUTLINED_FUNCTION0'.
>> Did you have the same problem?
>>
>> Note: I have cloned your repository from
>> https://github.com/ornata/llvm.git and for clang, I used commit
>> aa5fc8f0161578a00cb5e61a19cb6c6429ff85e3.
>>
>>
>> I hope that you can help me resolve these issues, or tell me if I am doing
>> something wrong here. :)
>>
>> Violeta
>>
>>
>> On 29.09.2016. 09:38, Jessica Paquette wrote:
>>>
>>> Hi Violeta,
>>>
>>> I compiled with
>>>
>>> clang -Oz and
>>> clang -Oz -mno-red-zone for comparisons against Oz
>>>
>>> and
>>>
>>> clang -O0 and
>>> clang -O0 -mno-red-zone for comparisons against a default clang.
>>>
>>> I unfortunately don’t have the clang commit I worked with on my home
>>> laptop, and don’t have access to the computer I was using at Apple, so I
>>> can’t help you there.
>>>
>>>
>>> Jessica
>>>
>>>> On Sep 28, 2016, at 11:22 AM, Violeta Vukobrat
>>>> <violeta.vukobrat at rt-rk.com> wrote:
>>>>
>>>> Hi Jessica,
>>>>
>>>>
>>>> I am looking into trying out your patch and reproducing results that you
>>>> got for code size reduction. Could you tell me what compiler options you
>>>> used? Also, which clang commit did you work with?
>>>>
>>>>
>>>> Violeta
>>>>
>>>> --
>>>> Violeta Vukobrat
>>>> Software Engineer
>>>> RT-RK Computer Based Systems LLC
>>>> www.rt-rk.com
>>
>>
>
> --
> Violeta Vukobrat
> Software Engineer
> RT-RK Computer Based Systems LLC
> www.rt-rk.com
>


More information about the llvm-dev mailing list