LowerTypeTests: When importing functions skip definitions where the summary contains a decl.

This normally indicates mixed CFI + non-CFI compilation, and will
result in us treating the function in the same way as a function
defined outside of the LTO unit.

Part of PR33752.

Differential Revision: https://reviews.llvm.org/D35281

llvm-svn: 307744
This commit is contained in:
Peter Collingbourne 2017-07-12 00:39:12 +00:00
parent 68fbf8563f
commit cacac6a104
3 changed files with 16 additions and 3 deletions

View File

@ -855,15 +855,20 @@ void LowerTypeTestsModule::importFunction(Function *F, bool isDefinition) {
FDecl = Function::Create(F->getFunctionType(), GlobalValue::ExternalLinkage,
Name + ".cfi_jt", &M);
FDecl->setVisibility(GlobalValue::HiddenVisibility);
} else {
// Definition.
assert(isDefinition);
} else if (isDefinition) {
F->setName(Name + ".cfi");
F->setLinkage(GlobalValue::ExternalLinkage);
F->setVisibility(GlobalValue::HiddenVisibility);
FDecl = Function::Create(F->getFunctionType(), GlobalValue::ExternalLinkage,
Name, &M);
FDecl->setVisibility(Visibility);
} else {
// Function definition without type metadata, where some other translation
// unit contained a declaration with type metadata. This normally happens
// during mixed CFI + non-CFI compilation. We do nothing with the function
// so that it is treated the same way as a function defined outside of the
// LTO unit.
return;
}
if (F->isWeakForLinker())

View File

@ -16,4 +16,5 @@ CfiFunctionDefs:
CfiFunctionDecls:
- external
- external_weak
- local_decl
...

View File

@ -19,6 +19,10 @@ define i8 @use_b() {
ret i8 %x
}
define void @local_decl() {
call void @local_decl()
ret void
}
declare void @external()
declare extern_weak void @external_weak()
@ -33,6 +37,9 @@ declare extern_weak void @external_weak()
; CHECK: define internal i8 @local_b() {
; CHECK-NEXT: call i8 @local_a()
; CHECK: define void @local_decl()
; CHECK-NEXT: call void @local_decl()
; CHECK: declare void @external()
; CHECK: declare extern_weak void @external_weak()
; CHECK: declare i8 @local_a()