[patch] Teach GlobalDCE how to remove empty global_ctor entries
Rafael EspĂndola
rafael.espindola at gmail.com
Thu May 1 20:31:21 PDT 2014
OptimizeGlobalCtorsList
start the name with a lowercase.
+bool IsEmptyFunction(Function* F) {
+ BasicBlock &Entry = F->getEntryBlock();
+ return Entry.size() == 1 && isa<ReturnInst>(Entry.front());
}
There is no way to cast to void in llvm, right? The thing I am afraid
of is if a trapping constant can be hidden in there.
+/// Given a specified llvm.global_ctors list, install the
+/// specified array, returning the new global to use.
+void InstallGlobalCtors(GlobalVariable *GCL,
lowercase. Returning? install?
ParseGlobalCtors
lowercase.
+ if (!GV->hasUniqueInitializer()) return nullptr;
please clang-format.
+ // Init priority must be standard.
Do you know why? At least for the empty case it should be valid to
drop constructors of any priority.
+ ... Call "Remove" for
It is actually a predicate, so maybe ShouldRemove?
This is a case where an integration test might be a good idea. Do you
have a reasonably size test where this change causes a ctor to be
deleted at -O2? We might want to test that, so that even if we go with
a different optimization strategy in the future we still have a test
of the end result (the ctor gets deleted somewhere in -O2).
Cheers,
Rafael
More information about the llvm-commits
mailing list