[Lldb-commits] [lldb] r204750 - Fixed the IRInterpreter to ignore call instructions

Sean Callanan scallanan at apple.com
Tue Mar 25 12:33:16 PDT 2014


Author: spyffe
Date: Tue Mar 25 14:33:15 2014
New Revision: 204750

URL: http://llvm.org/viewvc/llvm-project?rev=204750&view=rev
Log:
Fixed the IRInterpreter to ignore call instructions
that call debug-information intrinsics.

Modified:
    lldb/trunk/source/Expression/IRInterpreter.cpp

Modified: lldb/trunk/source/Expression/IRInterpreter.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/IRInterpreter.cpp?rev=204750&r1=204749&r2=204750&view=diff
==============================================================================
--- lldb/trunk/source/Expression/IRInterpreter.cpp (original)
+++ lldb/trunk/source/Expression/IRInterpreter.cpp Tue Mar 25 14:33:15 2014
@@ -20,6 +20,7 @@
 #include "llvm/IR/DataLayout.h"
 #include "llvm/IR/Function.h"
 #include "llvm/IR/Instructions.h"
+#include "llvm/IR/Intrinsics.h"
 #include "llvm/IR/Module.h"
 #include "llvm/Support/raw_ostream.h"
 
@@ -58,6 +59,29 @@ PrintType(const Type *type, bool truncat
     return s;
 }
 
+static bool
+CanIgnoreCall (const CallInst *call)
+{
+    const llvm::Function *called_function = call->getCalledFunction();
+    
+    if (!called_function)
+        return false;
+    
+    if (called_function->isIntrinsic())
+    {
+        switch (called_function->getIntrinsicID())
+        {
+        default:
+            break;
+        case llvm::Intrinsic::dbg_declare:
+        case llvm::Intrinsic::dbg_value:
+            return true;
+        }
+    }
+    
+    return false;
+}
+
 class InterpreterStackFrame
 {
 public:
@@ -471,6 +495,27 @@ IRInterpreter::CanInterpret (llvm::Modul
             case Instruction::Alloca:
             case Instruction::BitCast:
             case Instruction::Br:
+                break;
+            case Instruction::Call:
+                {
+                    CallInst *call_inst = dyn_cast<CallInst>(ii);
+                    
+                    if (!call_inst)
+                    {
+                        error.SetErrorToGenericError();
+                        error.SetErrorString(interpreter_internal_error);
+                        return false;
+                    }
+                    
+                    if (!CanIgnoreCall(call_inst))
+                    {
+                        if (log)
+                            log->Printf("Unsupported instruction: %s", PrintValue(ii).c_str());
+                        error.SetErrorToGenericError();
+                        error.SetErrorString(unsupported_opcode_error);
+                        return false;
+                    }
+                }
             case Instruction::GetElementPtr:
                 break;
             case Instruction::ICmp:
@@ -622,6 +667,29 @@ IRInterpreter::Interpret (llvm::Module &
         {
             default:
                 break;
+            case Instruction::Call:
+            {
+                const CallInst *call_inst = dyn_cast<CallInst>(inst);
+                
+                if (!call_inst)
+                {
+                    if (log)
+                        log->Printf("getOpcode() returns %s, but instruction is not a CallInst", inst->getOpcodeName());
+                    error.SetErrorToGenericError();
+                    error.SetErrorString(interpreter_internal_error);
+                    return false;
+                }
+                
+                if (!CanIgnoreCall(call_inst))
+                {
+                    if (log)
+                        log->Printf("The interpreter shouldn't have accepted %s", PrintValue(call_inst).c_str());
+                    error.SetErrorToGenericError();
+                    error.SetErrorString(interpreter_internal_error);
+                    return false;
+                }
+            }
+                break;
             case Instruction::Add:
             case Instruction::Sub:
             case Instruction::Mul:





More information about the lldb-commits mailing list