Skip to content
Snippets Groups Projects
Commit a64e88b2 authored by Benjamin Kramer's avatar Benjamin Kramer
Browse files

CodeGen: Don't emit linkage on thunks that aren't emitted because they're vararg.

This can happen when we're trying to emit a thunk with available_externally
linkage with optimization enabled but bail because it doesn't make sense
for vararg functions.

PR18098.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@196658 91177308-0d34-0410-b5e6-96231b3b80d8
parent d45fce1c
No related branches found
No related tags found
No related merge requests found
...@@ -422,14 +422,15 @@ void CodeGenVTables::emitThunk(GlobalDecl GD, const ThunkInfo &Thunk, ...@@ -422,14 +422,15 @@ void CodeGenVTables::emitThunk(GlobalDecl GD, const ThunkInfo &Thunk,
// expensive/sucky at the moment, so don't generate the thunk unless // expensive/sucky at the moment, so don't generate the thunk unless
// we have to. // we have to.
// FIXME: Do something better here; GenerateVarArgsThunk is extremely ugly. // FIXME: Do something better here; GenerateVarArgsThunk is extremely ugly.
if (!UseAvailableExternallyLinkage) if (!UseAvailableExternallyLinkage) {
CodeGenFunction(CGM).GenerateVarArgsThunk(ThunkFn, FnInfo, GD, Thunk); CodeGenFunction(CGM).GenerateVarArgsThunk(ThunkFn, FnInfo, GD, Thunk);
CGM.getCXXABI().setThunkLinkage(ThunkFn, ForVTable);
}
} else { } else {
// Normal thunk body generation. // Normal thunk body generation.
CodeGenFunction(CGM).GenerateThunk(ThunkFn, FnInfo, GD, Thunk); CodeGenFunction(CGM).GenerateThunk(ThunkFn, FnInfo, GD, Thunk);
CGM.getCXXABI().setThunkLinkage(ThunkFn, ForVTable);
} }
CGM.getCXXABI().setThunkLinkage(ThunkFn, ForVTable);
} }
void CodeGenVTables::maybeEmitThunkForVTable(GlobalDecl GD, void CodeGenVTables::maybeEmitThunkForVTable(GlobalDecl GD,
......
// RUN: %clang_cc1 %s -triple=x86_64-pc-linux-gnu -munwind-tables -emit-llvm -o - | FileCheck %s // RUN: %clang_cc1 %s -triple=x86_64-pc-linux-gnu -munwind-tables -emit-llvm -o - | FileCheck %s
// RUN: %clang_cc1 %s -triple=x86_64-pc-linux-gnu -munwind-tables -emit-llvm -o - -O1 -disable-llvm-optzns | FileCheck %s
// RUN: %clang_cc1 %s -triple=x86_64-pc-linux-gnu -munwind-tables -fhidden-weak-vtables -emit-llvm -o - | FileCheck -check-prefix=CHECK-HIDDEN %s // RUN: %clang_cc1 %s -triple=x86_64-pc-linux-gnu -munwind-tables -fhidden-weak-vtables -emit-llvm -o - | FileCheck -check-prefix=CHECK-HIDDEN %s
namespace Test1 { namespace Test1 {
...@@ -342,6 +343,27 @@ namespace Test14 { ...@@ -342,6 +343,27 @@ namespace Test14 {
// CHECK: define void @_ZThn8_N6Test141C1fEv({{.*}}) unnamed_addr [[NUW:#[0-9]+]] // CHECK: define void @_ZThn8_N6Test141C1fEv({{.*}}) unnamed_addr [[NUW:#[0-9]+]]
} }
// Varargs non-covariant thunk test.
// PR18098
namespace Test15 {
struct A {
virtual ~A();
};
struct B {
virtual void f(int x, ...);
};
struct C : A, B {
virtual void c();
virtual void f(int x, ...);
};
void C::c() {}
// C::c
// CHECK: declare void @_ZN6Test151C1fEiz
// non-virtual thunk to C::f
// CHECK: declare void @_ZThn8_N6Test151C1fEiz
}
/**** The following has to go at the end of the file ****/ /**** The following has to go at the end of the file ****/
// This is from Test5: // This is from Test5:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment