17#include "llvm/Transforms/Utils/Cloning.h"
23bool WorkaroundLLVMPR39177Pass::runOnModule(Module &M) {
24 bool modified =
false;
26 const char *libfunctions[] = {
52 for (
auto *funcname : libfunctions) {
53 if (M.getFunction(funcname) !=
nullptr)
56 GlobalValue *gv = M.getNamedValue(funcname);
57 auto *alias = dyn_cast_or_null<GlobalAlias>(gv);
62 while (
auto *ga = dyn_cast<GlobalAlias>(alias->getAliasee())) {
63 assert(ga != alias &&
"alias pointing to itself");
66 Function *f = dyn_cast<Function>(alias->getAliasee());
70 std::string aliasName = alias->getName().str();
73 ValueToValueMapTy VMap;
74 Function *g = CloneFunction(f, VMap);
77 alias->replaceAllUsesWith(g);
79 alias->eraseFromParent();
82 "WorkaroundLLVMPR39177: replaced alias @%s with clone of function @%s",
83 aliasName.c_str(), f->getName().str().c_str());
90char WorkaroundLLVMPR39177Pass::ID = 0;
void klee_message(const char *msg,...) __attribute__((format(printf