[cfe-dev] Sometimes throwing constructors / destructors
Arnaud A. de Grandmaison
arnaud.degrandmaison at arm.com
Fri Jul 25 01:23:51 PDT 2014
I am a bit puzzled when looking at the IR generated for the following
testcase.
Why don’t we get an invoke for the first temporary constructor or destructor
call ?
At the same time, at other places in the exception path, the destructor for
the first temporary is assumed to be throwing as it is invoked (and not just
called).
$ cat testcase.cpp
struct X {
X();
~X();
};
extern void use(const X &, const X &);
void test() {
use(X(), X());
}
$ clang++ -O1 –S –emit-llvm –o – testcase.cpp
…
; Function Attrs: uwtable
define void @_Z4testv() #0 {
%1 = alloca %struct.X, align 1
%2 = alloca %struct.X, align 1
call void @_ZN1XC1Ev(%struct.X* %1) ; ç non throwing
constructor ?
invoke void @_ZN1XC1Ev(%struct.X* %2)
to label %3 unwind label %6
; <label>:3 ; preds = %0
invoke void @_Z3useRK1XS1_(%struct.X* dereferenceable(1) %1, %struct.X*
dereferenceable(1) %2)
to label %4 unwind label %10
; <label>:4 ; preds = %3
invoke void @_ZN1XD1Ev(%struct.X* %2)
to label %5 unwind label %6
; <label>:5 ; preds = %4
call void @_ZN1XD1Ev(%struct.X* %1) ; ç non throwing
destructor ?
ret void
; <label>:6 ; preds = %4, %0
%7 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)*
@__gxx_personality_v0 to i8*)
cleanup
%8 = extractvalue { i8*, i32 } %7, 0
%9 = extractvalue { i8*, i32 } %7, 1
br label %14
; <label>:10 ; preds = %3
%11 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)*
@__gxx_personality_v0 to i8*)
cleanup
%12 = extractvalue { i8*, i32 } %11, 0
%13 = extractvalue { i8*, i32 } %11, 1
invoke void @_ZN1XD1Ev(%struct.X* %2)
to label %14 unwind label %18
; <label>:14 ; preds = %10, %6
%.01 = phi i8* [ %8, %6 ], [ %12, %10 ]
%.0 = phi i32 [ %9, %6 ], [ %13, %10 ]
invoke void @_ZN1XD1Ev(%struct.X* %1)
to label %15 unwind label %18 ; ç throwing
destructor ?
; <label>:15 ; preds = %14
%16 = insertvalue { i8*, i32 } undef, i8* %.01, 0
%17 = insertvalue { i8*, i32 } %16, i32 %.0, 1
resume { i8*, i32 } %17
; <label>:18 ; preds = %14, %10
%19 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)*
@__gxx_personality_v0 to i8*)
catch i8* null
%20 = extractvalue { i8*, i32 } %19, 0
call void @__clang_call_terminate(i8* %20) #3
unreachable
}
--
Arnaud A. de Grandmaison
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20140725/0df60f6c/attachment.html>
More information about the cfe-dev
mailing list