[llvm] r249187 - [WebAssembly] Fix CFG stackification of nested loops.
Dan Gohman via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 2 16:58:22 PDT 2015
Hi Richard,
Thanks for reporting it. It's now fixed in r249217.
Dan
On Fri, Oct 2, 2015 at 4:46 PM, Richard Trieu <rtrieu at google.com> wrote:
> Hi Dan,
>
> I am getting the follow testing failure when running the test
> cfg-stackify.ll:
>
> cfg-stackify.ll:203:10: error: expected string not found in input
> ; CHECK: (loop $BB8_1)
> ^
> <stdin>:177:2: note: scanning from here
> (loop $BB8_2)
> ^
>
> Diff the output from llc run line between revisions:
> 11c11
> < (loop $BB0_3)
> ---
> > (loop $BB0_2)
> 32c32
> < (loop $BB1_3)
> ---
> > (loop $BB1_2)
> 55c55
> < (loop $BB2_2)
> ---
> > (loop $BB2_1)
> 162c162
> < (loop $BB7_2)
> ---
> > (loop $BB7_1)
> 177c177
> < (loop $BB8_2)
> ---
> > (loop $BB8_1)
> 239,263d238
> <
> < ;; .globl test3
> < (func $test3
> < (param i32)
> < (block $BB11_1)
> < (setlocal @0 (argument 0))
> < (setlocal @1 (immediate 0))
> < (brif $BB11_1 @1)
> < (br $BB11_2)
> < BB11_1:
> < (return)
> < BB11_2:
> < (loop $BB11_5)
> < (block $BB11_4)
> < (block $BB11_2)
> < (setlocal @3 (eq @4 @1))
> < BB11_3:
> < (loop $BB11_4)
> < (setlocal @5 (eq @6 @0))
> < (brif $BB11_4 @5)
> < (br $BB11_3)
> < BB11_4:
> < (call $bar)
> < (br $BB11_2)
> < ) ;; end func $test3
>
>
> On Fri, Oct 2, 2015 at 2:11 PM, Dan Gohman via llvm-commits <
> llvm-commits at lists.llvm.org> wrote:
>
>> Author: djg
>> Date: Fri Oct 2 16:11:36 2015
>> New Revision: 249187
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=249187&view=rev
>> Log:
>> [WebAssembly] Fix CFG stackification of nested loops.
>>
>> Modified:
>> llvm/trunk/lib/Target/WebAssembly/WebAssemblyCFGStackify.cpp
>> llvm/trunk/test/CodeGen/WebAssembly/cfg-stackify.ll
>>
>> Modified: llvm/trunk/lib/Target/WebAssembly/WebAssemblyCFGStackify.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/WebAssembly/WebAssemblyCFGStackify.cpp?rev=249187&r1=249186&r2=249187&view=diff
>>
>> ==============================================================================
>> --- llvm/trunk/lib/Target/WebAssembly/WebAssemblyCFGStackify.cpp
>> (original)
>> +++ llvm/trunk/lib/Target/WebAssembly/WebAssemblyCFGStackify.cpp Fri Oct
>> 2 16:11:36 2015
>> @@ -194,8 +194,10 @@ static void SortBlocks(MachineFunction &
>> if (MachineLoop *Loop = MLI.getLoopFor(&MBB)) {
>> // Assert that loops are contiguous.
>> assert(Loop->getHeader() == Loop->getTopBlock());
>> - assert(Loop->getHeader() == &MBB ||
>> - MLI.getLoopFor(prev(MachineFunction::iterator(&MBB))) ==
>> Loop);
>> + assert((Loop->getHeader() == &MBB ||
>> + Loop->contains(
>> +
>> MLI.getLoopFor(prev(MachineFunction::iterator(&MBB))))) &&
>> + "Loop isn't contiguous");
>> } else {
>> // Assert that non-loops have no backedge predecessors.
>> for (auto Pred : MBB.predecessors())
>> @@ -245,9 +247,18 @@ static void PlaceMarkers(MachineFunction
>> for (auto &MBB : MF) {
>> // Place the LOOP for loops.
>> if (MachineLoop *Loop = MLI.getLoopFor(&MBB))
>> - if (Loop->getHeader() == &MBB)
>> + if (Loop->getHeader() == &MBB) {
>> + // The operand of a LOOP is the first block after the loop. If
>> the loop
>> + // is the bottom of the function, insert a dummy block at the
>> end.
>> + MachineBasicBlock *Bottom = Loop->getBottomBlock();
>> + auto Iter = next(MachineFunction::iterator(Bottom));
>> + if (Iter == MF.end()) {
>> + MF.push_back(MF.CreateMachineBasicBlock());
>> + Iter = next(MachineFunction::iterator(Bottom));
>> + }
>> BuildMI(MBB, MBB.begin(), DebugLoc(), TII.get(WebAssembly::LOOP))
>> - .addMBB(Loop->getBottomBlock());
>> + .addMBB(Iter);
>> + }
>>
>> // Check for forward branches and switches that need BLOCKS placed.
>> for (auto &Term : MBB.terminators())
>>
>> Modified: llvm/trunk/test/CodeGen/WebAssembly/cfg-stackify.ll
>> URL:
>> http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/WebAssembly/cfg-stackify.ll?rev=249187&r1=249186&r2=249187&view=diff
>>
>> ==============================================================================
>> --- llvm/trunk/test/CodeGen/WebAssembly/cfg-stackify.ll (original)
>> +++ llvm/trunk/test/CodeGen/WebAssembly/cfg-stackify.ll Fri Oct 2
>> 16:11:36 2015
>> @@ -272,3 +272,33 @@ exit:
>> store volatile i32 4, i32* %p
>> ret i32 0
>> }
>> +
>> +; Test that nested loops are handled.
>> +
>> +declare void @bar()
>> +
>> +define void @test3(i32 %w) {
>> +entry:
>> + br i1 undef, label %outer.ph, label %exit
>> +
>> +outer.ph:
>> + br label %outer
>> +
>> +outer:
>> + %tobool = icmp eq i32 undef, 0
>> + br i1 %tobool, label %inner, label %unreachable
>> +
>> +unreachable:
>> + unreachable
>> +
>> +inner:
>> + %c = icmp eq i32 undef, %w
>> + br i1 %c, label %if.end, label %inner
>> +
>> +exit:
>> + ret void
>> +
>> +if.end:
>> + call void @bar()
>> + br label %outer
>> +}
>>
>>
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151002/dc337a84/attachment.html>
More information about the llvm-commits
mailing list