-
Notifications
You must be signed in to change notification settings - Fork 10.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ModuleUtils] Handle globals_ctors/dtors with non-literal type (PR56809)
If the global already exists, use its existing type, so we don't try to mix literal and non-literal structs among the elements. Fixes #56809.
- Loading branch information
Showing
2 changed files
with
42 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
llvm/test/Transforms/LowerGlobalDestructors/non-literal-type.ll
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --check-globals --include-generated-funcs --version 2 | ||
; RUN: opt -passes=lower-global-dtors -S < %s | FileCheck %s | ||
|
||
%ty = type { i32, ptr, ptr } | ||
|
||
declare void @ctor() | ||
declare void @dtor() | ||
|
||
@llvm.global_ctors = appending global [1 x %ty] [%ty {i32 65535, ptr @ctor, ptr zeroinitializer }], align 8 | ||
@llvm.global_dtors = appending global [1 x %ty] [%ty {i32 65535, ptr @dtor, ptr zeroinitializer }], align 8 | ||
|
||
;. | ||
; CHECK: @[[__DSO_HANDLE:[a-zA-Z0-9_$"\\.-]+]] = extern_weak hidden constant i8 | ||
; CHECK: @[[LLVM_GLOBAL_CTORS:[a-zA-Z0-9_$"\\.-]+]] = appending global [2 x %ty] [[[TY:%.*]] { i32 65535, ptr @ctor, ptr null }, [[TY]] { i32 65535, ptr @register_call_dtors, ptr null }] | ||
;. | ||
; CHECK-LABEL: define private void @call_dtors | ||
; CHECK-SAME: (ptr [[TMP0:%.*]]) { | ||
; CHECK-NEXT: body: | ||
; CHECK-NEXT: call void @dtor() | ||
; CHECK-NEXT: ret void | ||
; | ||
; | ||
; CHECK-LABEL: define private void @register_call_dtors() { | ||
; CHECK-NEXT: entry: | ||
; CHECK-NEXT: [[CALL:%.*]] = call i32 @__cxa_atexit(ptr @call_dtors, ptr null, ptr @__dso_handle) | ||
; CHECK-NEXT: [[TMP0:%.*]] = icmp ne i32 [[CALL]], 0 | ||
; CHECK-NEXT: br i1 [[TMP0]], label [[FAIL:%.*]], label [[RETURN:%.*]] | ||
; CHECK: fail: | ||
; CHECK-NEXT: call void @llvm.trap() | ||
; CHECK-NEXT: unreachable | ||
; CHECK: return: | ||
; CHECK-NEXT: ret void | ||
; | ||
;. | ||
; CHECK: attributes #[[ATTR0:[0-9]+]] = { cold noreturn nounwind } | ||
;. |