Skip to content

Commit 35f8ef5

Browse files
committed
More reponses to review comments by @gribozavr.
One larger change is that we're now also running this test in C as well as C++.
1 parent e31c7bc commit 35f8ef5

File tree

5 files changed

+42
-31
lines changed

5 files changed

+42
-31
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#ifdef __cplusplus
2+
#define INLINE inline
3+
#else
4+
// When compiling as C, make the functions `static inline`. This is the flavor
5+
// of inline functions for which we require the behavior checked by this test.
6+
// Non-static C inline functions don't require Swift to emit LLVM IR for them
7+
// because the idea is that there will we one `.c` file that declares them
8+
// `extern inline`, causing an out-of-line definition to be emitted to the
9+
// corresponding .o file.
10+
#define INLINE static inline
11+
#endif
12+
13+
INLINE int notCalled() {
14+
return 42;
15+
}
16+
17+
INLINE int calledTransitively() {
18+
return 42;
19+
}
20+
21+
INLINE int calledFromSwift() {
22+
return calledTransitively();
23+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Test that we emit LLVM IR for inline functions that are called directly or
2+
// transitively from Swift.
3+
//
4+
// Test that we don't emit LLVM IR for inline functions that are not called from
5+
// Swift.
6+
7+
// RUN: %empty-directory(%t)
8+
// RUN: %target-swift-frontend %s -I %S/Inputs -Xcc -std=c99 -emit-ir -o - | %FileCheck %s -check-prefix C99 --implicit-check-not notCalled
9+
// RUN: %target-swift-frontend %s -I %S/Inputs -enable-cxx-interop -emit-ir -o - | %FileCheck %s -check-prefix CXX --implicit-check-not notCalled
10+
11+
import EmitCalledFunction
12+
13+
// C99-DAG: define internal i32 @calledFromSwift() #{{[0-9]+}} {
14+
// C99-DAG: define internal i32 @calledTransitively() #{{[0-9]+}} {
15+
16+
// CXX-DAG: define linkonce_odr i32 @_Z15calledFromSwiftv() #{{[0-9]+}} comdat {
17+
// CXX-DAG: define linkonce_odr i32 @_Z18calledTransitivelyv() #{{[0-9]+}} comdat {
18+
19+
calledFromSwift()

test/Interop/Cxx/function/Inputs/emit-called-function.h

Lines changed: 0 additions & 11 deletions
This file was deleted.

test/Interop/Cxx/function/emit-called-function-irgen.swift

Lines changed: 0 additions & 20 deletions
This file was deleted.

0 commit comments

Comments
 (0)