llvm-pretty-0.15.0.0: A pretty printing library inspired by the llvm binding.
LicenseBSD3
MaintainerKevin Quick <kquick@galois.com>
Stabilityprovisional
Safe HaskellNone
LanguageHaskell2010

Text.LLVM.Combine

Description

This module provides the ability to smash together LLVM Module specifications to provide the ability to load separate LLVM Modules (e.g. bitcode files) and analyze them as if they had been linked together as a single program.

Synopsis

Documentation

llvmModuleCombine :: Module -> Module -> Module Source #

Combines LLVM Modules into a single, composite Module. This is akin to linking, but just from the perspective of what is needed for program analysis.

This differs from `llvm-link` in the following known ways:

  1. The `llvm-link` tool uses structural typing resolution: if two modules each have a type with the same structure, the resulting module will only have one type; the name from one of the modules is chosen and all references to the typename in the other module will be rewritten to the first module.

The llvmModuleCombine function takes a slightly different approach: types are not structurally coalesced, but this means that type names are deconflicted by adding a numbered suffix. This still requires modifying the type name throughout that module, but (a) there are probably fewer type name conflicts than structural equivalences, and (b) the original name is still part of the new name which maintains origin information.

  1. The `llvm-link` tool will occasionally rewrite calls to llvm intrinsics to explicitly add the default personality specification. For example, `llvm.stacksave` may be rewritten to `llvm.stacksave.p0`. Because these are intrinsics, this should not have any significant impact on the result, but llvmModuleCombine does not perform this naming update.
  2. External declaration resolution is type independent and only name sensitive. If Module A has an external declaration `declare f(i32 x)` and Module B has a definition `define f(float x)`, then this llvmModuleCombine operation will use the latter to satisfy the former (by removing the former) even though the types do not match.