HWASan fixes for ART tests (part 2)

Ensure the attribute is not dropped by the compiler for inlined methods.

(cherry picked from commit a8106bc4d8c12a4877cbab64d1dd0c1619b6ad50)

Bug: 156593692
Test: SANITIZE_TARGET=hwaddress art/tools/run-gtests.sh
Change-Id: I6a946050db1fdecb2150384dcd8d3c8bff27ef7f
Merged-In: I6a946050db1fdecb2150384dcd8d3c8bff27ef7f
diff --git a/libartbase/base/memory_tool.h b/libartbase/base/memory_tool.h
index 5ed9cda..eba1d73 100644
--- a/libartbase/base/memory_tool.h
+++ b/libartbase/base/memory_tool.h
@@ -68,7 +68,9 @@
 
 #if __has_feature(hwaddress_sanitizer)
 # define HWADDRESS_SANITIZER
-# define ATTRIBUTE_NO_SANITIZE_HWADDRESS __attribute__((no_sanitize("hwaddress")))
+// NB: The attribute also implies NO_INLINE. If inlined, the hwasan attribute would be lost.
+//     If method is also separately marked as ALWAYS_INLINE, the NO_INLINE takes precedence.
+# define ATTRIBUTE_NO_SANITIZE_HWADDRESS __attribute__((no_sanitize("hwaddress"), noinline))
 #else
 # define ATTRIBUTE_NO_SANITIZE_HWADDRESS
 #endif