Created
September 9, 2015 11:38
-
-
Save maleadt/d555de9cf83c2186fe9b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// At this point, there shouldn't be any external references in the module | |
llvm::SmallVector<const llvm::GlobalValue*, 2> ExternalReferences; | |
for (const auto& GV : M->getGlobalList()) | |
if (GV.isDeclaration()) | |
ExternalReferences.push_back(&GV); | |
for (const auto& F : M->getFunctionList()) | |
if (F.isDeclaration() && !F.isIntrinsic()) | |
ExternalReferences.push_back(&F); | |
for (const auto* V: ExternalReferences) { | |
JL_PRINTF(JL_STDERR, "Warning: detected use of external value '%s'\n", | |
V->getName()); | |
for (const auto& Use: V->uses()) { | |
if (auto* I = llvm::dyn_cast<Instruction>(Use.getUser())) { | |
if (llvm::MDNode *N = I->getMetadata("dbg")) { | |
llvm::DILocation Loc(N); | |
JL_PRINTF(JL_STDERR, " - at %s:%i\n", | |
Loc.getFilename().str().data(), | |
Loc.getLineNumber()); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment