Fixed ssa problems in stage 1 of pinpoint plugin

This commit is contained in:
York Jasper Niebuhr 2025-10-25 16:35:08 +02:00
parent ef755456da
commit b7a3524779
2 changed files with 23 additions and 4 deletions

View File

@ -8,5 +8,6 @@
#include <gimplify.h>
#include <gimple-iterator.h>
#include <gimple-pretty-print.h>
#include <ssa.h>
#endif

View File

@ -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;