00001 //-*-c++-*- 00002 00003 // ==================================================================== 00004 // ==================================================================== 00005 // 00006 // Copyright (C) 2007, University of Delaware, Hewlett-Packard Company, 00007 // All Rights Reserved. 00008 // 00009 // This program is free software; you can redistribute it and/or modify 00010 // it under the terms of version 2 of the GNU General Public License as 00011 // published by the Free Software Foundation. 00012 // 00013 // This program is distributed in the hope that it would be useful, but 00014 // WITHOUT ANY WARRANTY; without even the implied warranty of 00015 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00016 // 00017 // Further, this software is distributed without any warranty that it 00018 // is free of the rightful claim of any third person regarding 00019 // infringement or the like. Any license provided herein, whether 00020 // implied or otherwise, applies only to this software file. Patent 00021 // licenses, if any, provided herein do not apply to combinations of 00022 // this program with other software, or any other product whatsoever. 00023 // 00024 // You should have received a copy of the GNU General Public License 00025 // along with this program; if not, write the Free Software Foundation, 00026 // Inc., 59 Temple Place - Suite 330, Boston MA 02111-1307, USA. 00027 // 00028 // ==================================================================== 00029 #include "defs.h" // INT32, INT64 00030 #include "config.h" // Alias_Pointer_Parms 00031 #include "opt_defs.h" 00032 #include "tracing.h" // trace flags 00033 #include "config_opt.h" 00034 00035 #include "erglob.h" 00036 #include "opt_cfg.h" // for EXITBB_ITER 00037 #include "opt_sym.h" 00038 #include "opt_misc.h" 00039 00040 static void 00041 Analyze_pu_noreturn_attr (OPT_STAB* stab, PU* pu, ST* pu_st) { 00042 00043 EXITBB_ITER iter(stab->Cfg()); 00044 FOR_ALL_ITEM (iter, Init()) { 00045 BB_NODE* exit_bb = iter.Cur_exit_bb(); 00046 WN *wn = exit_bb->Laststmt(); 00047 if (wn && 00048 (WN_operator (wn) == OPR_RETURN || 00049 WN_operator (wn) == OPR_RETURN_VAL)) { 00050 wn = WN_prev (wn); 00051 } 00052 if (!wn || WN_operator (wn) != OPR_CALL) return; 00053 00054 PU& pu_ent = Pu_Table[ST_pu(WN_st(wn))]; 00055 if (!PU_has_attr_noreturn (pu_ent)) { 00056 return; 00057 } 00058 } 00059 00060 // Now, all exit blocks are ended with call having 00061 // __attribute__((noreturn), this function itself 00062 // satisify the "noreturn" semantic 00063 Set_PU_has_attr_noreturn (*pu); 00064 00065 } 00066 00067 // Analyze_pu_attr() conducts following things 00068 // 00069 // - reveal _attribute_ semantics 00070 // - points-to summary 00071 // 00072 void 00073 Analyze_pu_attr (OPT_STAB* opt_stab, ST* pu_st) { 00074 00075 WN* pu_tree = opt_stab->Pu (); 00076 if (WN_opcode(pu_tree)!=OPC_FUNC_ENTRY) { 00077 // not applicable, give up. 00078 return; 00079 } 00080 00081 PU& pu_ent = Pu_Table[ST_pu(pu_st)]; 00082 00083 // analyze __attribute__((noreturn) 00084 if (WOPT_Enable_Noreturn_Attr_Opt && !PU_has_attr_noreturn (pu_ent)) { 00085 Analyze_pu_noreturn_attr (opt_stab, &pu_ent, pu_st); 00086 } 00087 00088 if (WOPT_Enable_Pt_Summary) { 00089 SET_OPT_PHASE("Points-to Summary"); 00090 opt_stab->Summarize_points_to (); 00091 } 00092 } 00093
1.5.6