Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[BasicBlockSections] Make sure that the labels for address-taken bloc…
…ks are emitted after switching the seciton. Currently, AsmPrinter code is organized in a way in which the labels of address-taken blocks are emitted in the previous section, which makes the relocation incorrect. This patch reorganizes the code to switch to the basic block section before handling address-taken blocks. Reviewed By: snehasish, MaskRay Differential Revision: https://reviews.llvm.org/D88517
- Loading branch information
Showing
2 changed files
with
55 additions
and
16 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
35 changes: 35 additions & 0 deletions
35
llvm/test/CodeGen/X86/basic-block-sections-blockaddress-taken.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,35 @@ | ||
;; This test verifies that basic-block-sections works with address-taken basic blocks. | ||
; RUN: llc < %s -mtriple=x86_64 -basic-block-sections=all | FileCheck %s | ||
|
||
define void @foo(i1 zeroext %0) nounwind { | ||
entry: | ||
%1 = select i1 %0, i8* blockaddress(@foo, %bb1), i8* blockaddress(@foo, %bb2) ; <i8*> [#uses=1] | ||
indirectbr i8* %1, [label %bb1, label %bb2] | ||
|
||
; CHECK: .text | ||
; CHECK-LABEL: foo: | ||
; CHECK: movl $.Ltmp0, %eax | ||
; CHECK-NEXT: movl $.Ltmp1, %ecx | ||
; CHECK-NEXT: cmovneq %rax, %rcx | ||
; CHECK-NEXT: jmpq *%rcx | ||
|
||
bb1: ; preds = %entry | ||
%2 = call i32 @bar() | ||
ret void | ||
; CHECK: .section .text,"ax",@progbits,unique,1 | ||
; CHECK-NEXT: .Ltmp0: | ||
; CHECK-NEXT: foo.1 | ||
; CHECK-NEXT: callq bar | ||
; | ||
|
||
bb2: ; preds = %entry | ||
%3 = call i32 @baz() | ||
ret void | ||
; CHECK: .section .text,"ax",@progbits,unique,2 | ||
; CHECK-NEXT: .Ltmp1: | ||
; CHECK-NEXT: foo.2 | ||
; CHECK-NEXT: callq baz | ||
} | ||
|
||
declare i32 @bar() | ||
declare i32 @baz() |