user3707531
user3707531

Reputation: 63

Associate metadata to LLVM basic blocks in an analysis pass

How can I store per-basic-block information produced in a custom LLVM analysis pass to make it available in future optimization passes?

For example, let's assume that I'm deriving class FunctionPass to implement liveness analysis. This pass would produce sets LiveIn and LiveOut for each basic block in the function. Where should I declare these sets for future use by other LLVM passes? How can I make them directly accessible from their associated llvm::BasicBlock data structure?

Upvotes: 1

Views: 653

Answers (1)

hadi sadeghi
hadi sadeghi

Reputation: 537

At the moment there is not any direct way to attach metadata to BasicBlocks, since BasicBlock class does not have Metadata as a data member. you can extend the BasicBlock class as one option, another option which is common is to attach BasicBlock related metadata to its Terminator instruction, but every pass which merges or splits BasicBloks or modifies CFG, might invalidate your information.

Upvotes: 2

Related Questions