[llvm-commits] [128026] Do bitcase before pushing onto vector and remove GlobalInit.
lattner at apple.com
lattner at apple.com
Tue Jun 5 16:45:36 PDT 2007
Revision: 128026
Author: lattner
Date: 2007-06-05 16:45:35 -0700 (Tue, 05 Jun 2007)
Log Message:
-----------
Do bitcase before pushing onto vector and remove GlobalInit. Clear vectors for used and noinline attributes when finished.
Modified Paths:
--------------
apple-local/branches/llvm/gcc/llvm-backend.cpp
apple-local/branches/llvm/gcc/llvm-convert.cpp
apple-local/branches/llvm/gcc/llvm-internal.h
Modified: apple-local/branches/llvm/gcc/llvm-backend.cpp
===================================================================
--- apple-local/branches/llvm/gcc/llvm-backend.cpp 2007-06-05 17:39:31 UTC (rev 128025)
+++ apple-local/branches/llvm/gcc/llvm-backend.cpp 2007-06-05 23:45:35 UTC (rev 128026)
@@ -79,8 +79,8 @@
llvm::OStream *AsmOutFile = 0;
std::vector<std::pair<Function*, int> > StaticCtors, StaticDtors;
-std::vector<GlobalValue*> AttributeUsedGlobals;
-std::vector<Function*> AttributeNoinlineFunctions;
+std::vector<Constant*> AttributeUsedGlobals;
+std::vector<Constant*> AttributeNoinlineFunctions;
/// PerFunctionPasses - This is the list of cleanup passes run per-function
/// as each is compiled. In cases where we are not doing IPO, it includes the
@@ -467,31 +467,26 @@
CreateStructorsList(StaticDtors, "llvm.global_dtors");
if (!AttributeUsedGlobals.empty()) {
- std::vector<Constant*> GlobalInit;
const Type *SBP = PointerType::get(Type::Int8Ty);
- for (unsigned i = 0, e = AttributeUsedGlobals.size(); i != e; ++i)
- GlobalInit.push_back(ConstantExpr::getBitCast(AttributeUsedGlobals[i],
- SBP));
ArrayType *AT = ArrayType::get(SBP, AttributeUsedGlobals.size());
- Constant *Init = ConstantArray::get(AT, GlobalInit);
+ Constant *Init = ConstantArray::get(AT, AttributeUsedGlobals);
new GlobalVariable(AT, false, GlobalValue::AppendingLinkage, Init,
"llvm.used", TheModule);
+ AttributeUsedGlobals.clear();
}
// Add llvm.noinline
if (!AttributeNoinlineFunctions.empty()) {
- std::vector<Constant*> GlobalInit;
const Type *SBP= PointerType::get(Type::Int8Ty);
- for (unsigned i = 0, e = AttributeNoinlineFunctions.size(); i != e; ++i)
- GlobalInit.push_back(ConstantExpr::getBitCast(
- AttributeNoinlineFunctions[i],
- SBP));
ArrayType *AT = ArrayType::get(SBP, AttributeNoinlineFunctions.size());
- Constant *Init = ConstantArray::get(AT, GlobalInit);
+ Constant *Init = ConstantArray::get(AT, AttributeUsedGlobals);
GlobalValue *gv = new GlobalVariable(AT, false,
GlobalValue::AppendingLinkage, Init,
"llvm.noinline", TheModule);
gv->setSection("llvm.metadata");
+
+ // Clear vector
+ AttributeNoinlineFunctions.clear();
}
// Finish off the per-function pass.
@@ -763,8 +758,10 @@
}
// Handle used decls
- if (DECL_PRESERVE_P (decl))
- AttributeUsedGlobals.push_back(GV);
+ if (DECL_PRESERVE_P (decl)) {
+ const Type *SBP= PointerType::get(Type::Int8Ty);
+ AttributeUsedGlobals.push_back(ConstantExpr::getBitCast(GV, SBP));
+ }
}
if (TheDebugInfo) TheDebugInfo->EmitGlobalVariable(GV, decl);
Modified: apple-local/branches/llvm/gcc/llvm-convert.cpp
===================================================================
--- apple-local/branches/llvm/gcc/llvm-convert.cpp 2007-06-05 17:39:31 UTC (rev 128025)
+++ apple-local/branches/llvm/gcc/llvm-convert.cpp 2007-06-05 23:45:35 UTC (rev 128026)
@@ -589,12 +589,16 @@
Fn->setSection(TREE_STRING_POINTER(DECL_SECTION_NAME(FnDecl)));
// Handle used Functions
- if (DECL_PRESERVE_P (FnDecl))
- AttributeUsedGlobals.push_back(Fn);
+ if (DECL_PRESERVE_P (FnDecl)) {
+ const Type *SBP= PointerType::get(Type::Int8Ty);
+ AttributeUsedGlobals.push_back(ConstantExpr::getBitCast(Fn,SBP));
+ }
// Handle noinline Functions
- if (DECL_UNINLINABLE (FnDecl))
- AttributeNoinlineFunctions.push_back(Fn);
+ if (DECL_UNINLINABLE (FnDecl)) {
+ const Type *SBP= PointerType::get(Type::Int8Ty);
+ AttributeNoinlineFunctions.push_back(ConstantExpr::getBitCast(Fn,SBP));
+ }
// Create a new basic block for the function.
Builder.SetInsertPoint(new BasicBlock("entry", Fn));
Modified: apple-local/branches/llvm/gcc/llvm-internal.h
===================================================================
--- apple-local/branches/llvm/gcc/llvm-internal.h 2007-06-05 17:39:31 UTC (rev 128025)
+++ apple-local/branches/llvm/gcc/llvm-internal.h 2007-06-05 23:45:35 UTC (rev 128026)
@@ -86,11 +86,11 @@
extern std::vector<std::pair<Function*, int> > StaticCtors, StaticDtors;
/// AttributeUsedGlobals - The list of globals that are marked attribute(used).
-extern std::vector<GlobalValue*> AttributeUsedGlobals;
+extern std::vector<Constant*> AttributeUsedGlobals;
/// AttributeNoinlineFunctions - The list of functions that are
/// marked attribute(noinline)
-extern std::vector<Function*> AttributeNoinlineFunctions;
+extern std::vector<Constant*> AttributeNoinlineFunctions;
void changeLLVMValue(Value *Old, Value *New);
void readLLVMTypesStringTable();
More information about the llvm-commits
mailing list