Files
clang-p2996/llvm/test/Instrumentation/AddressSanitizer/module-flags.ll
Fangrui Song 2786e673c7 [IR][sanitizer] Add module flag "frame-pointer" and set it for cc1 -mframe-pointer={non-leaf,all}
The Linux kernel objtool diagnostic `call without frame pointer save/setup`
arise in multiple instrumentation passes (asan/tsan/gcov). With the mechanism
introduced in D100251, it's trivial to respect the command line
-m[no-]omit-leaf-frame-pointer/-f[no-]omit-frame-pointer, so let's do it.

Fix: https://github.com/ClangBuiltLinux/linux/issues/1236 (tsan)
Fix: https://github.com/ClangBuiltLinux/linux/issues/1238 (asan)

Also document the function attribute "frame-pointer" which is long overdue.

Differential Revision: https://reviews.llvm.org/D101016
2021-04-22 18:07:30 -07:00

25 lines
668 B
LLVM

; RUN: opt < %s -passes='asan-pipeline' -S | FileCheck %s
target triple = "x86_64-unknown-linux-gnu"
@g = dso_local global i32 0, align 4
define i32 @test_load() sanitize_address {
entry:
%tmp = load i32, i32* @g, align 4
ret i32 %tmp
}
!llvm.module.flags = !{!0, !1}
;; Due to -fasynchronous-unwind-tables.
!0 = !{i32 7, !"uwtable", i32 1}
;; Due to -fno-omit-frame-pointer.
!1 = !{i32 7, !"frame-pointer", i32 2}
;; Set the uwtable attribute on ctor/dtor.
; CHECK: define internal void @asan.module_ctor() #[[#ATTR:]]
; CHECK: define internal void @asan.module_dtor() #[[#ATTR]]
; CHECK: attributes #[[#ATTR]] = { nounwind uwtable "frame-pointer"="all" }