DECL_VISIBILITY is valid only if TREE_PUBLIC is set. This patch uses the same approach used by varasm.c I applied this patch. - Devang
Index: llvm-backend.cpp =================================================================== --- llvm-backend.cpp (revision 122793) +++ llvm-backend.cpp (working copy) @@ -536,7 +536,7 @@ void emit_global_to_llvm(tree decl) { #endif /* TARGET_ADJUST_LLVM_LINKAGE */ // Handle visibility style - if (DECL_VISIBILITY(decl) == VISIBILITY_HIDDEN) + if (TREE_PUBLIC(decl) && DECL_VISIBILITY(decl) == VISIBILITY_HIDDEN) GV->setVisibility(GlobalValue::HiddenVisibility); // Set the section for the global. @@ -700,7 +700,7 @@ void make_decl_llvm(tree decl) { #endif /* TARGET_ADJUST_LLVM_LINKAGE */ // Handle visibility style - if (DECL_VISIBILITY(decl) == VISIBILITY_HIDDEN) + if (TREE_PUBLIC(decl) && DECL_VISIBILITY(decl) == VISIBILITY_HIDDEN) FnEntry->setVisibility(Function::HiddenVisibility); assert(FnEntry->getName() == Name &&"Preexisting fn with the same name!"); @@ -729,7 +729,7 @@ void make_decl_llvm(tree decl) { #endif /* TARGET_ADJUST_LLVM_LINKAGE */ // Handle visibility style - if (DECL_VISIBILITY(decl) == VISIBILITY_HIDDEN) + if (TREE_PUBLIC(decl) && DECL_VISIBILITY(decl) == VISIBILITY_HIDDEN) GV->setVisibility(Function::HiddenVisibility); } else { // If the global has a name, prevent multiple vars with the same name from @@ -749,7 +749,7 @@ void make_decl_llvm(tree decl) { #endif /* TARGET_ADJUST_LLVM_LINKAGE */ // Handle visibility style - if (DECL_VISIBILITY(decl) == VISIBILITY_HIDDEN) + if (TREE_PUBLIC(decl) && DECL_VISIBILITY(decl) == VISIBILITY_HIDDEN) GV->setVisibility(Function::HiddenVisibility); } else { GV = GVE; // Global already created, reuse it. Index: llvm-convert.cpp =================================================================== --- llvm-convert.cpp (revision 122793) +++ llvm-convert.cpp (working copy) @@ -295,7 +295,7 @@ void TreeToLLVM::StartFunctionBody() { "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) + if (TREE_PUBLIC(FnDecl) && DECL_VISIBILITY(FnDecl) == VISIBILITY_HIDDEN) Fn->setVisibility(Function::HiddenVisibility); else if (DECL_VISIBILITY(FnDecl) == VISIBILITY_DEFAULT) Fn->setVisibility(Function::DefaultVisibility); @@ -350,7 +350,7 @@ void TreeToLLVM::StartFunctionBody() { #endif /* TARGET_ADJUST_LLVM_LINKAGE */ // Handle visibility style - if (DECL_VISIBILITY(FnDecl) == VISIBILITY_HIDDEN) + if (TREE_PUBLIC(FnDecl) && DECL_VISIBILITY(FnDecl) == VISIBILITY_HIDDEN) Fn->setVisibility(Function::HiddenVisibility); // Handle functions in specified sections. _______________________________________________ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits