Hi,
Could a gate keeper review the patch for bug 718? Thank you very much.
Index: ../osprey/common/com/symtab_access.h
===================================================================
--- ../osprey/common/com/symtab_access.h (revision 3475)
+++ ../osprey/common/com/symtab_access.h (working copy)
@@ -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; }
Index: ../osprey/common/com/symtab_defs.h
===================================================================
--- ../osprey/common/com/symtab_defs.h (revision 3475)
+++ ../osprey/common/com/symtab_defs.h (working copy)
@@ -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
Index: ../osprey/wgen/wgen_decl.cxx
===================================================================
--- ../osprey/wgen/wgen_decl.cxx (revision 3475)
+++ ../osprey/wgen/wgen_decl.cxx (working copy)
@@ -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: ../osprey/ipa/main/optimize/ipo_alias_class.cxx
===================================================================
--- ../osprey/ipa/main/optimize/ipo_alias_class.cxx (revision 3475)
+++ ../osprey/ipa/main/optimize/ipo_alias_class.cxx (working copy)
@@ -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 {
The patch contains 3 part:
1. Remove unused PU flag PU_IS_MALLOC since the value of PU_IS_MALLOC is the
same as PU_HAS_ATTR_MALLOC and 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.
--
Regards,
Lai Jian-Xin
------------------------------------------------------------------------------
The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
Pinpoint memory and threading errors before they happen.
Find and fix more than 250 security defects in the development cycle.
Locate bottlenecks in serial and parallel code that limit performance.
http://p.sf.net/sfu/intel-dev2devfeb
_______________________________________________
Open64-devel mailing list
Open64-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/open64-devel