[llvm] r208934 - Implement global merge optimization for global variables.

Rafael EspĂ­ndola rafael.espindola at gmail.com
Thu Jun 5 07:01:20 PDT 2014


On 5 June 2014 03:26, Jiangning Liu <liujiangning1 at gmail.com> wrote:
> Hi Rafael,
>
> I think now I understand your point and agree with you this alignment setup
> can be treated as a pure back-end issue AArch64 can handle it privately and
> we can avoid exposing it to shared code.
>
> So now attached is the updated patch by removing -global-merge-aligned
> switch. I will work out separate patches to handle AArch64 specific stuff
> later on.

Awesome!

-static cl::opt<bool>
-EnableGlobalMerge("global-merge", cl::Hidden,
-                  cl::desc("Enable global merge pass"),
-                  cl::init(true));
+static cl::opt<bool> EnableGlobalMerge("enable-global-merge", cl::NotHidden,
+                                       cl::desc("Enable global merge pass"),
+                                       cl::init(true));

Please commit this option rename first to reduce the noise in the patch.


+static cl::opt<bool> EnableGlobalMergeOnExternal(
+    "global-merge-on-external", cl::Hidden,
+    cl::desc("Enable global merge pass on external linkage"), cl::init(false));
+

This is a transitional option, right? I assume it will go away once it
is tested and benchmarked. Please add a comment stating that if that
is the case.

-INITIALIZE_PASS(GlobalMerge, "global-merge",
-                "Global Merge", false, false)

+static void *initializeGlobalMergePassOnce(PassRegistry &Registry) {
+  PassInfo *PI = new PassInfo(
+      "Merge global variables", "global-merge", &GlobalMerge::ID,
+      PassInfo::NormalCtor_t(callDefaultCtor<GlobalMerge>), false, false,
+      PassInfo::TargetMachineCtor_t(callTargetMachineCtor<GlobalMerge>));
+  Registry.registerPass(*PI, true);
+  return PI;
+}
+
+void llvm::initializeGlobalMergePass(PassRegistry &Registry) {
+  CALL_ONCE_INITIALIZATION(initializeGlobalMergePassOnce)
+}


Why is this necessary?

+  initializeGlobalMergePass(Registry);

same here.


+attributes #0 = { nounwind ssp "less-precise-fpmad"="false"
"no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf"
"no-infs-fp-math"="false" "no-nans-fp-math"="false"
"stack-protector-buffer-size"="8" "unsafe-fp-math"="false"
"use-soft-float"="false" }
+attributes #1 = { "less-precise-fpmad"="false"
"no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf"
"no-infs-fp-math"="false" "no-nans-fp-math"="false"
"stack-protector-buffer-size"="8" "unsafe-fp-math"="false"
"use-soft-float"="false" }
+attributes #2 = { nounwind readnone ssp "less-precise-fpmad"="false"
"no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf"
"no-infs-fp-math"="false" "no-nans-fp-math"="false"
"stack-protector-buffer-size"="8" "unsafe-fp-math"="false"
"use-soft-float"="false" }
+attributes #3 = { nounwind }
+
+!llvm.ident = !{!0}
+
+!0 = metadata !{metadata !"LLVM version 3.4 "}
+!1 = metadata !{metadata !2, metadata !2, i64 0}
+!2 = metadata !{metadata !"int", metadata !3, i64 0}
+!3 = metadata !{metadata !"omnipotent char", metadata !4, i64 0}
+!4 = metadata !{metadata !"Simple C/C++ TBAA"}

You probably don't need all this in the test.

Cheers,
Rafael



More information about the llvm-commits mailing list