From f5d1b6413f4f9a160e030b1a467be0aee7dbfafc Mon Sep 17 00:00:00 2001 From: Ranjeet Singh Date: Tue, 4 Dec 2018 00:01:23 +0000 Subject: [IR] Don't assume all functions are 4 byte aligned In some cases different alignments for function might be used to save space e.g. thumb mode with -Oz will try to use 2 byte function alignment. Similar patch that fixed this in other areas exists here https://reviews.llvm.org/D46110 Differential Revision: https://reviews.llvm.org/D55115 llvm-svn: 348215 --- .../Analysis/ConstantFolding/func-and-folding.ll | 27 ++++++++++++++++++++++ .../2004-03-07-FunctionAddressAlignment.ll | 16 ------------- 2 files changed, 27 insertions(+), 16 deletions(-) create mode 100644 llvm/test/Analysis/ConstantFolding/func-and-folding.ll delete mode 100644 llvm/test/Assembler/2004-03-07-FunctionAddressAlignment.ll (limited to 'llvm/test') diff --git a/llvm/test/Analysis/ConstantFolding/func-and-folding.ll b/llvm/test/Analysis/ConstantFolding/func-and-folding.ll new file mode 100644 index 00000000000..eaa55ab06ca --- /dev/null +++ b/llvm/test/Analysis/ConstantFolding/func-and-folding.ll @@ -0,0 +1,27 @@ +; RUN: opt < %s -constprop -S -o - | FileCheck %s + +; Function Attrs: minsize norecurse nounwind optsize readnone +define dso_local void @foo1() #0 { +entry: + ret void +} + +; Function Attrs: minsize norecurse nounwind optsize readnone +define dso_local void @foo2() align 4 { +entry: + ret void +} + +; Function Attrs: minsize nounwind optsize +define dso_local i32 @main() local_unnamed_addr #1 { +entry: +; CHECK: ptrtoint + %call = tail call i32 bitcast (i32 (...)* @process to i32 (i32)*)(i32 and (i32 ptrtoint (void ()* @foo1 to i32), i32 2)) #3 +; CHECK-NEXT: ptrtoint + %call2 = tail call i32 bitcast (i32 (...)* @process to i32 (i32)*)(i32 and (i32 ptrtoint (void ()* @foo2 to i32), i32 2)) #3 + ret i32 0 +} + +; Function Attrs: minsize optsize +declare dso_local i32 @process(...) local_unnamed_addr #2 + diff --git a/llvm/test/Assembler/2004-03-07-FunctionAddressAlignment.ll b/llvm/test/Assembler/2004-03-07-FunctionAddressAlignment.ll deleted file mode 100644 index 7fa0802db40..00000000000 --- a/llvm/test/Assembler/2004-03-07-FunctionAddressAlignment.ll +++ /dev/null @@ -1,16 +0,0 @@ -; RUN: llvm-as < %s | llvm-dis | not grep ptrtoint -; RUN: verify-uselistorder %s -; All of these should be eliminable - - -define i32 @foo() { - ret i32 and (i32 ptrtoint (i32()* @foo to i32), i32 1) -} - -define i32 @foo2() { - ret i32 and (i32 1, i32 ptrtoint (i32()* @foo2 to i32)) -} - -define i1 @foo3() { - ret i1 icmp ne (i1()* @foo3, i1()* null) -} -- cgit v1.2.3