From 44dc7b0d4485f4bc300210984db4e4369a48503b Mon Sep 17 00:00:00 2001 From: Justin Seyster Date: Fri, 13 Aug 2010 22:30:14 -0400 Subject: [PATCH] Fixed crash when initial block has no first_stmt. Still need to figure out how to correctly get the filename/lineno for functions that have an entry block with no first_stmt. --- src/aop-duplicate.c | 13 +++++++++++-- src/aop-pc-entry.c | 17 +++++++++++++++-- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/src/aop-duplicate.c b/src/aop-duplicate.c index 89d6d57..69f1913 100644 --- a/src/aop-duplicate.c +++ b/src/aop-duplicate.c @@ -150,8 +150,17 @@ duplicate_function_body (const char *tmpvar_name, gimple call) source_location orig_loc; /* Remember the source location in the original first block. */ - cur_bb = ENTRY_BLOCK_PTR_FOR_FUNCTION (cfun); - orig_loc = gimple_location (first_stmt (cur_bb->next_bb)); + { + basic_block bb; + gimple stmt; + + bb = ENTRY_BLOCK_PTR_FOR_FUNCTION (cfun); + stmt = first_stmt (bb->next_bb); + if (stmt != NULL) + orig_loc = gimple_location (first_stmt (bb->next_bb)); + else + orig_loc = 0; + } bb_pairs = VEC_alloc (bb_pair, gc, INITIAL_PAIRS); label_pairs = VEC_alloc (label_pair, heap, INITIAL_PAIRS); diff --git a/src/aop-pc-entry.c b/src/aop-pc-entry.c index a828a9e..f30d945 100644 --- a/src/aop-pc-entry.c +++ b/src/aop-pc-entry.c @@ -49,9 +49,22 @@ get_function_entry_xloc() { basic_block bb; expanded_location xloc; - + gimple stmt; + + /* TODO: How do we figure out the line number and file number when + their is no first_stmt? */ bb = ENTRY_BLOCK_PTR_FOR_FUNCTION (cfun); - xloc = expand_location (gimple_location (first_stmt (bb->next_bb))); + stmt = first_stmt (bb->next_bb); + if (stmt != NULL) + { + xloc = expand_location (gimple_location (stmt)); + } + else + { + xloc.line = 0; + xloc.file = NULL; + } + return xloc; } -- 2.34.1