[llvm-commits] [llvm] r150323 - in /llvm/trunk: include/llvm/Target/TargetLibraryInfo.h lib/Target/TargetLibraryInfo.cpp lib/Transforms/IPO/GlobalOpt.cpp
Nick Lewycky
nicholas at mxc.ca
Sat Feb 11 18:15:20 PST 2012
Author: nicholas
Date: Sat Feb 11 20:15:20 2012
New Revision: 150323
URL: http://llvm.org/viewvc/llvm-project?rev=150323&view=rev
Log:
Remove redundant getAnalysis<> calls in GlobalOpt. Add a few Itanium ABI calls
to TargetLibraryInfo and use one of them in GlobalOpt.
Modified:
llvm/trunk/include/llvm/Target/TargetLibraryInfo.h
llvm/trunk/lib/Target/TargetLibraryInfo.cpp
llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp
Modified: llvm/trunk/include/llvm/Target/TargetLibraryInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetLibraryInfo.h?rev=150323&r1=150322&r2=150323&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Target/TargetLibraryInfo.h (original)
+++ llvm/trunk/include/llvm/Target/TargetLibraryInfo.h Sat Feb 11 20:15:20 2012
@@ -199,6 +199,15 @@
truncf,
/// long double truncl(long double x);
truncl,
+ /// int __cxa_atexit(void (*f)(void *), void *p, void *d);
+ cxa_atexit,
+ /// void __cxa_guard_abort(guard_t *guard);
+ /// guard_t is int64_t in Itanium ABI or int32_t on ARM eabi.
+ cxa_guard_abort,
+ /// int __cxa_guard_acquire(guard_t *guard);
+ cxa_guard_acquire,
+ /// void __cxa_guard_release(guard_t *guard);
+ cxa_guard_release,
NumLibFuncs
};
Modified: llvm/trunk/lib/Target/TargetLibraryInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/TargetLibraryInfo.cpp?rev=150323&r1=150322&r2=150323&view=diff
==============================================================================
--- llvm/trunk/lib/Target/TargetLibraryInfo.cpp (original)
+++ llvm/trunk/lib/Target/TargetLibraryInfo.cpp Sat Feb 11 20:15:20 2012
@@ -113,7 +113,11 @@
"tanhf",
"trunc",
"truncf",
- "truncl"
+ "truncl",
+ "__cxa_atexit",
+ "__cxa_guard_abort",
+ "__cxa_guard_acquire",
+ "__cxa_guard_release"
};
/// initialize - Initialize the set of available library functions based on the
Modified: llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp?rev=150323&r1=150322&r2=150323&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp Sat Feb 11 20:15:20 2012
@@ -1938,8 +1938,6 @@
// Simplify the initializer.
if (GV->hasInitializer())
if (ConstantExpr *CE = dyn_cast<ConstantExpr>(GV->getInitializer())) {
- TargetData *TD = getAnalysisIfAvailable<TargetData>();
- TargetLibraryInfo *TLI = &getAnalysis<TargetLibraryInfo>();
Constant *New = ConstantFoldConstantExpression(CE, TD, TLI);
if (New && New != CE)
GV->setInitializer(New);
@@ -2645,9 +2643,6 @@
bool MadeChange = false;
if (Ctors.empty()) return false;
- const TargetData *TD = getAnalysisIfAvailable<TargetData>();
- const TargetLibraryInfo *TLI = &getAnalysis<TargetLibraryInfo>();
-
// Loop over global ctors, optimizing them when we can.
for (unsigned i = 0; i != Ctors.size(); ++i) {
Function *F = Ctors[i];
@@ -2737,12 +2732,15 @@
return Changed;
}
-static Function *FindCXAAtExit(Module &M) {
- Function *Fn = M.getFunction("__cxa_atexit");
+static Function *FindCXAAtExit(Module &M, TargetLibraryInfo *TLI) {
+ if (!TLI->has(LibFunc::cxa_atexit))
+ return false;
+
+ Function *Fn = M.getFunction(TLI->getName(LibFunc::cxa_atexit));
if (!Fn)
return 0;
-
+
FunctionType *FTy = Fn->getFunctionType();
// Checking that the function has the right return type, the right number of
@@ -2854,12 +2852,12 @@
bool Changed = false;
TD = getAnalysisIfAvailable<TargetData>();
- TLI = getAnalysisIfAvailable<TargetLibraryInfo>();
+ TLI = &getAnalysis<TargetLibraryInfo>();
// Try to find the llvm.globalctors list.
GlobalVariable *GlobalCtors = FindGlobalCtors(M);
- Function *CXAAtExitFn = FindCXAAtExit(M);
+ Function *CXAAtExitFn = FindCXAAtExit(M, TLI);
bool LocalChange = true;
while (LocalChange) {
More information about the llvm-commits
mailing list