简体   繁体   中英

Getting all Values in LLVM Module

I am working on an analysis pass and I need to find all InlineAsm values in a module .

I have tried using Module::getValueSymbolTable() but it looks to only contain global and function symbols.

I also tried calling Function::getValueSymbolTable() for each function in the module, but the documentation is not clear about which symbols it contains and it appears to still be missing the InlineAsm values I'm looking for.

Just for reference, my current (non-working) approach is something like:

llvm::Module M = ...;
auto &MS = M.getValueSymbolTable();
for (auto it = MS.begin(), end = MS.end(); it != end; ++it) {
    if (isa<InlineAsm>(it->second)) {
        // do something
    }
}

for (auto &F : M) {
    auto FS = F.getValueSymbolTable();
    for (auto it = FS->begin(), end = FS->end(); it != end; ++it) {
        if (isa<InlineAsm>(it->second)) {
            // do something
        }
    }
}

How can I get all the values on an llvm Module?

I'd assume you need to collect all inlineasm instructions (and not module-level inline assembler nodes). For this you'd need to iterate over all Functions of a Module. Inside a Function you need to iterate over all Instructions checking whether the instruction in question represents an InlineAsm instruction or not. Something like http://llvm.org/docs/ProgrammersManual.html#iterating-over-the-instruction-in-a-function will help.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM