[llvm-dev] How to understand LLVM-C API?

Peng Yu via llvm-dev llvm-dev at lists.llvm.org
Mon Feb 18 10:53:01 PST 2019


Hi,

I am learning LLVM-C API (I don't plan to learn the C++ API at this
moment.). I am able to get this example to compile and run.

http://www.duskborn.com/posts/optimizing-llvm-ir-from-the-c-api/

However, I don't understand the usage of LLVMReplaceAllUsesWith().

    // replace all uses of the old instruction with the new one
    LLVMReplaceAllUsesWith(instruction, replacementValue);

How can a value replace an instruction?

The reference is not helpful either. It shows both OldVal, NewVal are
just LLVMValueRef,  why an instruction can be used as a value?

http://llvm.org/doxygen/group__LLVMCCoreValueGeneral.html#ga5180328ab0b7fd00cd814304a33c0b0e

In general, the reference generated by doxygen is not good for
learning and the type hierarchy is too complex. Is there any more
effective materials for learning the C API.

Thanks.

-- 
Regards,
Peng


More information about the llvm-dev mailing list