Resolves: https://github.com/llvm/llvm-project/issues/164150 C++26 allows for constexpr packs in structured bindings. This is a new feature (the code doesn't compile on lower the -std=c++26) and so was previously unhandled in clang. This makes clang aware of packs and handle them as one constant unit instead of materializing them as separate mutable reference temporaries allowing llvm to optimize them. This turns the example code from the issue into this as you would expect without compiling for zen 5 (the good codegen described). ```asm movq %rdi, %rax movups (%rsi), %xmm0 movups %xmm0, (%rdi) movups (%rdx), %xmm0 movups %xmm0, 16(%rdi) retq ```
11 lines
608 B
C++
11 lines
608 B
C++
// RUN: %clang_cc1 %std_cxx98-14 -emit-llvm %s -o - -triple=i386-pc-win32 -fms-extensions | FileCheck %s --check-prefixes=CHECK,PRE17
|
|
// RUN: %clang_cc1 %std_cxx17- -emit-llvm %s -o - -triple=i386-pc-win32 -fms-extensions | FileCheck %s --check-prefixes=CHECK,CXX17
|
|
|
|
const int __declspec(dllexport) &Exported = 42;
|
|
|
|
// The reference temporary shouldn't be dllexport, even if the reference is.
|
|
// PRE17: @"?$RT1@Exported@@3ABHB" = internal constant i32 42
|
|
// CXX17: @"?$RT1@Exported@@3ABHB" = internal constant i32 42
|
|
|
|
// CHECK: @"?Exported@@3ABHB" = dso_local dllexport constant ptr @"?$RT1@Exported@@3ABHB"
|