[LLVMdev] disable llc optimizations

642 views
Skip to first unread message

Andrew Lukefahr

unread,
Dec 6, 2010, 12:39:46 PM12/6/10
to llvmdev
Hi,

How would I disable dead code elimination in llc?  Can that be done via the command line or do I need to modify llc's source? 

Thanks

Andrew Lukefahr
andrewl...@gmail.com

Open Source, Open Minds

Duncan Sands

unread,
Dec 6, 2010, 1:11:15 PM12/6/10
to llv...@cs.uiuc.edu
Hi Andrew,

> How would I disable dead code elimination in llc? Can that be done via the
> command line or do I need to modify llc's source?

I don't think llc does non-trivial dead code elimination (though I could be
wrong). Did you mean "opt"?

Ciao, Duncan.
_______________________________________________
LLVM Developers mailing list
LLV...@cs.uiuc.edu http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev

John Criswell

unread,
Dec 6, 2010, 1:57:25 PM12/6/10
to Andrew Lukefahr, llv...@cs.uiuc.edu
On 12/6/10 11:39 AM, Andrew Lukefahr wrote:
Hi,

How would I disable dead code elimination in llc?  Can that be done via the command line or do I need to modify llc's source? 

You can use llc --help-hidden to see a list of options.  There are several -disable-xxx options that disable various code generator optimizations.

That said, I, like Duncan, wasn't aware that llc did any dead-code elimination (beyond peephole optimization).  Are you sure llc is removing the instructions you care about?

-- John T.

Jim Grosbach

unread,
Dec 6, 2010, 2:08:23 PM12/6/10
to John Criswell, Andrew Lukefahr, llv...@cs.uiuc.edu

On Dec 6, 2010, at 10:57 AM, John Criswell wrote:

> On 12/6/10 11:39 AM, Andrew Lukefahr wrote:
>> Hi,
>>
>> How would I disable dead code elimination in llc? Can that be done via the command line or do I need to modify llc's source?
>
> You can use llc --help-hidden to see a list of options. There are several -disable-xxx options that disable various code generator optimizations.
>
> That said, I, like Duncan, wasn't aware that llc did any dead-code elimination (beyond peephole optimization). Are you sure llc is removing the instructions you care about?
>


Perhaps the dead machine instruction elimination pass? (DeadMachineInstructionElim.cpp) I don't think there's a way to disable that.

-Jim

Andrew Lukefahr

unread,
Dec 7, 2010, 11:46:45 AM12/7/10
to llv...@cs.uiuc.edu
Ok,

I'm trying to get llvm to decide when to turn the multiplier "on" and "off" for an ARM simulator.  These instructions are just to let the simulator know when to power on/off the multiplier.  I need to insert an instruction before the first multiply and another one after the last multiply in a basic block.  I'm currently trying to figure out the best way to do that without having to add a new instruction to llvm. 

My plan was to insert useless instructions, let llc generate an assembly (.s) file, then use sed to replace the useless instructions with my special instructions.  However, llc eliminates my useless instructions. ( Allocas and binary operators go away,  volatile loads and stores change the register allocation. )

%mul_en = alloca i32
%2 = mul nsw i32 %y, %x
%mul_dis = alloca i32

becomes...

mul r12, r12, r0


Next I tried using llvm-dis and llvm-as to manually replace my useless instructions with a inline no-op in the .bc file.  However, llc then  moves the volatile no-op below the multiply. 

tail call void asm sideeffect "NOP", ""() nounwind
%2 = mul nsw i32 %y, %x
tail call void asm sideeffect "NOP", ""() nounwind

becomes....

mul r12, r12, r0
...
@APP
NOP
@NO_APP
@APP
NOP
@NO_APP



Andrew Lukefahr
andrewl...@gmail.com

Open Source, Open Minds


John Criswell

unread,
Dec 7, 2010, 12:33:04 PM12/7/10
to llv...@cs.uiuc.edu
On 12/7/10 10:46 AM, Andrew Lukefahr wrote:
Ok,

I'm trying to get llvm to decide when to turn the multiplier "on" and "off" for an ARM simulator.  These instructions are just to let the simulator know when to power on/off the multiplier.  I need to insert an instruction before the first multiply and another one after the last multiply in a basic block.  I'm currently trying to figure out the best way to do that without having to add a new instruction to llvm. 

Can you use inline assembly to insert your instructions?  I think the LLVM IR optimizers will leave inline assembly alone.  The only trick then is to use an inline assembly sequence that doesn't appear as dead code to the code generator.

-- John T.
Reply all
Reply to author
Forward
0 new messages