<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#ffffff">
On 12/7/10 10:46 AM, Andrew Lukefahr wrote:
<blockquote
cite="mid:AANLkTikNj+Bas3juThEFt6O=76QO6rjVoGVXW0JCEhRL@mail.gmail.com"
type="cite">Ok, <br>
<br>
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. <br>
</blockquote>
<br>
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.<br>
<br>
-- John T.<br>
<br>
<blockquote
cite="mid:AANLkTikNj+Bas3juThEFt6O=76QO6rjVoGVXW0JCEhRL@mail.gmail.com"
type="cite">
<br>
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. )<br>
<br>
%mul_en = alloca i32<br>
%2 = mul nsw i32 %y, %x<br>
%mul_dis = alloca i32<br>
<br>
becomes...<br>
<br>
mul r12, r12, r0<br>
<br>
<br>
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. <br>
<br>
tail call void asm sideeffect "NOP", ""() nounwind<br>
%2 = mul nsw i32 %y, %x<br>
tail call void asm sideeffect "NOP", ""() nounwind<br>
<br clear="all">
becomes....<br>
<br>
mul r12, r12, r0<br>
...<br>
@APP<br>
NOP<br>
@NO_APP<br>
@APP<br>
NOP<br>
@NO_APP<br>
<br>
<br>
Andrew Lukefahr<br>
<a moz-do-not-send="true" href="mailto:andrewlukefahr@gmail.com"
target="_blank">andrewlukefahr@gmail.com</a><br>
<br>
Open Source, Open Minds<br>
<br>
<br>
<div class="gmail_quote">On Mon, Dec 6, 2010 at 2:08 PM, Jim
Grosbach <span dir="ltr"><<a moz-do-not-send="true"
href="mailto:grosbach@apple.com" target="_blank">grosbach@apple.com</a>></span>
wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt
0.8ex; border-left: 1px solid rgb(204, 204, 204);
padding-left: 1ex;">
<div><br>
On Dec 6, 2010, at 10:57 AM, John Criswell wrote:<br>
<br>
> On 12/6/10 11:39 AM, Andrew Lukefahr wrote:<br>
>> Hi,<br>
>><br>
>> 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?<br>
><br>
> You can use llc --help-hidden to see a list of options.
There are several -disable-xxx options that disable various
code generator optimizations.<br>
><br>
> 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?<br>
><br>
<br>
<br>
</div>
Perhaps the dead machine instruction elimination pass?
(DeadMachineInstructionElim.cpp) I don't think there's a way
to disable that.<br>
<font color="#888888"><br>
-Jim<br>
<br>
</font></blockquote>
</div>
<br>
</blockquote>
<br>
</body>
</html>