[SimplifyLibCalls] Ignore nobuiltin/unavailable fortified libcalls.
authorAhmed Bougacha <ahmed.bougacha@gmail.com>
Wed, 1 Apr 2015 00:45:09 +0000 (00:45 +0000)
committerAhmed Bougacha <ahmed.bougacha@gmail.com>
Wed, 1 Apr 2015 00:45:09 +0000 (00:45 +0000)
commit252c120f4a4c8f0fb8999c2d55bf885eef74ddca
tree5a49634221957778176c229cbff7dce6cc8375c7
parent54ab6ce385acd8bcfdb235fc171dea255b490467
[SimplifyLibCalls] Ignore nobuiltin/unavailable fortified libcalls.

We used to do this before refactorings around r225640.
Some clang users checked for _chk libcall availability using:
  __has_builtin(__builtin___memcpy_chk)
When compiling with -fno-builtin, this is always true.
When passing -ffreestanding/-mkernel, which both imply -fno-builtin, we
end up with fortified libcalls, which isn't acceptable in a freestanding
environment which only provides their non-fortified counterparts.

Until we change clang and/or teach external users to check for availability
differently, disregard the "nobuiltin" attribute and TLI::has.

Workaround for PR23093.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@233776 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Transforms/Utils/SimplifyLibCalls.cpp
test/Transforms/CodeGenPrepare/X86/memset_chk-simplify-nobuiltin.ll [new file with mode: 0644]