-
Notifications
You must be signed in to change notification settings - Fork 10.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[BOLT][AArch64] Fix instrumentation deadloop
According to ARMv8-a architecture reference manual B2.10.5 software must avoid having any explicit memory accesses between exclusive load and associated store instruction. Otherwise exclusive monitor might clear the exclusivity without application-related cause which may result in the deadloop. Disable instrumentation for such functions, since between exclusive load and store there might be branches and we would insert instrumentation snippet which contains loads and stores. The better solution would be to analyze with BFS finding the exact BBs between load and store and not instrumenting them. Or even better to recognize such sequences and replace them with more complex one, e.g. loading value non exclusively, and for the brach where exclusive store is made make exclusive load and store sequentially, but for now just disable instrumentation for such functions completely. Differential Revision: https://reviews.llvm.org/D159520
- Loading branch information
Showing
4 changed files
with
94 additions
and
0 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
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
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
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,39 @@ | ||
// This test checks that the foo function having exclusive memory access | ||
// instructions won't be instrumented. | ||
|
||
// REQUIRES: system-linux,bolt-runtime,target=aarch64{{.*}} | ||
|
||
// RUN: llvm-mc -filetype=obj -triple aarch64-unknown-unknown \ | ||
// RUN: %s -o %t.o | ||
// RUN: %clang %cflags -fPIC -pie %t.o -o %t.exe -nostdlib -Wl,-q -Wl,-fini=dummy | ||
// RUN: llvm-bolt %t.exe -o %t.bolt -instrument -v=1 | FileCheck %s | ||
|
||
// CHECK: Function foo has exclusive instructions, skip instrumentation | ||
|
||
.global foo | ||
.type foo, %function | ||
foo: | ||
ldaxr w9, [x10] | ||
cbnz w9, .Lret | ||
stlxr w12, w11, [x9] | ||
cbz w12, foo | ||
clrex | ||
.Lret: | ||
ret | ||
.size foo, .-foo | ||
|
||
.global _start | ||
.type _start, %function | ||
_start: | ||
cmp x0, #0 | ||
b.eq .Lexit | ||
bl foo | ||
.Lexit: | ||
ret | ||
.size _start, .-_start | ||
|
||
.global dummy | ||
.type dummy, %function | ||
dummy: | ||
ret | ||
.size dummy, .-dummy |