ConstantFoldInstruction - Try to constant fold the specified instruction. If successful, the constant result is returned, if not, null is returned. Note that this fails if not all of the operands are constant. Otherwise, this function can only fail when attempting to fold instructions like loads and stores, which have no constant expression form.
Declared in <llvm/Analysis/ConstantFolding.h>
Constant*
ConstantFoldInstruction(
Instruction const* I,
DataLayout const& DL,
TargetLibraryInfo const* TLI = nullptr);
This is an important base class in LLVM. It provides the common facilities of all constant values in an LLVM program. A constant is a value that is immutable at runtime. Functions are constants because their address is immutable. Same with global variables.
| Name | Description |
|---|---|
| DL | A parsed version of the target data layout string in and methods for querying it. |
| TLI | Provides information about what library functions are available for the current target. |