Revision: 126950 Author: clattner Date: 2007-05-05 11:15:40 -0700 (Sat, 05 May 2007)
Log Message: ----------- add support for protected visibility (PR1363) Patch by Lauro Venancio Modified Paths: -------------- apple-local/branches/llvm/gcc/llvm-backend.cpp apple-local/branches/llvm/gcc/llvm-convert.cpp Modified: apple-local/branches/llvm/gcc/llvm-backend.cpp =================================================================== --- apple-local/branches/llvm/gcc/llvm-backend.cpp 2007-05-05 18:11:46 UTC (rev 126949) +++ apple-local/branches/llvm/gcc/llvm-backend.cpp 2007-05-05 18:15:40 UTC (rev 126950) @@ -573,7 +573,6 @@ } GlobalValue::LinkageTypes Linkage; - GlobalValue::VisibilityTypes Visibility; // Check for external weak linkage if (DECL_EXTERNAL(decl) && DECL_WEAK(decl)) @@ -586,8 +585,12 @@ GlobalAlias* GA = new GlobalAlias(Aliasee->getType(), Linkage, "", Aliasee, TheModule); // Handle visibility style - if (TREE_PUBLIC(decl) && DECL_VISIBILITY(decl) == VISIBILITY_HIDDEN) - GA->setVisibility(GlobalValue::HiddenVisibility); + if (TREE_PUBLIC(decl)) { + if (DECL_VISIBILITY(decl) == VISIBILITY_HIDDEN) + GA->setVisibility(GlobalValue::HiddenVisibility); + else if (DECL_VISIBILITY(decl) == VISIBILITY_PROTECTED) + GA->setVisibility(GlobalValue::ProtectedVisibility); + } if (V->getType() == GA->getType()) V->replaceAllUsesWith(GA); @@ -692,11 +695,15 @@ #ifdef TARGET_ADJUST_LLVM_LINKAGE TARGET_ADJUST_LLVM_LINKAGE(GV,decl); #endif /* TARGET_ADJUST_LLVM_LINKAGE */ - + // Handle visibility style - if (TREE_PUBLIC(decl) && DECL_VISIBILITY(decl) == VISIBILITY_HIDDEN) - GV->setVisibility(GlobalValue::HiddenVisibility); - + if (TREE_PUBLIC(decl)) { + if (DECL_VISIBILITY(decl) == VISIBILITY_HIDDEN) + GV->setVisibility(GlobalValue::HiddenVisibility); + else if (DECL_VISIBILITY(decl) == VISIBILITY_PROTECTED) + GV->setVisibility(GlobalValue::ProtectedVisibility); + } + // Set the section for the global. if (TREE_CODE(decl) == VAR_DECL || TREE_CODE(decl) == CONST_DECL) { if (DECL_SECTION_NAME(decl)) { @@ -862,9 +869,13 @@ #endif /* TARGET_ADJUST_LLVM_LINKAGE */ // Handle visibility style - if (TREE_PUBLIC(decl) && DECL_VISIBILITY(decl) == VISIBILITY_HIDDEN) - FnEntry->setVisibility(Function::HiddenVisibility); - + if (TREE_PUBLIC(decl)) { + if (DECL_VISIBILITY(decl) == VISIBILITY_HIDDEN) + FnEntry->setVisibility(GlobalValue::HiddenVisibility); + else if (DECL_VISIBILITY(decl) == VISIBILITY_PROTECTED) + FnEntry->setVisibility(GlobalValue::ProtectedVisibility); + } + assert(FnEntry->getName() == Name &&"Preexisting fn with the same name!"); } SET_DECL_LLVM(decl, FnEntry); @@ -892,8 +903,13 @@ #endif /* TARGET_ADJUST_LLVM_LINKAGE */ // Handle visibility style - if (TREE_PUBLIC(decl) && DECL_VISIBILITY(decl) == VISIBILITY_HIDDEN) - GV->setVisibility(Function::HiddenVisibility); + if (TREE_PUBLIC(decl)) { + if (DECL_VISIBILITY(decl) == VISIBILITY_HIDDEN) + GV->setVisibility(GlobalValue::HiddenVisibility); + else if (DECL_VISIBILITY(decl) == VISIBILITY_PROTECTED) + GV->setVisibility(GlobalValue::ProtectedVisibility); + } + } else { // If the global has a name, prevent multiple vars with the same name from // being created. @@ -912,9 +928,13 @@ #endif /* TARGET_ADJUST_LLVM_LINKAGE */ // Handle visibility style - if (TREE_PUBLIC(decl) && DECL_VISIBILITY(decl) == VISIBILITY_HIDDEN) - GV->setVisibility(Function::HiddenVisibility); - + if (TREE_PUBLIC(decl)) { + if (DECL_VISIBILITY(decl) == VISIBILITY_HIDDEN) + GV->setVisibility(GlobalValue::HiddenVisibility); + else if (DECL_VISIBILITY(decl) == VISIBILITY_PROTECTED) + GV->setVisibility(GlobalValue::ProtectedVisibility); + } + // If GV got renamed, then there is already an object with this name in // the symbol table. If this happens, the old one must be a forward // decl, just replace it with a cast of the new one. Modified: apple-local/branches/llvm/gcc/llvm-convert.cpp =================================================================== --- apple-local/branches/llvm/gcc/llvm-convert.cpp 2007-05-05 18:11:46 UTC (rev 126949) +++ apple-local/branches/llvm/gcc/llvm-convert.cpp 2007-05-05 18:15:40 UTC (rev 126950) @@ -486,11 +486,15 @@ 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 (TREE_PUBLIC(FnDecl) && DECL_VISIBILITY(FnDecl) == VISIBILITY_HIDDEN) - Fn->setVisibility(Function::HiddenVisibility); - else if (DECL_VISIBILITY(FnDecl) == VISIBILITY_DEFAULT) - Fn->setVisibility(Function::DefaultVisibility); + // function. Set to current. + if (TREE_PUBLIC(FnDecl)) { + if (DECL_VISIBILITY(FnDecl) == VISIBILITY_HIDDEN) + Fn->setVisibility(Function::HiddenVisibility); + else if (DECL_VISIBILITY(FnDecl) == VISIBILITY_PROTECTED) + Fn->setVisibility(Function::ProtectedVisibility); + else if (DECL_VISIBILITY(FnDecl) == VISIBILITY_DEFAULT) + Fn->setVisibility(Function::DefaultVisibility); + } } else { Function *FnEntry = TheModule->getFunction(Name); if (FnEntry) { @@ -535,9 +539,13 @@ #endif /* TARGET_ADJUST_LLVM_LINKAGE */ // Handle visibility style - if (TREE_PUBLIC(FnDecl) && DECL_VISIBILITY(FnDecl) == VISIBILITY_HIDDEN) - Fn->setVisibility(Function::HiddenVisibility); - + if (TREE_PUBLIC(FnDecl)) { + if (DECL_VISIBILITY(FnDecl) == VISIBILITY_HIDDEN) + Fn->setVisibility(Function::HiddenVisibility); + else if (DECL_VISIBILITY(FnDecl) == VISIBILITY_PROTECTED) + Fn->setVisibility(Function::ProtectedVisibility); + } + // Handle functions in specified sections. if (DECL_SECTION_NAME(FnDecl)) Fn->setSection(TREE_STRING_POINTER(DECL_SECTION_NAME(FnDecl))); _______________________________________________ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits