Skip to content

Commit cacac6a

Browse files
committedJul 12, 2017
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
1 parent 68fbf85 commit cacac6a

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed
 

‎llvm/lib/Transforms/IPO/LowerTypeTests.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -855,15 +855,20 @@ void LowerTypeTestsModule::importFunction(Function *F, bool isDefinition) {
855855
FDecl = Function::Create(F->getFunctionType(), GlobalValue::ExternalLinkage,
856856
Name + ".cfi_jt", &M);
857857
FDecl->setVisibility(GlobalValue::HiddenVisibility);
858-
} else {
859-
// Definition.
860-
assert(isDefinition);
858+
} else if (isDefinition) {
861859
F->setName(Name + ".cfi");
862860
F->setLinkage(GlobalValue::ExternalLinkage);
863861
F->setVisibility(GlobalValue::HiddenVisibility);
864862
FDecl = Function::Create(F->getFunctionType(), GlobalValue::ExternalLinkage,
865863
Name, &M);
866864
FDecl->setVisibility(Visibility);
865+
} else {
866+
// Function definition without type metadata, where some other translation
867+
// unit contained a declaration with type metadata. This normally happens
868+
// during mixed CFI + non-CFI compilation. We do nothing with the function
869+
// so that it is treated the same way as a function defined outside of the
870+
// LTO unit.
871+
return;
867872
}
868873

869874
if (F->isWeakForLinker())

‎llvm/test/Transforms/LowerTypeTests/Inputs/import-icall.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,5 @@ CfiFunctionDefs:
1616
CfiFunctionDecls:
1717
- external
1818
- external_weak
19+
- local_decl
1920
...

‎llvm/test/Transforms/LowerTypeTests/import-icall.ll

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ define i8 @use_b() {
1919
ret i8 %x
2020
}
2121

22+
define void @local_decl() {
23+
call void @local_decl()
24+
ret void
25+
}
2226

2327
declare void @external()
2428
declare extern_weak void @external_weak()
@@ -33,6 +37,9 @@ declare extern_weak void @external_weak()
3337
; CHECK: define internal i8 @local_b() {
3438
; CHECK-NEXT: call i8 @local_a()
3539

40+
; CHECK: define void @local_decl()
41+
; CHECK-NEXT: call void @local_decl()
42+
3643
; CHECK: declare void @external()
3744
; CHECK: declare extern_weak void @external_weak()
3845
; CHECK: declare i8 @local_a()

0 commit comments

Comments
 (0)
Please sign in to comment.