[LLVMbugs] [Bug 7117] New: regparm attribute combined with K&R declarations causes illegal instruction
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Tue May 11 13:23:17 PDT 2010
http://llvm.org/bugs/show_bug.cgi?id=7117
Summary: regparm attribute combined with K&R declarations
causes illegal instruction
Product: clang
Version: trunk
Platform: PC
OS/Version: FreeBSD
Status: NEW
Severity: normal
Priority: P
Component: -New Bugs
AssignedTo: unassignedclangbugs at nondot.org
ReportedBy: dimitry at andric.com
CC: llvmbugs at cs.uiuc.edu
While building and testing the FreeBSD version of GNU libregex with
clang, I consistently got 'illegal instruction' from it at runtime.
It turned out clang had inserted instruction "ud2" at many places inside
the object code. This seems to have been caused by quite a number of
functions inside the regex compiler having this attribute tacked on:
__attribute ((regparm (3), stdcall))
While this in itself should probably cause no harm, it apparently does
become problematic, when used in combination with K&R-style function
declarations.
I reduced this phenomenon to the following testcase:
int re_string_construct(int) __attribute__((regparm(3), stdcall));
int re_string_construct(dfa)
{
}
int re_compile_internal(void)
{
init_dfa();
re_string_construct(0);
}
Compile with "clang -cc1 -O2 -emit-llvm" and the last function becomes:
define i32 @re_compile_internal() noreturn nounwind {
entry:
%call = tail call i32 (...)* @init_dfa() nounwind ; <i32> [#uses=0]
tail call void @llvm.trap()
unreachable
}
which is obviously incorrect. Compiling with -O0, or removing the
attribute altogether produces correct output.
(Yes, I realize K&R is really really deprecated now, but unfortunately a
lot of code out there still uses it, especially older GNU stuff... :)
--
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
More information about the llvm-bugs
mailing list