<html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div>Hi,</div><div><br></div><div>I’ve noticed that all the work performed by the GlobalMerge pass is done within the doInitialization method.</div><div>It’s unclear to me if it is a valid design or not, because according to <a href="http://llvm.org/docs/WritingAnLLVMPass.html#the-functionpass-class:">http://llvm.org/docs/WritingAnLLVMPass.html#the-functionpass-class:</a></div><div>- On one hand:</div><div>FunctionPass subclasses are not allowed to:</div><div>[…]</div><div>3. Add or remove global variables from the current Module.</div><div>- On the other hand:</div><div>The doInitialization method is allowed to do most of the things that FunctionPasses are not allowed to do.</div><div><br></div><div>What is clear however is: This design prevents other passes to take advantage of this pass. Let’s say I write a pass A that creates some global variables and I’d like to see these variables merged. Thus, I’ll add GlobalMerge pass after A. This does not work unless I push all the work of pass A into doInitialization…</div><div><br></div><div>The proposed patch turns GlobalMerge into a ModulePass and move all its work in runOnModule method.</div><div>Although this patch does not intend to make any functionality change it seems that the phase ordering implied by this design was expected!</div><div><br></div><div>Indeed, with this patch I have two make check failures related to debug info:</div><div><font face="Courier New">test/CodeGen/ARM/2011-01-19-MergedGlobalDbg.ll:26:14: error: expected string not found in input</font></div><div><font face="Courier New">;CHECK-NEXT: .long __MergedGlobals</font></div><div><font face="Courier New">             ^</font></div><div><font face="Courier New"><stdin>:233:2: note: scanning from here</font></div><div><font face="Courier New"> .long _x2</font></div><div><font face="Courier New"> ^</font></div><div><font face="Courier New">--</font></div><div>and</div><div><font face="Courier New">test/CodeGen/ARM/2011-08-02-MergedGlobalDbg.ll:17:14: error: expected string not found in input</font></div><div><font face="Courier New">;CHECK-NEXT: .long __MergedGlobals</font></div><div><font face="Courier New">             ^</font></div><div><font face="Courier New"><stdin>:205:2: note: scanning from here</font></div><div><font face="Courier New"> .long _x2</font></div><div><font face="Courier New"> ^</font></div><div><font face="Courier New">—</font></div><div><br></div><div>Any ideas on how I can fix those?</div><div><br></div><div>-Quentin</div><div></div></body></html>