diff --git a/pinpoint/safegcc/safe-gimple.h b/pinpoint/safegcc/safe-gimple.h index 9181c77..20d7edd 100644 --- a/pinpoint/safegcc/safe-gimple.h +++ b/pinpoint/safegcc/safe-gimple.h @@ -8,5 +8,6 @@ #include #include #include +#include #endif diff --git a/pinpoint/stage1/asm_offset_pass.cpp b/pinpoint/stage1/asm_offset_pass.cpp index df577cc..248370c 100644 --- a/pinpoint/stage1/asm_offset_pass.cpp +++ b/pinpoint/stage1/asm_offset_pass.cpp @@ -65,13 +65,30 @@ static gimple* make_stage1_separator(tree lhs, UID target, std::size_t offset) { if (!new_gasm) return nullptr; - SSA_NAME_DEF_STMT(lhs) = new_gasm; - separators.emplace(uid, separator); return new_gasm; } -static void separator_assemble_maybe(gimple_stmt_iterator* gsi) { +static void separator_update_ssa_def(function* fn, gimple* old_def, gimple* new_def) { + if (!fn || !old_def) + return; + + // Stage 0 separator call was definition statement of temporary variable + + unsigned i; + tree name; + FOR_EACH_SSA_NAME(i, name, fn) { + if (!name) + continue; + + if (SSA_NAME_DEF_STMT(name) != old_def) + continue; + + SSA_NAME_DEF_STMT(name) = new_def; + } +} + +static void separator_assemble_maybe(function* fn, gimple_stmt_iterator* gsi) { if (!gsi) return; @@ -90,6 +107,7 @@ static void separator_assemble_maybe(gimple_stmt_iterator* gsi) { pinpoint_fatal(); gsi_replace(gsi, replacement, true); + separator_update_ssa_def(fn, stmt, replacement); } static const pass_data asm_offset_pass_data = { @@ -110,7 +128,7 @@ unsigned int asm_offset_pass::execute(function* fn) { basic_block bb; FOR_EACH_BB_FN(bb, fn) { for (gimple_stmt_iterator gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) - separator_assemble_maybe(&gsi); + separator_assemble_maybe(fn, &gsi); } return 0;