File: hwasan-zero-ptr.ll

package info (click to toggle)
llvm-toolchain-20 1%3A20.1.6-1~exp1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 2,111,304 kB
  • sloc: cpp: 7,438,677; ansic: 1,393,822; asm: 1,012,926; python: 241,650; f90: 86,635; objc: 75,479; lisp: 42,144; pascal: 17,286; sh: 10,027; ml: 5,082; perl: 4,730; awk: 3,523; makefile: 3,349; javascript: 2,251; xml: 892; fortran: 672
file content (67 lines) | stat: -rw-r--r-- 2,686 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5
; RUN: llc -filetype asm -o - %s | FileCheck %s

; This shows that CodeGen for AArch64 will elide the tag check when lowering
; the HWASan memaccess intrinsic for null pointers.
;
; N.B. The HWASan pass will normally omit the memaccess intrinsic if the
;      pointer is already statically known to be null.
;
; The source was generated from llvm/test/Instrumentation/HWAddressSanitizer/zero-ptr.ll
; with the memaccess deliberately retained.

; ModuleID = '<stdin>'
source_filename = "<stdin>"
target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
target triple = "aarch64--linux-android10000"

$hwasan.module_ctor = comdat any

@__start_hwasan_globals = external hidden constant [0 x i8]
@__stop_hwasan_globals = external hidden constant [0 x i8]
@hwasan.note = private constant { i32, i32, i32, [8 x i8], i32, i32 } { i32 8, i32 8, i32 3, [8 x i8] c"LLVM\00\00\00\00", i32 trunc (i64 sub (i64 ptrtoint (ptr @__start_hwasan_globals to i64), i64 ptrtoint (ptr @hwasan.note to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint (ptr @__stop_hwasan_globals to i64), i64 ptrtoint (ptr @hwasan.note to i64)) to i32) }, section ".note.hwasan.globals", comdat($hwasan.module_ctor), align 4

; Function Attrs: sanitize_hwaddress
define void @test_store_to_zeroptr() #0 {
; CHECK-LABEL: test_store_to_zeroptr:
; CHECK:       // %bb.0: // %entry
; CHECK-NEXT:    str x30, [sp, #-16]! // 8-byte Folded Spill
; CHECK-NEXT:    .cfi_def_cfa_offset 16
; CHECK-NEXT:    .cfi_offset w30, -16
; CHECK-NEXT:    mov x8, xzr
; CHECK-NEXT:    mov w9, #42 // =0x2a
; CHECK-NEXT:    str x9, [x8]
; CHECK-NEXT:    ldr x30, [sp], #16 // 8-byte Folded Reload
; CHECK-NEXT:    ret
entry:
  %.hwasan.shadow = call ptr asm "", "=r,0"(ptr null)
  %b = inttoptr i64 0 to ptr
  call void @llvm.hwasan.check.memaccess.shortgranules.fixedshadow(ptr %b, i32 19, i64 0)
  store i64 42, ptr %b, align 8
  ret void
}

; Function Attrs: nounwind
declare void @llvm.hwasan.check.memaccess.shortgranules.fixedshadow(ptr, i32 immarg, i64 immarg) #1

attributes #0 = { sanitize_hwaddress }
attributes #1 = { nounwind }

declare void @__hwasan_init()

; Function Attrs: nounwind
define internal void @hwasan.module_ctor() #1 comdat {
; CHECK-LABEL: hwasan.module_ctor:
; CHECK:       // %bb.0:
; CHECK-NEXT:    str x30, [sp, #-16]! // 8-byte Folded Spill
; CHECK-NEXT:    bl __hwasan_init
; CHECK-NEXT:    ldr x30, [sp], #16 // 8-byte Folded Reload
; CHECK-NEXT:    ret
  call void @__hwasan_init()
  ret void
}

!llvm.module.flags = !{!1}

!0 = !{ptr @hwasan.note}
!1 = !{i32 4, !"nosanitize_hwaddress", i32 1}