Check if function names start with "llvm." before trying to lookup them up as
authorBob Wilson <bob.wilson@apple.com>
Thu, 18 Mar 2010 16:52:15 +0000 (16:52 +0000)
committerBob Wilson <bob.wilson@apple.com>
Thu, 18 Mar 2010 16:52:15 +0000 (16:52 +0000)
intrinsics.  The intrinsic lookup code assumes that this check has been done
and assumes the names are at least 6 characters long.  Valgrind complained
about this.  pr6638.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@98831 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/Blackfin/BlackfinIntrinsicInfo.cpp
lib/Target/MBlaze/MBlazeIntrinsicInfo.cpp

index ea9480d7625527367541f02c1b052d9a1a256b84..34a8d3809ea23c0648738e3ae868c651aa4b0a72 100644 (file)
@@ -53,6 +53,10 @@ std::string BlackfinIntrinsicInfo::getName(unsigned IntrID, const Type **Tys,
 
 unsigned
 BlackfinIntrinsicInfo::lookupName(const char *Name, unsigned Len) const {
+  if (Len < 5 || Name[4] != '.' || Name[0] != 'l' || Name[1] != 'l'
+      || Name[2] != 'v' || Name[3] != 'm')
+    return 0;  // All intrinsics start with 'llvm.'
+
 #define GET_FUNCTION_RECOGNIZER
 #include "BlackfinGenIntrinsics.inc"
 #undef GET_FUNCTION_RECOGNIZER
index c8faffc84527365025351a717329fd67b00a3cb0..4931860912a10146f686262231cf325165154f29 100644 (file)
@@ -57,6 +57,10 @@ std::string MBlazeIntrinsicInfo::getName(unsigned IntrID, const Type **Tys,
 
 unsigned MBlazeIntrinsicInfo::
 lookupName(const char *Name, unsigned Len) const {
+  if (Len < 5 || Name[4] != '.' || Name[0] != 'l' || Name[1] != 'l'
+      || Name[2] != 'v' || Name[3] != 'm')
+    return 0;  // All intrinsics start with 'llvm.'
+
 #define GET_FUNCTION_RECOGNIZER
 #include "MBlazeGenIntrinsics.inc"
 #undef GET_FUNCTION_RECOGNIZER