Files
revng-revng/lib/EarlyFunctionAnalysis/CMakeLists.txt
Alessandro Di Federico f68b7866b3 Introduce BasicBlockID
This commit introduces `BasicBlockID` as the unique identifier for a
`efa::BasicBlock` into the CFG. A `BasicBlockID` is defined by a
`MetaAddress` plus an incremental integer. This enables us to have
multiple instances of the same block in a single function, which is
particularly useful when inlining multiple times the same function.

Apart from this, the commit also does the following:

* It drops representing `MetaAddress`es a `structs` in the IR. This created
  several issues related to ABI. We now represent them as strings.

* It defines more functions in `support.h`, instead of defining prototypes
  by hand in `CodeGenerator.cpp` and the like. Specifically, `unknownPC`
  and `raise_exception_helper`. We also introduce a C "constructor" for
  `PlainMetaAddress`.

* It significantly reduces the API of `GeneratedCodeBasicInfo`, which
  was supposed to be put on a diet since a long time.  Specifically,
  many jump target related methods have been moved to free functions in
  `IRHelpers.h`.  Also `GCBI::getSuccessors` has been pushed into its
  only user, `PruneRetSuccessors`, to prevent further usage of a
  deprecated API. In the future, it would be nice to drop it entirely.

* It introduces `efa::BasicBlock::InlinedFrom`.

* Introduce an enum to represent named argument indices for `newpc`.
  This enables us to more effectively manipulate its argument list.

* It improves the verification and error reporting for
  `efa::FunctionMetadata`.

* Update tests.

This commit is preliminary to another piece of work to improve the
generality of inlining beyond the simple "fake function" scenario, for
which the feature was originally conceived.
2023-02-23 14:51:10 +01:00

76 lines
1.8 KiB
CMake

#
# This file is distributed under the MIT License. See LICENSE.md for details.
#
add_subdirectory(ABIAnalyses)
# Define revngEarlyFunctionAnalysis library
revng_add_analyses_library_internal(
revngEarlyFunctionAnalysis
AAWriterPass.cpp
AttachDebugInfo.cpp
CFGAnalyzer.cpp
CollectCFG.cpp
CollectFunctionsFromCalleesPass.cpp
CollectFunctionsFromUnusedAddressesPass.cpp
DetectABI.cpp
FunctionMetadata.cpp
FunctionSummaryOracle.cpp
IndirectBranchInfoPrinterPass.cpp
FunctionMetadataCache.cpp
Outliner.cpp
PromoteGlobalToLocalVars.cpp
SegregateDirectStackAccesses.cpp
${GENERATED_IMPLS})
llvm_map_components_to_libnames(
LLVM_LIBRARIES
Analysis
TransformUtils
ScalarOpts
InstCombine
Passes
CodeGen)
target_link_libraries(
revngEarlyFunctionAnalysis
revngBasicAnalyses
revngABI
revngABIAnalyses
revngSupport
revngModel
revngPipes
${LLVM_LIBRARIES})
# Header files containing efa YAML must be added here
set(EFA_HEADERS_DIR "${CMAKE_SOURCE_DIR}/include/revng/EarlyFunctionAnalysis")
set(OUTPUT_DIR
"${CMAKE_BINARY_DIR}/include/revng/EarlyFunctionAnalysis/Generated")
set(SCHEMA_PATH "${CMAKE_BINARY_DIR}/efa-schema.yml")
target_tuple_tree_generator(
revngEarlyFunctionAnalysis
INSTALL
HEADER_DIRECTORY
EarlyFunctionAnalysis
NAMESPACE
efa
SCHEMA_PATH
${SCHEMA_PATH}
ROOT_TYPE
FunctionMetadata
SEPARATE_STRING_TYPES
"MetaAddress"
SCALAR_TYPES
"BasicBlockID"
"MetaAddress"
"model::FunctionAttribute::Values"
HEADERS
"${EFA_HEADERS_DIR}/BasicBlock.h"
"${EFA_HEADERS_DIR}/CallEdge.h"
"${EFA_HEADERS_DIR}/FunctionEdge.h"
"${EFA_HEADERS_DIR}/FunctionEdgeBase.h"
"${EFA_HEADERS_DIR}/FunctionEdgeType.h"
"${EFA_HEADERS_DIR}/FunctionMetadata.h")
install(DIRECTORY ${OUTPUT_DIR} DESTINATION include/revng/EarlyFunctionAnalysis)