[llvm] r307744 - LowerTypeTests: When importing functions skip definitions where the summary contains a decl.

Peter Collingbourne via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 11 17:39:12 PDT 2017


Author: pcc
Date: Tue Jul 11 17:39:12 2017
New Revision: 307744

URL: http://llvm.org/viewvc/llvm-project?rev=307744&view=rev
Log:
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

Modified:
    llvm/trunk/lib/Transforms/IPO/LowerTypeTests.cpp
    llvm/trunk/test/Transforms/LowerTypeTests/Inputs/import-icall.yaml
    llvm/trunk/test/Transforms/LowerTypeTests/import-icall.ll

Modified: llvm/trunk/lib/Transforms/IPO/LowerTypeTests.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/LowerTypeTests.cpp?rev=307744&r1=307743&r2=307744&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/IPO/LowerTypeTests.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/LowerTypeTests.cpp Tue Jul 11 17:39:12 2017
@@ -855,15 +855,20 @@ void LowerTypeTestsModule::importFunctio
     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())

Modified: llvm/trunk/test/Transforms/LowerTypeTests/Inputs/import-icall.yaml
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/LowerTypeTests/Inputs/import-icall.yaml?rev=307744&r1=307743&r2=307744&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/LowerTypeTests/Inputs/import-icall.yaml (original)
+++ llvm/trunk/test/Transforms/LowerTypeTests/Inputs/import-icall.yaml Tue Jul 11 17:39:12 2017
@@ -16,4 +16,5 @@ CfiFunctionDefs:
 CfiFunctionDecls:
   - external
   - external_weak
+  - local_decl
 ...

Modified: llvm/trunk/test/Transforms/LowerTypeTests/import-icall.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/LowerTypeTests/import-icall.ll?rev=307744&r1=307743&r2=307744&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/LowerTypeTests/import-icall.ll (original)
+++ llvm/trunk/test/Transforms/LowerTypeTests/import-icall.ll Tue Jul 11 17:39:12 2017
@@ -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()




More information about the llvm-commits mailing list