Author: laijx
Date: 2011-02-22 04:14:56 -0500 (Tue, 22 Feb 2011)
New Revision: 3487
Modified:
trunk/osprey/common/com/symtab_access.h
trunk/osprey/common/com/symtab_defs.h
trunk/osprey/ipa/main/optimize/ipo_alias_class.cxx
trunk/osprey/wgen/wgen_decl.cxx
Log:
Fix the bug 718. This patch contains 3 kinds of changes:
1. Remove unused PU flag PU_IS_MALLOC since it's never used.
2. Enhance the WGEN to set the PU_HAS_ATTR_MALLOC if
__attribute__((__malloc__)) is specified. Enhance the
IP_ALIAS_CLASSIFICATION::Callee_returns_new_memory() to detect this
flag.
3. Bug fix for 718. In this case, 'malloc' is a user defined function
but marked as 'return new memory', which will cause the assertion in
Handle_function_definition(). In this patch, we also check if the
function is user defined or not by detecting the sclass. Also, for
function 'returns new memory', Return_class_member() should be used
instead of Returns().
Code Reviewed by Sun.
Modified: trunk/osprey/common/com/symtab_access.h
===================================================================
--- trunk/osprey/common/com/symtab_access.h 2011-02-22 08:54:12 UTC (rev
3486)
+++ trunk/osprey/common/com/symtab_access.h 2011-02-22 09:14:56 UTC (rev
3487)
@@ -1033,13 +1033,6 @@
Clear_PU_is_operator (PU& pu) { pu.flags &= ~PU_IS_OPERATOR; }
inline BOOL
-PU_is_malloc (const PU& pu) { return (pu.flags &
PU_IS_MALLOC) != 0; }
-inline void
-Set_PU_is_malloc (PU& pu) { pu.flags |= PU_IS_MALLOC; }
-inline void
-Clear_PU_is_malloc (PU& pu) { pu.flags &= ~PU_IS_MALLOC; }
-
-inline BOOL
PU_has_attr_malloc (const PU& pu) { return (pu.flags &
PU_HAS_ATTR_MALLOC) != 0; }
inline void
Set_PU_has_attr_malloc (PU& pu) { pu.flags |= PU_HAS_ATTR_MALLOC; }
Modified: trunk/osprey/common/com/symtab_defs.h
===================================================================
--- trunk/osprey/common/com/symtab_defs.h 2011-02-22 08:54:12 UTC (rev
3486)
+++ trunk/osprey/common/com/symtab_defs.h 2011-02-22 09:14:56 UTC (rev
3487)
@@ -739,7 +739,6 @@
#define PU_NO_INSTRUMENT 0x0000010000000000LL // -finstrument-functions
will skip PU
#endif
-#define PU_IS_MALLOC 0x0000020000000000LL //
__attribute__((malloc)) semantic
#define PU_HAS_ATTR_MALLOC 0x0000020000000000LL //
__attribute__((malloc)) semantic
#define PU_HAS_ATTR_PURE 0x0000040000000000LL // __attribute__((pure))
semantic
#define PU_HAS_ATTR_NORETURN 0x0000080000000000LL //
__attribute__((noreturn)) semantic
Modified: trunk/osprey/ipa/main/optimize/ipo_alias_class.cxx
===================================================================
--- trunk/osprey/ipa/main/optimize/ipo_alias_class.cxx 2011-02-22 08:54:12 UTC
(rev 3486)
+++ trunk/osprey/ipa/main/optimize/ipo_alias_class.cxx 2011-02-22 09:14:56 UTC
(rev 3487)
@@ -1475,7 +1475,7 @@
ST *pu_st = Scope_tab[CURRENT_SYMTAB].st;
IP_ALIAS_CLASS_REP *pu_acr =
_base_id_map[Base_id(pu_st, 0ll)]->Base_member().Alias_class();
- IP_ALIAS_CLASS_MEMBER *return_ac_member = pu_acr->Signature().Returns();
+ IP_ALIAS_CLASS_MEMBER *return_ac_member =
pu_acr->Signature().Return_class_member();
Classify_deref_of_expr(return_ac_member, WN_kid0(stmt), FALSE);
@@ -1544,16 +1544,7 @@
if (WN_Call_Does_Mem_Alloc(call_wn))
return TRUE;
if (WN_operator(call_wn) == OPR_CALL) {
- const ST *const st = WN_st(call_wn);
-
- // Cheap hack for now, to test performance. This should be based on
- // some real mechanism in the future instead of cheesebag hacks.
- if ((strcmp("malloc", ST_name(st)) == 0) ||
- (strcmp("alloca", ST_name(st)) == 0) ||
- (strcmp("calloc", ST_name(st)) == 0) ||
- (strcmp("_F90_ALLOCATE", ST_name(st)) == 0)) {
- return TRUE;
- }
+ return Callee_returns_new_memory(WN_st(call_wn));
}
else if (WN_operator(call_wn) == OPR_INTRINSIC_CALL) {
if ((WN_intrinsic(call_wn) == INTRN_U4I4ALLOCA) ||
@@ -1571,13 +1562,18 @@
BOOL
IP_ALIAS_CLASSIFICATION::Callee_returns_new_memory(const ST *const st)
{
+ Is_True(ST_class(st) == CLASS_FUNC, ("invalid st class"));
+ if (PU_has_attr_malloc (Pu_Table[ST_pu(st)]))
+ return TRUE;
+
#ifdef KEY
// Cheap hack for now, to test performance. This should be based on
// some real mechanism in the future instead of cheesebag hacks.
- if ((strcmp("malloc", ST_name(st)) == 0) ||
- (strcmp("alloca", ST_name(st)) == 0) ||
- (strcmp("calloc", ST_name(st)) == 0) ||
- (strcmp("_F90_ALLOCATE", ST_name(st)) == 0)) {
+ if ((strcmp("malloc", ST_name(st)) == 0 ||
+ strcmp("alloca", ST_name(st)) == 0 ||
+ strcmp("calloc", ST_name(st)) == 0 ||
+ strcmp("_F90_ALLOCATE", ST_name(st)) == 0) &&
+ ST_sclass(st) == SCLASS_EXTERN) {
return TRUE;
}
else {
Modified: trunk/osprey/wgen/wgen_decl.cxx
===================================================================
--- trunk/osprey/wgen/wgen_decl.cxx 2011-02-22 08:54:12 UTC (rev 3486)
+++ trunk/osprey/wgen/wgen_decl.cxx 2011-02-22 09:14:56 UTC (rev 3487)
@@ -1484,6 +1484,9 @@
else if (is_attribute("used", attr))
Set_PU_no_delete (Pu_Table [ST_pu (func_st)]); // bug 3697
#endif
+ else if (is_attribute("malloc", attr)) {
+ Set_PU_has_attr_malloc (Pu_Table [ST_pu (func_st)]);
+ }
}
}
}
------------------------------------------------------------------------------
Index, Search & Analyze Logs and other IT data in Real-Time with Splunk
Collect, index and harness all the fast moving IT data generated by your
applications, servers and devices whether physical, virtual or in the cloud.
Deliver compliance at lower cost and gain new business insights.
Free Software Download: http://p.sf.net/sfu/splunk-dev2dev
_______________________________________________
Open64-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/open64-devel