llvm optimizes with library functions

后端 未结 2 1415
没有蜡笔的小新
没有蜡笔的小新 2021-01-05 05:47

Starting with code like this

void lib_memset( unsigned char *dest, unsigned char c, unsigned int n)
{
    while(n--)
    {
        *dest=c;
        dest++;
          


        
2条回答
  •  一个人的身影
    2021-01-05 06:38

    I encounter the same problem and if it still can help anyone this is what I did to solve it - I modify the LoopIdiomRecognize.cpp file in the llvm source code: there is a code that checks if the name of the function is memset or memcpy it cancel the optimization, so I changed it from:

    StringRef Name = L->getHeader()->getParent()->getName();
      if (Name == "memset" || Name == "memcpy")
    

    to

    StringRef Name = L->getHeader()->getParent()->getName();
      if (Name.endswith("memset") || Name == "memcpy")
    

提交回复
热议问题