diff options
author | Peter Collingbourne <peter@pcc.me.uk> | 2010-11-14 17:35:41 +0000 |
---|---|---|
committer | Peter Collingbourne <peter@pcc.me.uk> | 2010-11-14 17:35:41 +0000 |
commit | 6059a197c0ef4760d680973c9fa10459b1746b8c (patch) | |
tree | 3da22b798cab9912a8984d2e5581d6c1cebc7705 /lib/Module | |
parent | 74ef9ab52bd440187dd21a898c60b9dec792be4a (diff) | |
download | klee-6059a197c0ef4760d680973c9fa10459b1746b8c.tar.gz |
On LLVM 2.9+, use TargetLowering::ExpandInlineAsm to expand asm code
git-svn-id: https://llvm.org/svn/llvm-project/klee/trunk@119046 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Module')
-rw-r--r-- | lib/Module/Passes.h | 5 | ||||
-rw-r--r-- | lib/Module/RaiseAsm.cpp | 24 |
2 files changed, 29 insertions, 0 deletions
diff --git a/lib/Module/Passes.h b/lib/Module/Passes.h index f9454ffd..2b1ea9bc 100644 --- a/lib/Module/Passes.h +++ b/lib/Module/Passes.h @@ -23,6 +23,7 @@ namespace llvm { class Instruction; class Module; class TargetData; + class TargetLowering; class Type; } @@ -33,6 +34,10 @@ namespace klee { class RaiseAsmPass : public llvm::ModulePass { static char ID; +#if (LLVM_VERSION_MAJOR == 2 && LLVM_VERSION_MINOR >= 9) + const llvm::TargetLowering *TLI; +#endif + llvm::Function *getIntrinsic(llvm::Module &M, unsigned IID, const llvm::Type **Tys, diff --git a/lib/Module/RaiseAsm.cpp b/lib/Module/RaiseAsm.cpp index f89a7661..11c89009 100644 --- a/lib/Module/RaiseAsm.cpp +++ b/lib/Module/RaiseAsm.cpp @@ -14,6 +14,12 @@ #if !(LLVM_VERSION_MAJOR == 2 && LLVM_VERSION_MINOR < 7) #include "llvm/LLVMContext.h" #endif +#if (LLVM_VERSION_MAJOR == 2 && LLVM_VERSION_MINOR >= 9) +#include "llvm/Support/raw_ostream.h" +#include "llvm/System/Host.h" +#include "llvm/Target/TargetLowering.h" +#include "llvm/Target/TargetRegistry.h" +#endif using namespace llvm; using namespace klee; @@ -32,6 +38,10 @@ Function *RaiseAsmPass::getIntrinsic(llvm::Module &M, bool RaiseAsmPass::runOnInstruction(Module &M, Instruction *I) { if (CallInst *ci = dyn_cast<CallInst>(I)) { if (InlineAsm *ia = dyn_cast<InlineAsm>(ci->getCalledValue())) { +#if (LLVM_VERSION_MAJOR == 2 && LLVM_VERSION_MINOR >= 9) + (void) ia; + return TLI && TLI->ExpandInlineAsm(ci); +#else const std::string &as = ia->getAsmString(); const std::string &cs = ia->getConstraintString(); const llvm::Type *T = ci->getType(); @@ -59,6 +69,7 @@ bool RaiseAsmPass::runOnInstruction(Module &M, Instruction *I) { #endif return true; } +#endif } } @@ -67,6 +78,19 @@ bool RaiseAsmPass::runOnInstruction(Module &M, Instruction *I) { bool RaiseAsmPass::runOnModule(Module &M) { bool changed = false; + +#if (LLVM_VERSION_MAJOR == 2 && LLVM_VERSION_MINOR >= 9) + std::string Err; + std::string HostTriple = llvm::sys::getHostTriple(); + const Target *NativeTarget = TargetRegistry::lookupTarget(HostTriple, Err); + if (NativeTarget == 0) { + llvm::errs() << "Warning: unable to select native target: " << Err << "\n"; + TLI = 0; + } else { + TargetMachine *TM = NativeTarget->createTargetMachine(HostTriple, ""); + TLI = TM->getTargetLowering(); + } +#endif for (Module::iterator fi = M.begin(), fe = M.end(); fi != fe; ++fi) { for (Function::iterator bi = fi->begin(), be = fi->end(); bi != be; ++bi) { |