[PATCH] Promote GlobalMerge pass to a ModulePass to ease reuse

Quentin Colombet qcolombet at apple.com
Tue Apr 16 16:27:23 PDT 2013


Hi,

I’ve noticed that all the work performed by the GlobalMerge pass is done within the doInitialization method.
It’s unclear to me if it is a valid design or not, because according to http://llvm.org/docs/WritingAnLLVMPass.html#the-functionpass-class:
- On one hand:
FunctionPass subclasses are not allowed to:
[…]
3. Add or remove global variables from the current Module.
- On the other hand:
The doInitialization method is allowed to do most of the things that FunctionPasses are not allowed to do.

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…

The proposed patch turns GlobalMerge into a ModulePass and move all its work in runOnModule method.
Although this patch does not intend to make any functionality change it seems that the phase ordering implied by this design was expected!

Indeed, with this patch I have two make check failures related to debug info:
test/CodeGen/ARM/2011-01-19-MergedGlobalDbg.ll:26:14: error: expected string not found in input
;CHECK-NEXT: .long __MergedGlobals
             ^
<stdin>:233:2: note: scanning from here
 .long _x2
 ^
--
and
test/CodeGen/ARM/2011-08-02-MergedGlobalDbg.ll:17:14: error: expected string not found in input
;CHECK-NEXT: .long __MergedGlobals
             ^
<stdin>:205:2: note: scanning from here
 .long _x2
 ^
—

Any ideas on how I can fix those?

-Quentin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130416/eb36238e/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: GlobalMergeToModulePass.patch
Type: application/octet-stream
Size: 2128 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130416/eb36238e/attachment.obj>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130416/eb36238e/attachment-0001.html>


More information about the llvm-commits mailing list