diff options
author | Reid Kleckner <reid@kleckner.net> | 2015-07-20 20:35:30 +0000 |
---|---|---|
committer | Reid Kleckner <reid@kleckner.net> | 2015-07-20 20:35:30 +0000 |
commit | eab97d3d47e24f208b964fb4a15475836a33ba82 (patch) | |
tree | ac50590df345c7c52349d664d0ca43bf732146cd /clang/test/CodeGenCXX/static-init.cpp | |
parent | 93d608c3c3ecc7ce55a4b7f3281240a864f11b1c (diff) | |
download | llvm-eab97d3d47e24f208b964fb4a15475836a33ba82.zip llvm-eab97d3d47e24f208b964fb4a15475836a33ba82.tar.gz llvm-eab97d3d47e24f208b964fb4a15475836a33ba82.tar.bz2 |
Fix a case where we forgot to make a static local variable comdat
Sometimes we can provide an initializer for static locals, in which case
we sometimes might need to change the type. Changing the type requires
making a new LLVM GlobalVariable, and in this codepath we were
forgetting to transfer the comdat.
Fixes PR23838.
Patch by Ivan Garramona.
llvm-svn: 242704
Diffstat (limited to 'clang/test/CodeGenCXX/static-init.cpp')
-rw-r--r-- | clang/test/CodeGenCXX/static-init.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/clang/test/CodeGenCXX/static-init.cpp b/clang/test/CodeGenCXX/static-init.cpp index 25489f0..255251e 100644 --- a/clang/test/CodeGenCXX/static-init.cpp +++ b/clang/test/CodeGenCXX/static-init.cpp @@ -9,6 +9,7 @@ // CHECK: @_ZZ2h2vE1i = linkonce_odr global i32 0, comdat, align // CHECK: @_ZGVZ2h2vE1i = linkonce_odr global i64 0, comdat{{$}} // CHECK: @_ZZN5test1L6getvarEiE3var = internal constant [4 x i32] [i32 1, i32 0, i32 2, i32 4], align 16 +// CHECK: @_ZZN5test414useStaticLocalEvE3obj = linkonce_odr global %"struct.test4::HasVTable" zeroinitializer, comdat, align 8 struct A { A(); @@ -154,3 +155,19 @@ namespace test3 { // CHECK-LABEL: define void @_ZN5test31BC2Ev( // CHECK-LABEL: define void @_ZN5test31BC1Ev( } + +// We forgot to set the comdat when replacing the global with a different type. +namespace test4 { +struct HasVTable { + virtual void f(); +}; +inline HasVTable &useStaticLocal() { + static HasVTable obj; + return obj; +} +void useit() { + useStaticLocal(); +} +// CHECK: define linkonce_odr dereferenceable(8) %"struct.test4::HasVTable"* @_ZN5test414useStaticLocalEv() +// CHECK: ret %"struct.test4::HasVTable"* @_ZZN5test414useStaticLocalEvE3obj +} |