Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BOLT] assertion failure: "fragment of non-simple function should also be non-simple" #112837

Open
linsinan1995 opened this issue Oct 18, 2024 · 2 comments
Labels

Comments

@linsinan1995
Copy link
Member

Many checks in BOLT only update the parent functions to non-simple, leaving their fragment status unchanged. This might trigger an assertion failure: "fragment of non-simple function should also be non-simple" in BinaryFunction::getOutputAddressRanges.

@llvmbot
Copy link
Collaborator

llvmbot commented Oct 18, 2024

@llvm/issue-subscribers-bolt

Author: sinan (linsinan1995)

Many checks in BOLT only update the parent functions to non-simple, leaving their fragment status unchanged. This might trigger an assertion failure: "fragment of non-simple function should also be non-simple" in BinaryFunction::getOutputAddressRanges.

@linsinan1995
Copy link
Member Author

We could remove this assertion(since it looks like it is being allowed if there are no indirect branches to fragments) or add all non-simple BF with fragments to addFragmentsToSkip.

Here is a reduced case for this assertion fail (example_function fails on postProcessIndirectBranches but its fragment is still simple):

# REQUIRES: system-linux

# RUN: llvm-mc -filetype=obj -triple x86_64-unknown-linux %s -o %t.o
# RUN: %clang %cflags %t.o -Wl,-q -o %t.exe
# RUN: llvm-bolt %t.exe -o %t.bolt.exe --update-debug-sections -v=1

	.text
.Ltext0:
	.globl	example_function
	.type	example_function, @function
example_function:
.LFB0:
	.file 1 "test.c"
	.loc 1 4 0
	.loc 1 5 0
	testl	%edi, %edi
	jne	.L3
	movq	0x10(%rdi), %rax
	jmpq	*%rax
	ret
.size	example_function, .-example_function
.Letext0:

	.section	.text.unlikely,"ax",@progbits
.Ltext_cold0:
	.type	example_function.cold, @function
example_function.cold:
.L3:
	.loc 1 8 0
	xorl	%eax, %eax
	jmp	example_function
.LFE0:
	.size	example_function.cold, .-example_function.cold
.Letext_cold0:

	.section	.debug_info,"",@progbits
.Ldebug_info0:
	.long	0x33
	.value	0x4
	.long	.Ldebug_abbrev0
	.byte	0x8
	.uleb128 0x1
	.long	.LASF0
	.byte	0xc
	.long	.LASF1
	.long	.LASF2
	.long	.Ldebug_ranges0+0x30
	.quad	0
	.long	.Ldebug_line0
	.uleb128 0x2
	.long	.LASF3
	.byte	0x1
	.byte	0x4
	.long	.Ldebug_ranges0+0
	.uleb128 0x1
	.byte	0x9c
	.byte	0
	.section	.debug_abbrev,"",@progbits
.Ldebug_abbrev0:
	.uleb128 0x1
	.uleb128 0x11
	.byte	0x1
	.uleb128 0x25
	.uleb128 0xe
	.uleb128 0x13
	.uleb128 0xb
	.uleb128 0x3
	.uleb128 0xe
	.uleb128 0x1b
	.uleb128 0xe
	.uleb128 0x55
	.uleb128 0x17
	.uleb128 0x11
	.uleb128 0x1
	.uleb128 0x10
	.uleb128 0x17
	.byte	0
	.byte	0
	.uleb128 0x2
	.uleb128 0x2e
	.byte	0
	.uleb128 0x3f
	.uleb128 0x19
	.uleb128 0x3
	.uleb128 0xe
	.uleb128 0x3a
	.uleb128 0xb
	.uleb128 0x3b
	.uleb128 0xb
	.uleb128 0x55
	.uleb128 0x17
	.uleb128 0x40
	.uleb128 0x18
	.byte	0
	.byte	0
	.byte	0
	.section	.debug_aranges,"",@progbits
	.long	0x3c
	.value	0x2
	.long	.Ldebug_info0
	.byte	0x8
	.byte	0
	.value	0
	.value	0
	.quad	.Ltext0
	.quad	.Letext0-.Ltext0
	.quad	.Ltext_cold0
	.quad	.Letext_cold0-.Ltext_cold0
	.quad	0
	.quad	0
	.section	.debug_ranges,"",@progbits
.Ldebug_ranges0:
	.quad	.LFB0
	.quad	.Letext0
	.quad	.L3
	.quad	.Letext_cold0
	.quad	0
	.quad	0
	.quad	.Ltext0
	.quad	.Letext0
	.quad	.Ltext_cold0
	.quad	.Letext_cold0
	.quad	0
	.quad	0
	.section	.debug_line,"",@progbits
.Ldebug_line0:
	.section	.debug_str,"MS",@progbits,1
.LASF0:
	.string	"GNU C17 9.2.1"
.LASF2:
	.string	"/dir"
.LASF1:
	.string	"test.c"
.LASF3:
	.string	"example_function"
	.ident	"GCC: (GNU) 9.2.1"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants