Skip to content

Commit

Permalink
LowerTypeTests: When importing functions skip definitions where the s…
Browse files Browse the repository at this point in the history
…ummary 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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@307744 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
pcc committed Jul 12, 2017
1 parent 3b58ca7 commit 8a1e607
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
11 changes: 8 additions & 3 deletions lib/Transforms/IPO/LowerTypeTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
1 change: 1 addition & 0 deletions test/Transforms/LowerTypeTests/Inputs/import-icall.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ CfiFunctionDefs:
CfiFunctionDecls:
- external
- external_weak
- local_decl
...
7 changes: 7 additions & 0 deletions test/Transforms/LowerTypeTests/import-icall.ll
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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()
Expand Down

0 comments on commit 8a1e607

Please sign in to comment.