* [PATCH] clone_function_name_1: Retain any stdcall suffix
@ 2015-08-18 20:27 Ray Donnelly
2015-08-29 14:10 ` Kai Tietz
0 siblings, 1 reply; 2+ messages in thread
From: Ray Donnelly @ 2015-08-18 20:27 UTC (permalink / raw)
To: gcc-patches; +Cc: Kai Tietz, hubicka
[-- Attachment #1: Type: text/plain, Size: 175 bytes --]
I'm not familiar with setting up GCC testcases yet so I expect to have
to do that at least. To aid discussion, the commit message contains a
testcase.
--
Best regards,
Ray.
[-- Attachment #2: 0022-clone_function_name_1-Retain-any-stdcall-suffix.patch --]
[-- Type: application/octet-stream, Size: 3584 bytes --]
From 38274147bb2a3fa481d0a1853c185c2337550260 Mon Sep 17 00:00:00 2001
From: Ray Donnelly <mingw.android@gmail.com>
Date: Mon, 17 Aug 2015 22:57:46 +0100
Subject: [PATCH 22/22] clone_function_name_1: Retain any stdcall suffix
Previously, clone_function_name_1 would add a suffix after
any existing stdcall suffix, for example ipa-split.c would
clone test@4 as test@4.part.0.
Later, i386_pe_strip_name_encoding_full would come along
and strip off everything from the last @ onwards which had
the effect of generating incorrect section names which
would then fall over with errors such as:
error: void test() causes a section type conflict with \
void test@4.part.0()
The following testcase, reduced from Firefox can be used
to reproduce this.
test.ii:
class ClassA {
public:
virtual int __attribute__((__stdcall__)) Dispatch() = 0;
};
class ClassB {
public:
ClassA* __attribute__((__stdcall__)) operator->();
};
class ClassC : ClassA {
int *some_int_ptr_variable;
int __attribute__((__stdcall__)) Dispatch() {
return some_int_ptr_variable
? 42
: m_ClassInstanceB->Dispatch();
}
ClassB m_ClassInstanceB;
};
ClassC ClassInstanceC;
Compile for i686-w64-mingw32 with:
cc1plus -O -fpartial-inlining -fdevirtualize \
-fdevirtualize-speculatively test.ii
Outputs:
test.ii: In member function 'virtual int ClassC::Dispatch()':
test.ii:11:36: error: virtual int ClassC::Dispatch() causes \
a section type conflict with int ClassC::_ZN6ClassC8DispatchEv@4.part.0()
int __attribute__((CALLTYPE)) Dispatch() {
^
test.ii:11:36: note: \
'int ClassC::_ZN6ClassC8DispatchEv@4.part.0()' was declared here
---
gcc/cgraphclones.c | 13 ++++++++++++-
gcc/defaults.h | 2 +-
2 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/gcc/cgraphclones.c b/gcc/cgraphclones.c
index 9e9f1a0..69b8a91 100644
--- a/gcc/cgraphclones.c
+++ b/gcc/cgraphclones.c
@@ -519,15 +519,24 @@ cgraph_node::create_clone (tree new_decl, gcov_type gcov_count, int freq,
static GTY(()) unsigned int clone_fn_id_num;
/* Return a new assembler name for a clone with SUFFIX of a decl named
- NAME. */
+ NAME. Final stdcall @N suffixes are maintained. */
tree
clone_function_name_1 (const char *name, const char *suffix)
{
size_t len = strlen (name);
char *tmp_name, *prefix;
+ char *at_suffix = NULL;
prefix = XALLOCAVEC (char, len + strlen (suffix) + 2);
+ /* name + 1 to skip fastcall which begins with '@' */
+ at_suffix = strchr (name + 1, '@');
+ size_t at_suffix_len = 0;
+ if (at_suffix)
+ {
+ at_suffix_len = strlen (at_suffix);
+ len -= at_suffix_len;
+ }
memcpy (prefix, name, len);
strcpy (prefix + len + 1, suffix);
#ifndef NO_DOT_IN_LABEL
@@ -538,6 +547,8 @@ clone_function_name_1 (const char *name, const char *suffix)
prefix[len] = '_';
#endif
ASM_FORMAT_PRIVATE_NAME (tmp_name, prefix, clone_fn_id_num++);
+ if (at_suffix)
+ strcat (tmp_name, at_suffix);
return get_identifier (tmp_name);
}
diff --git a/gcc/defaults.h b/gcc/defaults.h
index 9d38ba1..c34478a 100644
--- a/gcc/defaults.h
+++ b/gcc/defaults.h
@@ -51,7 +51,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
# define ASM_FORMAT_PRIVATE_NAME(OUTPUT, NAME, LABELNO) \
do { const char *const name_ = (NAME); \
char *const output_ = (OUTPUT) = \
- (char *) alloca (strlen (name_) + 32); \
+ (char *) alloca (strlen (name_) + 35); \
sprintf (output_, ASM_PN_FORMAT, name_, (unsigned long)(LABELNO)); \
} while (0)
#endif
--
2.5.0
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-08-29 13:51 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-08-18 20:27 [PATCH] clone_function_name_1: Retain any stdcall suffix Ray Donnelly
2015-08-29 14:10 ` Kai Tietz
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).