Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Driver] Add support for -finline-functions and /Ob2 flags
-finline-functions and /Ob2 are currently ignored by Clang. The only way to enable inlining is to use the global O flags, which also enable other options, or to emit LLVM bitcode using Clang, then running opt by hand with the inline pass. This patch allows to simply use the -finline-functions flag (same as GCC) or /Ob2 in clang-cl mode to enable inlining without other optimizations. This is the first patch of a serie to improve support for the /Ob flags. Patch by Rudy Pons <rudy.pons@ilod.org>! Differential Revision: http://reviews.llvm.org/D20576 llvm-svn: 270609
- Loading branch information
Showing
7 changed files
with
41 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// Make sure -finline-functions family flags are behaving correctly. | ||
|
||
// RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck -check-prefix=NOINLINE %s | ||
// RUN: %clang_cc1 -O3 -fno-inline-functions -emit-llvm %s -o - | FileCheck -check-prefix=NOINLINE %s | ||
// RUN: %clang_cc1 -finline-functions -emit-llvm %s -o - | FileCheck -check-prefix=INLINE %s | ||
|
||
inline int inline_hint(int a, int b) { return(a+b); } | ||
|
||
int inline_no_hint(int a, int b) { return (a/b); } | ||
|
||
inline __attribute__ ((__always_inline__)) int inline_always(int a, int b) { return(a*b); } | ||
|
||
volatile int *pa = (int*) 0x1000; | ||
void foo() { | ||
// NOINLINE-LABEL: @foo | ||
// INLINE-LABEL: @foo | ||
// NOINLINE: call i32 @inline_hint | ||
// INLINE-NOT: call i32 @inline_hint | ||
pa[0] = inline_hint(pa[1],pa[2]); | ||
// NOINLINE-NOT: call i32 @inline_always | ||
// INLINE-NOT: call i32 @inline_always | ||
pa[3] = inline_always(pa[4],pa[5]); | ||
// NOINLINE: call i32 @inline_no_hint | ||
// INLINE-NOT: call i32 @inline_no_hint | ||
pa[6] = inline_no_hint(pa[7], pa[8]); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters