mirror of
https://github.com/revng/revng
synced 2026-06-21 14:07:57 +00:00
TypeNames: drop stack inlinig logic
This commit is contained in:
committed by
Pietro Fezzardi
parent
5a61f28729
commit
8b4462c902
@@ -1,14 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
//
|
||||
// This file is distributed under the MIT License. See LICENSE.md for details.
|
||||
//
|
||||
|
||||
#include "llvm/Support/CommandLine.h"
|
||||
|
||||
namespace revng::options {
|
||||
|
||||
// Enabled by default.
|
||||
extern llvm::cl::opt<bool> EnableStackFrameInlining;
|
||||
|
||||
} // namespace revng::options
|
||||
@@ -28,16 +28,6 @@ protected:
|
||||
|
||||
public:
|
||||
struct ConfigurationOptions {
|
||||
/// When set to true, function stack frame types are printed also inside the
|
||||
/// function body, and not just in the header.
|
||||
/// This may break the property that we emit syntactically valid C code,
|
||||
/// because including the header will cause the definition of the stack
|
||||
/// frame type to be duplicated in the header and inside the function body.
|
||||
/// For this reason it's disabled by default. And it should only be turned
|
||||
/// on when printing artifacts that only show the body of the function, for
|
||||
/// which emitting recompilable C code is not a strict requirement.
|
||||
bool EnableStackFrameInlining = false;
|
||||
|
||||
/// Because we are emitting C11, we cannot specify underlying enum type
|
||||
/// (the feature was only backported from C++ in C23), which means that
|
||||
/// when we need to preserve enum size across the compilation boundary
|
||||
|
||||
@@ -35,7 +35,6 @@
|
||||
#include "revng/ABI/ModelHelpers.h"
|
||||
#include "revng/Backend/DecompileFunction.h"
|
||||
#include "revng/EarlyFunctionAnalysis/ControlFlowGraphCache.h"
|
||||
#include "revng/HeadersGeneration/Options.h"
|
||||
#include "revng/InitModelTypes/InitModelTypes.h"
|
||||
#include "revng/Model/Binary.h"
|
||||
#include "revng/Model/FunctionTags.h"
|
||||
@@ -1945,19 +1944,9 @@ void CCodeGenerator::emitFunction(bool NeedsLocalStateVar) {
|
||||
|
||||
revng_assert(not IsStackDefined, "Multiple stack variables?");
|
||||
const model::StructDefinition &Struct = *ModelFunction.stackFrameType();
|
||||
// In the artifacts generated by this LLVM-based backend we've given up
|
||||
// the requirement of emitting syntactically valid C code. Hence, we can
|
||||
// always emit the stack frame type definition inside the body of the
|
||||
// function itself, because we don't care anymore if it clashes with a
|
||||
// global definition that we have emitted in a header outside the
|
||||
// function's body.
|
||||
if (B.Configuration.EnableStackFrameInlining) {
|
||||
B.printDefinition(Struct, " " + std::move(VarName));
|
||||
} else {
|
||||
auto Named = B.getNamedCInstance(*ModelFunction.StackFrame().Type(),
|
||||
std::move(VarName));
|
||||
B.append(Named + ";\n");
|
||||
}
|
||||
auto Named = B.getNamedCInstance(*ModelFunction.StackFrame().Type(),
|
||||
std::move(VarName));
|
||||
B.append(Named + ";\n");
|
||||
IsStackDefined = true;
|
||||
|
||||
} else {
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
|
||||
#include "revng/Backend/DecompileFunction.h"
|
||||
#include "revng/Backend/DecompilePipe.h"
|
||||
#include "revng/HeadersGeneration/Options.h"
|
||||
#include "revng/Model/Binary.h"
|
||||
#include "revng/Pipeline/AllRegistries.h"
|
||||
#include "revng/Pipes/Kinds.h"
|
||||
@@ -145,12 +144,9 @@ void Decompile::run(pipeline::ExecutionContext &EC,
|
||||
const model::Binary &Model = *getModelFromContext(EC);
|
||||
ControlFlowGraphCache Cache(CFGMap);
|
||||
|
||||
namespace options = revng::options;
|
||||
ptml::ModelCBuilder
|
||||
B(llvm::nulls(),
|
||||
Model,
|
||||
/* EnableTaglessMode = */ false,
|
||||
{ .EnableStackFrameInlining = options::EnableStackFrameInlining });
|
||||
ptml::ModelCBuilder B(llvm::nulls(),
|
||||
Model,
|
||||
/* EnableTaglessMode = */ false);
|
||||
|
||||
for (const model::Function &Function :
|
||||
getFunctionsAndCommit(EC, DecompiledFunctions.name())) {
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
revng_add_analyses_library_internal(
|
||||
revngModelToHeader ModelToHeader.cpp ModelToHeaderPipe.cpp
|
||||
ModelTypeDefinitionPipe.cpp Options.cpp)
|
||||
ModelTypeDefinitionPipe.cpp)
|
||||
|
||||
target_link_libraries(
|
||||
revngModelToHeader
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
|
||||
#include "revng/HeadersGeneration/ConfigurationHelpers.h"
|
||||
#include "revng/HeadersGeneration/ModelToHeaderPipe.h"
|
||||
#include "revng/HeadersGeneration/Options.h"
|
||||
#include "revng/HeadersGeneration/PTMLHeaderBuilder.h"
|
||||
#include "revng/Pipeline/AllRegistries.h"
|
||||
#include "revng/Pipeline/RegisterContainerFactory.h"
|
||||
@@ -26,8 +25,7 @@ void ModelToHeader::run() {
|
||||
B(*Out,
|
||||
Binary,
|
||||
/* EnableTaglessMode = */ false,
|
||||
{ .EnableStackFrameInlining = revng::options::EnableStackFrameInlining,
|
||||
.EnablePrintingOfTheMaximumEnumValue = true,
|
||||
{ .EnablePrintingOfTheMaximumEnumValue = true,
|
||||
.ExplicitTargetPointerSize = getExplicitPointerSize(Binary) });
|
||||
ptml::HeaderBuilder(B).printModelHeader(/*DefineOpaqueTypes*/ true);
|
||||
Out->flush();
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
//
|
||||
// This file is distributed under the MIT License. See LICENSE.md for details.
|
||||
//
|
||||
|
||||
#include "revng/HeadersGeneration/Options.h"
|
||||
|
||||
using namespace llvm::cl;
|
||||
|
||||
namespace revng::options {
|
||||
|
||||
opt<bool> EnableStackFrameInlining("enable-stack-frame-inlining",
|
||||
desc("Enable printing the definition "
|
||||
"of a function's stack type inside "
|
||||
"the function's body."),
|
||||
init(false));
|
||||
|
||||
} // namespace revng::options
|
||||
Reference in New Issue
Block a user