[PATCH] D58390: [X86] Don't consider functions ABI compatible for ArgumentPromotion pass if they would legalize 512-bit vectors differently.

Craig Topper via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 19 09:36:49 PST 2019


craig.topper created this revision.
craig.topper added reviewers: chandlerc, RKSimon, spatel, echristo.
Herald added a subscriber: jdoerfert.

The use of the -mprefer-vector-width=256 command line option mixed with functions using vector intrinsics can create situations where one function thinks 512 vectors are legal, but another fucntion does not.

If a 512 bit vector is passed between them via a pointer, its possible ArgumentPromotion might try to pass by value instead. This will result in type legalization for the two functions handling the 512 bit vector differently leading to runtime failures.

Had the 512 bit vector been passed by value from clang codegen, both functions would have been tagged with a min-legal-vector-width=512 function attribute. That would make them be legalized the same way.

I observed this issue in 32-bit mode where a union containing a 512 bit vector was being passed by a function that used intrinsics to one that did not. The caller ended up passing in zmm0 and the callee tried to read it from ymm0 and ymm1.

The fix implemented here is just to consider it a mismatch if two functions would handle 512 bit differently without looking at the types that are being considered. This is the easist and safest fix, but it can be improved in the future.


https://reviews.llvm.org/D58390

Files:
  lib/Target/X86/X86TargetTransformInfo.cpp
  lib/Target/X86/X86TargetTransformInfo.h
  test/Transforms/ArgumentPromotion/X86/min-legal-vector-width.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D58390.187394.patch
Type: text/x-patch
Size: 10803 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190219/8d2fc5e0/attachment.bin>


More information about the llvm-commits mailing list