Commit Graph

2366 Commits

Author SHA1 Message Date
Andrea Gussoni 7a92d70b8c Introduce llvm::dfs usage for graph algorithms
Implement a couple of restructure algorithms in a template manner, so
that they can be used with any data structure implementing
`GraphTraits`.

Test the algorithms using the `GenericGraph` data structure.
2023-04-27 17:28:22 +02:00
Ivan Krysak 5034488766 GenericGraph: hasSuccessor and hasPredecessor
Older node types didn't have these helpers, so they were added
for compatibility.
2023-04-27 17:28:22 +02:00
Ivan Krysak 49d3499b26 EFA: fix buildControlFlowGraph requirements 2023-04-27 17:28:22 +02:00
Ivan Krysak 7ca012dbc3 Minor improvements 2023-04-27 17:28:22 +02:00
Massimo Fioravanti 69aafd4181 TupleTree: implement tracking data manipulation
Implement the core visits that are able to inspect the model bypassing
the instrumentation.
2023-04-21 17:51:05 +02:00
Massimo Fioravanti 254dc99fcb TupleTreeGenerator: emit tracking machinery 2023-04-21 17:50:16 +02:00
Massimo Fioravanti d65d73359d TrackingContainer: review API 2023-04-21 17:49:26 +02:00
Giacomo Vercesi a2b7d0e0bf PipelineC: add tracing
Add support for tracing onto the PipelineC. This is done by:
1. Creating wrapper functions for each PipelineC function with the
   script in `scripts/PipelineC_add_tracing.py`. These will call a
   special function called `wrap` which will ultimately call a method
   with a `_` prepended to the name
2. Conversion of all PipelineC methods in `PipelineC.cpp` to `static`
   and their rename with a `_` in front, in order for them to work with
   the wrapper function in (1)
3. Generation of 2 additional include files, one for types and one for
   functions, to be used by users of tracing files in order to have
   introspection.

These steps allow the creation of a trace file with the use of the
`REVNG_C_API_TRACE_PATH` environment variable. The traces can then be
used in conjunction with the `revng trace run` and `revng trace
inspect` commands.
2023-04-20 14:43:13 +02:00
Giacomo Vercesi 19bb38d32b PipelineC: fix UAF on rp_targets_list
The underlying rp_target pointer was not stable, switch to returning a
copy of the target instead.
2023-04-20 14:43:13 +02:00
Giacomo Vercesi 566cb6310b PipelineC: make indexed object stably sorted
Many Pipeline objects (Globals, Ranks, Kinds, Targets in a TargetList)
were ordered by load order, this makes the playback of traces difficult.
Moreover the order of loading of pipeline files also influences the
ordering of other elements (Step, Analys{is,esLists}). These are also
ordered to prevent incosistent ordering.
2023-04-20 14:43:13 +02:00
Giacomo Vercesi 8d89c6a318 PipelineC: rp_initialize: only use argc and argv
Switch from specifying `libraries` and `pipelines` in `rp_initialize`
and `rp_manager_create` to the use of command-line options that are to
be passed via `argc` and `argv` in `rp_initialize`.
2023-04-20 14:43:12 +02:00
Giacomo Vercesi 9a972009d1 PipelineC: size and const-correctness
Fix the return type (often mismatched from uint64_t to int) and the
const-correctness of many functions in PipelineC
2023-04-20 14:43:12 +02:00
Alessandro Di Federico a9eae1c96b Purge remaining traces of InsertValueInst
InsertValue has long been superseded by `struct_initialier`, so we don't
expect it in the IR we work on.
2023-04-14 14:54:14 +02:00
Alessandro Di Federico 79c2ca38f6 Introduce SplitOverflowIntrinsicsPass
This pass splits calls `*.with.overflow*` intrinsics into the a pair of
instructions: the underlying operation and a call to an `Helper`-tagged
function that computes whether such operation overflowed.

For instance, we go from:

    %2 = call { i32, i1 } @llvm.umul.with.overflow.i32(i32 %0, i32 %1)
    %3 = extractvalue { i32, i1 } %2, 1
    br i1 %3, label %..., label %...

To:

    %2 = mul i32 %0, %1
    %3 = call i1 @mul_overflow_u32(i32 %0, i32 %1)
    br i1 %3, label %..., label %...

This saves from handling `struct` in the backend.
2023-04-14 14:54:14 +02:00
Alessandro Di Federico 886e1696a2 llvmIntToModelType: adapt to opaque pointers
This commit introduces modelType, which supersedes `llvmIntToModelType`
in order to better handle translation of LLVM types into model types
after introduction of opaque pointer types.  The main differences is
that `modelType` accepts the `Value` (instead of just the `Type`), so it
can better handle `AllocaInst` and `GlobalVariable`, which provide
information about the pointee.
2023-04-14 14:54:14 +02:00
Alessandro Di Federico f6ad90cfd5 WeightTraits<llvm::BasicBlock *>: fix mistake
We were always returning the same value instead of the computed weight.
2023-04-14 14:54:14 +02:00
Alessandro Di Federico 7291314505 Stop using getPointer
After introduction of opaque pointers, it's not very effective.
2023-04-14 14:54:14 +02:00
Alessandro Di Federico 4c469e5180 Adopt getCallToTagged
`isCallToTagged` used to return a pointer in case of success.
We now have `getCallToTagged` for that.

Also, these functions have been moved to revng.
2023-04-14 14:54:14 +02:00
Alessandro Di Federico ead746ba68 Adopt MemoryEffects
Switch from function attributes to MemoryEffects.
2023-04-14 14:54:14 +02:00
Alessandro Di Federico c56b250c99 RegionCFGTree: add missing const 2023-04-14 14:54:14 +02:00
Alessandro Di Federico 95615cf400 Adopt new APInt::toString signature 2023-04-14 14:54:14 +02:00
Alessandro Di Federico cad027abb2 Add missing includes 2023-04-14 14:54:14 +02:00
Alessandro Di Federico ab089a6d3a Adopt clang-format 16 2023-04-14 14:54:14 +02:00
Alessandro Di Federico 5b8d5a8a41 Introduce OpaqueFunctionsPool::initializeFromName 2023-04-14 08:36:05 +02:00
Alessandro Di Federico 40135aad97 Drop CSVAliasAnalysisPass 2023-04-13 18:11:48 +02:00
Alessandro Di Federico 8ef567471b LLVMContainer::mergeBackImpl: postpone verify
This commit moves module verification after cleanup.
2023-04-13 18:11:48 +02:00
Alessandro Di Federico 060d26f212 Introduce getLocation(Instruction *) 2023-04-13 18:11:48 +02:00
Alessandro Di Federico 8c5f6628d1 Stop considering Instructions Taggable
Adding custom (i.e., non-dbg) metadata to Instructions has proven to be
too brittle.
2023-04-13 18:11:48 +02:00
Alessandro Di Federico bce3555285 Drop CallToLifted tag
This commit drops the `CallToLifted` tag in favor of a
`getCallToIsolatedFunction` function which checks if the call has the
`IsolatedFunction` tag. The function also assumes that indirect calls
are calls to lifted functions.
2023-04-13 18:11:48 +02:00
Alessandro Di Federico 92b9ba5571 Import findPhiTreeLeaves 2023-04-08 08:42:24 +02:00
Alessandro Di Federico dc7f731bef Mark build_PlainMetaAddress as const 2023-04-08 08:42:24 +02:00
Alessandro Di Federico 995d44cf73 Implement Location::{parent,back} 2023-04-08 08:42:24 +02:00
Alessandro Di Federico 52ee85f55f Implement efa::BasicBlock::contains 2023-04-08 08:42:24 +02:00
Alessandro Di Federico 6564fc0568 Minor changes 2023-04-08 08:42:24 +02:00
Alessandro Di Federico daafc6a1e7 AVI: handle SCEV's scSequentialUMinExpr 2023-04-08 08:42:24 +02:00
Alessandro Di Federico bcd374038c s/zextOrSelf/zext/g 2023-04-08 08:42:24 +02:00
Alessandro Di Federico ae871f5062 Adopt setOnlyReadsMemory 2023-04-08 08:42:24 +02:00
Alessandro Di Federico 43fd690ea8 InaccessibleMemOnly: adopt MemoryEffects 2023-04-08 08:42:24 +02:00
Alessandro Di Federico e131817334 Drop usage of Type::getPointerElementType 2023-04-08 08:42:24 +02:00
Alessandro Di Federico f777ccc4d3 Replace llvm::sys::fs::F_None with OF_None 2023-04-08 08:42:24 +02:00
Alessandro Di Federico 06f9bca598 Adopt {add,remove}FnAttribute 2023-04-08 08:42:24 +02:00
Alessandro Di Federico 394111ed40 Add missing includes 2023-04-08 08:42:24 +02:00
Alessandro Di Federico d2caa1fad0 Make CreateLoad usages opaque pointers-compatible 2023-04-08 08:42:24 +02:00
Alessandro Di Federico dbcdad0a4d Switch from llvm::Optional to std::optional 2023-04-08 08:42:24 +02:00
Alessandro Di Federico 389342411a Drop makeArrayRef 2023-04-08 08:42:24 +02:00
Alessandro Di Federico 5ed9432a68 Fix ambiguous template function
Bumping LLVM version turned these into compiler errors.
2023-04-08 08:42:23 +02:00
Alessandro Di Federico e3f9519ffc Get rid of std::iterator 2023-04-08 08:42:23 +02:00
Alessandro Di Federico 74ae629853 Drop experimental from coroutines 2023-04-08 08:42:23 +02:00
Alessandro Di Federico 52521f8cac Adopt more standard library's features 2023-04-08 08:42:23 +02:00
Alessandro Di Federico b2f22c168f Adopt clang-format 16 2023-04-08 08:42:23 +02:00