[LLVMbugs] [Bug 7656] New: Clang generates incorrect IR for __attribute__((cleanup))
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Thu Jul 15 15:58:44 PDT 2010
http://llvm.org/bugs/show_bug.cgi?id=7656
Summary: Clang generates incorrect IR for
__attribute__((cleanup))
Product: clang
Version: trunk
Platform: PC
OS/Version: All
Status: NEW
Severity: normal
Priority: P
Component: LLVM Codegen
AssignedTo: unassignedclangbugs at nondot.org
ReportedBy: csdavec at swan.ac.uk
CC: llvmbugs at cs.uiuc.edu
For this simple test case:
$ cat clean.m
static void foo(void*a){}
void wibble(void);
void bar(void)
{
__attribute__((cleanup(foo))) int a = 12;
wibble();
}
If wibble() throws, clang unwinds to this basic block:
; <label>:3 ; preds = %0
%4 = call i8* @llvm.eh.exception() ; <i8*> [#uses=2]
%5 = call i32 (i8*, i8*, ...)* @llvm.eh.selector(i8* %4, i8* bitcast (i32
(...)* @__gnu_objc_personality_v0 to i8*), i8* null) ; <i32> [#uses=0]
%6 = bitcast i32* %a to i8* ; <i8*> [#uses=1]
invoke void @foo(i8* %6)
to label %7 unwind label %8
Note the i8* null at the end of the llvm.eh.selector() call. This indicates a
catchall, rather than a cleanup, which causes incorrect behaviour (i.e.
crashing). I've looked at the code in CGException.cpp, and nothing seems
obviously wrong, so I'm having trouble working out why I'm seeing this. Adding
some debugging lines to the personality function, it's definitely finding
something that looks like a catchall and delivering the exception. In code
compiled with GCC, it only sees a cleanup for this frame.
(In this example, it is using the GNU ObjC personality function because the
file is a .m, but if it's a .c then it still thinks it's a cleanup, it just
uses a different personality function. This may or may not work, depending on
the exact implementation of the personality function.)
--
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