Keil Logo

Technical Support

On-Line Manuals

Compiler Reference Guide

Preface armclang Command-line Options Support level definitions Summary of armclang command-line options -C -c -D -E -e -fbare-metal-pie -fbracket-depth=N -fcommon, -fno-common -fdata-sections, -fno-data-sections -ffast-math, -fno-fast-math -ffixed-rN -ffp-mode -ffunction-sections, -fno-function-sections -fident, -fno-ident @file -fldm-stm, -fno-ldm-stm -fno-builtin -fno-inline-functions -flto, -fno-lto -fexceptions, -fno-exceptions -fomit-frame-pointer, -fno-omit-frame-pointer -fropi, -fno-ropi -fropi-lowering, -fno-ropi-lowering -frwpi, -fno-rwpi -frwpi-lowering, -fno-rwpi-lowering -fshort-enums, -fno-short-enums -fshort-wchar, -fno-short-wchar -fstack-protector, -fstack-protector-all, -fstack- -fstrict-aliasing, -fno-strict-aliasing -ftrapv -fvectorize, -fno-vectorize -fvisibility -fwrapv -g, -gdwarf-2, -gdwarf-3, -gdwarf-4 -I -include -L -l -M, -MM -MD, -MMD -MF -MG -MP -MT -march -marm -masm -mbig-endian -mbranch-protection -mcmse -mcpu -mexecute-only -mfloat-abi -mfpu -mimplicit-it -mlittle-endian -mmemtag-stack, -mno-memtag-stack -mno-neg-immediates -moutline, -mno-outline -mpixolib -munaligned-access, -mno-unaligned-access -mthumb -nostdlib -nostdlibinc -o -O -pedantic -pedantic-errors -Rpass -S -save-temps -std --target -U -u -v --version --version_number --vsn -W -Wl -Xlinker -x -### Compiler-specific Keywords and Operators Compiler-specific Function, Variable, and Type Att Compiler-specific Intrinsics Compiler-specific Pragmas Other Compiler-specific Features Standard C Implementation Definition Standard C++ Implementation Definition armclang Integrated Assembler armclang Inline Assembler

-moutline, -mno-outline

1.61 -moutline, -mno-outline

The outliner searches for identical sequences of code and puts them in a separate function. The outliner then replaces the original sequences of code with calls to this function.

Outlining reduces code size, but it can increase the execution time. The operation of -moutline depends on the optimization level and the complexity of the code.

Note:

-moutline is only supported in AArch64 state.

Default

If the optimization level is -Oz, the default is -moutline. Otherwise the default is -mno-outline.

Syntax

-moutline
Enables outlining.
-mno-outline
Disables outlining.

Parameters

None.

Restrictions

Inline assembly might prevent the outlining of functions.

Examples

This example uses the following C file to show the effects of -moutline:

// foo.c

int func3(int x)
{
    return x*x;
}

int func1(int x)
{
    int i = x;
    i = i * i;
    i+=1;
    //i=func3(i);
    i+=2;
    
    return i;
}

char func2(char x)
{
    int i = x;
    i = i * i;
    i+=1;
    //i=func3(i);
    i+=2;
    
    return i;
}

Compile using -S to output the disassembly to a file as follows:

armclang.exe --target=aarch64-arm-none-eabi -march=armv8.5-a -moutline foo.c -S -o foo.s
armclang.exe --target=aarch64-arm-none-eabi -march=armv8.5-a -moutline foo.c -S -O1 -o foo_O1.s
armclang.exe --target=aarch64-arm-none-eabi -march=armv8.5-a -moutline foo.c -S -O2 -o foo_O2.s

Enable the calls to func3 in foo.c, recompile with -O1 and -O2 and _func3 appended to the output assembly filenames. The following tables show comparisons of the output:

  • With no optimization and with -O1 and the calls to func3 disabled.
  • With no optimization and with -O2 and the calls to func3 enabled.

Compiler-generated comments have been removed for brevity.

Functions func1 and func2 are outlined at -O1, as shown in foo_01.s.

If you enable the calls to func3 and recompile with -O1, then no outlining occurs as shown in foo_01_func3.s. This case is not shown in the tables.

If you enable the calls to func3 and recompile with -O2, then outlining occurs as shown in foo_02_func3.s.

Table 1-7 Comparison of disassembly for -moutline with and without -O1 optimization

No optimization (foo.s) -O1 (foo_01.s)
func3:
// %bb.0:
  sub	sp, sp, #16
  str	w0, [sp, #12]
  ldr	w0, [sp, #12]
  ldr	w8, [sp, #12]
  mul	w0, w0, w8
  add	sp, sp, #16
  ret
.Lfunc_end0:

...

func1:
// %bb.0:
  sub	sp, sp, #16
  str	w0, [sp, #12]
  ldr	w0, [sp, #12]

...

  ldr	w0, [sp, #8]
  add	sp, sp, #16
  ret
.Lfunc_end1:

...

func2:
// %bb.0:
	sub	sp, sp, #16
	strb	w0, [sp, #15]
	ldrb	w0, [sp, #15]

...

	mov	w0, w8
	add	sp, sp, #16
	ret
.Lfunc_end2:
func3:
// %bb.0:
	mul	w0, w0, w0
	ret
.Lfunc_end0:

...

func1:
// %bb.0:
  b	OUTLINED_FUNCTION_0
.Lfunc_end1:

...

func2:
// %bb.0:
  b	OUTLINED_FUNCTION_0

...

  .section	.text.OUTLINED_FUNCTION_0,"ax",@progbits
  .p2align	2
  .type	OUTLINED_FUNCTION_0,@function
OUTLINED_FUNCTION_0:
  .cfi_sections .debug_frame
  .cfi_startproc
// %bb.0:
  orr	w8, wzr, #0x3
  madd	w0, w0, w0, w8
  ret
.Lfunc_end3:
  .size	OUTLINED_FUNCTION_0, .Lfunc_end3-OUTLINED_FUNCTION_0
  .cfi_endproc

Table 1-8 Comparison of disassembly for -moutline with and without -O2 optimization and with func3 enabled

No optimization (foo_func3.s) -O2 and func3 enabled (foo_02_func3.s)
func3:
// %bb.0:
  sub	sp, sp, #16
  str	w0, [sp, #12]
  ldr	w0, [sp, #12]
  ldr	w8, [sp, #12]
  mul	w0, w0, w8
  add	sp, sp, #16
  ret
.Lfunc_end0:

...

func1:
// %bb.0:
  sub	sp, sp, #32
  str	x30, [sp, #16]
  str	w0, [sp, #12]

...

  ldr	x30, [sp, #16]
  add	sp, sp, #32
  ret
.Lfunc_end1:

...

func2:
// %bb.0:
	sub	sp, sp, #32
	str	x30, [sp, #16]
	strb	w0, [sp, #15]

...

	ldr	x30, [sp, #16]
	add	sp, sp, #32
	ret
.Lfunc_end2:
func3:
// %bb.0:
  mul	w0, w0, w0
  ret
.Lfunc_end0:

...

func1:
// %bb.0:
  orr	w8, wzr, #0x1
  madd	w8, w0, w0, w8
  b	OUTLINED_FUNCTION_0
.Lfunc_end1:

...

func2:
// %bb.0:
  and	w8, w0, #0xff
  orr	w9, wzr, #0x1
  madd	w8, w8, w8, w9
  b	OUTLINED_FUNCTION_0
.Lfunc_end2:
  .size	func2, .Lfunc_end2-func2

  .section	.text.OUTLINED_FUNCTION_0,"ax",@progbits
  .p2align	2
  .type	OUTLINED_FUNCTION_0,@function
OUTLINED_FUNCTION_0:
  .cfi_sections .debug_frame
  .cfi_startproc
// %bb.0:
  orr	w9, wzr, #0x2
  madd	w0, w8, w8, w9
  ret
.Lfunc_end3:
  .size	OUTLINED_FUNCTION_0, .Lfunc_end3-OUTLINED_FUNCTION_0
  .cfi_endproc
Non-ConfidentialPDF file icon PDF version100067_0612_00_en
Copyright © 2014–2019 Arm Limited or its affiliates. All rights reserved. 
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.