[llvm-commits] [llvm-gcc-4.0] r41748 - in /llvm-gcc-4.0/trunk/gcc: llvm-backend.cpp llvm-convert.cpp llvm-internal.h
Devang Patel
dpatel at apple.com
Thu Sep 6 12:00:21 PDT 2007
Author: dpatel
Date: Thu Sep 6 14:00:20 2007
New Revision: 41748
URL: http://llvm.org/viewvc/llvm-project?rev=41748&view=rev
Log:
Replace GV from AttributeUsedGlobals list.
Modified:
llvm-gcc-4.0/trunk/gcc/llvm-backend.cpp
llvm-gcc-4.0/trunk/gcc/llvm-convert.cpp
llvm-gcc-4.0/trunk/gcc/llvm-internal.h
Modified: llvm-gcc-4.0/trunk/gcc/llvm-backend.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.0/trunk/gcc/llvm-backend.cpp?rev=41748&r1=41747&r2=41748&view=diff
==============================================================================
--- llvm-gcc-4.0/trunk/gcc/llvm-backend.cpp (original)
+++ llvm-gcc-4.0/trunk/gcc/llvm-backend.cpp Thu Sep 6 14:00:20 2007
@@ -84,7 +84,7 @@
static cl::opt<bool> DisableLLVMOptimizations("disable-llvm-optzns");
std::vector<std::pair<Function*, int> > StaticCtors, StaticDtors;
-std::vector<Constant*> AttributeUsedGlobals;
+SmallPtrSet<Constant*, 32> AttributeUsedGlobals;
std::vector<Constant*> AttributeNoinlineFunctions;
std::vector<Constant*> AttributeAnnotateGlobals;
@@ -439,6 +439,7 @@
createOptimizationPasses();
+ AttributeUsedGlobals.clear();
timevar_pop(TV_LLVM_INIT);
}
@@ -479,9 +480,15 @@
CreateStructorsList(StaticDtors, "llvm.global_dtors");
if (!AttributeUsedGlobals.empty()) {
- const Type *SBP = PointerType::get(Type::Int8Ty);
- ArrayType *AT = ArrayType::get(SBP, AttributeUsedGlobals.size());
- Constant *Init = ConstantArray::get(AT, AttributeUsedGlobals);
+ std::vector<Constant *> AUGs;
+ const Type *SBP= PointerType::get(Type::Int8Ty);
+ for (SmallPtrSet<Constant *,32>::iterator AI = AttributeUsedGlobals.begin(),
+ AE = AttributeUsedGlobals.end(); AI != AE; ++AI) {
+ Constant *C = *AI;
+ AUGs.push_back(ConstantExpr::getBitCast(C, SBP));
+ }
+ ArrayType *AT = ArrayType::get(SBP, AUGs.size());
+ Constant *Init = ConstantArray::get(AT, AUGs);
GlobalValue* gv = new GlobalVariable(AT, false,
GlobalValue::AppendingLinkage, Init,
"llvm.used", TheModule);
@@ -796,6 +803,10 @@
GlobalValue::ExternalLinkage, 0,
GV->getName(), TheModule);
GV->replaceAllUsesWith(ConstantExpr::getBitCast(NGV, GV->getType()));
+ if (AttributeUsedGlobals.count(GV)) {
+ AttributeUsedGlobals.erase(GV);
+ AttributeUsedGlobals.insert(NGV);
+ }
delete GV;
SET_DECL_LLVM(decl, NGV);
GV = NGV;
@@ -853,10 +864,8 @@
}
// Handle used decls
- if (DECL_PRESERVE_P (decl)) {
- const Type *SBP= PointerType::get(Type::Int8Ty);
- AttributeUsedGlobals.push_back(ConstantExpr::getBitCast(GV, SBP));
- }
+ if (DECL_PRESERVE_P (decl))
+ AttributeUsedGlobals.insert(GV);
// Add annotate attributes for globals
if (DECL_ATTRIBUTES(decl))
Modified: llvm-gcc-4.0/trunk/gcc/llvm-convert.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.0/trunk/gcc/llvm-convert.cpp?rev=41748&r1=41747&r2=41748&view=diff
==============================================================================
--- llvm-gcc-4.0/trunk/gcc/llvm-convert.cpp (original)
+++ llvm-gcc-4.0/trunk/gcc/llvm-convert.cpp Thu Sep 6 14:00:20 2007
@@ -594,10 +594,8 @@
Fn->setSection(TREE_STRING_POINTER(DECL_SECTION_NAME(FnDecl)));
// Handle used Functions
- if (DECL_PRESERVE_P (FnDecl)) {
- const Type *SBP= PointerType::get(Type::Int8Ty);
- AttributeUsedGlobals.push_back(ConstantExpr::getBitCast(Fn,SBP));
- }
+ if (DECL_PRESERVE_P (FnDecl))
+ AttributeUsedGlobals.insert(Fn);
// Handle noinline Functions
if (lookup_attribute ("noinline", DECL_ATTRIBUTES (FnDecl))) {
Modified: llvm-gcc-4.0/trunk/gcc/llvm-internal.h
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.0/trunk/gcc/llvm-internal.h?rev=41748&r1=41747&r2=41748&view=diff
==============================================================================
--- llvm-gcc-4.0/trunk/gcc/llvm-internal.h (original)
+++ llvm-gcc-4.0/trunk/gcc/llvm-internal.h Thu Sep 6 14:00:20 2007
@@ -34,6 +34,7 @@
#include <string>
#include "llvm/Intrinsics.h"
#include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/Support/DataTypes.h"
#include "llvm/Support/LLVMBuilder.h"
#include "llvm/Support/Streams.h"
@@ -86,7 +87,7 @@
extern std::vector<std::pair<Function*, int> > StaticCtors, StaticDtors;
/// AttributeUsedGlobals - The list of globals that are marked attribute(used).
-extern std::vector<Constant*> AttributeUsedGlobals;
+extern SmallPtrSet<Constant *,32> AttributeUsedGlobals;
/// AttributeNoinlineFunctions - The list of functions that are
/// marked attribute(noinline)
More information about the llvm-commits
mailing list