[hwasan] add stack frame descriptions.
Summary:
At compile-time, create an array of {PC,HumanReadableStackFrameDescription}
for every function that has an instrumented frame, and pass this array
to the run-time at the module-init time.
Similar to how we handle pc-table in SanitizerCoverage.
The run-time is dummy, will add the actual logic in later commits.
Reviewers: morehouse, eugenis
Reviewed By: eugenis
Subscribers: srhines, llvm-commits, kubamracek
Differential Revision: https://reviews.llvm.org/D53227
llvm-svn: 344985
diff --git a/llvm/test/Instrumentation/HWAddressSanitizer/basic.ll b/llvm/test/Instrumentation/HWAddressSanitizer/basic.ll
index e801099..8253016 100644
--- a/llvm/test/Instrumentation/HWAddressSanitizer/basic.ll
+++ b/llvm/test/Instrumentation/HWAddressSanitizer/basic.ll
@@ -354,5 +354,6 @@
; CHECK: define internal void @hwasan.module_ctor() {
; CHECK-NEXT: call void @__hwasan_init()
+; CHECK-NEXT: call void @__hwasan_init_frames(
; CHECK-NEXT: ret void
; CHECK-NEXT: }
diff --git a/llvm/test/Instrumentation/HWAddressSanitizer/frame-descriptor.ll b/llvm/test/Instrumentation/HWAddressSanitizer/frame-descriptor.ll
new file mode 100644
index 0000000..3fd4197
--- /dev/null
+++ b/llvm/test/Instrumentation/HWAddressSanitizer/frame-descriptor.ll
@@ -0,0 +1,27 @@
+; Test frame descriptors
+;
+; RUN: opt < %s -hwasan -S | FileCheck %s
+
+target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
+target triple = "aarch64--linux-android"
+
+declare void @use32(i32*, i64*)
+
+define void @test_alloca() sanitize_hwaddress {
+entry:
+ %XYZ = alloca i32, align 4
+ %ABC = alloca i64, align 4
+ call void @use32(i32* nonnull %XYZ, i64 *nonnull %ABC)
+ ret void
+}
+
+; CHECK: @[[STR:[0-9]*]] = private unnamed_addr constant [15 x i8] c"4 XYZ; 8 ABC; \00", align 1
+; CHECK: private constant { void ()*, [15 x i8]* } { void ()* @test_alloca, [15 x i8]* @[[STR]] }, section "__hwasan_frames", comdat($test_alloca)
+
+; CHECK-LABEL: @test_alloca(
+; CHECK: ret void
+
+; CHECK-LABEL: @hwasan.module_ctor
+; CHECK: call void @__hwasan_init_frames(i8* @__start___hwasan_frames, i8* @__stop___hwasan_frames)
+; CHECK: ret void
+
diff --git a/llvm/test/Instrumentation/HWAddressSanitizer/with-calls.ll b/llvm/test/Instrumentation/HWAddressSanitizer/with-calls.ll
index 768434c..8d6068c 100644
--- a/llvm/test/Instrumentation/HWAddressSanitizer/with-calls.ll
+++ b/llvm/test/Instrumentation/HWAddressSanitizer/with-calls.ll
@@ -199,5 +199,6 @@
; CHECK: define internal void @hwasan.module_ctor() {
; CHECK-NEXT: call void @__hwasan_init()
+; CHECK-NEXT: call void @__hwasan_init_frames(
; CHECK-NEXT: ret void
; CHECK-NEXT: }