Prevent inlining so that the compiler can't optimize out the check.
| 354 | #ifndef __aarch64__ |
| 355 | // Prevent inlining so that the compiler can't optimize out the check. |
| 356 | __attribute__((noinline)) |
| 357 | int CpuInfoIsSupportedHoistHelper(int64_t cpu_info_flag, int arg) { |
| 358 | if (CpuInfo::IsSupported(cpu_info_flag)) { |
| 359 | // Assembly follows similar pattern to popcnt instruction but executes |
| 360 | // illegal instruction. |
| 361 | int64_t result; |
| 362 | __asm__ __volatile__("ud2" : "=a"(result): "mr"(arg): "cc"); |
| 363 | return result; |
| 364 | } else { |
| 365 | return 12345; |
| 366 | } |
| 367 | } |
| 368 | |
| 369 | // Regression test for IMPALA-6882 - make sure illegal instruction isn't hoisted out of |
| 370 | // CpuInfo::IsSupported() checks. This doesn't test the bug precisely but is a canary for |