[llvm] fcf7490 - [GlobalOpt] Add test for PR51879 (NFC)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 10 07:18:31 PST 2021


Author: Nikita Popov
Date: 2021-12-10T16:18:18+01:00
New Revision: fcf749002827260676580a2eb0173697e5233d1c

URL: https://github.com/llvm/llvm-project/commit/fcf749002827260676580a2eb0173697e5233d1c
DIFF: https://github.com/llvm/llvm-project/commit/fcf749002827260676580a2eb0173697e5233d1c.diff

LOG: [GlobalOpt] Add test for PR51879 (NFC)

Added: 
    llvm/test/Transforms/GlobalOpt/pr51879.ll

Modified: 
    

Removed: 
    


################################################################################
diff  --git a/llvm/test/Transforms/GlobalOpt/pr51879.ll b/llvm/test/Transforms/GlobalOpt/pr51879.ll
new file mode 100644
index 0000000000000..0fe1a9f754a79
--- /dev/null
+++ b/llvm/test/Transforms/GlobalOpt/pr51879.ll
@@ -0,0 +1,28 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --check-globals
+; RUN: opt -S -globalopt < %s | FileCheck %s
+
+; TODO: This currently computes an incorrect initializer value.
+
+%type = type { { i8** } }
+
+ at g = internal global %type zeroinitializer
+ at g2 = external global i8*
+
+ at llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @ctor, i8* null }]
+
+;.
+; CHECK: @[[G:[a-zA-Z0-9_$"\\.-]+]] = internal global [[TYPE:%.*]] zeroinitializer
+; CHECK: @[[LLVM_GLOBAL_CTORS:[a-zA-Z0-9_$"\\.-]+]] = appending global [0 x { i32, void ()*, i8* }] zeroinitializer
+;.
+define internal void @ctor() {
+  store i64 0, i64* bitcast (%type* @g to i64*), align 8
+  store i8** @g2, i8*** getelementptr inbounds (%type, %type* @g, i64 0, i32 0, i32 0), align 8
+  ret void
+}
+
+define %type* @test() {
+; CHECK-LABEL: @test(
+; CHECK-NEXT:    ret %type* @g
+;
+  ret %type* @g
+}


        


More information about the llvm-commits mailing list