aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNick Lewycky <nicholas@mxc.ca>2012-02-12 02:15:20 +0000
committerNick Lewycky <nicholas@mxc.ca>2012-02-12 02:15:20 +0000
commit6a7df9aae620801d97da72d718e9aff76eebac9b (patch)
treeb491962ce8254c65b2e16a8a09b22a04757a301b
parent6a577f82ba56a4da48e984702240a01c3ba7e941 (diff)
downloadexternal_llvm-6a7df9aae620801d97da72d718e9aff76eebac9b.zip
external_llvm-6a7df9aae620801d97da72d718e9aff76eebac9b.tar.gz
external_llvm-6a7df9aae620801d97da72d718e9aff76eebac9b.tar.bz2
Remove redundant getAnalysis<> calls in GlobalOpt. Add a few Itanium ABI calls
to TargetLibraryInfo and use one of them in GlobalOpt. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@150323 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/llvm/Target/TargetLibraryInfo.h9
-rw-r--r--lib/Target/TargetLibraryInfo.cpp6
-rw-r--r--lib/Transforms/IPO/GlobalOpt.cpp18
3 files changed, 22 insertions, 11 deletions
diff --git a/include/llvm/Target/TargetLibraryInfo.h b/include/llvm/Target/TargetLibraryInfo.h
index 3fe22b9..70e26bf 100644
--- a/include/llvm/Target/TargetLibraryInfo.h
+++ b/include/llvm/Target/TargetLibraryInfo.h
@@ -199,6 +199,15 @@ namespace llvm {
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
};
diff --git a/lib/Target/TargetLibraryInfo.cpp b/lib/Target/TargetLibraryInfo.cpp
index 2119c4e..269958f 100644
--- a/lib/Target/TargetLibraryInfo.cpp
+++ b/lib/Target/TargetLibraryInfo.cpp
@@ -113,7 +113,11 @@ const char* TargetLibraryInfo::StandardNames[LibFunc::NumLibFuncs] =
"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
diff --git a/lib/Transforms/IPO/GlobalOpt.cpp b/lib/Transforms/IPO/GlobalOpt.cpp
index 175d0d0..60a8b1c 100644
--- a/lib/Transforms/IPO/GlobalOpt.cpp
+++ b/lib/Transforms/IPO/GlobalOpt.cpp
@@ -1938,8 +1938,6 @@ bool GlobalOpt::OptimizeGlobalVars(Module &M) {
// 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 GlobalOpt::OptimizeGlobalCtorsList(GlobalVariable *&GCL) {
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 @@ bool GlobalOpt::OptimizeGlobalAliases(Module &M) {
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 GlobalOpt::runOnModule(Module &M) {
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) {