Skip to content

Commit

Permalink
gcc: Make plugin gcc8 compatible
Browse files Browse the repository at this point in the history
- merge updates from torvalds gcc-common.h
- attribut_spec initialization for gcc8
  • Loading branch information
Fletex authored and florommel committed Jul 25, 2018
1 parent f475da7 commit 6bbbdd8
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 13 deletions.
43 changes: 33 additions & 10 deletions gcc-plugin/gcc-common.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
*
* See git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
*/
/* SPDX-License-Identifier: GPL-2.0 */

#ifndef GCC_COMMON_H_INCLUDED
#define GCC_COMMON_H_INCLUDED
Expand Down Expand Up @@ -70,6 +71,13 @@
#endif

#if BUILDING_GCC_VERSION >= 4006
/*
* The c-family headers were moved into a subdirectory in GCC version
* 4.7, but most plugin-building users of GCC 4.6 are using the Debian
* or Ubuntu package, which has an out-of-tree patch to move this to the
* same location as found in 4.7 and later:
* https://sources.debian.net/src/gcc-4.6/4.6.3-14/debian/patches/pr45078.diff/
*/
#include "c-family/c-common.h"
#else
#include "c-common.h"
Expand All @@ -96,6 +104,10 @@
#include "predict.h"
#include "ipa-utils.h"

#if BUILDING_GCC_VERSION >= 8000
#include "stringpool.h"
#endif

#if BUILDING_GCC_VERSION >= 4009
#include "attribs.h"
#include "varasm.h"
Expand Down Expand Up @@ -391,13 +403,6 @@ static inline struct cgraph_node *cgraph_alias_target(struct cgraph_node *n)
}
#endif

#if BUILDING_GCC_VERSION >= 4007 && BUILDING_GCC_VERSION <= 4009
#define cgraph_create_edge(caller, callee, call_stmt, count, freq, nest) \
cgraph_create_edge((caller), (callee), (call_stmt), (count), (freq))
#define cgraph_create_edge_including_clones(caller, callee, old_call_stmt, call_stmt, count, freq, nest, reason) \
cgraph_create_edge_including_clones((caller), (callee), (old_call_stmt), (call_stmt), (count), (freq), (reason))
#endif

#if BUILDING_GCC_VERSION <= 4008
#define ENTRY_BLOCK_PTR_FOR_FN(FN) ENTRY_BLOCK_PTR_FOR_FUNCTION(FN)
#define EXIT_BLOCK_PTR_FOR_FN(FN) EXIT_BLOCK_PTR_FOR_FUNCTION(FN)
Expand Down Expand Up @@ -722,10 +727,23 @@ static inline const char *get_decl_section_name(const_tree decl)
#define varpool_get_node(decl) varpool_node::get(decl)
#define dump_varpool_node(file, node) (node)->dump(file)

#define cgraph_create_edge(caller, callee, call_stmt, count, freq, nest) \
#if BUILDING_GCC_VERSION >= 8000
#define cgraph_create_edge(caller, callee, call_stmt, count, freq) \
(caller)->create_edge((callee), (call_stmt), (count))

#define cgraph_create_edge_including_clones(caller, callee, \
old_call_stmt, call_stmt, count, freq, reason) \
(caller)->create_edge_including_clones((callee), \
(old_call_stmt), (call_stmt), (count), (reason))
#else
#define cgraph_create_edge(caller, callee, call_stmt, count, freq) \
(caller)->create_edge((callee), (call_stmt), (count), (freq))
#define cgraph_create_edge_including_clones(caller, callee, old_call_stmt, call_stmt, count, freq, nest, reason) \
(caller)->create_edge_including_clones((callee), (old_call_stmt), (call_stmt), (count), (freq), (reason))

#define cgraph_create_edge_including_clones(caller, callee, \
old_call_stmt, call_stmt, count, freq, reason) \
(caller)->create_edge_including_clones((callee), \
(old_call_stmt), (call_stmt), (count), (freq), (reason))
#endif

typedef struct cgraph_node *cgraph_node_ptr;
typedef struct cgraph_edge *cgraph_edge_p;
Expand Down Expand Up @@ -957,4 +975,9 @@ static inline void debug_gimple_stmt(const_gimple s)
get_inner_reference(exp, pbitsize, pbitpos, poffset, pmode, punsignedp, preversep, pvolatilep)
#endif

#if BUILDING_GCC_VERSION < 7000
#define SET_DECL_ALIGN(decl, align) DECL_ALIGN(decl) = (align)
#define SET_DECL_MODE(decl, mode) DECL_MODE(decl) = (mode)
#endif

#endif
11 changes: 8 additions & 3 deletions gcc-plugin/multiverse.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,11 @@
#include <vector>
#include <set>


#include "gcc-common.h"
#include "multiverse.h"

#if BUILDING_GCC_VERSION < 6000 || BUILDING_GCC_VERSION > 7110
#error "Currently, the plugin supports only GCC 6 and GCC 7."
#if BUILDING_GCC_VERSION < 6000 || BUILDING_GCC_VERSION >= 9000
#error "Currently, the plugin supports GCC 6, 7 and 8."
#endif


Expand Down Expand Up @@ -173,8 +172,14 @@ static struct attribute_spec mv_attribute =
.decl_required = true,
.type_required = false,
.function_type_required = false,
#if BUILDING_GCC_VERSION >= 8000
.affects_type_identity = false,
.handler = handle_mv_attribute,
.exclude = nullptr,
#else
.handler = handle_mv_attribute,
.affects_type_identity = false,
#endif /* >= 8000 */
};


Expand Down

0 comments on commit 6bbbdd8

Please sign in to comment.