Skip to content

Instantly share code, notes, and snippets.

@minglotus-6
minglotus-6 / alloca-struct.ll
Last active December 2, 2021 22:18
llvm/test/Transforms/SROA/alloca-struct.ll by update_check_test.py
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt < %s -sroa -S | FileCheck %s
; RUN: opt < %s -passes=sroa -S | FileCheck %s
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
%struct.RetValIntChar = type { i32, i8 }
%struct.RetValTwoInts = type { i32, i32 }
%struct.RetValOneIntTwoChar = type { i32, i8 }
source_filename = "tail_struct.cpp"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
%struct.RetVal = type { i32, i32 }
; Function Attrs: mustprogress uwtable
define dso_local i64 @_Z5ParsebPF6RetValvE(i1 zeroext %test, i64 ()* %p) #0 {
entry:
%retval = alloca %struct.RetVal, align 4
%test.addr = alloca i8, align 1
*** IR Dump After SimplifyCFGPass on _Z5ParsebPF6RetValvE ***
; Function Attrs: mustprogress uwtable
define dso_local i64 @_Z5ParsebPF6RetValvE(i1 zeroext %test, i64 ()* %p) #0 {
entry:
%retval = alloca %struct.RetVal, align 4
%test.addr = alloca i8, align 1
%p.addr = alloca i64 ()*, align 8
%frombool = zext i1 %test to i8
store i8 %frombool, i8* %test.addr, align 1, !tbaa !3
store i64 ()* %p, i64 ()** %p.addr, align 8, !tbaa !7
*** IR Dump After SROA on _Z5ParsebPF6RetValvE ***
; Function Attrs: mustprogress uwtable
define dso_local i64 @_Z5ParsebPF6RetValvE(i1 zeroext %test, i64 ()* %p) #0 {
entry:
%frombool = zext i1 %test to i8
%tobool = trunc i8 %frombool to i1
br i1 %tobool, label %if.then, label %if.end
if.then: ; preds = %entry
br label %return
Dump export summary:
^0 = module: (path: "[Regular LTO]", hash: (0, 0, 0, 0, 0))
^1 = gv: (name: "llvm.type.test") ; guid = 608142985856744218
^2 = gv: (name: "_ZdlPv") ; guid = 950067649961216671
^3 = gv: (name: "_ZN7DerivedD0Ev", summaries: (function: (module: ^0, flags: (linkage: linkonce_odr, visibility: hidden, notEligibleToImport: 1, live: 1, dsoLocal: 1, canAutoHide: 1), insts: 8, funcFlags: (readNone: 0, readOnly: 0, noRecurse: 0, returnDoesNotAlias: 0, noInline: 0, alwaysInline: 0, noUnwind: 1, mayThrow: 0, hasUnknownCall: 0, mustBeUnreachable: 0), calls: ((callee: ^16), (callee: ^2)), refs: (^4, ^21, ^13, ^6, ^9)))) ; guid = 1073348456555726098
^4 = gv: (name: "__gxx_personality_v0") ; guid = 1233668236132380018
^5 = gv: (name: "_Z3fooP4Base", summaries: (function: (module: ^0, flags: (linkage: external, visibility: hidden, notEligibleToImport: 1, live: 1, dsoLocal: 1, canAutoHide: 0), insts: 12, funcFlags: (readNone: 0, readOnly: 0, noRecurse: 0, returnDoesNotAlias: 0, noInline: 0, alwaysInline: 0,
; ModuleID = 'lib.cc'
source_filename = "lib.cc"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
%class.Derived = type { %class.Base }
%class.Base = type { i32 (...)** }
$_ZN7DerivedD2Ev = comdat any
; Test that unreachable functions are ignored by WPD in hybrid LTO.
; In this test case, the unreachable function is the virtual deleting destructor of an abstract class.
; Generate split module with summary for hybrid Regular LTO WPD
; RUN: opt -thinlto-bc -thinlto-split-lto-unit %s -o %t-main.bc
; RUN: opt -thinlto-bc -thinlto-split-lto-unit %p/Inputs/devirt_hybrid_after_filtering_unreachable_lib.ll -o %t-foo.bc
; Tests that devirtualization happens.
; RUN: llvm-lto2 run -save-temps %t-main.bc %t-foo.bc -pass-remarks=. -o %t \
; RUN: -whole-program-visibility \
; RUN: -r=%t-foo.bc,_ZN7Derived1xEv,pl \
struct RetVal {
char x;
int y;
};
typedef RetVal (*Parser)();
RetVal Parse(bool test, Parser p) {
if (test) return {};
return p();
}
=== _Z3fooPlll
Creating new node: t2: i64,ch = CopyFromReg t0, Register:i64 %0
Creating new node: t4: i64,ch = CopyFromReg t0, Register:i64 %1
Creating new node: t6: i64,ch = CopyFromReg t0, Register:i64 %2
Creating constant: t7: i64 = Constant<0>
Creating new node: t8: i64 = undef
Creating new node: t9: i64,ch = load<(load (s64) from %ir.0)> t0, t2, undef:i64
=== _Z3fooPlll
Creating new node: t2: i64,ch = CopyFromReg t0, Register:i64 %0
Creating new node: t4: i64,ch = CopyFromReg t0, Register:i64 %1
Creating new node: t6: i64,ch = CopyFromReg t0, Register:i64 %2
Creating constant: t7: i64 = Constant<0>
Creating new node: t8: i64 = undef
Creating new node: t9: i64,ch = load<(load (s64) from %ir.0)> t0, t2, undef:i64