This is an archive of the discontinued LLVM Phabricator instance.

[ARM] Wrong t2STMIA size optimization in Thumb2SizeReduction
ClosedPublic

Authored by sdmitrouk on Sep 10 2014, 4:20 AM.

Details

Reviewers
t.p.northover
Summary

Wrong check in Thumb2SizeReduction caused reduction of t2STMIA instruction
to t1STMIA even when t2STMIA has LR register in its register list. This is
wrong as register list of t1STMIA is 8 bit long (for R0-R7 only), thus LR
register (R14) is just thrown away on emitting binary representation of t1STMIA.
It causes some data to be silently lost at run-time, in very rare cases.

Diff Detail

Event Timeline

sdmitrouk updated this revision to Diff 13528.Sep 10 2014, 4:20 AM
sdmitrouk retitled this revision from to [ARM] Wrong t2STMIA size optimization in Thumb2SizeReduction.
sdmitrouk updated this object.
sdmitrouk edited the test plan for this revision. (Show Details)
sdmitrouk added a subscriber: Unknown Object (MLST).

Hi Sergey,

The code itself looks fine, but the test can be made much more robust, and simpler at the same time. It's always a good idea to keep some regalloc-bait handy!

 declare i8* @llvm.returnaddress(i32)

 define i32* @foo(i32* %addr, i32 %val0) minsize {
   store i32 %val0, i32* %addr

   %addr1 = getelementptr i32* %addr, i32 1
   %lr = call i8* @llvm.returnaddress(i32 0)
   %lr32 = ptrtoint i8* %lr to i32
   store i32 %lr32, i32* %addr1

   %addr2 = getelementptr i32* %addr1, i32 1
   ret i32* %addr2
}

Cheers.

Tim.

sdmitrouk updated this revision to Diff 13533.Sep 10 2014, 5:24 AM

Replaced test function with much better one provided by Tim.

Hi Tim,

Thanks a lot for a much better test! I'm not good at writing IR
and tried to reduce output of Clang.

Regards,
Sergey

Hi Sergey,

Thanks for updating the patch, I think this looks fine now.

Cheers.

Tim.

t.p.northover accepted this revision.Sep 10 2014, 5:34 AM
t.p.northover added a reviewer: t.p.northover.
This revision is now accepted and ready to land.Sep 10 2014, 5:34 AM

Tim,

Great, but I don't have commit access. Could you please commit it?

Thanks,
Sergey

Sure, it's r217498.

Cheers.

Tim.

sdmitrouk closed this revision.Nov 25 2014, 7:05 AM