Skip to content

Miscompilations on AArch64 since "[SimplifyCFG] don't sink common insts too soon" #38898

Closed
@mstorsjo

Description

@mstorsjo
Bugzilla Link 39550
Resolution FIXED
Resolved on Dec 07, 2018 12:42
Version trunk
OS All
Blocks #38454
Attachments Reproduction code
CC @ahmedbougacha,@efriedma-quic,@MatzeB,@rotateright,@TNorthover,@tstellar
Fixed by commit(s) r346203 r348444 r348636 r348642

Extended Description

I'm running into a case where code seems to miscompile after SVN r320749, "[SimplifyCFG] don't sink common insts too soon (#34603 )" (part of LLVM 6.0, but the same issues can be reproduced with the latest trunk version as well).

I can't (yet) point out exactly where the new generated code is wrong, but this commit changed the outcome of the attached code.

To reproduce (somewhat), compile the attached sample with "clang -std=c99 -O3 -fvisibility=hidden -fomit-frame-pointer -ffast-math --target=aarch64-linux-gnu -c ref_mvs-preproc.c". If compiled with clang built from before SVN r320749, the compiled code does what it is supposed to, while if compiled with a later version, it produces incorrect results.

I have tried looking at the output from compiling with -mllvm -print-after-all to look at differences between before and after this commit, and there obviously are differences, but nothing that I could spot that stands out as obviously incorrect.

Surprisingly, the same code built for other architectures (both 32 and 64 bit x86, and armv7) with newer clang/llvm versions run just fine without any of the misbehaviour as I run into on AArch64.

Can someone spot what this SimplifyCFG change does wrt to this code sample, if there's some overlooked case? Or are the transformations correct and it just happens to trigger buggy codepaths in the AArch64 target after the transformation?

Metadata

Metadata

Assignees

Labels

bugzillaIssues migrated from bugzilla

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions