为什么Module :: getOrInsertFunction返回一个指向Constant的指针

Tho*_*son 2 llvm

Module::getOrInsertFunction在LLVM中有4个变体,如下所示,所有这些变量都返回Constant*.为什么要Constant返回创建指针Function?

Constant * getOrInsertFunction (StringRef Name, FunctionType *T, AttributeSet AttributeList)

Ism*_*awi 6

该文件内容如下:

四种可能性:1.如果不存在,请为函数添加原型并将其返回.2.如果它存在且具有本地链接,则重命名现有函数并插入新函数.3.否则,如果现有函数具有正确的原型,则返回现有函数.4.最后,函数存在但具有错误的原型:将constantexpr强制转换为右侧原型的函数.

对于案例4,返回值为a ConstantExpr*,而不是a Function*.因此,返回类型是Constant*常见的超类.