From 7234c9cdfc896434b10f30383153e0bde5b7aa28 Mon Sep 17 00:00:00 2001 From: Zhijin Zeng Date: Fri, 10 Nov 2023 15:01:51 +0800 Subject: [PATCH] fix issue #33 for WHIRL2llvm 1. The w2ll will crash if compile the code like that: ``` typedef struct msa_struct { char **aseq; int alen; int nseq; } MSA; void WriteA2M1(MSA *msa) { int pos; char buf[64]; int cpl = 60; buf[cpl] = '\0'; for (pos = 0; pos < msa->alen; pos+=cpl) { strncpy(buf, &(msa->aseq[0][pos]), cpl); } } ``` 2. Error Log: ``` Assertion failure ../../../../osprey/ir_tools/whirl2llvm.cxx:5815: WHIRL2llvm::STMT2llvm, intrinsic(521) not handled ``` Signed-off-by: Zhijin Zeng --- osprey/ir_tools/whirl2llvm.cxx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/osprey/ir_tools/whirl2llvm.cxx b/osprey/ir_tools/whirl2llvm.cxx index 3a44486b..5421407e 100644 --- a/osprey/ir_tools/whirl2llvm.cxx +++ b/osprey/ir_tools/whirl2llvm.cxx @@ -3588,7 +3588,9 @@ WHIRL2llvm::Handle_intrn_call(WN *wn) { case INTRN_F8COS: func_name = "cos"; break; case INTRN_STRLEN: func_name = "strlen"; break; case INTRN_STRCPY: func_name = "strcpy"; break; + case INTRN_STRNCPY: func_name = "strncpy"; break; case INTRN_STRCMP: func_name = "strcmp"; break; + case INTRN_STRNCMP: func_name = "strncmp"; break; case INTRN_MEMCPY: func_name = "memcpy"; break; case INTRN_MEMSET: func_name = "memset"; break; case INTRN_MEMCMP: func_name = "memcmp"; break; @@ -5798,7 +5800,9 @@ WHIRL2llvm::STMT2llvm(WN *wn, W2LBB *lvbb) case INTRN_MEMCPY: case INTRN_MEMSET: case INTRN_STRCPY: + case INTRN_STRNCPY: case INTRN_STRCMP: + case INTRN_STRNCMP: case INTRN_STRLEN: case INTRN_MEMCCPY: case INTRN_MEMMOVE: {