[llvm-bugs] [Bug 45527] New: The 'cleanuppad' IR instruction doesn't work on Linux
via llvm-bugs
llvm-bugs at lists.llvm.org
Tue Apr 14 02:16:19 PDT 2020
https://bugs.llvm.org/show_bug.cgi?id=45527
Bug ID: 45527
Summary: The 'cleanuppad' IR instruction doesn't work on Linux
Product: libraries
Version: 10.0
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: Core LLVM classes
Assignee: unassignedbugs at nondot.org
Reporter: akornilov.82 at gmail.com
CC: llvm-bugs at lists.llvm.org
Created attachment 23347
--> https://bugs.llvm.org/attachment.cgi?id=23347&action=edit
ex-cleanuppad.ll
I have prepared this simple example of using cleanup for Linux with 'old'
instruction 'landingpad':
; ModuleID = 'ex-landingpad.bc'
source_filename = "ExTest.cpp"
@_ZTIi = external constant i8*
declare i8* @__cxa_allocate_exception(i64)
declare void @__cxa_throw(i8*, i8*, i8*)
declare void @__jetvm_backtrace(i32)
define i32 @sum(i32 %0, i32 %1) {
%3 = call i8* @__cxa_allocate_exception(i64 4)
store i8 33, i8* %3
call void @__cxa_throw(i8* %3, i8* bitcast (i8** @_ZTIi to i8*), i8* null)
unreachable
}
; Function Attrs: noinline optnone uwtable
define i32 @calc() #0 personality i8* bitcast (i32 (...)* @__gxx_personality_v0
to i8*) {
%1 = alloca i8*
%2 = invoke i32 @sum(i32 99, i32 77)
to label %3 unwind label %4
3: ; preds = %0
ret i32 %2
4: ; preds = %0
%5 = landingpad { i8*, i32 }
cleanup
; Some cleanup actions
resume { i8*, i32 } %5
}
declare i32 @__gxx_personality_v0(...)
attributes #0 = { noinline optnone uwtable }
It works fine on Linux. After that I have tried to use 'new' instruction
'cleanuppad':
; ModuleID = 'ex-cleanuppad.bc'
source_filename = "ExTest.cpp"
@_ZTIi = external constant i8*
declare i8* @__cxa_allocate_exception(i64)
declare void @__cxa_throw(i8*, i8*, i8*)
declare void @__jetvm_backtrace(i32)
define i32 @sum(i32 %0, i32 %1) {
%3 = call i8* @__cxa_allocate_exception(i64 4)
store i8 33, i8* %3
call void @__cxa_throw(i8* %3, i8* bitcast (i8** @_ZTIi to i8*), i8* null)
unreachable
}
; Function Attrs: noinline optnone uwtable
define i32 @calc() #0 personality i8* bitcast (i32 (...)* @__gxx_personality_v0
to i8*) {
%1 = invoke i32 @sum(i32 99, i32 77)
to label %2 unwind label %3
2: ; preds = %0
ret i32 %1
3: ; preds = %0
%4 = cleanuppad within none []
; Some cleanup actions
cleanupret from %4 unwind to caller
}
declare i32 @__gxx_personality_v0(...)
attributes #0 = { noinline optnone uwtable }
But application crashes in this case.
I obtained assembler versions (x86_64) of IR by LLC and have noticed that in
'landingpad' case instruction 'resume' transformed into _Unwind_Resume. But for
'cleanupret' just 'retq' generated.
All files are attached to this ticket.
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20200414/373bd247/attachment-0001.html>
More information about the llvm-bugs
mailing list