mirror of
https://github.com/revng/revng
synced 2026-06-21 14:07:57 +00:00
isolate: keep CSVs used by helpers
We used not to put CSVs in `declarations-only`, since `lift` is able to create them. However, this led to have less CSVs than those we get post-inlining (some are only used in helpers). This represents a problem since sometimes we ignore non-existing registers.
This commit is contained in:
committed by
Pietro Fezzardi
parent
1660b44cfe
commit
ffd8710492
@@ -781,6 +781,19 @@ private:
|
||||
CalledFunctions.insert(CalledFunction);
|
||||
}
|
||||
|
||||
// Preserve all the CSVs used by helpers as well, this saves us from
|
||||
// having "surprises" later, which can be a problem since sometimes we
|
||||
// ignore non-existing CSVs.
|
||||
if (auto *Call = getCallToHelper(&Instruction)) {
|
||||
auto MaybeUsedCSVs = tryGetCSVUsedByHelperCall(Call);
|
||||
if (MaybeUsedCSVs) {
|
||||
for (auto *CSV : MaybeUsedCSVs->Read)
|
||||
UsedGVs.insert(CSV);
|
||||
for (auto *CSV : MaybeUsedCSVs->Written)
|
||||
UsedGVs.insert(CSV);
|
||||
}
|
||||
}
|
||||
|
||||
std::queue<llvm::User *> Users;
|
||||
Users.push(&Instruction);
|
||||
|
||||
|
||||
@@ -29,11 +29,14 @@ public:
|
||||
}
|
||||
|
||||
// The global variables are not needed in this module. Drop their debug info
|
||||
// and their initializer. GlobalDCE will be run later to remove them. This
|
||||
// is except a couple of special ones that are always needed.
|
||||
// and their initializer. GlobalDCE will be run later to remove them.
|
||||
// Note that we preserve CSVs and some other special variables. In
|
||||
// particular, we need CSVs to avoid having new CSVs popping up
|
||||
// post-inlining, which is problematic since sometimes we handle
|
||||
// non-existing CSVs in a special way.
|
||||
for (GlobalVariable &GV : M.globals()) {
|
||||
GV.eraseMetadata(LLVMContext::MD_dbg);
|
||||
if (not isSpecialGV(GV))
|
||||
if (not isSpecialGV(GV) and not FunctionTags::CSV.isTagOf(&GV))
|
||||
GV.setInitializer(nullptr);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user