config->ltoPartitions = args::getInteger(args, OPT_lto_partitions, 1);
config->ltoSampleProfile = args.getLastArgValue(OPT_lto_sample_profile);
config->ltoBasicBlockSections =
- args.getLastArgValue(OPT_lto_basicblock_sections);
+ args.getLastArgValue(OPT_lto_basic_block_sections);
config->ltoUniqueBasicBlockSectionNames =
- args.hasFlag(OPT_lto_unique_bb_section_names,
- OPT_no_lto_unique_bb_section_names, false);
+ args.hasFlag(OPT_lto_unique_basic_block_section_names,
+ OPT_no_lto_unique_basic_block_section_names, false);
config->mapFile = args.getLastArgValue(OPT_Map);
config->mipsGotSize = args::getInteger(args, OPT_mips_got_size, 0xfff0);
config->mergeArmExidx =
c.Options.DataSections = true;
// Check if basic block sections must be used.
- // Allowed values for --lto-basicblock-sections are "all", "labels",
+ // Allowed values for --lto-basic-block-sections are "all", "labels",
// "<file name specifying basic block ids>", or none. This is the equivalent
// of -fbasic-block-sections= flag in clang.
if (!config->ltoBasicBlockSections.empty()) {
def opt_remarks_format: Separate<["--"], "opt-remarks-format">,
HelpText<"The format used for serializing remarks (default: YAML)">;
def save_temps: F<"save-temps">;
-def lto_basicblock_sections: JJ<"lto-basicblock-sections=">,
+def lto_basic_block_sections: JJ<"lto-basic-block-sections=">,
HelpText<"Enable basic block sections for LTO">;
-defm lto_unique_bb_section_names: BB<"lto-unique-bb-section-names",
+defm lto_unique_basic_block_section_names: BB<"lto-unique-basic-block-section-names",
"Give unique names to every basic block section for LTO",
"Do not give unique names to every basic block section for LTO (default)">;
def shuffle_sections: JJ<"shuffle-sections=">, MetaVarName<"<seed>">,
--- /dev/null
+# REQUIRES: x86
+## basic-block-sections tests.
+## This simple test checks foo is folded into bar with bb sections
+## and the jumps are deleted.
+
+# RUN: llvm-mc -filetype=obj -triple=x86_64 %s -o %t.o
+# RUN: ld.lld --optimize-bb-jumps --icf=all %t.o -o %t.out
+# RUN: llvm-objdump -d %t.out| FileCheck %s
+
+# CHECK: <foo>:
+# CHECK-NEXT: nopl (%rax)
+# CHECK-NEXT: je 0x{{[[:xdigit:]]+}} <aa.BB.foo>
+# CHECK-NOT: jmp
+
+# CHECK: <a.BB.foo>:
+## Explicity check that bar is folded and not emitted.
+# CHECK-NOT: <bar>:
+# CHECK-NOT: <a.BB.bar>:
+# CHECK-NOT: <aa.BB.bar>:
+
+.section .text.bar,"ax",@progbits
+.type bar,@function
+bar:
+ nopl (%rax)
+ jne a.BB.bar
+ jmp aa.BB.bar
+
+.section .text.a.BB.bar,"ax",@progbits,unique,3
+a.BB.bar:
+ nopl (%rax)
+
+aa.BB.bar:
+ ret
+
+.section .text.foo,"ax",@progbits
+.type foo,@function
+foo:
+ nopl (%rax)
+ jne a.BB.foo
+ jmp aa.BB.foo
+
+.section .text.a.BB.foo,"ax",@progbits,unique,2
+a.BB.foo:
+ nopl (%rax)
+
+aa.BB.foo:
+ ret
--- /dev/null
+# REQUIRES: x86
+## basic-block-sections tests.
+## This simple test checks if redundant direct jumps are converted to
+## implicit fallthrus. The jcc's must be converted to their inverted
+## opcode, for instance jne to je and jmp must be deleted.
+
+# RUN: llvm-mc -filetype=obj -triple=x86_64 %s -o %t.o
+# RUN: ld.lld --optimize-bb-jumps %t.o -o %t.out
+# RUN: llvm-objdump -d %t.out| FileCheck %s
+
+# CHECK: <foo>:
+# CHECK-NEXT: nopl (%rax)
+# CHECK-NEXT: jne 0x{{[[:xdigit:]]+}} <r.BB.foo>
+# CHECK-NOT: jmp
+
+
+.section .text,"ax",@progbits
+.type foo,@function
+foo:
+ nopl (%rax)
+ je a.BB.foo
+ jmp r.BB.foo
+
+# CHECK: <a.BB.foo>:
+# CHECK-NEXT: nopl (%rax)
+# CHECK-NEXT: je 0x{{[[:xdigit:]]+}} <r.BB.foo>
+# CHECK-NOT: jmp
+
+.section .text,"ax",@progbits,unique,3
+a.BB.foo:
+ nopl (%rax)
+ jne aa.BB.foo
+ jmp r.BB.foo
+
+# CHECK: <aa.BB.foo>:
+# CHECK-NEXT: nopl (%rax)
+# CHECK-NEXT: jle 0x{{[[:xdigit:]]+}} <r.BB.foo>
+# CHECK-NOT: jmp
+#
+.section .text,"ax",@progbits,unique,4
+aa.BB.foo:
+ nopl (%rax)
+ jg aaa.BB.foo
+ jmp r.BB.foo
+
+# CHECK: <aaa.BB.foo>:
+# CHECK-NEXT: nopl (%rax)
+# CHECK-NEXT: jl 0x{{[[:xdigit:]]+}} <r.BB.foo>
+# CHECK-NOT: jmp
+#
+.section .text,"ax",@progbits,unique,5
+aaa.BB.foo:
+ nopl (%rax)
+ jge aaaa.BB.foo
+ jmp r.BB.foo
+
+# CHECK: <aaaa.BB.foo>:
+# CHECK-NEXT: nopl (%rax)
+# CHECK-NEXT: jae 0x{{[[:xdigit:]]+}} <r.BB.foo>
+# CHECK-NOT: jmp
+#
+.section .text,"ax",@progbits,unique,6
+aaaa.BB.foo:
+ nopl (%rax)
+ jb aaaaa.BB.foo
+ jmp r.BB.foo
+
+# CHECK: <aaaaa.BB.foo>:
+# CHECK-NEXT: nopl (%rax)
+# CHECK-NEXT: ja 0x{{[[:xdigit:]]+}} <r.BB.foo>
+# CHECK-NOT: jmp
+#
+.section .text,"ax",@progbits,unique,7
+aaaaa.BB.foo:
+ nopl (%rax)
+ jbe aaaaaa.BB.foo
+ jmp r.BB.foo
+
+# CHECK: <aaaaaa.BB.foo>:
+# CHECK-NEXT: nopl (%rax)
+# CHECK-NEXT: jge 0x{{[[:xdigit:]]+}} <r.BB.foo>
+# CHECK-NOT: jmp
+#
+.section .text,"ax",@progbits,unique,8
+aaaaaa.BB.foo:
+ nopl (%rax)
+ jl aaaaaaa.BB.foo
+ jmp r.BB.foo
+
+# CHECK: <aaaaaaa.BB.foo>:
+# CHECK-NEXT: nopl (%rax)
+# CHECK-NEXT: jg 0x{{[[:xdigit:]]+}} <r.BB.foo>
+# CHECK-NOT: jmp
+#
+.section .text,"ax",@progbits,unique,9
+aaaaaaa.BB.foo:
+ nopl (%rax)
+ jle aaaaaaaa.BB.foo
+ jmp r.BB.foo
+
+# CHECK: <aaaaaaaa.BB.foo>:
+# CHECK-NEXT: nopl (%rax)
+# CHECK-NEXT: jbe 0x{{[[:xdigit:]]+}} <r.BB.foo>
+# CHECK-NOT: jmp
+#
+.section .text,"ax",@progbits,unique,10
+aaaaaaaa.BB.foo:
+ nopl (%rax)
+ ja aaaaaaaaa.BB.foo
+ jmp r.BB.foo
+
+# CHECK: <aaaaaaaaa.BB.foo>:
+# CHECK-NEXT: nopl (%rax)
+# CHECK-NEXT: jb 0x{{[[:xdigit:]]+}} <r.BB.foo>
+# CHECK-NOT: jmp
+#
+.section .text,"ax",@progbits,unique,11
+aaaaaaaaa.BB.foo:
+ nopl (%rax)
+ jae aaaaaaaaaa.BB.foo
+ jmp r.BB.foo
+
+.section .text,"ax",@progbits,unique,20
+aaaaaaaaaa.BB.foo:
+ nopl (%rax)
+
+r.BB.foo:
+ ret
--- /dev/null
+# REQUIRES: x86
+## basic-block-sections tests.
+## This simple test checks if redundant direct jumps are converted to
+## implicit fallthrus when PC32 reloc is present. The jcc's must be converted
+## to their inverted opcode, for instance jne to je and jmp must be deleted.
+
+# RUN: llvm-mc -filetype=obj -triple=x86_64 %s -o %t.o
+# RUN: llvm-objdump -dr %t.o| FileCheck %s --check-prefix=RELOC
+# RUN: ld.lld --optimize-bb-jumps %t.o -o %t.out
+# RUN: llvm-objdump -d %t.out| FileCheck %s
+
+# RELOC: jmp
+# RELOC-NEXT: R_X86_64_PC32
+
+# CHECK: <foo>:
+# CHECK-NEXT: nopl (%rax)
+# CHECK-NEXT: jne 0x{{[[:xdigit:]]+}} <r.BB.foo>
+# CHECK-NOT: jmp
+
+
+.section .text,"ax",@progbits
+.type foo,@function
+foo:
+ nopl (%rax)
+ je a.BB.foo
+# Encode a jmp r.BB.foo insn using a PC32 reloc
+ .byte 0xe9
+ .long r.BB.foo - . - 4
+
+# CHECK: <a.BB.foo>:
+# CHECK-NEXT: nopl (%rax)
+
+.section .text,"ax",@progbits,unique,3
+a.BB.foo:
+ nopl (%rax)
+r.BB.foo:
+ ret
+++ /dev/null
-# REQUIRES: x86
-## basicblock-sections tests.
-## This simple test checks foo is folded into bar with bb sections
-## and the jumps are deleted.
-
-# RUN: llvm-mc -filetype=obj -triple=x86_64 %s -o %t.o
-# RUN: ld.lld --optimize-bb-jumps --icf=all %t.o -o %t.out
-# RUN: llvm-objdump -d %t.out| FileCheck %s
-
-# CHECK: <foo>:
-# CHECK-NEXT: nopl (%rax)
-# CHECK-NEXT: je 0x{{[[:xdigit:]]+}} <aa.BB.foo>
-# CHECK-NOT: jmp
-
-# CHECK: <a.BB.foo>:
-## Explicity check that bar is folded and not emitted.
-# CHECK-NOT: <bar>:
-# CHECK-NOT: <a.BB.bar>:
-# CHECK-NOT: <aa.BB.bar>:
-
-.section .text.bar,"ax",@progbits
-.type bar,@function
-bar:
- nopl (%rax)
- jne a.BB.bar
- jmp aa.BB.bar
-
-.section .text.a.BB.bar,"ax",@progbits,unique,3
-a.BB.bar:
- nopl (%rax)
-
-aa.BB.bar:
- ret
-
-.section .text.foo,"ax",@progbits
-.type foo,@function
-foo:
- nopl (%rax)
- jne a.BB.foo
- jmp aa.BB.foo
-
-.section .text.a.BB.foo,"ax",@progbits,unique,2
-a.BB.foo:
- nopl (%rax)
-
-aa.BB.foo:
- ret
+++ /dev/null
-# REQUIRES: x86
-## basicblock-sections tests.
-## This simple test checks if redundant direct jumps are converted to
-## implicit fallthrus. The jcc's must be converted to their inverted
-## opcode, for instance jne to je and jmp must be deleted.
-
-# RUN: llvm-mc -filetype=obj -triple=x86_64 %s -o %t.o
-# RUN: ld.lld --optimize-bb-jumps %t.o -o %t.out
-# RUN: llvm-objdump -d %t.out| FileCheck %s
-
-# CHECK: <foo>:
-# CHECK-NEXT: nopl (%rax)
-# CHECK-NEXT: jne 0x{{[[:xdigit:]]+}} <r.BB.foo>
-# CHECK-NOT: jmp
-
-
-.section .text,"ax",@progbits
-.type foo,@function
-foo:
- nopl (%rax)
- je a.BB.foo
- jmp r.BB.foo
-
-# CHECK: <a.BB.foo>:
-# CHECK-NEXT: nopl (%rax)
-# CHECK-NEXT: je 0x{{[[:xdigit:]]+}} <r.BB.foo>
-# CHECK-NOT: jmp
-
-.section .text,"ax",@progbits,unique,3
-a.BB.foo:
- nopl (%rax)
- jne aa.BB.foo
- jmp r.BB.foo
-
-# CHECK: <aa.BB.foo>:
-# CHECK-NEXT: nopl (%rax)
-# CHECK-NEXT: jle 0x{{[[:xdigit:]]+}} <r.BB.foo>
-# CHECK-NOT: jmp
-#
-.section .text,"ax",@progbits,unique,4
-aa.BB.foo:
- nopl (%rax)
- jg aaa.BB.foo
- jmp r.BB.foo
-
-# CHECK: <aaa.BB.foo>:
-# CHECK-NEXT: nopl (%rax)
-# CHECK-NEXT: jl 0x{{[[:xdigit:]]+}} <r.BB.foo>
-# CHECK-NOT: jmp
-#
-.section .text,"ax",@progbits,unique,5
-aaa.BB.foo:
- nopl (%rax)
- jge aaaa.BB.foo
- jmp r.BB.foo
-
-# CHECK: <aaaa.BB.foo>:
-# CHECK-NEXT: nopl (%rax)
-# CHECK-NEXT: jae 0x{{[[:xdigit:]]+}} <r.BB.foo>
-# CHECK-NOT: jmp
-#
-.section .text,"ax",@progbits,unique,6
-aaaa.BB.foo:
- nopl (%rax)
- jb aaaaa.BB.foo
- jmp r.BB.foo
-
-# CHECK: <aaaaa.BB.foo>:
-# CHECK-NEXT: nopl (%rax)
-# CHECK-NEXT: ja 0x{{[[:xdigit:]]+}} <r.BB.foo>
-# CHECK-NOT: jmp
-#
-.section .text,"ax",@progbits,unique,7
-aaaaa.BB.foo:
- nopl (%rax)
- jbe aaaaaa.BB.foo
- jmp r.BB.foo
-
-# CHECK: <aaaaaa.BB.foo>:
-# CHECK-NEXT: nopl (%rax)
-# CHECK-NEXT: jge 0x{{[[:xdigit:]]+}} <r.BB.foo>
-# CHECK-NOT: jmp
-#
-.section .text,"ax",@progbits,unique,8
-aaaaaa.BB.foo:
- nopl (%rax)
- jl aaaaaaa.BB.foo
- jmp r.BB.foo
-
-# CHECK: <aaaaaaa.BB.foo>:
-# CHECK-NEXT: nopl (%rax)
-# CHECK-NEXT: jg 0x{{[[:xdigit:]]+}} <r.BB.foo>
-# CHECK-NOT: jmp
-#
-.section .text,"ax",@progbits,unique,9
-aaaaaaa.BB.foo:
- nopl (%rax)
- jle aaaaaaaa.BB.foo
- jmp r.BB.foo
-
-# CHECK: <aaaaaaaa.BB.foo>:
-# CHECK-NEXT: nopl (%rax)
-# CHECK-NEXT: jbe 0x{{[[:xdigit:]]+}} <r.BB.foo>
-# CHECK-NOT: jmp
-#
-.section .text,"ax",@progbits,unique,10
-aaaaaaaa.BB.foo:
- nopl (%rax)
- ja aaaaaaaaa.BB.foo
- jmp r.BB.foo
-
-# CHECK: <aaaaaaaaa.BB.foo>:
-# CHECK-NEXT: nopl (%rax)
-# CHECK-NEXT: jb 0x{{[[:xdigit:]]+}} <r.BB.foo>
-# CHECK-NOT: jmp
-#
-.section .text,"ax",@progbits,unique,11
-aaaaaaaaa.BB.foo:
- nopl (%rax)
- jae aaaaaaaaaa.BB.foo
- jmp r.BB.foo
-
-.section .text,"ax",@progbits,unique,20
-aaaaaaaaaa.BB.foo:
- nopl (%rax)
-
-r.BB.foo:
- ret
+++ /dev/null
-# REQUIRES: x86
-## basicblock-sections tests.
-## This simple test checks if redundant direct jumps are converted to
-## implicit fallthrus when PC32 reloc is present. The jcc's must be converted
-## to their inverted opcode, for instance jne to je and jmp must be deleted.
-
-# RUN: llvm-mc -filetype=obj -triple=x86_64 %s -o %t.o
-# RUN: llvm-objdump -dr %t.o| FileCheck %s --check-prefix=RELOC
-# RUN: ld.lld --optimize-bb-jumps %t.o -o %t.out
-# RUN: llvm-objdump -d %t.out| FileCheck %s
-
-# RELOC: jmp
-# RELOC-NEXT: R_X86_64_PC32
-
-# CHECK: <foo>:
-# CHECK-NEXT: nopl (%rax)
-# CHECK-NEXT: jne 0x{{[[:xdigit:]]+}} <r.BB.foo>
-# CHECK-NOT: jmp
-
-
-.section .text,"ax",@progbits
-.type foo,@function
-foo:
- nopl (%rax)
- je a.BB.foo
-# Encode a jmp r.BB.foo insn using a PC32 reloc
- .byte 0xe9
- .long r.BB.foo - . - 4
-
-# CHECK: <a.BB.foo>:
-# CHECK-NEXT: nopl (%rax)
-
-.section .text,"ax",@progbits,unique,3
-a.BB.foo:
- nopl (%rax)
-r.BB.foo:
- ret
CGBINDOPT(FunctionSections);
static cl::opt<std::string> BBSections(
- "basicblock-sections",
+ "basic-block-sections",
cl::desc("Emit basic blocks into separate sections"),
cl::value_desc("all | <function list (file)> | labels | none"),
cl::init("none"));
CGBINDOPT(UniqueSectionNames);
static cl::opt<bool> UniqueBasicBlockSectionNames(
- "unique-bb-section-names",
+ "unique-basic-block-section-names",
cl::desc("Give unique names to every basic block section"),
cl::init(false));
CGBINDOPT(UniqueBasicBlockSectionNames);
--- /dev/null
+; BB cluster sections test for optimizing basic block branches.
+;
+; Test1: Basic blocks #0 (entry) and #2 will be placed in the same section.
+; There should be a jne from #0 to #1 and a fallthrough to #2.
+; BB #1 will be in a unique section. Therefore, it should retain its jmp to #3.
+; #2 must also have an explicit jump to #3.
+; RUN: echo '!foo' > %t1
+; RUN: echo '!!0 2' >> %t1
+; RUN: echo '!!1' >> %t1
+; RUN: llc < %s -O0 -mtriple=x86_64-pc-linux -function-sections -basic-block-sections=%t1 | FileCheck %s -check-prefix=LINUX-SECTIONS1
+;
+; Test2: Basic blocks #1 and #3 will be placed in the same section.
+; The rest (#0 and #2) go into the function's section.
+; This means #1 must fall through to #3, and #0 must fall through to #2.
+; #2 must have an explicit jump to #3.
+; RUN: echo '!foo' > %t2
+; RUN: echo '!!1 3' >> %t2
+; RUN: llc < %s -O0 -mtriple=x86_64-pc-linux -function-sections -basic-block-sections=%t2 | FileCheck %s -check-prefix=LINUX-SECTIONS2
+
+define void @foo(i1 zeroext) nounwind {
+ %2 = alloca i8, align 1
+ %3 = zext i1 %0 to i8
+ store i8 %3, i8* %2, align 1
+ %4 = load i8, i8* %2, align 1
+ %5 = trunc i8 %4 to i1
+ br i1 %5, label %6, label %8
+
+6: ; preds = %1
+ %7 = call i32 @bar()
+ br label %10
+
+8: ; preds = %1
+ %9 = call i32 @baz()
+ br label %10
+
+10: ; preds = %8, %6
+ ret void
+}
+
+declare i32 @bar() #1
+
+declare i32 @baz() #1
+
+; LINUX-SECTIONS1: .section .text.foo,"ax",@progbits
+; LINUX-SECTIONS1-LABEL: foo:
+; LINUX-SECTIONS1: jne foo.1
+; LINUX-SECTIONS1-NOT: {{jne|je|jmp}}
+; LINUX-SECTIONS1-LABEL: # %bb.2:
+; LINUX-SECTIONS1: jmp foo.cold
+; LINUX-SECTIONS1: .section .text.foo,"ax",@progbits,unique,1
+; LINUX-SECTIONS1-LABEL: foo.1:
+; LINUX-SECTIONS1: jmp foo.cold
+; LINUX-SECTIONS1: .section .text.unlikely.foo,"ax",@progbits
+; LINUX-SECTIONS1-LABEL: foo.cold:
+
+; LINUX-SECTIONS2: .section .text.foo,"ax",@progbits
+; LINUX-SECTIONS2-LABEL: foo:
+; LINUX-SECTIONS2: jne foo.0
+; LINUX-SECTIONS2-NOT: {{jne|je|jmp}}
+; LINUX-SECTIONS2-LABEL: # %bb.2:
+; LINUX-SECTIONS2: jmp .LBB0_3
+; LINUX-SECTIONS2: .section .text.foo,"ax",@progbits,unique,1
+; LINUX-SECTIONS2: foo.0:
+; LINUX-SECTIONS2-NOT: {{jne|je|jmp}}
+; LINUX-SECTIONS2: .LBB0_3:
--- /dev/null
+; BB cluster section test for exception handling.
+;
+; Test1: Basic blocks #1 and #3 are landing pads and must be in the same section.
+; Basic block 2 will be placed in a unique section, but #1 and #3 are placed in the special exception section.
+; The rest will be placed in a section along with the entry basic block.
+; RUN: echo '!main' > %t1
+; RUN: echo '!!1 2' >> %t1
+; RUN: llc < %s -O0 -mtriple=x86_64-pc-linux -function-sections -basic-block-sections=%t1 | FileCheck %s -check-prefix=LINUX-SECTIONS1
+;
+; Test2: Basic blocks #1, #2, and #3 go into a separate section.
+; No separate exception section will be created as #1 and #3 are already in one section.
+; The rest will be placed in a section along with the entry basic block.
+; RUN: echo '!main' > %t2
+; RUN: echo '!!1 2 3' >> %t2
+; RUN: llc < %s -O0 -mtriple=x86_64-pc-linux -function-sections -basic-block-sections=%t2 | FileCheck %s -check-prefix=LINUX-SECTIONS2
+
+@_ZTIi = external constant i8*
+
+define i32 @main() uwtable optsize ssp personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {
+entry:
+ invoke void @_Z1fv() optsize
+ to label %try.cont unwind label %lpad1
+
+lpad1:
+ %0 = landingpad { i8*, i32 }
+ cleanup
+ catch i8* bitcast (i8** @_ZTIi to i8*)
+ br label %eh.resume1
+
+try.cont:
+ invoke void @_Z2fv() optsize
+ to label %try.cont unwind label %lpad2
+ ret i32 0
+
+lpad2:
+ %2 = landingpad { i8*, i32 }
+ cleanup
+ catch i8* bitcast (i8** @_ZTIi to i8*)
+ br label %eh.resume2
+
+eh.resume1:
+ resume { i8*, i32 } %0
+
+eh.resume2:
+ resume { i8*, i32 } %2
+}
+
+declare void @_Z1fv() optsize
+
+declare void @_Z2fv() optsize
+
+declare i32 @__gxx_personality_v0(...)
+
+; LINUX-SECTIONS1: .section .text.main,"ax",@progbits
+; LINUX-SECTIONS1-LABEL: main:
+; LINUX-SECTIONS1-NOT: .section
+; LINUX-SECTIONS1-LABEL: .LBB0_4:
+; LINUX-SECTIONS1-NOT: .section
+; LINUX-SECTIONS1-LABEL: .LBB0_5:
+; LINUX-SECTIONS1-NOT: .section
+; LINUX-SECTIONS1-LABEL: .LBB0_6:
+; LINUX-SECTIONS1: .section .text.main,"ax",@progbits,unique,1
+; LINUX-SECTIONS1-LABEL: main.0:
+; LINUX-SECTIONS1: .section .text.eh.main,"ax",@progbits
+; LINUX-SECTIONS1-LABEL: main.eh:
+; LINUX-SECTIONS1-NOT: .section
+; LINUX-SECTIONS1-LABEL: .LBB0_3:
+; LINUX-SECTIONS1-NOT: .section
+; LINUX-SECTIONS1: .section .text.main,"ax",@progbits
+; LINUX-SECTIONS1-LABEL: .Lfunc_end0
+
+
+; LINUX-SECTIONS2: .section .text.main,"ax",@progbits
+; LINUX-SECTIONS2-LABEL: main:
+; LINUX-SECTIONS2-NOT: .section
+; LINUX-SECTIONS2-LABEL: .LBB0_4:
+; LINUX-SECTIONS2-NOT: .section
+; LINUX-SECTIONS2-LABEL: .LBB0_5:
+; LINUX-SECTIONS2-NOT: .section
+; LINUX-SECTIONS2-LABEL: .LBB0_6:
+; LINUX-SECTIONS2: .section .text.main,"ax",@progbits,unique,1
+; LINUX-SECTIONS2-LABEL: main.0:
+; LINUX-SECTIONS2-NOT: .section
+; LINUX-SECTIONS2-LABEL: .LBB0_2:
+; LINUX-SECTIONS2-NOT: .section
+; LINUX-SECTIONS2-LABEL: .LBB0_3:
+; LINUX-SECTIONS2: .section .text.main,"ax",@progbits
+; LINUX-SECTIONS2-LABEL: .Lfunc_end0
--- /dev/null
+; BB cluster sections error handling
+; RUN: echo '!f' > %t1
+; RUN: echo '!!1 4' >> %t1
+; RUN: echo '!!1' >> %t1
+; RUN: not --crash llc < %s -O0 -mtriple=x86_64-pc-linux -function-sections -basic-block-sections=%t1 2>&1 | FileCheck %s --check-prefix=CHECK-ERROR1
+; CHECK-ERROR1: LLVM ERROR: Invalid profile {{.*}} at line 3: Duplicate basic block id found '1'.
+; RUN: echo '!f' > %t2
+; RUN: echo '!!4 0' >> %t2
+; RUN: not --crash llc < %s -O0 -mtriple=x86_64-pc-linux -function-sections -basic-block-sections=%t2 2>&1 | FileCheck %s --check-prefix=CHECK-ERROR2
+; CHECK-ERROR2: LLVM ERROR: Invalid profile {{.*}} at line 2: Entry BB (0) does not begin a cluster.
+; RUN: echo '!f' > %t3
+; RUN: echo '!!-1' >> %t3
+; RUN: not --crash llc < %s -O0 -mtriple=x86_64-pc-linux -function-sections -basic-block-sections=%t3 2>&1 | FileCheck %s --check-prefix=CHECK-ERROR3
+; CHECK-ERROR3: LLVM ERROR: Invalid profile {{.*}} at line 2: Unsigned integer expected: '-1'.
+; RUN: echo '!!1' > %t4
+; RUN: echo '!f' >> %t4
+; RUN: not --crash llc < %s -O0 -mtriple=x86_64-pc-linux -function-sections -basic-block-sections=%t4 2>&1 | FileCheck %s --check-prefix=CHECK-ERROR4
+; CHECK-ERROR4: LLVM ERROR: Invalid profile {{.*}} at line 1: Cluster list does not follow a function name specifier.
+
+define i32 @dummy(i32 %x, i32 %y, i32 %z) {
+ entry:
+ %tmp = mul i32 %x, %y
+ %tmp2 = add i32 %tmp, %z
+ ret i32 %tmp2
+}
--- /dev/null
+; BB cluster section tests.
+;
+; Test1: Basic blocks #0 (entry) and #2 will be placed in the same section.
+; Basic block 1 will be placed in a unique section.
+; The rest will be placed in the cold section.
+; RUN: echo '!foo' > %t1
+; RUN: echo '!!0 2' >> %t1
+; RUN: echo '!!1' >> %t1
+; RUN: llc < %s -O0 -mtriple=x86_64-pc-linux -function-sections -basic-block-sections=%t1 | FileCheck %s -check-prefix=LINUX-SECTIONS1
+;
+; Test2: Basic blocks #1 and #3 will be placed in the same section.
+; All other BBs (including the entry block) go into the function's section.
+; RUN: echo '!foo' > %t2
+; RUN: echo '!!1 3' >> %t2
+; RUN: llc < %s -O0 -mtriple=x86_64-pc-linux -function-sections -basic-block-sections=%t2 | FileCheck %s -check-prefix=LINUX-SECTIONS2
+
+define void @foo(i1 zeroext) nounwind {
+ %2 = alloca i8, align 1
+ %3 = zext i1 %0 to i8
+ store i8 %3, i8* %2, align 1
+ %4 = load i8, i8* %2, align 1
+ %5 = trunc i8 %4 to i1
+ br i1 %5, label %6, label %8
+
+6: ; preds = %1
+ %7 = call i32 @bar()
+ br label %10
+
+8: ; preds = %1
+ %9 = call i32 @baz()
+ br label %10
+
+10: ; preds = %8, %6
+ ret void
+}
+
+declare i32 @bar() #1
+
+declare i32 @baz() #1
+
+; LINUX-SECTIONS1: .section .text.foo,"ax",@progbits
+; LINUX-SECTIONS1-NOT: .section
+; LINUX-SECTIONS1-LABEL: foo:
+; LINUX-SECTIONS1-NOT: .section
+; LINUX-SECTIONS1-LABEL: # %bb.2:
+; LINUX-SECTIONS1: .section .text.foo,"ax",@progbits,unique,1
+; LINUX-SECTIONS1-LABEL: foo.1:
+; LINUX-SECTIONS1-LABEL: .Ltmp0:
+; LINUX-SECTIONS1-NEXT: .size foo.1, .Ltmp0-foo.1
+; LINUX-SECTIONS1-NOT: .section
+; LINUX-SECTIONS1: .section .text.unlikely.foo,"ax",@progbits
+; LINUX-SECTIONS1-LABEL: foo.cold:
+; LINUX-SECTIONS1: .section .text.foo,"ax",@progbits
+; LINUX-SECTIONS1-LABEL: .Lfunc_end0:
+; LINUX-SECTIONS1-NEXT: .size foo, .Lfunc_end0-foo
+
+; LINUX-SECTIONS2: .section .text.foo,"ax",@progbits
+; LINUX-SECTIONS2-NOT: .section
+; LINUX-SECTIONS2-LABEL: foo:
+; LINUX-SECTIONS2-NOT: .section
+; LINUX-SECTIONS2-LABEL: # %bb.2:
+; LINUX-SECTIONS2: .section .text.foo,"ax",@progbits,unique,1
+; LINUX-SECTIONS2-NEXT: foo.0:
+; LINUX-SECTIONS2-NOT: .section
+; LINUX-SECTIONS2-LABEL: .LBB0_3:
+; LINUX-SECTIONS2-LABEL: .Ltmp0:
+; LINUX-SECTIONS2-NEXT: .size foo.0, .Ltmp0-foo.0
+; LINUX-SECTIONS2: .section .text.foo,"ax",@progbits
+; LINUX-SECTIONS2-LABEL: .Lfunc_end0:
+; LINUX-SECTIONS2-NEXT: .size foo, .Lfunc_end0-foo
--- /dev/null
+; Check if basic blocks that don't get unique sections are placed in cold sections.
+; Basic block with id 1 and 2 must be in the cold section.
+; RUN: echo '!_Z3bazb' > %t
+; RUN: echo '!!0' >> %t
+; RUN: llc < %s -mtriple=x86_64-pc-linux -function-sections -basic-block-sections=%t -unique-basic-block-section-names | FileCheck %s -check-prefix=LINUX-SECTIONS
+
+define void @_Z3bazb(i1 zeroext) nounwind {
+ %2 = alloca i8, align 1
+ %3 = zext i1 %0 to i8
+ store i8 %3, i8* %2, align 1
+ %4 = load i8, i8* %2, align 1
+ %5 = trunc i8 %4 to i1
+ br i1 %5, label %6, label %8
+
+6: ; preds = %1
+ %7 = call i32 @_Z3barv()
+ br label %10
+
+8: ; preds = %1
+ %9 = call i32 @_Z3foov()
+ br label %10
+
+10: ; preds = %8, %6
+ ret void
+}
+
+declare i32 @_Z3barv() #1
+
+declare i32 @_Z3foov() #1
+
+; LINUX-SECTIONS: .section .text._Z3bazb,"ax",@progbits
+; LINUX-SECTIONS: _Z3bazb:
+; Check that the basic block with id 1 doesn't get a section.
+; LINUX-SECTIONS-NOT: .section .text._Z3bazb._Z3bazb.1,"ax",@progbits,unique
+; Check that a single cold section is started here and id 1 and 2 blocks are placed here.
+; LINUX-SECTIONS: .section .text.unlikely._Z3bazb,"ax",@progbits
+; LINUX-SECTIONS: _Z3bazb.cold:
+; LINUX-SECTIONS-NOT: .section .text._Z3bazb._Z3bazb.2,"ax",@progbits,unique
+; LINUX-SECTIONS: .LBB0_2:
+; LINUX-SECTIONS: .size _Z3bazb, .Lfunc_end{{[0-9]}}-_Z3bazb
--- /dev/null
+; RUN: llc < %s -mtriple=x86_64-pc-linux -function-sections -basic-block-sections=all -unique-basic-block-section-names | FileCheck %s -check-prefix=LINUX-SECTIONS
+; RUN: llc < %s -mtriple=i386-unknown-linux-gnu -function-sections -basic-block-sections=all -unique-basic-block-section-names | FileCheck %s -check-prefix=LINUX-SECTIONS
+
+define void @_Z3bazb(i1 zeroext) {
+ %2 = alloca i8, align 1
+ %3 = zext i1 %0 to i8
+ store i8 %3, i8* %2, align 1
+ %4 = load i8, i8* %2, align 1
+ %5 = trunc i8 %4 to i1
+ br i1 %5, label %6, label %9
+
+6: ; preds = %1
+ %7 = call i32 @_Z3barv()
+ %8 = trunc i32 %7 to i1
+ br i1 %8, label %11, label %9
+
+9: ; preds = %1
+ %10 = call i32 @_Z3foov()
+ br label %11
+
+11: ; preds = %9, %6
+ ret void
+}
+
+declare i32 @_Z3barv() #1
+
+declare i32 @_Z3foov() #1
+
+
+; LINUX-SECTIONS: .section .text._Z3bazb,"ax",@progbits
+; LINUX-SECTIONS: _Z3bazb:
+; LINUX-SECTIONS: jmp _Z3bazb.1
+; LINUX-SECTIONS: .section .text._Z3bazb._Z3bazb.1,"ax",@progbits
+; LINUX-SECTIONS: _Z3bazb.1:
+; LINUX-SECTIONS: jmp _Z3bazb.2
+; LINUX-SECTIONS: .section .text._Z3bazb._Z3bazb.2,"ax",@progbits
+; LINUX-SECTIONS: _Z3bazb.2:
+; LINUX-SECTIONS: jmp _Z3bazb.3
--- /dev/null
+; Check if landing pads are kept in a separate eh section
+; RUN: llc < %s -mtriple=i386-unknown-linux-gnu -function-sections -basic-block-sections=all -unique-basic-block-section-names | FileCheck %s -check-prefix=LINUX-SECTIONS
+
+@_ZTIb = external constant i8*
+define i32 @_Z3foob(i1 zeroext %0) #0 personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {
+ %2 = alloca i32, align 4
+ %3 = alloca i8, align 1
+ %4 = alloca i8*
+ %5 = alloca i32
+ %6 = alloca i8, align 1
+ %7 = zext i1 %0 to i8
+ store i8 %7, i8* %3, align 1
+ %8 = load i8, i8* %3, align 1
+ %9 = trunc i8 %8 to i1
+ br i1 %9, label %10, label %11
+
+10: ; preds = %1
+ store i32 1, i32* %2, align 4
+ br label %31
+
+11: ; preds = %1
+ %12 = call i8* @__cxa_allocate_exception(i64 1) #2
+ %13 = load i8, i8* %3, align 1
+ %14 = trunc i8 %13 to i1
+ %15 = zext i1 %14 to i8
+ store i8 %15, i8* %12, align 16
+ invoke void @__cxa_throw(i8* %12, i8* bitcast (i8** @_ZTIb to i8*), i8* null) #3
+ to label %38 unwind label %16
+
+16: ; preds = %11
+ %17 = landingpad { i8*, i32 }
+ catch i8* bitcast (i8** @_ZTIb to i8*)
+ %18 = extractvalue { i8*, i32 } %17, 0
+ store i8* %18, i8** %4, align 8
+ %19 = extractvalue { i8*, i32 } %17, 1
+ store i32 %19, i32* %5, align 4
+ br label %20
+
+20: ; preds = %16
+ %21 = load i32, i32* %5, align 4
+ %22 = call i32 @llvm.eh.typeid.for(i8* bitcast (i8** @_ZTIb to i8*)) #2
+ %23 = icmp eq i32 %21, %22
+ br i1 %23, label %24, label %33
+
+24: ; preds = %20
+ %25 = load i8*, i8** %4, align 8
+ %26 = call i8* @__cxa_begin_catch(i8* %25) #2
+ %27 = load i8, i8* %26, align 1
+ %28 = trunc i8 %27 to i1
+ %29 = zext i1 %28 to i8
+ store i8 %29, i8* %6, align 1
+ call void @__cxa_end_catch() #2
+ br label %30
+
+30: ; preds = %24
+ store i32 0, i32* %2, align 4
+ br label %31
+
+31: ; preds = %30, %10
+ %32 = load i32, i32* %2, align 4
+ ret i32 %32
+
+33: ; preds = %20
+ %34 = load i8*, i8** %4, align 8
+ %35 = load i32, i32* %5, align 4
+ %36 = insertvalue { i8*, i32 } undef, i8* %34, 0
+ %37 = insertvalue { i8*, i32 } %36, i32 %35, 1
+ resume { i8*, i32 } %37
+
+38: ; preds = %11
+ unreachable
+}
+declare i8* @__cxa_allocate_exception(i64)
+declare void @__cxa_throw(i8*, i8*, i8*)
+declare i32 @__gxx_personality_v0(...)
+; Function Attrs: nounwind readnone
+declare i32 @llvm.eh.typeid.for(i8*) #1
+declare i8* @__cxa_begin_catch(i8*)
+declare void @__cxa_end_catch()
+
+;LINUX-SECTIONS: .section .text._Z3foob,"ax",@progbits
+;LINUX-SECTIONS: _Z3foob:
+;LINUX-SECTIONS: .section .text._Z3foob._Z3foob.{{[0-9]+}},"ax",@progbits
+;LINUX-SECTIONS-LABEL: _Z3foob.{{[0-9]+}}:
+;LINUX-SECTIONS: calll __cxa_begin_catch
--- /dev/null
+; Check the basic block sections labels option
+; RUN: llc < %s -mtriple=x86_64-pc-linux -function-sections -basic-block-sections=labels | FileCheck %s -check-prefix=LINUX-LABELS
+
+define void @_Z3bazb(i1 zeroext) {
+ %2 = alloca i8, align 1
+ %3 = zext i1 %0 to i8
+ store i8 %3, i8* %2, align 1
+ %4 = load i8, i8* %2, align 1
+ %5 = trunc i8 %4 to i1
+ br i1 %5, label %6, label %8
+
+6: ; preds = %1
+ %7 = call i32 @_Z3barv()
+ br label %10
+
+8: ; preds = %1
+ %9 = call i32 @_Z3foov()
+ br label %10
+
+10: ; preds = %8, %6
+ ret void
+}
+
+declare i32 @_Z3barv() #1
+
+declare i32 @_Z3foov() #1
+
+; LINUX-LABELS: .section
+; LINUX-LABELS: _Z3bazb:
+; LINUX-LABELS-NOT: .section
+; LINUX-LABELS: r.BB._Z3bazb:
+; LINUX-LABELS-NOT: .section
+; LINUX-LABELS: rr.BB._Z3bazb:
--- /dev/null
+; Check the basic block sections list option.
+; RUN: echo '!_Z3foob' > %t
+; RUN: llc < %s -mtriple=x86_64-pc-linux -function-sections -basic-block-sections=%t -unique-basic-block-section-names | FileCheck %s -check-prefix=LINUX-SECTIONS
+
+define i32 @_Z3foob(i1 zeroext %0) nounwind {
+ %2 = alloca i32, align 4
+ %3 = alloca i8, align 1
+ %4 = zext i1 %0 to i8
+ store i8 %4, i8* %3, align 1
+ %5 = load i8, i8* %3, align 1
+ %6 = trunc i8 %5 to i1
+ %7 = zext i1 %6 to i32
+ %8 = icmp sgt i32 %7, 0
+ br i1 %8, label %9, label %11
+
+9: ; preds = %1
+ %10 = call i32 @_Z3barv()
+ store i32 %10, i32* %2, align 4
+ br label %13
+
+11: ; preds = %1
+ %12 = call i32 @_Z3bazv()
+ store i32 %12, i32* %2, align 4
+ br label %13
+
+13: ; preds = %11, %9
+ %14 = load i32, i32* %2, align 4
+ ret i32 %14
+}
+
+declare i32 @_Z3barv() #1
+declare i32 @_Z3bazv() #1
+
+define i32 @_Z3zipb(i1 zeroext %0) nounwind {
+ %2 = alloca i32, align 4
+ %3 = alloca i8, align 1
+ %4 = zext i1 %0 to i8
+ store i8 %4, i8* %3, align 1
+ %5 = load i8, i8* %3, align 1
+ %6 = trunc i8 %5 to i1
+ %7 = zext i1 %6 to i32
+ %8 = icmp sgt i32 %7, 0
+ br i1 %8, label %9, label %11
+
+9: ; preds = %1
+ %10 = call i32 @_Z3barv()
+ store i32 %10, i32* %2, align 4
+ br label %13
+
+11: ; preds = %1
+ %12 = call i32 @_Z3bazv()
+ store i32 %12, i32* %2, align 4
+ br label %13
+
+13: ; preds = %11, %9
+ %14 = load i32, i32* %2, align 4
+ ret i32 %14
+}
+
+; LINUX-SECTIONS: .section .text._Z3foob,"ax",@progbits
+; LINUX-SECTIONS: _Z3foob:
+; LINUX-SECTIONS: .section .text._Z3foob._Z3foob.1,"ax",@progbits
+; LINUX-SECTIONS: _Z3foob.1:
+; LINUX-SECTIONS: .section .text._Z3foob._Z3foob.2,"ax",@progbits
+; LINUX-SECTIONS: _Z3foob.2:
+; LINUX-SECTIONS: .section .text._Z3foob._Z3foob.3,"ax",@progbits
+; LINUX-SECTIONS: _Z3foob.3:
+
+; LINUX-SECTIONS: .section .text._Z3zipb,"ax",@progbits
+; LINUX-SECTIONS: _Z3zipb:
+; LINUX-SECTIONS-NOT: .section .text._Z3zipb._Z3zipb.{{[0-9]+}},"ax",@progbits
+; LINUX-SECTIONS-NOT: _Z3zipb.{{[0-9]+}}:
--- /dev/null
+; Fine-grained basic block sections, subset of basic blocks in a function.
+; Only basic block with id 2 must get a section.
+; RUN: echo '!_Z3bazb' > %t
+; RUN: echo '!!2' >> %t
+; RUN: llc < %s -mtriple=x86_64-pc-linux -function-sections -basic-block-sections=%t -unique-basic-block-section-names | FileCheck %s -check-prefix=LINUX-SECTIONS
+
+define void @_Z3bazb(i1 zeroext) nounwind {
+ %2 = alloca i8, align 1
+ %3 = zext i1 %0 to i8
+ store i8 %3, i8* %2, align 1
+ %4 = load i8, i8* %2, align 1
+ %5 = trunc i8 %4 to i1
+ br i1 %5, label %6, label %8
+
+6: ; preds = %1
+ %7 = call i32 @_Z3barv()
+ br label %10
+
+8: ; preds = %1
+ %9 = call i32 @_Z3foov()
+ br label %10
+
+10: ; preds = %8, %6
+ ret void
+}
+
+declare i32 @_Z3barv() #1
+
+declare i32 @_Z3foov() #1
+
+; Check that the correct block is found using the call insts for foo and bar.
+;
+; LINUX-SECTIONS: .section .text._Z3bazb,"ax",@progbits
+; LINUX-SECTIONS: _Z3bazb:
+; Check that the basic block with id 1 doesn't get a section.
+; LINUX-SECTIONS-NOT: .section .text._Z3bazb._Z3bazb.{{[0-9]+}},"ax",@progbits
+; LINUX-SECTIONS-LABEL: # %bb.1:
+; LINUX-SECTIONS-NEXT: callq _Z3barv
+; LINUX-SECTIONS: .section .text._Z3bazb._Z3bazb.{{[0-9]+}},"ax",@progbits
+; LINUX-SECTIONS-LABEL: _Z3bazb.{{[0-9]+}}:
+; LINUX-SECTIONS-NEXT: callq _Z3foov
+; LINUX-SECTIONS: .Ltmp0:
+; LINUX-SECTIONS-NEXT: .size _Z3bazb.{{[0-9]+}}, .Ltmp0-_Z3bazb.{{[0-9]+}}
--- /dev/null
+# Start after bbsections0-prepare and check if the right code is generated.
+# RUN: llc -mtriple x86_64-unknown-linux-gnu -start-after=bbsections-prepare %s -o - | FileCheck %s -check-prefix=CHECK
+
+
+# How to generate the input:
+# foo.cc
+# int foo(bool k) {
+# if (k) return 1;
+# return 0;
+# }
+#
+# clang -O0 -S -emit-llvm foo.cc
+# llc < foo.ll -stop-after=bbsections-prepare -basic-block-sections=all
+
+--- |
+ ; Function Attrs: noinline nounwind optnone uwtable
+ define dso_local i32 @_Z3foob(i1 zeroext %0) #0 {
+ %2 = alloca i32, align 4
+ %3 = alloca i8, align 1
+ %4 = zext i1 %0 to i8
+ store i8 %4, i8* %3, align 1
+ %5 = load i8, i8* %3, align 1
+ %6 = trunc i8 %5 to i1
+ br i1 %6, label %7, label %8
+
+ 7: ; preds = %1
+ store i32 1, i32* %2, align 4
+ br label %9
+
+ 8: ; preds = %1
+ store i32 0, i32* %2, align 4
+ br label %9
+
+ 9: ; preds = %8, %7
+ %10 = load i32, i32* %2, align 4
+ ret i32 %10
+ }
+
+ attributes #0 = { "frame-pointer"="all" "target-cpu"="x86-64" }
+
+
+...
+---
+name: _Z3foob
+alignment: 16
+exposesReturnsTwice: false
+legalized: false
+regBankSelected: false
+selected: false
+failedISel: false
+tracksRegLiveness: true
+hasWinCFI: false
+registers: []
+liveins:
+ - { reg: '$edi', virtual-reg: '' }
+frameInfo:
+ isFrameAddressTaken: false
+ isReturnAddressTaken: false
+ hasStackMap: false
+ hasPatchPoint: false
+ stackSize: 8
+ offsetAdjustment: -8
+ maxAlignment: 4
+ adjustsStack: false
+ hasCalls: false
+ stackProtector: ''
+ maxCallFrameSize: 0
+ cvBytesOfCalleeSavedRegisters: 0
+ hasOpaqueSPAdjustment: false
+ hasVAStart: false
+ hasMustTailInVarArgFunc: false
+ localFrameSize: 0
+ savePoint: ''
+ restorePoint: ''
+fixedStack:
+ - { id: 0, type: spill-slot, offset: -16, size: 8, alignment: 16, stack-id: default,
+ callee-saved-register: '', callee-saved-restored: true, debug-info-variable: '',
+ debug-info-expression: '', debug-info-location: '' }
+stack:
+ - { id: 0, type: default, offset: -24, size: 4,
+ alignment: 4, stack-id: default, callee-saved-register: '', callee-saved-restored: true,
+ debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
+ - { id: 1, type: default, offset: -17, size: 1,
+ alignment: 1, stack-id: default, callee-saved-register: '', callee-saved-restored: true,
+ debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
+callSites: []
+constants: []
+machineFunctionInfo: {}
+body: |
+ bb.0 (%ir-block.1, align 4, bbsections 0):
+ successors: %bb.2(0x40000000), %bb.1(0x40000000)
+ liveins: $edi
+
+ frame-setup PUSH64r killed $rbp, implicit-def $rsp, implicit $rsp
+ CFI_INSTRUCTION def_cfa_offset 16
+ CFI_INSTRUCTION offset $rbp, -16
+ $rbp = frame-setup MOV64rr $rsp
+ CFI_INSTRUCTION def_cfa_register $rbp
+ renamable $dil = AND8ri renamable $dil, 1, implicit-def dead $eflags, implicit killed $edi, implicit-def $edi
+ MOV8mr $rbp, 1, $noreg, -1, $noreg, renamable $dil, implicit killed $edi :: (store 1 into %ir.3)
+ TEST8mi $rbp, 1, $noreg, -1, $noreg, 1, implicit-def $eflags :: (load 1 from %ir.3)
+ JCC_1 %bb.2, 4, implicit killed $eflags
+ JMP_1 %bb.1
+
+ bb.1 (%ir-block.7, bbsections 1):
+ successors: %bb.3(0x80000000)
+
+ MOV32mi $rbp, 1, $noreg, -8, $noreg, 1 :: (store 4 into %ir.2)
+ JMP_1 %bb.3
+
+ bb.2 (%ir-block.8, bbsections 2):
+ successors: %bb.3(0x80000000)
+
+ MOV32mi $rbp, 1, $noreg, -8, $noreg, 0 :: (store 4 into %ir.2)
+ JMP_1 %bb.3
+
+ bb.3 (%ir-block.9, bbsections 3):
+ renamable $eax = MOV32rm $rbp, 1, $noreg, -8, $noreg :: (load 4 from %ir.2)
+ $rbp = frame-destroy POP64r implicit-def $rsp, implicit $rsp
+ CFI_INSTRUCTION def_cfa $rsp, 8
+ RETQ implicit $eax
+
+...
+
+# CHECK: _Z3foob:
+# CHECK: .section .text,"ax",@progbits,unique
+# CHECK: _Z3foob.1:
+# CHECK: .section .text,"ax",@progbits,unique
+# CHECK: _Z3foob.2:
+# CHECK: .section .text,"ax",@progbits,unique
+# CHECK: _Z3foob.3:
--- /dev/null
+; Stop after bbsections-prepare and check MIR output for section type.
+; RUN: echo '!_Z3foob' > %t
+; RUN: echo '!!1' >> %t
+; RUN: echo '!!2' >> %t
+; RUN: llc < %s -O0 -mtriple=x86_64-pc-linux -function-sections -basic-block-sections=%t -stop-after=bbsections-prepare | FileCheck %s -check-prefix=CHECK
+
+@_ZTIb = external constant i8*
+define dso_local i32 @_Z3foob(i1 zeroext %0) {
+ %2 = alloca i32, align 4
+ %3 = alloca i8, align 1
+ %4 = zext i1 %0 to i8
+ store i8 %4, i8* %3, align 1
+ %5 = load i8, i8* %3, align 1
+ %6 = trunc i8 %5 to i1
+ br i1 %6, label %7, label %8
+
+7: ; preds = %1
+ store i32 1, i32* %2, align 4
+ br label %9
+
+8: ; preds = %1
+ store i32 0, i32* %2, align 4
+ br label %9
+
+9: ; preds = %8, %7
+ %10 = load i32, i32* %2, align 4
+ ret i32 %10
+}
+
+; CHECK: bb.0 (%ir-block.1, bbsections Cold):
+; CHECK: bb.3 (%ir-block.9, bbsections Cold):
+; CHECK: bb.1 (%ir-block.7)
+; CHECK: bb.2 (%ir-block.8, bbsections 1):
--- /dev/null
+; RUN: llc < %s -mtriple=x86_64-pc-linux -function-sections -basic-block-sections=all -unique-basic-block-section-names | FileCheck %s -check-prefix=LINUX-SECTIONS
+; RUN: llc < %s -mtriple=i386-unknown-linux-gnu -function-sections -basic-block-sections=all -unique-basic-block-section-names | FileCheck %s -check-prefix=LINUX-SECTIONS
+
+define void @_Z3bazb(i1 zeroext) nounwind {
+ %2 = alloca i8, align 1
+ %3 = zext i1 %0 to i8
+ store i8 %3, i8* %2, align 1
+ %4 = load i8, i8* %2, align 1
+ %5 = trunc i8 %4 to i1
+ br i1 %5, label %6, label %8
+
+6: ; preds = %1
+ %7 = call i32 @_Z3barv()
+ br label %10
+
+8: ; preds = %1
+ %9 = call i32 @_Z3foov()
+ br label %10
+
+10: ; preds = %8, %6
+ ret void
+}
+
+declare i32 @_Z3barv() #1
+
+declare i32 @_Z3foov() #1
+
+
+; LINUX-SECTIONS: .section .text._Z3bazb,"ax",@progbits
+; LINUX-SECTIONS: _Z3bazb:
+; LINUX-SECTIONS: .section .text._Z3bazb._Z3bazb.1,"ax",@progbits
+; LINUX-SECTIONS: _Z3bazb.1:
+; LINUX-SECTIONS: .Ltmp0:
+; LINUX-SECTIONS-NEXT: .size _Z3bazb.1, .Ltmp0-_Z3bazb.1
+; LINUX-SECTIONS: .section .text._Z3bazb._Z3bazb.2,"ax",@progbits
+; LINUX-SECTIONS: _Z3bazb.2:
+; LINUX-SECTIONS: .Ltmp1:
+; LINUX-SECTIONS-NEXT: .size _Z3bazb.2, .Ltmp1-_Z3bazb.2
+++ /dev/null
-; BB cluster sections test for optimizing basic block branches.
-;
-; Test1: Basic blocks #0 (entry) and #2 will be placed in the same section.
-; There should be a jne from #0 to #1 and a fallthrough to #2.
-; BB #1 will be in a unique section. Therefore, it should retain its jmp to #3.
-; #2 must also have an explicit jump to #3.
-; RUN: echo '!foo' > %t1
-; RUN: echo '!!0 2' >> %t1
-; RUN: echo '!!1' >> %t1
-; RUN: llc < %s -O0 -mtriple=x86_64-pc-linux -function-sections -basicblock-sections=%t1 | FileCheck %s -check-prefix=LINUX-SECTIONS1
-;
-; Test2: Basic blocks #1 and #3 will be placed in the same section.
-; The rest (#0 and #2) go into the function's section.
-; This means #1 must fall through to #3, and #0 must fall through to #2.
-; #2 must have an explicit jump to #3.
-; RUN: echo '!foo' > %t2
-; RUN: echo '!!1 3' >> %t2
-; RUN: llc < %s -O0 -mtriple=x86_64-pc-linux -function-sections -basicblock-sections=%t2 | FileCheck %s -check-prefix=LINUX-SECTIONS2
-
-define void @foo(i1 zeroext) nounwind {
- %2 = alloca i8, align 1
- %3 = zext i1 %0 to i8
- store i8 %3, i8* %2, align 1
- %4 = load i8, i8* %2, align 1
- %5 = trunc i8 %4 to i1
- br i1 %5, label %6, label %8
-
-6: ; preds = %1
- %7 = call i32 @bar()
- br label %10
-
-8: ; preds = %1
- %9 = call i32 @baz()
- br label %10
-
-10: ; preds = %8, %6
- ret void
-}
-
-declare i32 @bar() #1
-
-declare i32 @baz() #1
-
-; LINUX-SECTIONS1: .section .text.foo,"ax",@progbits
-; LINUX-SECTIONS1-LABEL: foo:
-; LINUX-SECTIONS1: jne foo.1
-; LINUX-SECTIONS1-NOT: {{jne|je|jmp}}
-; LINUX-SECTIONS1-LABEL: # %bb.2:
-; LINUX-SECTIONS1: jmp foo.cold
-; LINUX-SECTIONS1: .section .text.foo,"ax",@progbits,unique,1
-; LINUX-SECTIONS1-LABEL: foo.1:
-; LINUX-SECTIONS1: jmp foo.cold
-; LINUX-SECTIONS1: .section .text.unlikely.foo,"ax",@progbits
-; LINUX-SECTIONS1-LABEL: foo.cold:
-
-; LINUX-SECTIONS2: .section .text.foo,"ax",@progbits
-; LINUX-SECTIONS2-LABEL: foo:
-; LINUX-SECTIONS2: jne foo.0
-; LINUX-SECTIONS2-NOT: {{jne|je|jmp}}
-; LINUX-SECTIONS2-LABEL: # %bb.2:
-; LINUX-SECTIONS2: jmp .LBB0_3
-; LINUX-SECTIONS2: .section .text.foo,"ax",@progbits,unique,1
-; LINUX-SECTIONS2: foo.0:
-; LINUX-SECTIONS2-NOT: {{jne|je|jmp}}
-; LINUX-SECTIONS2: .LBB0_3:
+++ /dev/null
-; BB cluster section test for exception handling.
-;
-; Test1: Basic blocks #1 and #3 are landing pads and must be in the same section.
-; Basic block 2 will be placed in a unique section, but #1 and #3 are placed in the special exception section.
-; The rest will be placed in a section along with the entry basic block.
-; RUN: echo '!main' > %t1
-; RUN: echo '!!1 2' >> %t1
-; RUN: llc < %s -O0 -mtriple=x86_64-pc-linux -function-sections -basicblock-sections=%t1 | FileCheck %s -check-prefix=LINUX-SECTIONS1
-;
-; Test2: Basic blocks #1, #2, and #3 go into a separate section.
-; No separate exception section will be created as #1 and #3 are already in one section.
-; The rest will be placed in a section along with the entry basic block.
-; RUN: echo '!main' > %t2
-; RUN: echo '!!1 2 3' >> %t2
-; RUN: llc < %s -O0 -mtriple=x86_64-pc-linux -function-sections -basicblock-sections=%t2 | FileCheck %s -check-prefix=LINUX-SECTIONS2
-
-@_ZTIi = external constant i8*
-
-define i32 @main() uwtable optsize ssp personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {
-entry:
- invoke void @_Z1fv() optsize
- to label %try.cont unwind label %lpad1
-
-lpad1:
- %0 = landingpad { i8*, i32 }
- cleanup
- catch i8* bitcast (i8** @_ZTIi to i8*)
- br label %eh.resume1
-
-try.cont:
- invoke void @_Z2fv() optsize
- to label %try.cont unwind label %lpad2
- ret i32 0
-
-lpad2:
- %2 = landingpad { i8*, i32 }
- cleanup
- catch i8* bitcast (i8** @_ZTIi to i8*)
- br label %eh.resume2
-
-eh.resume1:
- resume { i8*, i32 } %0
-
-eh.resume2:
- resume { i8*, i32 } %2
-}
-
-declare void @_Z1fv() optsize
-
-declare void @_Z2fv() optsize
-
-declare i32 @__gxx_personality_v0(...)
-
-; LINUX-SECTIONS1: .section .text.main,"ax",@progbits
-; LINUX-SECTIONS1-LABEL: main:
-; LINUX-SECTIONS1-NOT: .section
-; LINUX-SECTIONS1-LABEL: .LBB0_4:
-; LINUX-SECTIONS1-NOT: .section
-; LINUX-SECTIONS1-LABEL: .LBB0_5:
-; LINUX-SECTIONS1-NOT: .section
-; LINUX-SECTIONS1-LABEL: .LBB0_6:
-; LINUX-SECTIONS1: .section .text.main,"ax",@progbits,unique,1
-; LINUX-SECTIONS1-LABEL: main.0:
-; LINUX-SECTIONS1: .section .text.eh.main,"ax",@progbits
-; LINUX-SECTIONS1-LABEL: main.eh:
-; LINUX-SECTIONS1-NOT: .section
-; LINUX-SECTIONS1-LABEL: .LBB0_3:
-; LINUX-SECTIONS1-NOT: .section
-; LINUX-SECTIONS1: .section .text.main,"ax",@progbits
-; LINUX-SECTIONS1-LABEL: .Lfunc_end0
-
-
-; LINUX-SECTIONS2: .section .text.main,"ax",@progbits
-; LINUX-SECTIONS2-LABEL: main:
-; LINUX-SECTIONS2-NOT: .section
-; LINUX-SECTIONS2-LABEL: .LBB0_4:
-; LINUX-SECTIONS2-NOT: .section
-; LINUX-SECTIONS2-LABEL: .LBB0_5:
-; LINUX-SECTIONS2-NOT: .section
-; LINUX-SECTIONS2-LABEL: .LBB0_6:
-; LINUX-SECTIONS2: .section .text.main,"ax",@progbits,unique,1
-; LINUX-SECTIONS2-LABEL: main.0:
-; LINUX-SECTIONS2-NOT: .section
-; LINUX-SECTIONS2-LABEL: .LBB0_2:
-; LINUX-SECTIONS2-NOT: .section
-; LINUX-SECTIONS2-LABEL: .LBB0_3:
-; LINUX-SECTIONS2: .section .text.main,"ax",@progbits
-; LINUX-SECTIONS2-LABEL: .Lfunc_end0
+++ /dev/null
-; BB cluster sections error handling
-; RUN: echo '!f' > %t1
-; RUN: echo '!!1 4' >> %t1
-; RUN: echo '!!1' >> %t1
-; RUN: not --crash llc < %s -O0 -mtriple=x86_64-pc-linux -function-sections -basicblock-sections=%t1 2>&1 | FileCheck %s --check-prefix=CHECK-ERROR1
-; CHECK-ERROR1: LLVM ERROR: Invalid profile {{.*}} at line 3: Duplicate basic block id found '1'.
-; RUN: echo '!f' > %t2
-; RUN: echo '!!4 0' >> %t2
-; RUN: not --crash llc < %s -O0 -mtriple=x86_64-pc-linux -function-sections -basicblock-sections=%t2 2>&1 | FileCheck %s --check-prefix=CHECK-ERROR2
-; CHECK-ERROR2: LLVM ERROR: Invalid profile {{.*}} at line 2: Entry BB (0) does not begin a cluster.
-; RUN: echo '!f' > %t3
-; RUN: echo '!!-1' >> %t3
-; RUN: not --crash llc < %s -O0 -mtriple=x86_64-pc-linux -function-sections -basicblock-sections=%t3 2>&1 | FileCheck %s --check-prefix=CHECK-ERROR3
-; CHECK-ERROR3: LLVM ERROR: Invalid profile {{.*}} at line 2: Unsigned integer expected: '-1'.
-; RUN: echo '!!1' > %t4
-; RUN: echo '!f' >> %t4
-; RUN: not --crash llc < %s -O0 -mtriple=x86_64-pc-linux -function-sections -basicblock-sections=%t4 2>&1 | FileCheck %s --check-prefix=CHECK-ERROR4
-; CHECK-ERROR4: LLVM ERROR: Invalid profile {{.*}} at line 1: Cluster list does not follow a function name specifier.
-
-define i32 @dummy(i32 %x, i32 %y, i32 %z) {
- entry:
- %tmp = mul i32 %x, %y
- %tmp2 = add i32 %tmp, %z
- ret i32 %tmp2
-}
+++ /dev/null
-; BB cluster section tests.
-;
-; Test1: Basic blocks #0 (entry) and #2 will be placed in the same section.
-; Basic block 1 will be placed in a unique section.
-; The rest will be placed in the cold section.
-; RUN: echo '!foo' > %t1
-; RUN: echo '!!0 2' >> %t1
-; RUN: echo '!!1' >> %t1
-; RUN: llc < %s -O0 -mtriple=x86_64-pc-linux -function-sections -basicblock-sections=%t1 | FileCheck %s -check-prefix=LINUX-SECTIONS1
-;
-; Test2: Basic blocks #1 and #3 will be placed in the same section.
-; All other BBs (including the entry block) go into the function's section.
-; RUN: echo '!foo' > %t2
-; RUN: echo '!!1 3' >> %t2
-; RUN: llc < %s -O0 -mtriple=x86_64-pc-linux -function-sections -basicblock-sections=%t2 | FileCheck %s -check-prefix=LINUX-SECTIONS2
-
-define void @foo(i1 zeroext) nounwind {
- %2 = alloca i8, align 1
- %3 = zext i1 %0 to i8
- store i8 %3, i8* %2, align 1
- %4 = load i8, i8* %2, align 1
- %5 = trunc i8 %4 to i1
- br i1 %5, label %6, label %8
-
-6: ; preds = %1
- %7 = call i32 @bar()
- br label %10
-
-8: ; preds = %1
- %9 = call i32 @baz()
- br label %10
-
-10: ; preds = %8, %6
- ret void
-}
-
-declare i32 @bar() #1
-
-declare i32 @baz() #1
-
-; LINUX-SECTIONS1: .section .text.foo,"ax",@progbits
-; LINUX-SECTIONS1-NOT: .section
-; LINUX-SECTIONS1-LABEL: foo:
-; LINUX-SECTIONS1-NOT: .section
-; LINUX-SECTIONS1-LABEL: # %bb.2:
-; LINUX-SECTIONS1: .section .text.foo,"ax",@progbits,unique,1
-; LINUX-SECTIONS1-LABEL: foo.1:
-; LINUX-SECTIONS1-LABEL: .Ltmp0:
-; LINUX-SECTIONS1-NEXT: .size foo.1, .Ltmp0-foo.1
-; LINUX-SECTIONS1-NOT: .section
-; LINUX-SECTIONS1: .section .text.unlikely.foo,"ax",@progbits
-; LINUX-SECTIONS1-LABEL: foo.cold:
-; LINUX-SECTIONS1: .section .text.foo,"ax",@progbits
-; LINUX-SECTIONS1-LABEL: .Lfunc_end0:
-; LINUX-SECTIONS1-NEXT: .size foo, .Lfunc_end0-foo
-
-; LINUX-SECTIONS2: .section .text.foo,"ax",@progbits
-; LINUX-SECTIONS2-NOT: .section
-; LINUX-SECTIONS2-LABEL: foo:
-; LINUX-SECTIONS2-NOT: .section
-; LINUX-SECTIONS2-LABEL: # %bb.2:
-; LINUX-SECTIONS2: .section .text.foo,"ax",@progbits,unique,1
-; LINUX-SECTIONS2-NEXT: foo.0:
-; LINUX-SECTIONS2-NOT: .section
-; LINUX-SECTIONS2-LABEL: .LBB0_3:
-; LINUX-SECTIONS2-LABEL: .Ltmp0:
-; LINUX-SECTIONS2-NEXT: .size foo.0, .Ltmp0-foo.0
-; LINUX-SECTIONS2: .section .text.foo,"ax",@progbits
-; LINUX-SECTIONS2-LABEL: .Lfunc_end0:
-; LINUX-SECTIONS2-NEXT: .size foo, .Lfunc_end0-foo
+++ /dev/null
-; Check if basic blocks that don't get unique sections are placed in cold sections.
-; Basic block with id 1 and 2 must be in the cold section.
-; RUN: echo '!_Z3bazb' > %t
-; RUN: echo '!!0' >> %t
-; RUN: llc < %s -mtriple=x86_64-pc-linux -function-sections -basicblock-sections=%t -unique-bb-section-names | FileCheck %s -check-prefix=LINUX-SECTIONS
-
-define void @_Z3bazb(i1 zeroext) nounwind {
- %2 = alloca i8, align 1
- %3 = zext i1 %0 to i8
- store i8 %3, i8* %2, align 1
- %4 = load i8, i8* %2, align 1
- %5 = trunc i8 %4 to i1
- br i1 %5, label %6, label %8
-
-6: ; preds = %1
- %7 = call i32 @_Z3barv()
- br label %10
-
-8: ; preds = %1
- %9 = call i32 @_Z3foov()
- br label %10
-
-10: ; preds = %8, %6
- ret void
-}
-
-declare i32 @_Z3barv() #1
-
-declare i32 @_Z3foov() #1
-
-; LINUX-SECTIONS: .section .text._Z3bazb,"ax",@progbits
-; LINUX-SECTIONS: _Z3bazb:
-; Check that the basic block with id 1 doesn't get a section.
-; LINUX-SECTIONS-NOT: .section .text._Z3bazb._Z3bazb.1,"ax",@progbits,unique
-; Check that a single cold section is started here and id 1 and 2 blocks are placed here.
-; LINUX-SECTIONS: .section .text.unlikely._Z3bazb,"ax",@progbits
-; LINUX-SECTIONS: _Z3bazb.cold:
-; LINUX-SECTIONS-NOT: .section .text._Z3bazb._Z3bazb.2,"ax",@progbits,unique
-; LINUX-SECTIONS: .LBB0_2:
-; LINUX-SECTIONS: .size _Z3bazb, .Lfunc_end{{[0-9]}}-_Z3bazb
+++ /dev/null
-; RUN: llc < %s -mtriple=x86_64-pc-linux -function-sections -basicblock-sections=all -unique-bb-section-names | FileCheck %s -check-prefix=LINUX-SECTIONS
-; RUN: llc < %s -mtriple=i386-unknown-linux-gnu -function-sections -basicblock-sections=all -unique-bb-section-names | FileCheck %s -check-prefix=LINUX-SECTIONS
-
-define void @_Z3bazb(i1 zeroext) {
- %2 = alloca i8, align 1
- %3 = zext i1 %0 to i8
- store i8 %3, i8* %2, align 1
- %4 = load i8, i8* %2, align 1
- %5 = trunc i8 %4 to i1
- br i1 %5, label %6, label %9
-
-6: ; preds = %1
- %7 = call i32 @_Z3barv()
- %8 = trunc i32 %7 to i1
- br i1 %8, label %11, label %9
-
-9: ; preds = %1
- %10 = call i32 @_Z3foov()
- br label %11
-
-11: ; preds = %9, %6
- ret void
-}
-
-declare i32 @_Z3barv() #1
-
-declare i32 @_Z3foov() #1
-
-
-; LINUX-SECTIONS: .section .text._Z3bazb,"ax",@progbits
-; LINUX-SECTIONS: _Z3bazb:
-; LINUX-SECTIONS: jmp _Z3bazb.1
-; LINUX-SECTIONS: .section .text._Z3bazb._Z3bazb.1,"ax",@progbits
-; LINUX-SECTIONS: _Z3bazb.1:
-; LINUX-SECTIONS: jmp _Z3bazb.2
-; LINUX-SECTIONS: .section .text._Z3bazb._Z3bazb.2,"ax",@progbits
-; LINUX-SECTIONS: _Z3bazb.2:
-; LINUX-SECTIONS: jmp _Z3bazb.3
+++ /dev/null
-; Check if landing pads are kept in a separate eh section
-; RUN: llc < %s -mtriple=i386-unknown-linux-gnu -function-sections -basicblock-sections=all -unique-bb-section-names | FileCheck %s -check-prefix=LINUX-SECTIONS
-
-@_ZTIb = external constant i8*
-define i32 @_Z3foob(i1 zeroext %0) #0 personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {
- %2 = alloca i32, align 4
- %3 = alloca i8, align 1
- %4 = alloca i8*
- %5 = alloca i32
- %6 = alloca i8, align 1
- %7 = zext i1 %0 to i8
- store i8 %7, i8* %3, align 1
- %8 = load i8, i8* %3, align 1
- %9 = trunc i8 %8 to i1
- br i1 %9, label %10, label %11
-
-10: ; preds = %1
- store i32 1, i32* %2, align 4
- br label %31
-
-11: ; preds = %1
- %12 = call i8* @__cxa_allocate_exception(i64 1) #2
- %13 = load i8, i8* %3, align 1
- %14 = trunc i8 %13 to i1
- %15 = zext i1 %14 to i8
- store i8 %15, i8* %12, align 16
- invoke void @__cxa_throw(i8* %12, i8* bitcast (i8** @_ZTIb to i8*), i8* null) #3
- to label %38 unwind label %16
-
-16: ; preds = %11
- %17 = landingpad { i8*, i32 }
- catch i8* bitcast (i8** @_ZTIb to i8*)
- %18 = extractvalue { i8*, i32 } %17, 0
- store i8* %18, i8** %4, align 8
- %19 = extractvalue { i8*, i32 } %17, 1
- store i32 %19, i32* %5, align 4
- br label %20
-
-20: ; preds = %16
- %21 = load i32, i32* %5, align 4
- %22 = call i32 @llvm.eh.typeid.for(i8* bitcast (i8** @_ZTIb to i8*)) #2
- %23 = icmp eq i32 %21, %22
- br i1 %23, label %24, label %33
-
-24: ; preds = %20
- %25 = load i8*, i8** %4, align 8
- %26 = call i8* @__cxa_begin_catch(i8* %25) #2
- %27 = load i8, i8* %26, align 1
- %28 = trunc i8 %27 to i1
- %29 = zext i1 %28 to i8
- store i8 %29, i8* %6, align 1
- call void @__cxa_end_catch() #2
- br label %30
-
-30: ; preds = %24
- store i32 0, i32* %2, align 4
- br label %31
-
-31: ; preds = %30, %10
- %32 = load i32, i32* %2, align 4
- ret i32 %32
-
-33: ; preds = %20
- %34 = load i8*, i8** %4, align 8
- %35 = load i32, i32* %5, align 4
- %36 = insertvalue { i8*, i32 } undef, i8* %34, 0
- %37 = insertvalue { i8*, i32 } %36, i32 %35, 1
- resume { i8*, i32 } %37
-
-38: ; preds = %11
- unreachable
-}
-declare i8* @__cxa_allocate_exception(i64)
-declare void @__cxa_throw(i8*, i8*, i8*)
-declare i32 @__gxx_personality_v0(...)
-; Function Attrs: nounwind readnone
-declare i32 @llvm.eh.typeid.for(i8*) #1
-declare i8* @__cxa_begin_catch(i8*)
-declare void @__cxa_end_catch()
-
-;LINUX-SECTIONS: .section .text._Z3foob,"ax",@progbits
-;LINUX-SECTIONS: _Z3foob:
-;LINUX-SECTIONS: .section .text._Z3foob._Z3foob.{{[0-9]+}},"ax",@progbits
-;LINUX-SECTIONS-LABEL: _Z3foob.{{[0-9]+}}:
-;LINUX-SECTIONS: calll __cxa_begin_catch
+++ /dev/null
-; Check the basic block sections labels option
-; RUN: llc < %s -mtriple=x86_64-pc-linux -function-sections -basicblock-sections=labels | FileCheck %s -check-prefix=LINUX-LABELS
-
-define void @_Z3bazb(i1 zeroext) {
- %2 = alloca i8, align 1
- %3 = zext i1 %0 to i8
- store i8 %3, i8* %2, align 1
- %4 = load i8, i8* %2, align 1
- %5 = trunc i8 %4 to i1
- br i1 %5, label %6, label %8
-
-6: ; preds = %1
- %7 = call i32 @_Z3barv()
- br label %10
-
-8: ; preds = %1
- %9 = call i32 @_Z3foov()
- br label %10
-
-10: ; preds = %8, %6
- ret void
-}
-
-declare i32 @_Z3barv() #1
-
-declare i32 @_Z3foov() #1
-
-; LINUX-LABELS: .section
-; LINUX-LABELS: _Z3bazb:
-; LINUX-LABELS-NOT: .section
-; LINUX-LABELS: r.BB._Z3bazb:
-; LINUX-LABELS-NOT: .section
-; LINUX-LABELS: rr.BB._Z3bazb:
+++ /dev/null
-; Check the basic block sections list option.
-; RUN: echo '!_Z3foob' > %t
-; RUN: llc < %s -mtriple=x86_64-pc-linux -function-sections -basicblock-sections=%t -unique-bb-section-names | FileCheck %s -check-prefix=LINUX-SECTIONS
-
-define i32 @_Z3foob(i1 zeroext %0) nounwind {
- %2 = alloca i32, align 4
- %3 = alloca i8, align 1
- %4 = zext i1 %0 to i8
- store i8 %4, i8* %3, align 1
- %5 = load i8, i8* %3, align 1
- %6 = trunc i8 %5 to i1
- %7 = zext i1 %6 to i32
- %8 = icmp sgt i32 %7, 0
- br i1 %8, label %9, label %11
-
-9: ; preds = %1
- %10 = call i32 @_Z3barv()
- store i32 %10, i32* %2, align 4
- br label %13
-
-11: ; preds = %1
- %12 = call i32 @_Z3bazv()
- store i32 %12, i32* %2, align 4
- br label %13
-
-13: ; preds = %11, %9
- %14 = load i32, i32* %2, align 4
- ret i32 %14
-}
-
-declare i32 @_Z3barv() #1
-declare i32 @_Z3bazv() #1
-
-define i32 @_Z3zipb(i1 zeroext %0) nounwind {
- %2 = alloca i32, align 4
- %3 = alloca i8, align 1
- %4 = zext i1 %0 to i8
- store i8 %4, i8* %3, align 1
- %5 = load i8, i8* %3, align 1
- %6 = trunc i8 %5 to i1
- %7 = zext i1 %6 to i32
- %8 = icmp sgt i32 %7, 0
- br i1 %8, label %9, label %11
-
-9: ; preds = %1
- %10 = call i32 @_Z3barv()
- store i32 %10, i32* %2, align 4
- br label %13
-
-11: ; preds = %1
- %12 = call i32 @_Z3bazv()
- store i32 %12, i32* %2, align 4
- br label %13
-
-13: ; preds = %11, %9
- %14 = load i32, i32* %2, align 4
- ret i32 %14
-}
-
-; LINUX-SECTIONS: .section .text._Z3foob,"ax",@progbits
-; LINUX-SECTIONS: _Z3foob:
-; LINUX-SECTIONS: .section .text._Z3foob._Z3foob.1,"ax",@progbits
-; LINUX-SECTIONS: _Z3foob.1:
-; LINUX-SECTIONS: .section .text._Z3foob._Z3foob.2,"ax",@progbits
-; LINUX-SECTIONS: _Z3foob.2:
-; LINUX-SECTIONS: .section .text._Z3foob._Z3foob.3,"ax",@progbits
-; LINUX-SECTIONS: _Z3foob.3:
-
-; LINUX-SECTIONS: .section .text._Z3zipb,"ax",@progbits
-; LINUX-SECTIONS: _Z3zipb:
-; LINUX-SECTIONS-NOT: .section .text._Z3zipb._Z3zipb.{{[0-9]+}},"ax",@progbits
-; LINUX-SECTIONS-NOT: _Z3zipb.{{[0-9]+}}:
+++ /dev/null
-; Fine-grained basic block sections, subset of basic blocks in a function.
-; Only basic block with id 2 must get a section.
-; RUN: echo '!_Z3bazb' > %t
-; RUN: echo '!!2' >> %t
-; RUN: llc < %s -mtriple=x86_64-pc-linux -function-sections -basicblock-sections=%t -unique-bb-section-names | FileCheck %s -check-prefix=LINUX-SECTIONS
-
-define void @_Z3bazb(i1 zeroext) nounwind {
- %2 = alloca i8, align 1
- %3 = zext i1 %0 to i8
- store i8 %3, i8* %2, align 1
- %4 = load i8, i8* %2, align 1
- %5 = trunc i8 %4 to i1
- br i1 %5, label %6, label %8
-
-6: ; preds = %1
- %7 = call i32 @_Z3barv()
- br label %10
-
-8: ; preds = %1
- %9 = call i32 @_Z3foov()
- br label %10
-
-10: ; preds = %8, %6
- ret void
-}
-
-declare i32 @_Z3barv() #1
-
-declare i32 @_Z3foov() #1
-
-; Check that the correct block is found using the call insts for foo and bar.
-;
-; LINUX-SECTIONS: .section .text._Z3bazb,"ax",@progbits
-; LINUX-SECTIONS: _Z3bazb:
-; Check that the basic block with id 1 doesn't get a section.
-; LINUX-SECTIONS-NOT: .section .text._Z3bazb._Z3bazb.{{[0-9]+}},"ax",@progbits
-; LINUX-SECTIONS-LABEL: # %bb.1:
-; LINUX-SECTIONS-NEXT: callq _Z3barv
-; LINUX-SECTIONS: .section .text._Z3bazb._Z3bazb.{{[0-9]+}},"ax",@progbits
-; LINUX-SECTIONS-LABEL: _Z3bazb.{{[0-9]+}}:
-; LINUX-SECTIONS-NEXT: callq _Z3foov
-; LINUX-SECTIONS: .Ltmp0:
-; LINUX-SECTIONS-NEXT: .size _Z3bazb.{{[0-9]+}}, .Ltmp0-_Z3bazb.{{[0-9]+}}
+++ /dev/null
-# Start after bbsections0-prepare and check if the right code is generated.
-# RUN: llc -mtriple x86_64-unknown-linux-gnu -start-after=bbsections-prepare %s -o - | FileCheck %s -check-prefix=CHECK
-
-
-# How to generate the input:
-# foo.cc
-# int foo(bool k) {
-# if (k) return 1;
-# return 0;
-# }
-#
-# clang -O0 -S -emit-llvm foo.cc
-# llc < foo.ll -stop-after=bbsections-prepare -basicblock-sections=all
-
---- |
- ; Function Attrs: noinline nounwind optnone uwtable
- define dso_local i32 @_Z3foob(i1 zeroext %0) #0 {
- %2 = alloca i32, align 4
- %3 = alloca i8, align 1
- %4 = zext i1 %0 to i8
- store i8 %4, i8* %3, align 1
- %5 = load i8, i8* %3, align 1
- %6 = trunc i8 %5 to i1
- br i1 %6, label %7, label %8
-
- 7: ; preds = %1
- store i32 1, i32* %2, align 4
- br label %9
-
- 8: ; preds = %1
- store i32 0, i32* %2, align 4
- br label %9
-
- 9: ; preds = %8, %7
- %10 = load i32, i32* %2, align 4
- ret i32 %10
- }
-
- attributes #0 = { "frame-pointer"="all" "target-cpu"="x86-64" }
-
-
-...
----
-name: _Z3foob
-alignment: 16
-exposesReturnsTwice: false
-legalized: false
-regBankSelected: false
-selected: false
-failedISel: false
-tracksRegLiveness: true
-hasWinCFI: false
-registers: []
-liveins:
- - { reg: '$edi', virtual-reg: '' }
-frameInfo:
- isFrameAddressTaken: false
- isReturnAddressTaken: false
- hasStackMap: false
- hasPatchPoint: false
- stackSize: 8
- offsetAdjustment: -8
- maxAlignment: 4
- adjustsStack: false
- hasCalls: false
- stackProtector: ''
- maxCallFrameSize: 0
- cvBytesOfCalleeSavedRegisters: 0
- hasOpaqueSPAdjustment: false
- hasVAStart: false
- hasMustTailInVarArgFunc: false
- localFrameSize: 0
- savePoint: ''
- restorePoint: ''
-fixedStack:
- - { id: 0, type: spill-slot, offset: -16, size: 8, alignment: 16, stack-id: default,
- callee-saved-register: '', callee-saved-restored: true, debug-info-variable: '',
- debug-info-expression: '', debug-info-location: '' }
-stack:
- - { id: 0, type: default, offset: -24, size: 4,
- alignment: 4, stack-id: default, callee-saved-register: '', callee-saved-restored: true,
- debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
- - { id: 1, type: default, offset: -17, size: 1,
- alignment: 1, stack-id: default, callee-saved-register: '', callee-saved-restored: true,
- debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
-callSites: []
-constants: []
-machineFunctionInfo: {}
-body: |
- bb.0 (%ir-block.1, align 4, bbsections 0):
- successors: %bb.2(0x40000000), %bb.1(0x40000000)
- liveins: $edi
-
- frame-setup PUSH64r killed $rbp, implicit-def $rsp, implicit $rsp
- CFI_INSTRUCTION def_cfa_offset 16
- CFI_INSTRUCTION offset $rbp, -16
- $rbp = frame-setup MOV64rr $rsp
- CFI_INSTRUCTION def_cfa_register $rbp
- renamable $dil = AND8ri renamable $dil, 1, implicit-def dead $eflags, implicit killed $edi, implicit-def $edi
- MOV8mr $rbp, 1, $noreg, -1, $noreg, renamable $dil, implicit killed $edi :: (store 1 into %ir.3)
- TEST8mi $rbp, 1, $noreg, -1, $noreg, 1, implicit-def $eflags :: (load 1 from %ir.3)
- JCC_1 %bb.2, 4, implicit killed $eflags
- JMP_1 %bb.1
-
- bb.1 (%ir-block.7, bbsections 1):
- successors: %bb.3(0x80000000)
-
- MOV32mi $rbp, 1, $noreg, -8, $noreg, 1 :: (store 4 into %ir.2)
- JMP_1 %bb.3
-
- bb.2 (%ir-block.8, bbsections 2):
- successors: %bb.3(0x80000000)
-
- MOV32mi $rbp, 1, $noreg, -8, $noreg, 0 :: (store 4 into %ir.2)
- JMP_1 %bb.3
-
- bb.3 (%ir-block.9, bbsections 3):
- renamable $eax = MOV32rm $rbp, 1, $noreg, -8, $noreg :: (load 4 from %ir.2)
- $rbp = frame-destroy POP64r implicit-def $rsp, implicit $rsp
- CFI_INSTRUCTION def_cfa $rsp, 8
- RETQ implicit $eax
-
-...
-
-# CHECK: _Z3foob:
-# CHECK: .section .text,"ax",@progbits,unique
-# CHECK: _Z3foob.1:
-# CHECK: .section .text,"ax",@progbits,unique
-# CHECK: _Z3foob.2:
-# CHECK: .section .text,"ax",@progbits,unique
-# CHECK: _Z3foob.3:
+++ /dev/null
-; Stop after bbsections-prepare and check MIR output for section type.
-; RUN: echo '!_Z3foob' > %t
-; RUN: echo '!!1' >> %t
-; RUN: echo '!!2' >> %t
-; RUN: llc < %s -O0 -mtriple=x86_64-pc-linux -function-sections -basicblock-sections=%t -stop-after=bbsections-prepare | FileCheck %s -check-prefix=CHECK
-
-@_ZTIb = external constant i8*
-define dso_local i32 @_Z3foob(i1 zeroext %0) {
- %2 = alloca i32, align 4
- %3 = alloca i8, align 1
- %4 = zext i1 %0 to i8
- store i8 %4, i8* %3, align 1
- %5 = load i8, i8* %3, align 1
- %6 = trunc i8 %5 to i1
- br i1 %6, label %7, label %8
-
-7: ; preds = %1
- store i32 1, i32* %2, align 4
- br label %9
-
-8: ; preds = %1
- store i32 0, i32* %2, align 4
- br label %9
-
-9: ; preds = %8, %7
- %10 = load i32, i32* %2, align 4
- ret i32 %10
-}
-
-; CHECK: bb.0 (%ir-block.1, bbsections Cold):
-; CHECK: bb.3 (%ir-block.9, bbsections Cold):
-; CHECK: bb.1 (%ir-block.7)
-; CHECK: bb.2 (%ir-block.8, bbsections 1):
+++ /dev/null
-; RUN: llc < %s -mtriple=x86_64-pc-linux -function-sections -basicblock-sections=all -unique-bb-section-names | FileCheck %s -check-prefix=LINUX-SECTIONS
-; RUN: llc < %s -mtriple=i386-unknown-linux-gnu -function-sections -basicblock-sections=all -unique-bb-section-names | FileCheck %s -check-prefix=LINUX-SECTIONS
-
-define void @_Z3bazb(i1 zeroext) nounwind {
- %2 = alloca i8, align 1
- %3 = zext i1 %0 to i8
- store i8 %3, i8* %2, align 1
- %4 = load i8, i8* %2, align 1
- %5 = trunc i8 %4 to i1
- br i1 %5, label %6, label %8
-
-6: ; preds = %1
- %7 = call i32 @_Z3barv()
- br label %10
-
-8: ; preds = %1
- %9 = call i32 @_Z3foov()
- br label %10
-
-10: ; preds = %8, %6
- ret void
-}
-
-declare i32 @_Z3barv() #1
-
-declare i32 @_Z3foov() #1
-
-
-; LINUX-SECTIONS: .section .text._Z3bazb,"ax",@progbits
-; LINUX-SECTIONS: _Z3bazb:
-; LINUX-SECTIONS: .section .text._Z3bazb._Z3bazb.1,"ax",@progbits
-; LINUX-SECTIONS: _Z3bazb.1:
-; LINUX-SECTIONS: .Ltmp0:
-; LINUX-SECTIONS-NEXT: .size _Z3bazb.1, .Ltmp0-_Z3bazb.1
-; LINUX-SECTIONS: .section .text._Z3bazb._Z3bazb.2,"ax",@progbits
-; LINUX-SECTIONS: _Z3bazb.2:
-; LINUX-SECTIONS: .Ltmp1:
-; LINUX-SECTIONS-NEXT: .size _Z3bazb.2, .Ltmp1-_Z3bazb.2
-; RUN: llc -O0 %s --basicblock-sections=all -mtriple=x86_64 -filetype=asm --frame-pointer=all -o - | FileCheck --check-prefix=SECTIONS_CFI %s
-; RUN: llc -O0 %s --basicblock-sections=all -mtriple=x86_64 -filetype=asm --frame-pointer=none -o - | FileCheck --check-prefix=SECTIONS_NOFP_CFI %s
-; RUN: llc -O0 %s --basicblock-sections=all -mtriple=x86_64 -filetype=obj --frame-pointer=all -o - | llvm-dwarfdump --eh-frame - | FileCheck --check-prefix=EH_FRAME %s
+; RUN: llc -O0 %s --basic-block-sections=all -mtriple=x86_64 -filetype=asm --frame-pointer=all -o - | FileCheck --check-prefix=SECTIONS_CFI %s
+; RUN: llc -O0 %s --basic-block-sections=all -mtriple=x86_64 -filetype=asm --frame-pointer=none -o - | FileCheck --check-prefix=SECTIONS_NOFP_CFI %s
+; RUN: llc -O0 %s --basic-block-sections=all -mtriple=x86_64 -filetype=obj --frame-pointer=all -o - | llvm-dwarfdump --eh-frame - | FileCheck --check-prefix=EH_FRAME %s
;; void f1();
;; void f3(bool b) {
;; This test checks if CFI instructions for all callee saved registers are emitted
;; correctly with basic block sections.
-; RUN: llc %s -mtriple=x86_64 -filetype=asm --basicblock-sections=all --frame-pointer=all -o - | FileCheck --check-prefix=SECTIONS_CFI %s
+; RUN: llc %s -mtriple=x86_64 -filetype=asm --basic-block-sections=all --frame-pointer=all -o - | FileCheck --check-prefix=SECTIONS_CFI %s
; SECTIONS_CFI: _Z3foob:
; SECTIONS_CFI: .cfi_offset %rbp, -16
--- /dev/null
+; RUN: llc -O0 %s -mtriple=x86_64-* -filetype=obj -o %t && llvm-dwarfdump -debug-info -v %t | FileCheck --check-prefix=NO-SECTIONS %s
+; RUN: llc -O0 %s --basic-block-sections=all --unique-basic-block-section-names -mtriple=x86_64-* -filetype=obj -o %t && llvm-dwarfdump -debug-info -v %t | FileCheck --check-prefix=BB-SECTIONS %s
+; RUN: llc -O0 %s --basic-block-sections=all --unique-basic-block-section-names -mtriple=x86_64-* -filetype=obj -split-dwarf-file=%t.dwo -o %t && llvm-dwarfdump -debug-info -v %t | FileCheck --check-prefix=BB-SECTIONS %s
+; RUN: llc -O0 %s --basic-block-sections=all -mtriple=x86_64-* -filetype=asm -o - | FileCheck --check-prefix=BB-SECTIONS-ASM %s
+
+; From:
+; int foo(int a) {
+; if (a > 20)
+; return 2;
+; else
+; return 0;
+; }
+
+; NO-SECTIONS: DW_AT_low_pc [DW_FORM_addr] (0x0000000000000000 ".text")
+; NO-SECTIONS: DW_AT_high_pc [DW_FORM_data4] ({{.*}})
+; BB-SECTIONS: DW_AT_low_pc [DW_FORM_addr] (0x0000000000000000)
+; BB-SECTIONS-NEXT: DW_AT_ranges [DW_FORM_sec_offset]
+; BB-SECTIONS-NEXT: [{{.*}}) ".text._Z3fooi.1"
+; BB-SECTIONS-NEXT: [{{.*}}) ".text._Z3fooi.2"
+; BB-SECTIONS-NEXT: [{{.*}}) ".text._Z3fooi.3"
+; BB-SECTIONS-NEXT: [{{.*}}) ".text"
+; BB-SECTIONS-ASM: _Z3fooi:
+; BB-SECTIONS-ASM: .Ltmp{{[0-9]+}}:
+; BB-SECTIONS-ASM-NEXT: .loc 1 2 9 prologue_end
+; BB-SECTIONS-ASM: .Ltmp{{[0-9]+}}:
+; BB-SECTIONS-ASM-NEXT: .loc 1 2 7 is_stmt
+; BB-SECTIONS-ASM: _Z3fooi.1:
+; BB-SECTIONS-ASM: .Ltmp{{[0-9]+}}:
+; BB-SECTIONS-ASM: .size _Z3fooi.1, .Ltmp{{[0-9]+}}-_Z3fooi.1
+; BB-SECTIONS-ASM: _Z3fooi.2:
+; BB-SECTIONS-ASM: .Ltmp{{[0-9]+}}:
+; BB-SECTIONS-ASM-NEXT: .Ltmp{{[0-9]+}}:
+; BB-SECTIONS-ASM: .size _Z3fooi.2, .Ltmp{{[0-9]+}}-_Z3fooi.2
+; BB-SECTIONS-ASM: _Z3fooi.3:
+; BB-SECTIONS-ASM: .Ltmp{{[0-9]+}}:
+; BB-SECTIONS-ASM-NEXT: .Ltmp{{[0-9]+}}:
+; BB-SECTIONS-ASM: .size _Z3fooi.3, .Ltmp{{[0-9]+}}-_Z3fooi.3
+; BB-SECTIONS-ASM: .Lfunc_end0:
+; BB-SECTIONS-ASM: .Ldebug_ranges0:
+; BB-SECTIONS-ASM-NEXT: .quad _Z3fooi.1
+; BB-SECTIONS-ASM-NEXT: .quad .Ltmp{{[0-9]+}}
+; BB-SECTIONS-ASM-NEXT: .quad _Z3fooi.2
+; BB-SECTIONS-ASM-NEXT: .quad .Ltmp{{[0-9]+}}
+; BB-SECTIONS-ASM-NEXT: .quad _Z3fooi.3
+; BB-SECTIONS-ASM-NEXT: .quad .Ltmp{{[0-9]+}}
+; BB-SECTIONS-ASM-NEXT: .quad .Lfunc_begin0
+; BB-SECTIONS-ASM-NEXT: .quad .Lfunc_end0
+; BB-SECTIONS-ASM-NEXT: .quad 0
+; BB-SECTIONS-ASM-NEXT: .quad 0
+
+; Function Attrs: noinline nounwind optnone uwtable
+define dso_local i32 @_Z3fooi(i32 %0) !dbg !7 {
+ %2 = alloca i32, align 4
+ %3 = alloca i32, align 4
+ store i32 %0, i32* %3, align 4
+ call void @llvm.dbg.declare(metadata i32* %3, metadata !11, metadata !DIExpression()), !dbg !12
+ %4 = load i32, i32* %3, align 4, !dbg !13
+ %5 = icmp sgt i32 %4, 20, !dbg !15
+ br i1 %5, label %6, label %7, !dbg !16
+
+6: ; preds = %1
+ store i32 2, i32* %2, align 4, !dbg !17
+ br label %8, !dbg !17
+
+7: ; preds = %1
+ store i32 0, i32* %2, align 4, !dbg !18
+ br label %8, !dbg !18
+
+8: ; preds = %7, %6
+ %9 = load i32, i32* %2, align 4, !dbg !19
+ ret i32 %9, !dbg !19
+}
+
+; Function Attrs: nounwind readnone speculatable willreturn
+declare void @llvm.dbg.declare(metadata, metadata, metadata)
+
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!3, !4}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 10.0.0 (git@github.com:google/llvm-propeller.git f9421ebf4b3d8b64678bf6c49d1607fdce3f50c5)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, nameTableKind: None)
+!1 = !DIFile(filename: "debuginfo.cc", directory: "/")
+!2 = !{}
+!3 = !{i32 2, !"Dwarf Version", i32 4}
+!4 = !{i32 2, !"Debug Info Version", i32 3}
+!7 = distinct !DISubprogram(name: "foo", linkageName: "_Z3fooi", scope: !1, file: !1, line: 1, type: !8, scopeLine: 1, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2)
+!8 = !DISubroutineType(types: !9)
+!9 = !{!10, !10}
+!10 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
+!11 = !DILocalVariable(name: "a", arg: 1, scope: !7, file: !1, line: 1, type: !10)
+!12 = !DILocation(line: 1, column: 13, scope: !7)
+!13 = !DILocation(line: 2, column: 7, scope: !14)
+!14 = distinct !DILexicalBlock(scope: !7, file: !1, line: 2, column: 7)
+!15 = !DILocation(line: 2, column: 9, scope: !14)
+!16 = !DILocation(line: 2, column: 7, scope: !7)
+!17 = !DILocation(line: 3, column: 5, scope: !14)
+!18 = !DILocation(line: 5, column: 5, scope: !14)
+!19 = !DILocation(line: 6, column: 1, scope: !7)
+++ /dev/null
-; RUN: llc -O0 %s -mtriple=x86_64-* -filetype=obj -o %t && llvm-dwarfdump -debug-info -v %t | FileCheck --check-prefix=NO-SECTIONS %s
-; RUN: llc -O0 %s --basicblock-sections=all --unique-bb-section-names -mtriple=x86_64-* -filetype=obj -o %t && llvm-dwarfdump -debug-info -v %t | FileCheck --check-prefix=BB-SECTIONS %s
-; RUN: llc -O0 %s --basicblock-sections=all --unique-bb-section-names -mtriple=x86_64-* -filetype=obj -split-dwarf-file=%t.dwo -o %t && llvm-dwarfdump -debug-info -v %t | FileCheck --check-prefix=BB-SECTIONS %s
-; RUN: llc -O0 %s --basicblock-sections=all -mtriple=x86_64-* -filetype=asm -o - | FileCheck --check-prefix=BB-SECTIONS-ASM %s
-
-; From:
-; int foo(int a) {
-; if (a > 20)
-; return 2;
-; else
-; return 0;
-; }
-
-; NO-SECTIONS: DW_AT_low_pc [DW_FORM_addr] (0x0000000000000000 ".text")
-; NO-SECTIONS: DW_AT_high_pc [DW_FORM_data4] ({{.*}})
-; BB-SECTIONS: DW_AT_low_pc [DW_FORM_addr] (0x0000000000000000)
-; BB-SECTIONS-NEXT: DW_AT_ranges [DW_FORM_sec_offset]
-; BB-SECTIONS-NEXT: [{{.*}}) ".text._Z3fooi.1"
-; BB-SECTIONS-NEXT: [{{.*}}) ".text._Z3fooi.2"
-; BB-SECTIONS-NEXT: [{{.*}}) ".text._Z3fooi.3"
-; BB-SECTIONS-NEXT: [{{.*}}) ".text"
-; BB-SECTIONS-ASM: _Z3fooi:
-; BB-SECTIONS-ASM: .Ltmp{{[0-9]+}}:
-; BB-SECTIONS-ASM-NEXT: .loc 1 2 9 prologue_end
-; BB-SECTIONS-ASM: .Ltmp{{[0-9]+}}:
-; BB-SECTIONS-ASM-NEXT: .loc 1 2 7 is_stmt
-; BB-SECTIONS-ASM: _Z3fooi.1:
-; BB-SECTIONS-ASM: .Ltmp{{[0-9]+}}:
-; BB-SECTIONS-ASM: .size _Z3fooi.1, .Ltmp{{[0-9]+}}-_Z3fooi.1
-; BB-SECTIONS-ASM: _Z3fooi.2:
-; BB-SECTIONS-ASM: .Ltmp{{[0-9]+}}:
-; BB-SECTIONS-ASM-NEXT: .Ltmp{{[0-9]+}}:
-; BB-SECTIONS-ASM: .size _Z3fooi.2, .Ltmp{{[0-9]+}}-_Z3fooi.2
-; BB-SECTIONS-ASM: _Z3fooi.3:
-; BB-SECTIONS-ASM: .Ltmp{{[0-9]+}}:
-; BB-SECTIONS-ASM-NEXT: .Ltmp{{[0-9]+}}:
-; BB-SECTIONS-ASM: .size _Z3fooi.3, .Ltmp{{[0-9]+}}-_Z3fooi.3
-; BB-SECTIONS-ASM: .Lfunc_end0:
-; BB-SECTIONS-ASM: .Ldebug_ranges0:
-; BB-SECTIONS-ASM-NEXT: .quad _Z3fooi.1
-; BB-SECTIONS-ASM-NEXT: .quad .Ltmp{{[0-9]+}}
-; BB-SECTIONS-ASM-NEXT: .quad _Z3fooi.2
-; BB-SECTIONS-ASM-NEXT: .quad .Ltmp{{[0-9]+}}
-; BB-SECTIONS-ASM-NEXT: .quad _Z3fooi.3
-; BB-SECTIONS-ASM-NEXT: .quad .Ltmp{{[0-9]+}}
-; BB-SECTIONS-ASM-NEXT: .quad .Lfunc_begin0
-; BB-SECTIONS-ASM-NEXT: .quad .Lfunc_end0
-; BB-SECTIONS-ASM-NEXT: .quad 0
-; BB-SECTIONS-ASM-NEXT: .quad 0
-
-; Function Attrs: noinline nounwind optnone uwtable
-define dso_local i32 @_Z3fooi(i32 %0) !dbg !7 {
- %2 = alloca i32, align 4
- %3 = alloca i32, align 4
- store i32 %0, i32* %3, align 4
- call void @llvm.dbg.declare(metadata i32* %3, metadata !11, metadata !DIExpression()), !dbg !12
- %4 = load i32, i32* %3, align 4, !dbg !13
- %5 = icmp sgt i32 %4, 20, !dbg !15
- br i1 %5, label %6, label %7, !dbg !16
-
-6: ; preds = %1
- store i32 2, i32* %2, align 4, !dbg !17
- br label %8, !dbg !17
-
-7: ; preds = %1
- store i32 0, i32* %2, align 4, !dbg !18
- br label %8, !dbg !18
-
-8: ; preds = %7, %6
- %9 = load i32, i32* %2, align 4, !dbg !19
- ret i32 %9, !dbg !19
-}
-
-; Function Attrs: nounwind readnone speculatable willreturn
-declare void @llvm.dbg.declare(metadata, metadata, metadata)
-
-!llvm.dbg.cu = !{!0}
-!llvm.module.flags = !{!3, !4}
-
-!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 10.0.0 (git@github.com:google/llvm-propeller.git f9421ebf4b3d8b64678bf6c49d1607fdce3f50c5)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, nameTableKind: None)
-!1 = !DIFile(filename: "debuginfo.cc", directory: "/")
-!2 = !{}
-!3 = !{i32 2, !"Dwarf Version", i32 4}
-!4 = !{i32 2, !"Debug Info Version", i32 3}
-!7 = distinct !DISubprogram(name: "foo", linkageName: "_Z3fooi", scope: !1, file: !1, line: 1, type: !8, scopeLine: 1, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2)
-!8 = !DISubroutineType(types: !9)
-!9 = !{!10, !10}
-!10 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
-!11 = !DILocalVariable(name: "a", arg: 1, scope: !7, file: !1, line: 1, type: !10)
-!12 = !DILocation(line: 1, column: 13, scope: !7)
-!13 = !DILocation(line: 2, column: 7, scope: !14)
-!14 = distinct !DILexicalBlock(scope: !7, file: !1, line: 2, column: 7)
-!15 = !DILocation(line: 2, column: 9, scope: !14)
-!16 = !DILocation(line: 2, column: 7, scope: !7)
-!17 = !DILocation(line: 3, column: 5, scope: !14)
-!18 = !DILocation(line: 5, column: 5, scope: !14)
-!19 = !DILocation(line: 6, column: 1, scope: !7)