| 478 | } |
| 479 | |
| 480 | static std::unique_ptr<llvm::Module> |
| 481 | load_module(llvm::StringRef Identifier) |
| 482 | { |
| 483 | LLVMMemoryBufferRef buf; |
| 484 | LLVMModuleRef mod; |
| 485 | char path[MAXPGPATH]; |
| 486 | char *msg; |
| 487 | |
| 488 | snprintf(path, MAXPGPATH,"%s/bitcode/%s", pkglib_path, Identifier.data()); |
| 489 | |
| 490 | if (LLVMCreateMemoryBufferWithContentsOfFile(path, &buf, &msg)) |
| 491 | elog(FATAL, "failed to open bitcode file \"%s\": %s", |
| 492 | path, msg); |
| 493 | if (LLVMGetBitcodeModuleInContext2(LLVMGetGlobalContext(), buf, &mod)) |
| 494 | elog(FATAL, "failed to parse bitcode in file \"%s\"", path); |
| 495 | |
| 496 | /* |
| 497 | * Currently there's no use in more detailed debug info for JITed |
| 498 | * code. Until that changes, not much point in wasting memory and cycles |
| 499 | * on processing debuginfo. |
| 500 | */ |
| 501 | llvm::StripDebugInfo(*llvm::unwrap(mod)); |
| 502 | |
| 503 | return std::unique_ptr<llvm::Module>(llvm::unwrap(mod)); |
| 504 | } |
| 505 | |
| 506 | /* |
| 507 | * Compute list of referenced variables, functions and the instruction count |
no outgoing calls
no test coverage detected