Skip to content

Commit

Permalink
Merge pull request #35957 from JuliaLang/tb/llvm_extra_apis
Browse files Browse the repository at this point in the history
Expose some additional LLVM APIs.
  • Loading branch information
maleadt authored May 25, 2020
2 parents 4714a86 + 664e9ba commit c832e47
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/llvm-api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

#include <llvm/ADT/Triple.h>
#include <llvm/Analysis/TargetLibraryInfo.h>
#include <llvm/Analysis/TargetTransformInfo.h>
#include <llvm/IR/Attributes.h>
#include <llvm/IR/CallSite.h>
#include <llvm/IR/DebugInfo.h>
Expand All @@ -24,6 +25,7 @@
#include <llvm/IR/Module.h>
#include <llvm/Support/TargetSelect.h>
#include <llvm/Transforms/IPO.h>
#include <llvm/Transforms/Utils/ModuleUtils.h>

#include "julia.h"

Expand Down Expand Up @@ -208,6 +210,28 @@ extern "C" JL_DLLEXPORT void LLVMExtraAddInternalizePassWithExportList(
unwrap(PM)->add(createInternalizePass(PreserveFobj));
}

extern "C" JL_DLLEXPORT void LLVMExtraAppendToUsed(LLVMModuleRef Mod,
LLVMValueRef* Values,
size_t Count) {
SmallVector<GlobalValue *, 1> GlobalValues;
for (auto *Value : makeArrayRef(Values, Count))
GlobalValues.push_back(cast<GlobalValue>(unwrap(Value)));
appendToUsed(*unwrap(Mod), GlobalValues);
}

extern "C" JL_DLLEXPORT void LLVMExtraAppendToCompilerUsed(LLVMModuleRef Mod,
LLVMValueRef* Values,
size_t Count) {
SmallVector<GlobalValue *, 1> GlobalValues;
for (auto *Value : makeArrayRef(Values, Count))
GlobalValues.push_back(cast<GlobalValue>(unwrap(Value)));
appendToCompilerUsed(*unwrap(Mod), GlobalValues);
}

extern "C" JL_DLLEXPORT void LLVMExtraAddGenericAnalysisPasses(LLVMPassManagerRef PM) {
unwrap(PM)->add(createTargetTransformInfoWrapperPass(TargetIRAnalysis()));
}


// Awaiting D46627

Expand Down

0 comments on commit c832e47

Please sign in to comment.