From 09c97583047eab0c0b9d16651dbe0b2b683a87f7 Mon Sep 17 00:00:00 2001 From: jakub Date: Tue, 11 Dec 2012 10:28:35 +0000 Subject: * sanitizer.def: Add comment about importance of ordering of BUILT_IN_ASAN_REPORT* builtins. * cfgcleanup.c (old_insns_match_p): Don't cross-jump __asan_report_* builtins. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@194391 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cfgcleanup.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'gcc/cfgcleanup.c') diff --git a/gcc/cfgcleanup.c b/gcc/cfgcleanup.c index 94267b6e15d..5d142e9e465 100644 --- a/gcc/cfgcleanup.c +++ b/gcc/cfgcleanup.c @@ -1138,6 +1138,28 @@ old_insns_match_p (int mode ATTRIBUTE_UNUSED, rtx i1, rtx i2) CALL_INSN_FUNCTION_USAGE (i2)) || SIBLING_CALL_P (i1) != SIBLING_CALL_P (i2)) return dir_none; + + /* For address sanitizer, never crossjump __asan_report_* builtins, + otherwise errors might be reported on incorrect lines. */ + if (flag_asan) + { + rtx call = get_call_rtx_from (i1); + if (call && GET_CODE (XEXP (XEXP (call, 0), 0)) == SYMBOL_REF) + { + rtx symbol = XEXP (XEXP (call, 0), 0); + if (SYMBOL_REF_DECL (symbol) + && TREE_CODE (SYMBOL_REF_DECL (symbol)) == FUNCTION_DECL) + { + if ((DECL_BUILT_IN_CLASS (SYMBOL_REF_DECL (symbol)) + == BUILT_IN_NORMAL) + && DECL_FUNCTION_CODE (SYMBOL_REF_DECL (symbol)) + >= BUILT_IN_ASAN_REPORT_LOAD1 + && DECL_FUNCTION_CODE (SYMBOL_REF_DECL (symbol)) + <= BUILT_IN_ASAN_REPORT_STORE16) + return dir_none; + } + } + } } #ifdef STACK_REGS -- cgit v1.2.1