Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CodeGen] guarantee variable templates are initialized in the reverse…
… instantiation order Following up D127259. Fixes #61028.
- Loading branch information
Yuanfang Chen
committed
Mar 5, 2023
1 parent
bd1f7c4
commit 7f8d844
Showing
2 changed files
with
34 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// RUN: %clang_cc1 -std=c++14 -S -emit-llvm -disable-llvm-passes -o - %s -triple x86_64-linux-gnu | FileCheck %s | ||
|
||
template<int N> int Fib = Fib<N-2> + Fib<N-1>; | ||
template<> int Fib<0> = 0; | ||
template<> int Fib<1> = 1; | ||
int f = Fib<5>; | ||
|
||
template<int N> int Fib2 = Fib2<N-1> + Fib2<N-2>; | ||
template<> int Fib2<0> = 0; | ||
template<> int Fib2<1> = 1; | ||
int f2 = Fib2<5>; | ||
|
||
// CHECK: @llvm.global_ctors = appending global [9 x { i32, ptr, ptr }] [ | ||
// CHECK-SAME: { i32, ptr, ptr } { i32 65535, ptr @__cxx_global_var_init.4, ptr @_Z3FibILi2EE }, | ||
// CHECK-SAME: { i32, ptr, ptr } { i32 65535, ptr @__cxx_global_var_init.3, ptr @_Z3FibILi3EE }, | ||
// CHECK-SAME: { i32, ptr, ptr } { i32 65535, ptr @__cxx_global_var_init.5, ptr @_Z3FibILi4EE }, | ||
// CHECK-SAME: { i32, ptr, ptr } { i32 65535, ptr @__cxx_global_var_init.2, ptr @_Z3FibILi5EE }, | ||
// CHECK-SAME: { i32, ptr, ptr } { i32 65535, ptr @__cxx_global_var_init.8, ptr @_Z4Fib2ILi2EE }, | ||
// CHECK-SAME: { i32, ptr, ptr } { i32 65535, ptr @__cxx_global_var_init.9, ptr @_Z4Fib2ILi3EE }, | ||
// CHECK-SAME: { i32, ptr, ptr } { i32 65535, ptr @__cxx_global_var_init.7, ptr @_Z4Fib2ILi4EE }, | ||
// CHECK-SAME: { i32, ptr, ptr } { i32 65535, ptr @__cxx_global_var_init.6, ptr @_Z4Fib2ILi5EE }, | ||
// CHECK-SAME: { i32, ptr, ptr } { i32 65535, ptr @_GLOBAL__sub_I_static_init_variable_template.cpp, ptr null } |