This is an archive of the discontinued LLVM Phabricator instance.

[PowerPC] Fix lrint and llrint code generation
AbandonedPublic

Authored by vddvss on Oct 21 2019, 10:20 AM.

Details

Summary

This patch fixes an issue where, in certain instances, when compiling code using the lrint and llrint LLVM intrinsics, LLVM can incorrectly optimize a loop to use hardware loop counters.

In terms of background, r361875 added lrint and llrint intrinsics to LLVM; however, the series only added support for instructions for AArch64, so on PPC and other platforms ll/lrint was emitted as a function call. On PPC, the hardware loop transform pass assumed that since an intrinsic was used, the ctr register would not be clobbered, and a transformation of the loop to use hardware loop intrinsics was valid. The function call clobbered ctr, resulting in incorrect code generation.

Diff Detail

Event Timeline

vddvss created this revision.Oct 21 2019, 10:20 AM

I believe this is already addressed in https://reviews.llvm.org/D68841 which is waiting for review.

Thanks. Should have checked :) This issue is causing buffer overflows in some applications compiled with Clang 9, so hopefully your fix can be ok'd soon.

jsji added a comment.Nov 5 2019, 12:48 PM

https://reviews.llvm.org/D68841 has landed in https://reviews.llvm.org/rG97e36260709c541044f30092b420238511e13e5b. Does it fix your problem? If so, maybe you can abandon this revision. Thanks.

vddvss abandoned this revision.Nov 5 2019, 12:58 PM