[TLI] Robustize SDAG LibFunc proto checking by merging it into TLI.
This re-applies commit r292189, reverted in r292191.
SelectionDAGBuilder recognizes libfuncs using some homegrown
parameter type-checking.
Use TLI instead, removing another heap of redundant code.
This isn't strictly NFC, as the SDAG code was too lax.
Concretely, this means changes are required to a few tests:
- calling a non-variadic function via a variadic prototype isn't OK;
it just happens to work on x86_64 (but not on, e.g., aarch64).
- mempcpy has a size_t parameter; the SDAG code accepts any integer
type, which meant using i32 on x86_64 worked.
- a handful of SystemZ tests check the SDAG support for lax prototype
checking: Ulrich agrees on removing them.
I don't think it's worth supporting any of these (IMO) invalid
testcases. Instead, fix them to be more meaningful.
llvm-svn: 294028
diff --git a/llvm/test/CodeGen/X86/mempcpy-32.ll b/llvm/test/CodeGen/X86/mempcpy-32.ll
new file mode 100644
index 0000000..108442f
--- /dev/null
+++ b/llvm/test/CodeGen/X86/mempcpy-32.ll
@@ -0,0 +1,20 @@
+; RUN: llc < %s -mtriple=i686-unknown-linux -O2 | FileCheck %s
+
+; This tests the i686 lowering of mempcpy.
+; Also see mempcpy.ll
+
+@G = common global i8* null, align 8
+
+; CHECK-LABEL: RET_MEMPCPY:
+; CHECK: movl [[REG:%e[a-z0-9]+]], {{.*}}G
+; CHECK: calll {{.*}}memcpy
+; CHECK: movl [[REG]], %eax
+;
+define i8* @RET_MEMPCPY(i8* %DST, i8* %SRC, i32 %N) {
+ %add.ptr = getelementptr inbounds i8, i8* %DST, i32 %N
+ store i8* %add.ptr, i8** @G, align 8
+ %call = tail call i8* @mempcpy(i8* %DST, i8* %SRC, i32 %N)
+ ret i8* %call
+}
+
+declare i8* @mempcpy(i8*, i8*, i32)