Commit Graph

3168 Commits

Author SHA1 Message Date
Alessandro Di Federico ab089a6d3a Adopt clang-format 16 2023-04-14 14:54:14 +02:00
Alessandro Di Federico 8fd34ff0f7 pruneDICompileUnits: delegate to DIFinder 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 060d26f212 Introduce getLocation(Instruction *) 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 624cf2f160 AVI: add GVN
We should be able to drop this soon.
2023-04-13 18:11:48 +02:00
Alessandro Di Federico b5607efce0 struct_initializer: mark as pure 2023-04-13 18:11:48 +02:00
Alessandro Di Federico 98b92a5b01 Prevent merging calls to isolated functions
SimplifyCFG with instruction sinking enabled sometimes can merge two
call sites that are identical at LLVM IR level, but originally come from
two distinct addresses in the original binary.

The nomerge attribute prevents this type of problematic deduplication.
2023-04-13 18:11:48 +02:00
Alessandro Di Federico 79d9011b95 InlineHelpers: drop !dbg post-inlining 2023-04-13 18:11:48 +02:00
Alessandro Di Federico 401f731eda AttachDebugInfo: color instructions with a visit
We used to only color instructions in the same BasicBlock as the call to
`newpc`.  However, an instruction in the original binary can span
multiple BasicBlocks.
2023-04-13 18:11:48 +02:00
Pietro Fezzardi 96390027b7 MakeModelGEPPass.cpp: fix outOfBound in lowerBound 2023-04-11 15:54:20 +02:00
Alessandro Di Federico 92b9ba5571 Import findPhiTreeLeaves 2023-04-08 08:42:24 +02:00
Alessandro Di Federico 0c991af685 AVI: after function_call, jump to anypc
We used to jump to the dispatcher, however we only sink to an
unreachable `anypc`. We were threfore significantly complicating the CFG
in case of indirect function calls.
2023-04-08 08:42:24 +02:00
Alessandro Di Federico f313a72453 DropHelperCalls: pass in loaded CSVs, not pointers
We used to pass pointers to helper functions, but we just need to pass
the loaded value: no need to leak the pointer to the CSV.
2023-04-08 08:42:24 +02:00
Alessandro Di Federico 19d59ffd73 Implement Segment::dump 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 cdf1654f36 CSAA: do not use ptr, use pointee type 2023-04-08 08:42:24 +02:00
Alessandro Di Federico bc4833078c Fix InstCombine constructor invocation
In LLVM 12 the `InstCombine` constructor used to take a `bool`, in LLVM
16 it takes an integer. Implicit promotion was hiding this fact.
2023-04-08 08:42:24 +02:00
Alessandro Di Federico e73543e430 AsmCall: add parameter attribute for element type
Fix calls to inline assembly
2023-04-08 08:42:24 +02:00
Alessandro Di Federico a0c0cd9468 extractFromConstantStringPtr: no stripPointerCasts 2023-04-08 08:42:24 +02:00
Alessandro Di Federico f7f47ceac6 VariableManager: drop autodetection of ${ARCH}CPU 2023-04-08 08:42:24 +02:00
Alessandro Di Federico 71f754f811 PDBImporter: declare our own FilterOptions 2023-04-08 08:42:24 +02:00
Alessandro Di Federico de90eea243 Adopt get{Max,}PointerSizeInBits 2023-04-08 08:42:24 +02:00
Alessandro Di Federico 53715af613 Adopt {PassBuilder::,}OptimizationLevel::O2 2023-04-08 08:42:24 +02:00
Alessandro Di Federico 0570db6873 Drop dead llvm::initialize* invocations 2023-04-08 08:42:24 +02:00
Alessandro Di Federico 348ccec09b Adopt new llvm::MCContext constructor 2023-04-08 08:42:24 +02:00
Alessandro Di Federico 171ba353e5 Adopt llvm/{Support,MC}/TargetRegistry.h 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 6c115da619 Update pass names 2023-04-08 08:42:24 +02:00
Alessandro Di Federico 4182a94346 Adopt MemoryEffects::none 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 a0fa150576 Drop usages of LoadInst::getPointerOperandType 2023-04-08 08:42:24 +02:00
Alessandro Di Federico 7a08d51816 Drop usages of PointerType::getElementType 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 26765f3d84 Drop usages of getBasicBlockList 2023-04-08 08:42:24 +02:00
Alessandro Di Federico a99d54457b Drop usages of getInstList 2023-04-08 08:42:24 +02:00
Alessandro Di Federico aa6a60c5b8 Adopt new InlineFunction prototype 2023-04-08 08:42:24 +02:00
Alessandro Di Federico 449e95021a Replace CallBase::getNumArgOperands with arg_size 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 31b46de38c Remove dead code and fix spurious warnings
Remove some dead code or introduce suppressions for spurious.
These are results of more accurate warnings in clang 16.
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
Massimo Fioravanti fc3f106640 Pipeline: fix accidental container materialization
Pipeline lazy containers were incorrectly materialized when it was not
necessary.
2023-04-07 14:37:14 +02:00
Pietro Fezzardi 663bed90cc Avoid cstringLiteral in operands of local variable
Custom opcodes that are tagged AllocatesLocalVariable never have
arguments that should be replaced with SegmentRef or cstringLiteral.

Constant arguments or those custom opcodes are actually used to encode
another kinds of informations so they should be preserved.

This commit prevents that replacements to happen.
2023-04-06 23:32:08 +02:00
Pietro Fezzardi 28713ba7fe MakeModelGEPPass.cpp: drop leftover debug log 2023-04-06 22:54:25 +02:00
Pietro Fezzardi a37dc1cd77 DecompileFunction.cpp: statement-based emission
This commit refactors the C Backend as follows.
- The emission of basic blocks is now statement based.
  There are some instructions that are handled as statements.
  Those instructions are the points where the codegen starts from when
  emitting C.
  Conversely, all the other instructions are initially ignored when
  iterating on instructions in a basic block, and are only reached when
  traversing the dataflow that originates from statements.
- The TokenMap, that originally included all the string representing all
  the instructions, is now used only to store the names of funciton
  arguments and instructions representing local variables.
- Starting from each statement-like instruction, the C codegen is driven
  by a traversal of the dataflow of the operands. The dataflow is
  traversed recursively with the `getToken` method, materializing
  strings on the fly until the visit reaches "leaves" i.e. instruction
  that represent local variables, constants, or function arguments.

Adopting this approach allowed to reduce the peak memory consumption of
the backend, as well as making it faster on our benchmarks.
2023-04-06 14:56:14 +02:00