From daa2d4d202929f9f7ba38dd76feabf2fa34816ab Mon Sep 17 00:00:00 2001 From: Martin Nowack Date: Tue, 28 Apr 2020 18:23:50 +0100 Subject: [Module] Disable lifting for inline asm resembling memory fences with return values Inline asm used for memory barriers might use their operands and propagate them as return value. This is currently not supported. Tighten check for this condition and do not to lift those inline asm instructions. Fixes #1252 --- lib/Module/RaiseAsm.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/Module/RaiseAsm.cpp b/lib/Module/RaiseAsm.cpp index acb7d0cf..3de28f4d 100644 --- a/lib/Module/RaiseAsm.cpp +++ b/lib/Module/RaiseAsm.cpp @@ -10,14 +10,15 @@ #include "Passes.h" #include "klee/Config/Version.h" #include "klee/Support/ErrorHandling.h" + +#include "llvm/IR/Function.h" #include "llvm/IR/IRBuilder.h" #include "llvm/IR/InlineAsm.h" -#include "llvm/IR/LLVMContext.h" #include "llvm/IR/Instructions.h" - -#include "llvm/Support/raw_ostream.h" +#include "llvm/IR/LLVMContext.h" #include "llvm/Support/Host.h" #include "llvm/Support/TargetRegistry.h" +#include "llvm/Support/raw_ostream.h" #if LLVM_VERSION_CODE >= LLVM_VERSION(6, 0) #include "llvm/CodeGen/TargetLowering.h" #include "llvm/CodeGen/TargetSubtargetInfo.h" @@ -63,7 +64,8 @@ bool RaiseAsmPass::runOnInstruction(Module &M, Instruction *I) { triple.getOS() == llvm::Triple::Darwin || triple.getOS() == llvm::Triple::FreeBSD)) { - if (ia->getAsmString() == "" && ia->hasSideEffects()) { + if (ia->getAsmString() == "" && ia->hasSideEffects() && + ia->getFunctionType()->getReturnType()->isVoidTy()) { IRBuilder<> Builder(I); #if LLVM_VERSION_CODE >= LLVM_VERSION(3, 9) Builder.CreateFence(llvm::AtomicOrdering::SequentiallyConsistent); -- cgit 1.4.1