[Lldb-commits] [lldb] r115006 - /lldb/trunk/source/Expression/IRForTarget.cpp
Sean Callanan
scallanan at apple.com
Tue Sep 28 16:55:00 PDT 2010
Author: spyffe
Date: Tue Sep 28 18:55:00 2010
New Revision: 115006
URL: http://llvm.org/viewvc/llvm-project?rev=115006&view=rev
Log:
Removed a dreadful hack to get at the name of the
intrinsic being used. Thanks to Chris Lattner for
pointing out the proper way to do it.
Modified:
lldb/trunk/source/Expression/IRForTarget.cpp
Modified: lldb/trunk/source/Expression/IRForTarget.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/IRForTarget.cpp?rev=115006&r1=115005&r2=115006&view=diff
==============================================================================
--- lldb/trunk/source/Expression/IRForTarget.cpp (original)
+++ lldb/trunk/source/Expression/IRForTarget.cpp Tue Sep 28 18:55:00 2010
@@ -12,6 +12,7 @@
#include "llvm/Support/raw_ostream.h"
#include "llvm/InstrTypes.h"
#include "llvm/Instructions.h"
+#include "llvm/Intrinsics.h"
#include "llvm/Module.h"
#include "llvm/Target/TargetData.h"
#include "llvm/ValueSymbolTable.h"
@@ -633,34 +634,29 @@
}
}
- std::string str = fun->getName().str();
+ std::string str;
- if (str.find("llvm.") == 0)
+ if (fun->isIntrinsic())
{
- // Probably a LLVM built-in. Let's try again, but looking up the original.
- //
- // +- builtin_name_offset [in this case, 5]
- // |
- // |====| builtin_name_length [in this case, 6]
- // 0 |
- // | | +- builtin_name_end [in this case, 11]
- // V V V
- // llvm.______.i32.u8
- // 012345678901234567
- // 0 1
-
- size_t builtin_name_offset = sizeof("llvm.") - 1;
- size_t builtin_name_end = str.find('.', builtin_name_offset);
+ Intrinsic::ID intrinsic_id = (Intrinsic::ID)fun->getIntrinsicID();
- if (builtin_name_end == str.npos)
- builtin_name_end = str.size() + 1;
-
- size_t builtin_name_length = builtin_name_end - builtin_name_offset;
-
- str = str.substr(builtin_name_offset, builtin_name_length);
+ switch (intrinsic_id)
+ {
+ default:
+ if (log)
+ log->Printf("Unresolved intrinsic %s", Intrinsic::getName(intrinsic_id).c_str());
+ return false;
+ case Intrinsic::memcpy:
+ str = "memcpy";
+ break;
+ }
if (log)
- log->Printf("Extracted builtin function name %s", str.c_str());
+ log->Printf("Resolved intrinsic name %s", str.c_str());
+ }
+ else
+ {
+ str = fun->getName().str();
}
clang::NamedDecl *fun_decl = DeclForGlobalValue(M, fun);
More information about the lldb-commits
mailing list