[X86] When checking the bits in cpu_features for function multiversioning dispatcher...
authorCraig Topper <craig.topper@intel.com>
Sat, 20 Oct 2018 01:30:00 +0000 (01:30 +0000)
committerCraig Topper <craig.topper@intel.com>
Sat, 20 Oct 2018 01:30:00 +0000 (01:30 +0000)
commit9c8f3c9654885eb321573fbb4f5da58ae38cd087
treeaac33681563e634429fe874dda0b3d50d72cd36d
parent25dac79edf0c7b8c8481ce358c074352c7289006
[X86] When checking the bits in cpu_features for function multiversioning dispatcher in the resolver, make sure all the required bits are set. Not just one of them

Summary:
The multiversioning code repurposed the code from __builtin_cpu_supports for checking if a single feature is enabled. That code essentially performed (_cpu_features & (1 << C)) != 0. But with the multiversioning path, the mask is no longer guaranteed to be a power of 2. So we return true anytime any one of the bits in the mask is set not just all of the bits.

The correct check is (_cpu_features & mask) == mask

Reviewers: erichkeane, echristo

Reviewed By: echristo

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D53460

llvm-svn: 344824
clang/lib/CodeGen/CGBuiltin.cpp
clang/test/CodeGen/attr-target-mv.c
clang/test/CodeGen/builtin-cpu-supports.c