about summary refs log tree commit diff homepage
path: root/lib/Module
diff options
context:
space:
mode:
authorMartin Nowack <m.nowack@imperial.ac.uk>2020-04-28 18:23:50 +0100
committerCristian Cadar <c.cadar@imperial.ac.uk>2020-06-06 19:03:03 +0100
commitdaa2d4d202929f9f7ba38dd76feabf2fa34816ab (patch)
tree77d43893132707ab6f06a9d551e0c52352f363d1 /lib/Module
parent597df194218f2de174ead6b8a1abb2555f8bef4b (diff)
downloadklee-daa2d4d202929f9f7ba38dd76feabf2fa34816ab.tar.gz
[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
Diffstat (limited to 'lib/Module')
-rw-r--r--lib/Module/RaiseAsm.cpp10
1 files 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);