-
Notifications
You must be signed in to change notification settings - Fork 14k
[ARM,AArch64] Don't put BTI at asm goto branch targets #141562
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -121,14 +121,21 @@ bool IsValidCloning(const MachineFunction &MF, | |
} | ||
if (PathBB->isMachineBlockAddressTaken()) { | ||
// Avoid cloning blocks which have their address taken since we can't | ||
// rewire branches to those blocks as easily (e.g., branches within | ||
// inline assembly). | ||
// rewire branches to those blocks as easily. | ||
WithColor::warning() | ||
<< "block #" << BBID | ||
<< " has its machine block address taken in function " | ||
<< MF.getName() << "\n"; | ||
return false; | ||
} | ||
if (PathBB->isInlineAsmBrIndirectTarget()) { | ||
// Similarly for branches to the block within an asm goto. | ||
WithColor::warning() | ||
<< "block #" << BBID | ||
<< " is a branch target of an 'asm goto' in function " | ||
<< MF.getName() << "\n"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This won't handle anonymous functions correctly, in this context probably should use the mangled name There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That was surely true already of the "has its machine block address taken" clause just above, which I duplicated to make this version with the changed wording? Are you asking me to do that unrelated fix as part of this same commit? It seems to me that if it needs fixing at all it should be done separately. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The previous warning was broken, and this one is too. We probably should remove or rename getName, it's usually not appropriate to use outside of debugger contexts. Can fix separately |
||
return false; | ||
} | ||
} | ||
|
||
if (I != ClonePath.size() - 1 && !PathBB->empty() && | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
; RUN: llc < %s -mtriple=aarch64-linux-gnu | FileCheck %s | ||
|
||
; Test function which compares two integers and returns the value of | ||
; the overflow flag, by using an asm goto to make the asm block branch | ||
; based on that flag, and then a phi to set the return value based on | ||
; whether the branch was taken. | ||
define i32 @overflow(i64 %a, i64 %b) #0 { | ||
asm: | ||
callbr void asm sideeffect "cmp $0, $1 \0A\09 b.vs ${2:l}", | ||
"r,r,!i,~{cc}"(i64 %a, i64 %b) | ||
to label %fallthrough [label %indirect] | ||
|
||
indirect: | ||
br label %fallthrough | ||
|
||
fallthrough: | ||
; Return 1 if we came via the 'indirect' block (because the b.vs was | ||
; taken), and 0 if we came straight from the asm block (because it | ||
; was untaken). | ||
%retval = phi i32 [0, %asm], [1, %indirect] | ||
ret i32 %retval | ||
} | ||
|
||
; CHECK: overflow: | ||
; CHECK-NEXT: .cfi_startproc | ||
; CHECK-NEXT: // %bb.{{[0-9]+}}: | ||
; CHECK-NEXT: bti c | ||
; CHECK-NEXT: //APP | ||
; CHECK-NEXT: cmp x0, x1 | ||
; CHECK-NEXT: b.vs [[LABEL:\.[A-Za-z0-9_]+]] | ||
; CHECK-NEXT: //NO_APP | ||
; CHECK-NEXT: // %bb.{{[0-9]+}}: | ||
; CHECK-NEXT: mov w0, wzr | ||
; CHECK-NEXT: ret | ||
; CHECK-NEXT: [[LABEL]]: | ||
; CHECK-NOT: bti | ||
; CHECK: mov w0, #1 | ||
; CHECK-NEXT: ret | ||
|
||
attributes #0 = { "branch-target-enforcement" "target-features"="+bti" } |
Uh oh!
There was an error while loading. Please reload this page.