Missing SSA Info<p>I am having some problems with SSA.</p> <p align=left> </p> <p align=left>I generate SssaInfo at the beginning of the plugin, perform my transformations, and then I perform SsaInfo-&gt;Delete(), recreate SsaInfo, and rerun Build.</p> <p align=left> </p> <p align=left>The SSA information is regenerated fine for most of the program. However, it seems like VariableOperands that I created during my transformations do not have SSA information on them.</p> <p align=left> </p> <p align=left>For example, I create a counter operand as follows:</p> <p align=left> </p> <p align=left> <div class=codeseg> <div class=codecontent> <div class=codesniptitle><span style="width:100%">Code Snippet</span></div> <div class=codesniptitle> </div> <p align=left>search_name = Phx::Name::New(functionUnit-&gt;Lifetime, &quot;outerCounter0&quot;);</p> <p align=left>Phx::Symbols::LocalVariableSymbol ^new_counter_symbol =<br> Phx::Symbols::LocalVariableSymbol::NewAuto <br> (functionUnit-&gt;SymbolTable, 0, search_name,<br>  functionUnit-&gt;TypeTable-&gt;Int32Type);</p> <p align=left>Operand ^outerCounterOperand =<br> VariableOperand::New<br> (functionUnit, new_counter_symbol-&gt;Type, new_counter_symbol);</p> <p align=left> </p></div></div> <p align=left> </p> <p></p> <p align=left><br></p> <p align=left>However, even after using the outerCounter Operand repeatedly, there doesn't appear to be have been any SSA information generated for it.</p> <p align=left> </p> <p align=left>==== BasicBlock 16 Predecessor(5) Successor(20) previous 15 next 17<br>$L20: (references=1)                                                        #65<br>   outerCounter0     = ASSIGN 0                                             #65<br>                       GOTO $L24                                            #65<br>==== BasicBlock 17 Predecessor(36,35,34,7) Successor(28) previous 16 next 18<br>$L21: (references=4)                                                        #65<br>   stCoalesceCounter0 = ASSIGN 0                                            #65<br>   tv354-&lt;5&gt;         = MULTIPLY outerCounter0, 32(0x00000020)               #65<br>   t355              = CONVERT <a title="mailto:&amp;?threadIdx@@3Udim3@@A" href="mailto:&amp;?threadIdx@@3Udim3@@A">&amp;?threadIdx@@3Udim3@@A</a>                       #65<br>   thix              = ASSIGN t355                                          #65<br>   stModedCounter0   = ADD tv354-&lt;5&gt;, thix                                  #65<br>                       GOTO $L32                                            #65<br>==== BasicBlock 18 Predecessor(28) Successor(20) previous 17 next 19<br>$L22: (references=1)                                                        #65<br>   outerCounter0     = ADD outerCounter0, 1                                 #65<br>                       GOTO $L24                                            #65<br></p> <p align=left>If anyone can shed some light on this, I would really appreciate it.</p> <p align=left> </p> <p align=left>Thank you,</p> <p align=left>Sain</p>© 2009 Microsoft Corporation. Todos los derechos reservados.Thu, 19 Jun 2008 00:15:52 Z48e9c566-81d0-4fe1-ae14-775865c59727http://social.msdn.microsoft.com/Forums/es-ES/phoenix/thread/48e9c566-81d0-4fe1-ae14-775865c59727#48e9c566-81d0-4fe1-ae14-775865c59727http://social.msdn.microsoft.com/Forums/es-ES/phoenix/thread/48e9c566-81d0-4fe1-ae14-775865c59727#48e9c566-81d0-4fe1-ae14-775865c59727Sain-Zee Uenghttp://social.msdn.microsoft.com/Profile/es-ES/?user=Sain-Zee%20UengMissing SSA Info<p>I am having some problems with SSA.</p> <p align=left> </p> <p align=left>I generate SssaInfo at the beginning of the plugin, perform my transformations, and then I perform SsaInfo-&gt;Delete(), recreate SsaInfo, and rerun Build.</p> <p align=left> </p> <p align=left>The SSA information is regenerated fine for most of the program. However, it seems like VariableOperands that I created during my transformations do not have SSA information on them.</p> <p align=left> </p> <p align=left>For example, I create a counter operand as follows:</p> <p align=left> </p> <p align=left> <div class=codeseg> <div class=codecontent> <div class=codesniptitle><span style="width:100%">Code Snippet</span></div> <div class=codesniptitle> </div> <p align=left>search_name = Phx::Name::New(functionUnit-&gt;Lifetime, &quot;outerCounter0&quot;);</p> <p align=left>Phx::Symbols::LocalVariableSymbol ^new_counter_symbol =<br> Phx::Symbols::LocalVariableSymbol::NewAuto <br> (functionUnit-&gt;SymbolTable, 0, search_name,<br>  functionUnit-&gt;TypeTable-&gt;Int32Type);</p> <p align=left>Operand ^outerCounterOperand =<br> VariableOperand::New<br> (functionUnit, new_counter_symbol-&gt;Type, new_counter_symbol);</p> <p align=left> </p></div></div> <p align=left> </p> <p></p> <p align=left><br></p> <p align=left>However, even after using the outerCounter Operand repeatedly, there doesn't appear to be have been any SSA information generated for it.</p> <p align=left> </p> <p align=left>==== BasicBlock 16 Predecessor(5) Successor(20) previous 15 next 17<br>$L20: (references=1)                                                        #65<br>   outerCounter0     = ASSIGN 0                                             #65<br>                       GOTO $L24                                            #65<br>==== BasicBlock 17 Predecessor(36,35,34,7) Successor(28) previous 16 next 18<br>$L21: (references=4)                                                        #65<br>   stCoalesceCounter0 = ASSIGN 0                                            #65<br>   tv354-&lt;5&gt;         = MULTIPLY outerCounter0, 32(0x00000020)               #65<br>   t355              = CONVERT <a title="mailto:&amp;?threadIdx@@3Udim3@@A" href="mailto:&amp;?threadIdx@@3Udim3@@A">&amp;?threadIdx@@3Udim3@@A</a>                       #65<br>   thix              = ASSIGN t355                                          #65<br>   stModedCounter0   = ADD tv354-&lt;5&gt;, thix                                  #65<br>                       GOTO $L32                                            #65<br>==== BasicBlock 18 Predecessor(28) Successor(20) previous 17 next 19<br>$L22: (references=1)                                                        #65<br>   outerCounter0     = ADD outerCounter0, 1                                 #65<br>                       GOTO $L24                                            #65<br></p> <p align=left>If anyone can shed some light on this, I would really appreciate it.</p> <p align=left> </p> <p align=left>Thank you,</p> <p align=left>Sain</p>Tue, 29 Apr 2008 18:21:40 Z2008-04-29T18:21:40Zhttp://social.msdn.microsoft.com/Forums/es-ES/phoenix/thread/48e9c566-81d0-4fe1-ae14-775865c59727#288b1935-0288-4f5e-a095-7f2cbbdf8284http://social.msdn.microsoft.com/Forums/es-ES/phoenix/thread/48e9c566-81d0-4fe1-ae14-775865c59727#288b1935-0288-4f5e-a095-7f2cbbdf8284Andy Ayers - MSFThttp://social.msdn.microsoft.com/Profile/es-ES/?user=Andy%20Ayers%20-%20MSFTMissing SSA Info<p>I would guess that for some reason we think your new variables are aliased, and you are building SSA for unaliased only. Are you taking the address of &amp;outerCounter0 anywhere?</p> <p align=left> </p> <p align=left>To confirm this, can you try building SSA for aliased (that is, set your ssa build attribute to Aliased) -- and see if this puts your new locals into SSA form?</p> <p align=left><font face=Arial size=2></font> </p>Wed, 30 Apr 2008 18:59:14 Z2008-04-30T18:59:14Zhttp://social.msdn.microsoft.com/Forums/es-ES/phoenix/thread/48e9c566-81d0-4fe1-ae14-775865c59727#7132eed9-2605-4023-885f-76a9851e3dabhttp://social.msdn.microsoft.com/Forums/es-ES/phoenix/thread/48e9c566-81d0-4fe1-ae14-775865c59727#7132eed9-2605-4023-885f-76a9851e3dabSain-Zee Uenghttp://social.msdn.microsoft.com/Profile/es-ES/?user=Sain-Zee%20UengMissing SSA InfoNo, I'm not taking the address of outerCounter0. <p align=left><font face=Arial size=2></font> </p> <p>By building SSA for aliased, do you mean like the following?</p> <p align=left> </p> <p align=left> <div class=codeseg> <div class=codecontent> <div class=codesniptitle><span style="width:100%">Code Snippet</span></div> <p align=left>      functionUnit-&gt;SsaInfo = Phx::SSA::Info::New(functionUnit-&gt;Lifetime, functionUnit, <br>       Phx::SSA::Attribute::Aliased,<br>       Phx::SSA::BuildOption::Default);</p> <p align=left> </p></div></div> <p align=left> </p> <p></p> <p align=left> </p> <p>I was originally using NotAliasedScalars. Unfortunately, switching to Aliased did not put he new locals into SSA form.</p> <p align=left> </p> <p align=left>Thank you,</p> <p align=left>Sain</p>Wed, 30 Apr 2008 20:04:47 Z2008-04-30T20:04:47Zhttp://social.msdn.microsoft.com/Forums/es-ES/phoenix/thread/48e9c566-81d0-4fe1-ae14-775865c59727#68691962-57cc-459a-8466-14b7835ea574http://social.msdn.microsoft.com/Forums/es-ES/phoenix/thread/48e9c566-81d0-4fe1-ae14-775865c59727#68691962-57cc-459a-8466-14b7835ea574Andy Ayers - MSFThttp://social.msdn.microsoft.com/Profile/es-ES/?user=Andy%20Ayers%20-%20MSFTMissing SSA Info<p>Yes, that's what I meant. But evidently the problem is elsewhere.</p> <p align=left> </p> <p align=left>When are you running your plugin (after which phase)? If I modify the Loop Instrumentation sample to build SSA after it finishes instrumentation, the newly introduced loop counters are put into SSA form.</p> <p align=left><font face=Arial size=2></font> </p>Thu, 08 May 2008 00:31:24 Z2008-05-08T00:31:24Zhttp://social.msdn.microsoft.com/Forums/es-ES/phoenix/thread/48e9c566-81d0-4fe1-ae14-775865c59727#8a3cdf02-b91a-44ee-b431-5b3ada5a47e4http://social.msdn.microsoft.com/Forums/es-ES/phoenix/thread/48e9c566-81d0-4fe1-ae14-775865c59727#8a3cdf02-b91a-44ee-b431-5b3ada5a47e4Sain-Zee Uenghttp://social.msdn.microsoft.com/Profile/es-ES/?user=Sain-Zee%20UengMissing SSA Info<p>Hello Andy,</p> <p align=left> </p> <p align=left>I'm sorry, but I made a mistake. Changing the SSA build to Aliased does produce SSA info for all of my new local variables. However, it also introduces CHI instructions and {Virtual} Operands.</p> <p align=left> </p> <p align=left>I was using SSA to trace back along the DefinitionOperand to generate the expression for certain instructions. My current expression generation algorithm now gets trapped by the {Virtual} Operands and the CHI instructions, since parts of the expression do touch memory access.</p> <p align=left> </p> <p align=left>Could you perhaps explain in more detail what these constructs are for and if there is some way I can get around this problem?</p> <p align=left> </p> <p align=left>Thank you,</p> <p align=left>Sain</p>Thu, 08 May 2008 01:28:29 Z2008-05-08T01:28:29Zhttp://social.msdn.microsoft.com/Forums/es-ES/phoenix/thread/48e9c566-81d0-4fe1-ae14-775865c59727#b5caa2ad-7fc9-4b28-ad13-532b1a5062c2http://social.msdn.microsoft.com/Forums/es-ES/phoenix/thread/48e9c566-81d0-4fe1-ae14-775865c59727#b5caa2ad-7fc9-4b28-ad13-532b1a5062c2Andy Ayers - MSFThttp://social.msdn.microsoft.com/Profile/es-ES/?user=Andy%20Ayers%20-%20MSFTMissing SSA Info<p>The CHI's and virtual operands are there to record alias interference. Aliased locations are partitioned into equivalence classes, and each class is given a virtual variable to represent the class as a whole. Each operation that potentially updates a class member must be followed by a CHI that merges this update back into the whole. In some cases (eg calls that can throw) the merge information needs to be recorded on the updating instruction directly.</p> <p align=left> </p> <p align=left>If you don't care about aliasing then you can just walk back through a chain of CHIs to find the individual updates to the locations. Or you can be a bit more careful and follow the chain back only if the CHIs you skip through modify non-overlapping parts of the partition (SSA building already tries to do this, but it gives up after some number of CHIs).</p> <p align=left> </p> <p align=left>More specifically, suppose y is an aliased location, and you're at a use of y, and the definition of y is a virtual varible at a CHI. Look at the first source operand of the CHI -- this represents the specific part of the update. If that source operand is y then walk back from that to the definition to find the &quot;real&quot; defintion for y. If the source operand is something that partially overlaps with y then you have potential aliasing and need to decide what the appropriate action is for whatever it is you are trying to do.</p> <p align=left><font face=Arial size=2></font> </p>Fri, 09 May 2008 16:59:10 Z2008-05-09T16:59:10Zhttp://social.msdn.microsoft.com/Forums/es-ES/phoenix/thread/48e9c566-81d0-4fe1-ae14-775865c59727#efe05e73-e511-417a-94ba-a426364ad025http://social.msdn.microsoft.com/Forums/es-ES/phoenix/thread/48e9c566-81d0-4fe1-ae14-775865c59727#efe05e73-e511-417a-94ba-a426364ad025Sain-Zee Uenghttp://social.msdn.microsoft.com/Profile/es-ES/?user=Sain-Zee%20UengMissing SSA Info<p>Hello Andy,</p> <p align=left> </p> <p align=left>I have not looked into getting around CHIs yet, but I've found an alternative to my problem.</p> <p align=left> </p> <p align=left>I had used AllMemoryTag for some of the Address Operands that I was inserting. I switched to NotAliasedMemoryTag and SSA builds fine using NotAliasedScalars. This should be fine for me since I'm basically loading from memory for the most part and I understand that the few writes I do are safe.</p> <p align=left> </p> <p align=left>Hopefully this alternative will be sufficient for my work. <img height=19 alt=Smile src="http://forums.microsoft.com/MSDN/emoticons/emotion-1.gif" width=19></p> <p align=left> </p> <p align=left>Thanks for all of your help.</p> <p align=left> </p> <p align=left>Sain</p>Fri, 09 May 2008 19:42:40 Z2008-05-09T19:42:40Z