diff options
author | Yury Gribov <y.gribov@samsung.com> | 2014-02-05 05:22:29 +0000 |
---|---|---|
committer | Yury Gribov <ygribov@gcc.gnu.org> | 2014-02-05 05:22:29 +0000 |
commit | 25a07c7ee9e1a2e595efa48740ce5144d005e9ac (patch) | |
tree | c4458a513932ddf878811f6b9349550dfc2ba811 /gcc/ipa-inline.c | |
parent | 4bf2a588d4f65587e9678c8a5e068ebd92110f85 (diff) | |
download | gcc-25a07c7ee9e1a2e595efa48740ce5144d005e9ac.zip gcc-25a07c7ee9e1a2e595efa48740ce5144d005e9ac.tar.gz gcc-25a07c7ee9e1a2e595efa48740ce5144d005e9ac.tar.bz2 |
re PR sanitizer/59600 (no_sanitize_address mishandled when function is inlined)
PR sanitizer/59600
gcc/
* cif-code.def (ATTRIBUTE_MISMATCH): New CIF code.
* ipa-inline.c (report_inline_failed_reason): Handle mismatched
sanitization attributes.
(can_inline_edge_p): Likewise.
(sanitize_attrs_match_for_inline_p): New function.
gcc/testsuite/
* gcc.dg/asan/nosanitize-and-inline.c: : New test.
From-SVN: r207497
Diffstat (limited to 'gcc/ipa-inline.c')
-rw-r--r-- | gcc/ipa-inline.c | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/gcc/ipa-inline.c b/gcc/ipa-inline.c index 5f47e0b..ce24ea5 100644 --- a/gcc/ipa-inline.c +++ b/gcc/ipa-inline.c @@ -234,7 +234,25 @@ report_inline_failed_reason (struct cgraph_edge *e) } } -/* Decide if we can inline the edge and possibly update + /* Decide whether sanitizer-related attributes allow inlining. */ + +static bool +sanitize_attrs_match_for_inline_p (const_tree caller, const_tree callee) +{ + /* Don't care if sanitizer is disabled */ + if (!(flag_sanitize & SANITIZE_ADDRESS)) + return true; + + if (!caller || !callee) + return true; + + return !!lookup_attribute ("no_sanitize_address", + DECL_ATTRIBUTES (caller)) == + !!lookup_attribute ("no_sanitize_address", + DECL_ATTRIBUTES (callee)); +} + + /* Decide if we can inline the edge and possibly update inline_failed reason. We check whether inlining is possible at all and whether caller growth limits allow doing so. @@ -327,6 +345,12 @@ can_inline_edge_p (struct cgraph_edge *e, bool report, e->inline_failed = CIF_TARGET_OPTION_MISMATCH; inlinable = false; } + /* Don't inline a function with mismatched sanitization attributes. */ + else if (!sanitize_attrs_match_for_inline_p (e->caller->decl, callee->decl)) + { + e->inline_failed = CIF_ATTRIBUTE_MISMATCH; + inlinable = false; + } /* Check if caller growth allows the inlining. */ else if (!DECL_DISREGARD_INLINE_LIMITS (callee->decl) && !disregard_limits |