Hello, Everyone. Attached file will enable llvm-gcc to set visibility information.
-- With best regards, Anton Korobeynikov. Faculty of Mathematics & Mechanics, Saint Petersburg State University.
diff -r 26118361e7fc gcc/llvm-backend.cpp --- a/gcc/llvm-backend.cpp Thu Jan 11 10:36:30 2007 +0300 +++ b/gcc/llvm-backend.cpp Thu Jan 11 10:38:23 2007 +0300 @@ -529,6 +529,10 @@ void emit_global_to_llvm(tree decl) { #ifdef TARGET_ADJUST_LLVM_LINKAGE TARGET_ADJUST_LLVM_LINKAGE(GV,decl); #endif /* TARGET_ADJUST_LLVM_LINKAGE */ + // Handle visibility style + if (DECL_VISIBILITY(decl) == VISIBILITY_HIDDEN) + GV->setVisibility(GlobalValue::HiddenVisibility); + // Set the section for the global. if (TREE_CODE(decl) == VAR_DECL || TREE_CODE(decl) == CONST_DECL) { if (DECL_SECTION_NAME(decl)) { @@ -690,6 +696,10 @@ void make_decl_llvm(tree decl) { TARGET_ADJUST_LLVM_LINKAGE(FnEntry,decl); #endif /* TARGET_ADJUST_LLVM_LINKAGE */ + // Handle visibility style + if (DECL_VISIBILITY(decl) == VISIBILITY_HIDDEN) + FnEntry->setVisibility(Function::HiddenVisibility); + assert(FnEntry->getName() == Name &&"Preexisting fn with the same name!"); } SET_DECL_LLVM(decl, FnEntry); @@ -714,6 +724,10 @@ void make_decl_llvm(tree decl) { #ifdef TARGET_ADJUST_LLVM_LINKAGE TARGET_ADJUST_LLVM_LINKAGE(GV,decl); #endif /* TARGET_ADJUST_LLVM_LINKAGE */ + + // Handle visibility style + if (DECL_VISIBILITY(decl) == VISIBILITY_HIDDEN) + GV->setVisibility(Function::HiddenVisibility); } else { // If the global has a name, prevent multiple vars with the same name from // being created. @@ -730,6 +744,10 @@ void make_decl_llvm(tree decl) { #ifdef TARGET_ADJUST_LLVM_LINKAGE TARGET_ADJUST_LLVM_LINKAGE(GV,decl); #endif /* TARGET_ADJUST_LLVM_LINKAGE */ + + // Handle visibility style + if (DECL_VISIBILITY(decl) == VISIBILITY_HIDDEN) + GV->setVisibility(Function::HiddenVisibility); } else { GV = GVE; // Global already created, reuse it. } diff -r 26118361e7fc gcc/llvm-convert.cpp --- a/gcc/llvm-convert.cpp Thu Jan 11 10:36:30 2007 +0300 +++ b/gcc/llvm-convert.cpp Thu Jan 11 10:38:23 2007 +0300 @@ -293,6 +293,12 @@ void TreeToLLVM::StartFunctionBody() { Fn = cast<Function>(DECL_LLVM(FnDecl)); assert(Fn->getCallingConv() == CallingConv && "Calling convention disagreement between prototype and impl!"); + // The visibility can be changed from the last time we've seen this + // function. Set to current. + if (DECL_VISIBILITY(FnDecl) == VISIBILITY_HIDDEN) + Fn->setVisibility(Function::HiddenVisibility); + else if (DECL_VISIBILITY(FnDecl) == VISIBILITY_DEFAULT) + Fn->setVisibility(Function::DefaultVisibility); } else { Function *&FnEntry = EmittedFunctions[Name]; if (FnEntry) { @@ -338,11 +344,14 @@ void TreeToLLVM::StartFunctionBody() { } else if (DECL_COMDAT(FnDecl)) { Fn->setLinkage(Function::LinkOnceLinkage); } - #ifdef TARGET_ADJUST_LLVM_LINKAGE TARGET_ADJUST_LLVM_LINKAGE(Fn,FnDecl); #endif /* TARGET_ADJUST_LLVM_LINKAGE */ + + // Handle visibility style + if (DECL_VISIBILITY(FnDecl) == VISIBILITY_HIDDEN) + Fn->setVisibility(Function::HiddenVisibility); // Handle functions in specified sections. if (DECL_SECTION_NAME(FnDecl))
_______________________________________________ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits