Disabling certain optimizations in llvm-gcc and llc

Hi all,

I’m trying to prevent two things from happening:

  1. Intrinsic memcpy calls of for example 16 bytes in the IR code being translated into movl commands in x86 assembly code, for example, this code:
    call void @llvm.memcpy.p0i8.p0i8.i32(i8* %3, i8* getelementptr inbounds ([16 x i8]* @.str1, i32 0, i32 0), i32 16, i32 1, i1 false)
    translated into this x86 assembly
    movl $6384738, 12(%ecx) # imm = 0x616C62
    movl $543452274, 8(%ecx) # imm = 0x20646C72
    movl $1870078063, 4(%ecx) # imm = 0x6F77206F
    movl $1819043176, (%ecx) # imm = 0x6C6C6568
    this happens even if I run llc -O0. Any way to prevent it, instead calling memcpy in the assembly listing?

  2. sizeof’s being resolved to literals already at the llvm-gcc front end stage when emitting IR, no matter if I use -O0 flag Is there any way to prevent it?

Thanks a lot in advance!

Harel Cain

Hi Harel,

I'm trying to prevent two things from happening:

1. Intrinsic memcpy calls of for example 16 bytes in the IR code being
translated into movl commands in x86 assembly code, for example, this code:
         call void @llvm.memcpy.p0i8.p0i8.i32(i8* %3, i8* getelementptr inbounds
([16 x i8]* @.str1, i32 0, i32 0), i32 16, i32 1, i1 false)
translated into this x86 assembly
         movl $6384738, 12(%ecx) # imm = 0x616C62
         movl $543452274, 8(%ecx) # imm = 0x20646C72
         movl $1870078063, 4(%ecx) # imm = 0x6F77206F
         movl $1819043176, (%ecx) # imm = 0x6C6C6568
this happens even if I run llc -O0. Any way to prevent it, instead calling
memcpy in the assembly listing?

-fno-builtin

2. sizeof's being resolved to literals already at the llvm-gcc front end stage
when emitting IR, no matter if I use -O0 flag Is there any way to prevent it?

No. The GCC parts of llvm-gcc fold sizeof to a constant long before it hits
the LLVM parts.

Best wishes, Duncan.

Hello

2. sizeof's being resolved to literals already at the llvm-gcc front end
stage when emitting IR, no matter if I use -O0 flag Is there any way to
prevent it?

No. It's performed even before IR emission.