1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-26 04:32:44 +01:00
llvm-mirror/test/CodeGen/AArch64/read-pc.ll
Peter Collingbourne a8cf55d334 AArch64: Add support for reading pc using llvm.read_register.
This is useful for allowing code to efficiently take an address
that can be later mapped onto debug info. Currently the hwasan
pass achieves this by taking the address of the current function:
http://llvm-cs.pcc.me.uk/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp#921

but this costs two instructions (plus a GOT entry in PIC code) per function
with stack variables. This will allow the cost to be reduced to a single
instruction.

Differential Revision: https://reviews.llvm.org/D63471

llvm-svn: 364126
2019-06-22 03:03:25 +00:00

12 lines
244 B
LLVM

; RUN: llc < %s -mtriple=arm64-linux-gnu | FileCheck %s
define i64 @read_pc() {
; CHECK: adr x0, #0
%pc = call i64 @llvm.read_register.i64(metadata !0)
ret i64 %pc
}
declare i64 @llvm.read_register.i64(metadata) nounwind
!0 = !{!"pc"}