14#include "llvm/CodeGen/TargetLowering.h"
15#include "llvm/CodeGen/TargetSubtargetInfo.h"
16#include "llvm/IR/Function.h"
17#include "llvm/IR/IRBuilder.h"
18#include "llvm/IR/InlineAsm.h"
19#include "llvm/IR/Instructions.h"
20#include "llvm/IR/LLVMContext.h"
21#include "llvm/Support/Host.h"
22#include "llvm/Support/TargetRegistry.h"
23#include "llvm/Target/TargetMachine.h"
29char RaiseAsmPass::ID = 0;
31Function *RaiseAsmPass::getIntrinsic(llvm::Module &M,
unsigned IID, Type **Tys,
33 return Intrinsic::getDeclaration(&M, (llvm::Intrinsic::ID) IID,
34 llvm::ArrayRef<llvm::Type*>(Tys, NumTys));
41 CallInst *ci = dyn_cast<CallInst>(I);
45#if LLVM_VERSION_CODE >= LLVM_VERSION(8, 0)
46 InlineAsm *ia = dyn_cast<InlineAsm>(ci->getCalledOperand());
48 InlineAsm *ia = dyn_cast<InlineAsm>(ci->getCalledValue());
57 if (
TLI->ExpandInlineAsm(ci))
60 if ((
triple.getArch() == llvm::Triple::x86 ||
61 triple.getArch() == llvm::Triple::x86_64) &&
64 if (ia->getAsmString() ==
"" && ia->hasSideEffects() &&
65 ia->getFunctionType()->getReturnType()->isVoidTy()) {
66 IRBuilder<> Builder(I);
67 Builder.CreateFence(llvm::AtomicOrdering::SequentiallyConsistent);
81 std::string TargetTriple = M.getTargetTriple();
82 if (TargetTriple.empty())
83 TargetTriple = llvm::sys::getDefaultTargetTriple();
84 const Target *Target = TargetRegistry::lookupTarget(TargetTriple, Err);
86 TargetMachine * TM = 0;
88 klee_warning(
"Warning: unable to select target: %s", Err.c_str());
91 TM = Target->createTargetMachine(TargetTriple,
"",
"", TargetOptions(),
93 TLI = TM->getSubtargetImpl(*(M.begin()))->getTargetLowering();
95 triple = llvm::Triple(TargetTriple);
98 for (Module::iterator fi = M.begin(), fe = M.end(); fi != fe; ++fi) {
99 for (Function::iterator bi = fi->begin(), be = fi->end(); bi != be; ++bi) {
100 for (BasicBlock::iterator ii = bi->begin(), ie = bi->end(); ii != ie;) {
101 Instruction *i = &*ii;
bool runOnModule(llvm::Module &M) override
bool runOnInstruction(llvm::Module &M, llvm::Instruction *I)
const llvm::TargetLowering * TLI
void void void klee_warning(const char *msg,...) __attribute__((format(printf