mirror of
https://github.com/obfuscator-llvm/obfuscator
synced 2026-06-08 16:28:34 +00:00
Initial commit of LLVM 3.4
This commit is contained in:
@@ -12,6 +12,7 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "llvm/Transforms/Utils/ModuleUtils.h"
|
||||
#include "llvm/ADT/SmallPtrSet.h"
|
||||
#include "llvm/IR/DerivedTypes.h"
|
||||
#include "llvm/IR/Function.h"
|
||||
#include "llvm/IR/IRBuilder.h"
|
||||
@@ -62,3 +63,20 @@ void llvm::appendToGlobalCtors(Module &M, Function *F, int Priority) {
|
||||
void llvm::appendToGlobalDtors(Module &M, Function *F, int Priority) {
|
||||
appendToGlobalArray("llvm.global_dtors", M, F, Priority);
|
||||
}
|
||||
|
||||
GlobalVariable *
|
||||
llvm::collectUsedGlobalVariables(Module &M, SmallPtrSet<GlobalValue *, 8> &Set,
|
||||
bool CompilerUsed) {
|
||||
const char *Name = CompilerUsed ? "llvm.compiler.used" : "llvm.used";
|
||||
GlobalVariable *GV = M.getGlobalVariable(Name);
|
||||
if (!GV || !GV->hasInitializer())
|
||||
return GV;
|
||||
|
||||
const ConstantArray *Init = cast<ConstantArray>(GV->getInitializer());
|
||||
for (unsigned I = 0, E = Init->getNumOperands(); I != E; ++I) {
|
||||
Value *Op = Init->getOperand(I);
|
||||
GlobalValue *G = cast<GlobalValue>(Op->stripPointerCastsNoFollowAliases());
|
||||
Set.insert(G);
|
||||
}
|
||||
return GV;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user