[PATCH] D42576: [test-suite] Add prototypes to functions in Olden and MiBench
Matthias Braun via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun Jan 28 13:00:10 PST 2018
MatzeB added a comment.
In https://reviews.llvm.org/D42576#990020, @arichardson wrote:
> Calling K&R functions is not a problem. It is fine to use them as long as there is a declaration with the parameter types in the LLVM IR and not just an `declare i32 @foo(...)`. The problem is that we are calling functions that don't have a declaration and therefore the compiler assumes that it is a variadic function call. This leads to runtime crashes on our CHERI platform.
>
> They are not necessarily correct C programs since they include undefined behaviour
To the best of my knowledge, this is perfectly fine (even in C11):
/* a.c: */
short bar(x)
short x;
{
return x;
}
/* b.c: */
short bar();
int main(void) {
bar(42);
}
If a compiler cannot handle it then it has a bug and I'm not in favor of changing the benchmarks/tests because of a bug. On the contrary: We need tests to uncover such bugs!
I agree with you that llvm representing prototype-less functions and variadic functions the same is unfortunate (and appears to only allow implementations where they are the same at a first glance?). Maybe ask clang or llvm mailing lists for comments...
Repository:
rT test-suite
https://reviews.llvm.org/D42576
More information about the llvm-commits
mailing list