예제 #1
0
static bool shouldInternalize(const GlobalValue &GV,
                              const std::set<std::string> &ExternalNames,
                              bool OnlyHidden) {
  if (OnlyHidden && !GV.hasHiddenVisibility())
    return false;

  // Function must be defined here
  if (GV.isDeclaration())
    return false;

  // Available externally is really just a "declaration with a body".
  if (GV.hasAvailableExternallyLinkage())
    return false;

  // Assume that dllexported symbols are referenced elsewhere
  if (GV.hasDLLExportStorageClass())
    return false;

  // Already has internal linkage
  if (GV.hasLocalLinkage())
    return false;

  // Marked to keep external?
  if (ExternalNames.count(GV.getName()))
    return false;

  return true;
}
예제 #2
0
JITSymbolFlags llvm::JITSymbolFlags::fromGlobalValue(const GlobalValue &GV) {
  JITSymbolFlags Flags = JITSymbolFlags::None;
  if (GV.hasWeakLinkage() || GV.hasLinkOnceLinkage())
    Flags |= JITSymbolFlags::Weak;
  if (GV.hasCommonLinkage())
    Flags |= JITSymbolFlags::Common;
  if (!GV.hasLocalLinkage() && !GV.hasHiddenVisibility())
    Flags |= JITSymbolFlags::Exported;

  if (isa<Function>(GV))
    Flags |= JITSymbolFlags::Callable;
  else if (isa<GlobalAlias>(GV) &&
           isa<Function>(cast<GlobalAlias>(GV).getAliasee()))
    Flags |= JITSymbolFlags::Callable;

  return Flags;
}