summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2015-07-13 06:07:58 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2015-07-13 06:07:58 +0000
commitd6e669458c8d300f8ad7d3ebb684abfd89d67f3f (patch)
tree90645f1781311374e7af6f7288d2b4d3d4864860
parent9a92d4fb04d4b5b1780c632a15341149b227aee6 (diff)
downloadbcm5719-llvm-d6e669458c8d300f8ad7d3ebb684abfd89d67f3f.tar.gz
bcm5719-llvm-d6e669458c8d300f8ad7d3ebb684abfd89d67f3f.zip
Set the linkage before setting the visibility.
Otherwise the visibility setting code would not know that a given function was available_externally. Fixes PR24097. llvm-svn: 242012
-rw-r--r--clang/lib/CodeGen/CGVTables.cpp17
-rw-r--r--clang/lib/CodeGen/CodeGenFunction.h4
-rw-r--r--clang/test/CodeGenCXX/pr24097.cpp20
3 files changed, 30 insertions, 11 deletions
diff --git a/clang/lib/CodeGen/CGVTables.cpp b/clang/lib/CodeGen/CGVTables.cpp
index 64930628949..e36051c2053 100644
--- a/clang/lib/CodeGen/CGVTables.cpp
+++ b/clang/lib/CodeGen/CGVTables.cpp
@@ -364,7 +364,7 @@ void CodeGenFunction::EmitMustTailThunk(const CXXMethodDecl *MD,
FinishFunction();
}
-void CodeGenFunction::GenerateThunk(llvm::Function *Fn,
+void CodeGenFunction::generateThunk(llvm::Function *Fn,
const CGFunctionInfo &FnInfo,
GlobalDecl GD, const ThunkInfo &Thunk) {
StartThunk(Fn, GD, FnInfo);
@@ -376,13 +376,6 @@ void CodeGenFunction::GenerateThunk(llvm::Function *Fn,
// Make the call and return the result.
EmitCallAndReturnForThunk(Callee, &Thunk);
-
- // Set the right linkage.
- CGM.setFunctionLinkage(GD, Fn);
-
- // Set the right visibility.
- const CXXMethodDecl *MD = cast<CXXMethodDecl>(GD.getDecl());
- setThunkVisibility(CGM, MD, Thunk, Fn);
}
void CodeGenVTables::emitThunk(GlobalDecl GD, const ThunkInfo &Thunk,
@@ -455,11 +448,17 @@ void CodeGenVTables::emitThunk(GlobalDecl GD, const ThunkInfo &Thunk,
CodeGenFunction(CGM).GenerateVarArgsThunk(ThunkFn, FnInfo, GD, Thunk);
} else {
// Normal thunk body generation.
- CodeGenFunction(CGM).GenerateThunk(ThunkFn, FnInfo, GD, Thunk);
+ CodeGenFunction(CGM).generateThunk(ThunkFn, FnInfo, GD, Thunk);
}
+ CGM.setFunctionLinkage(GD, ThunkFn);
CGM.getCXXABI().setThunkLinkage(ThunkFn, ForVTable, GD,
!Thunk.Return.isEmpty());
+
+ // Set the right visibility.
+ const CXXMethodDecl *MD = cast<CXXMethodDecl>(GD.getDecl());
+ setThunkVisibility(CGM, MD, Thunk, ThunkFn);
+
if (CGM.supportsCOMDAT() && ThunkFn->isWeakForLinker())
ThunkFn->setComdat(CGM.getModule().getOrInsertComdat(ThunkFn->getName()));
}
diff --git a/clang/lib/CodeGen/CodeGenFunction.h b/clang/lib/CodeGen/CodeGenFunction.h
index 58bec1c2482..f2bc402f8b2 100644
--- a/clang/lib/CodeGen/CodeGenFunction.h
+++ b/clang/lib/CodeGen/CodeGenFunction.h
@@ -1294,8 +1294,8 @@ public:
void EmitMustTailThunk(const CXXMethodDecl *MD, llvm::Value *AdjustedThisPtr,
llvm::Value *Callee);
- /// GenerateThunk - Generate a thunk for the given method.
- void GenerateThunk(llvm::Function *Fn, const CGFunctionInfo &FnInfo,
+ /// Generate a thunk for the given method.
+ void generateThunk(llvm::Function *Fn, const CGFunctionInfo &FnInfo,
GlobalDecl GD, const ThunkInfo &Thunk);
llvm::Function *GenerateVarArgsThunk(llvm::Function *Fn,
diff --git a/clang/test/CodeGenCXX/pr24097.cpp b/clang/test/CodeGenCXX/pr24097.cpp
new file mode 100644
index 00000000000..122bf88506d
--- /dev/null
+++ b/clang/test/CodeGenCXX/pr24097.cpp
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 %s -triple=x86_64-pc-linux -fvisibility hidden -emit-llvm -O1 -disable-llvm-optzns -o - | FileCheck %s
+
+struct Filter {
+ virtual void Foo();
+};
+struct Sender {
+ virtual bool Send();
+};
+struct SyncMessageFilter : public Filter, public Sender {
+ bool Send();
+};
+struct TestSyncMessageFilter : public SyncMessageFilter {
+};
+void bar() {
+ TestSyncMessageFilter f;
+ f.Send();
+}
+
+// Test that it is not hidden
+// CHECK: define available_externally zeroext i1 @_ZThn8_N17SyncMessageFilter4SendEv
OpenPOWER on IntegriCloud