[Lldb-commits] [PATCH] D104176: [libunwind] Define and use portable macro for checking for presence of ASAN

2021-06-13 Thread Daniel Levin via Phabricator via lldb-commits
daniel-levin updated this revision to Diff 351709.

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D104176/new/

https://reviews.llvm.org/D104176

Files:
  libunwind/src/libunwind.cpp


Index: libunwind/src/libunwind.cpp
===
--- libunwind/src/libunwind.cpp
+++ libunwind/src/libunwind.cpp
@@ -16,15 +16,13 @@
 
 #include 
 
-#if defined(__has_feature)
-#define has_asan_portable __has_feature(address_sanitizer)
-#elif defined(__SANITIZE_ADDRESS__)
-#define has_asan_portable __SANITIZE_ADDRESS__
-#else
-#define has_asan_portable 0
+// Define the __has_feature extension for compilers that do not support it so 
that
+// we can later check for the presence of ASan in a compiler-neutral way.
+#if !defined(__has_feature)
+#define __has_feature(feature) 0
 #endif
 
-#if has_asan_portable
+#if __has__feature(address_sanitizer) || defined(__SANITIZE_ADDRESS__)
 #include 
 #endif
 
@@ -195,7 +193,7 @@
 /// Resume execution at cursor position (aka longjump).
 _LIBUNWIND_HIDDEN int __unw_resume(unw_cursor_t *cursor) {
   _LIBUNWIND_TRACE_API("__unw_resume(cursor=%p)", static_cast(cursor));
-#if has_asan_portable
+#if __has__feature(address_sanitizer) || defined(__SANITIZE_ADDRESS__)
   // Inform the ASan runtime that now might be a good time to clean stuff up.
   __asan_handle_no_return();
 #endif


Index: libunwind/src/libunwind.cpp
===
--- libunwind/src/libunwind.cpp
+++ libunwind/src/libunwind.cpp
@@ -16,15 +16,13 @@
 
 #include 
 
-#if defined(__has_feature)
-#define has_asan_portable __has_feature(address_sanitizer)
-#elif defined(__SANITIZE_ADDRESS__)
-#define has_asan_portable __SANITIZE_ADDRESS__
-#else
-#define has_asan_portable 0
+// Define the __has_feature extension for compilers that do not support it so that
+// we can later check for the presence of ASan in a compiler-neutral way.
+#if !defined(__has_feature)
+#define __has_feature(feature) 0
 #endif
 
-#if has_asan_portable
+#if __has__feature(address_sanitizer) || defined(__SANITIZE_ADDRESS__)
 #include 
 #endif
 
@@ -195,7 +193,7 @@
 /// Resume execution at cursor position (aka longjump).
 _LIBUNWIND_HIDDEN int __unw_resume(unw_cursor_t *cursor) {
   _LIBUNWIND_TRACE_API("__unw_resume(cursor=%p)", static_cast(cursor));
-#if has_asan_portable
+#if __has__feature(address_sanitizer) || defined(__SANITIZE_ADDRESS__)
   // Inform the ASan runtime that now might be a good time to clean stuff up.
   __asan_handle_no_return();
 #endif
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D104176: [libunwind] Define and use portable macro for checking for presence of ASAN

2021-06-13 Thread Daniel Levin via Phabricator via lldb-commits
daniel-levin updated this revision to Diff 351710.
daniel-levin added a comment.

Responded to comments from Saleem. Apologies for the noise in getting the diff 
correct. I had not used arc before.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D104176/new/

https://reviews.llvm.org/D104176

Files:
  libunwind/src/libunwind.cpp


Index: libunwind/src/libunwind.cpp
===
--- libunwind/src/libunwind.cpp
+++ libunwind/src/libunwind.cpp
@@ -16,7 +16,13 @@
 
 #include 
 
-#if __has_feature(address_sanitizer)
+// Define the __has_feature extension for compilers that do not support it so 
that
+// we can later check for the presence of ASan in a compiler-neutral way.
+#if !defined(__has_feature)
+#define __has_feature(feature) 0
+#endif
+
+#if __has__feature(address_sanitizer) || defined(__SANITIZE_ADDRESS__)
 #include 
 #endif
 


Index: libunwind/src/libunwind.cpp
===
--- libunwind/src/libunwind.cpp
+++ libunwind/src/libunwind.cpp
@@ -16,7 +16,13 @@
 
 #include 
 
-#if __has_feature(address_sanitizer)
+// Define the __has_feature extension for compilers that do not support it so that
+// we can later check for the presence of ASan in a compiler-neutral way.
+#if !defined(__has_feature)
+#define __has_feature(feature) 0
+#endif
+
+#if __has__feature(address_sanitizer) || defined(__SANITIZE_ADDRESS__)
 #include 
 #endif
 
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D104176: [libunwind] Define and use portable macro for checking for presence of ASAN

2021-06-13 Thread Daniel Levin via Phabricator via lldb-commits
daniel-levin updated this revision to Diff 351711.

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D104176/new/

https://reviews.llvm.org/D104176

Files:
  libunwind/src/libunwind.cpp


Index: libunwind/src/libunwind.cpp
===
--- libunwind/src/libunwind.cpp
+++ libunwind/src/libunwind.cpp
@@ -16,7 +16,13 @@
 
 #include 
 
-#if __has_feature(address_sanitizer)
+// Define the __has_feature extension for compilers that do not support it so 
that
+// we can later check for the presence of ASan in a compiler-neutral way.
+#if !defined(__has_feature)
+#define __has_feature(feature) 0
+#endif
+
+#if __has__feature(address_sanitizer) || defined(__SANITIZE_ADDRESS__)
 #include 
 #endif
 
@@ -187,7 +193,7 @@
 /// Resume execution at cursor position (aka longjump).
 _LIBUNWIND_HIDDEN int __unw_resume(unw_cursor_t *cursor) {
   _LIBUNWIND_TRACE_API("__unw_resume(cursor=%p)", static_cast(cursor));
-#if __has_feature(address_sanitizer)
+#if __has__feature(address_sanitizer) || defined(__SANITIZE_ADDRESS__)
   // Inform the ASan runtime that now might be a good time to clean stuff up.
   __asan_handle_no_return();
 #endif


Index: libunwind/src/libunwind.cpp
===
--- libunwind/src/libunwind.cpp
+++ libunwind/src/libunwind.cpp
@@ -16,7 +16,13 @@
 
 #include 
 
-#if __has_feature(address_sanitizer)
+// Define the __has_feature extension for compilers that do not support it so that
+// we can later check for the presence of ASan in a compiler-neutral way.
+#if !defined(__has_feature)
+#define __has_feature(feature) 0
+#endif
+
+#if __has__feature(address_sanitizer) || defined(__SANITIZE_ADDRESS__)
 #include 
 #endif
 
@@ -187,7 +193,7 @@
 /// Resume execution at cursor position (aka longjump).
 _LIBUNWIND_HIDDEN int __unw_resume(unw_cursor_t *cursor) {
   _LIBUNWIND_TRACE_API("__unw_resume(cursor=%p)", static_cast(cursor));
-#if __has_feature(address_sanitizer)
+#if __has__feature(address_sanitizer) || defined(__SANITIZE_ADDRESS__)
   // Inform the ASan runtime that now might be a good time to clean stuff up.
   __asan_handle_no_return();
 #endif
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D104176: [libunwind] Define and use portable macro for checking for presence of ASAN

2021-06-13 Thread Daniel Levin via Phabricator via lldb-commits
daniel-levin added a comment.

Yes please. I do not have commit access. Thank you Saleem :)


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D104176/new/

https://reviews.llvm.org/D104176

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D104176: [libunwind] Define and use portable macro for checking for presence of ASAN

2021-06-14 Thread Daniel Levin via Phabricator via lldb-commits
daniel-levin updated this revision to Diff 351707.
daniel-levin added a comment.
Herald added subscribers: lldb-commits, dexonsmith, pengfei, delcypher, 
hiraditya, mgorny.
Herald added a project: LLDB.

[libunwind] Use most appropriate macro for checking for presence of ASan.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D104176/new/

https://reviews.llvm.org/D104176

Files:
  libunwind/src/libunwind.cpp
  lldb/include/lldb/Utility/Timer.h
  lldb/source/Utility/Timer.cpp
  llvm/cmake/modules/AddLLVM.cmake
  llvm/include/llvm/CodeGen/TargetInstrInfo.h
  llvm/include/llvm/Support/Signposts.h
  llvm/lib/CodeGen/TwoAddressInstructionPass.cpp
  llvm/lib/Support/Signposts.cpp
  llvm/lib/Support/Timer.cpp
  llvm/lib/Target/X86/X86FixupLEAs.cpp
  llvm/lib/Target/X86/X86InstrInfo.cpp
  llvm/lib/Target/X86/X86InstrInfo.h
  llvm/test/CodeGen/X86/2009-03-23-MultiUseSched.ll
  llvm/test/CodeGen/X86/lea-opt2.ll
  llvm/test/CodeGen/X86/vp2intersect_multiple_pairs.ll
  llvm/utils/lit/lit/discovery.py

Index: llvm/utils/lit/lit/discovery.py
===
--- llvm/utils/lit/lit/discovery.py
+++ llvm/utils/lit/lit/discovery.py
@@ -53,8 +53,7 @@
 config_map = litConfig.params.get('config_map')
 if config_map:
 cfgpath = os.path.realpath(cfgpath)
-cfgpath = os.path.normcase(cfgpath)
-target = config_map.get(cfgpath)
+target = config_map.get(os.path.normcase(cfgpath))
 if target:
 cfgpath = target
 
Index: llvm/test/CodeGen/X86/vp2intersect_multiple_pairs.ll
===
--- llvm/test/CodeGen/X86/vp2intersect_multiple_pairs.ll
+++ llvm/test/CodeGen/X86/vp2intersect_multiple_pairs.ll
@@ -53,9 +53,9 @@
 ; X86-NEXT:addl %ecx, %edx
 ; X86-NEXT:kmovw %k1, %ecx
 ; X86-NEXT:addl %edi, %ecx
-; X86-NEXT:addl %ecx, %eax
-; X86-NEXT:addl %edx, %eax
-; X86-NEXT:movw %ax, (%esi)
+; X86-NEXT:addl %eax, %ecx
+; X86-NEXT:addl %edx, %ecx
+; X86-NEXT:movw %cx, (%esi)
 ; X86-NEXT:leal -8(%ebp), %esp
 ; X86-NEXT:popl %esi
 ; X86-NEXT:popl %edi
@@ -107,10 +107,10 @@
 ; X64-NEXT:kmovw %k1, %ebx
 ; X64-NEXT:addl %edi, %eax
 ; X64-NEXT:addl %ecx, %edx
-; X64-NEXT:addl %ebx, %eax
-; X64-NEXT:addl %esi, %eax
-; X64-NEXT:addl %edx, %eax
-; X64-NEXT:movw %ax, (%r14)
+; X64-NEXT:leal (%rbx,%rsi), %ecx
+; X64-NEXT:addl %eax, %ecx
+; X64-NEXT:addl %edx, %ecx
+; X64-NEXT:movw %cx, (%r14)
 ; X64-NEXT:leaq -16(%rbp), %rsp
 ; X64-NEXT:popq %rbx
 ; X64-NEXT:popq %r14
Index: llvm/test/CodeGen/X86/lea-opt2.ll
===
--- llvm/test/CodeGen/X86/lea-opt2.ll
+++ llvm/test/CodeGen/X86/lea-opt2.ll
@@ -11,14 +11,15 @@
 ;subl%edx, %ecx
 ;subl%eax, %ecx
 
+; TODO: replace lea with sub.
 ; C - (A + B)   -->C - A - B
 define i32 @test1(i32* %p, i32 %a, i32 %b, i32 %c) {
 ; CHECK-LABEL: test1:
 ; CHECK:   # %bb.0: # %entry
 ; CHECK-NEXT:# kill: def $edx killed $edx def $rdx
 ; CHECK-NEXT:movl %esi, %eax
-; CHECK-NEXT:subl %edx, %ecx
-; CHECK-NEXT:subl %eax, %ecx
+; CHECK-NEXT:leal (%rdx,%rax), %esi
+; CHECK-NEXT:subl %esi, %ecx
 ; CHECK-NEXT:movl %ecx, (%rdi)
 ; CHECK-NEXT:subl %edx, %eax
 ; CHECK-NEXT:# kill: def $eax killed $eax killed $rax
@@ -31,15 +32,16 @@
   ret i32 %sub1
 }
 
+; TODO: replace lea with add.
 ; (A + B) + C   -->C + A + B
 define i32 @test2(i32* %p, i32 %a, i32 %b, i32 %c) {
 ; CHECK-LABEL: test2:
 ; CHECK:   # %bb.0: # %entry
 ; CHECK-NEXT:# kill: def $edx killed $edx def $rdx
 ; CHECK-NEXT:movl %esi, %eax
-; CHECK-NEXT:addl %eax, %ecx
-; CHECK-NEXT:addl %edx, %ecx
-; CHECK-NEXT:movl %ecx, (%rdi)
+; CHECK-NEXT:leal (%rax,%rdx), %esi
+; CHECK-NEXT:addl %ecx, %esi
+; CHECK-NEXT:movl %esi, (%rdi)
 ; CHECK-NEXT:subl %edx, %eax
 ; CHECK-NEXT:# kill: def $eax killed $eax killed $rax
 ; CHECK-NEXT:retq
@@ -51,15 +53,16 @@
   ret i32 %sub1
 }
 
+; TODO: replace lea with add.
 ; C + (A + B)   -->C + A + B
 define i32 @test3(i32* %p, i32 %a, i32 %b, i32 %c) {
 ; CHECK-LABEL: test3:
 ; CHECK:   # %bb.0: # %entry
 ; CHECK-NEXT:# kill: def $edx killed $edx def $rdx
 ; CHECK-NEXT:movl %esi, %eax
-; CHECK-NEXT:addl %eax, %ecx
-; CHECK-NEXT:addl %edx, %ecx
-; CHECK-NEXT:movl %ecx, (%rdi)
+; CHECK-NEXT:leal (%rax,%rdx), %esi
+; CHECK-NEXT:addl %ecx, %esi
+; CHECK-NEXT:movl %esi, (%rdi)
 ; CHECK-NEXT:subl %edx, %eax
 ; CHECK-NEXT:# kill: def $eax killed $eax killed $rax
 ; CHECK-NEXT:retq
@@ -92,12 +95,13 @@
   ret i32 %sub1
 }
 
+; TODO: replace lea with sub.
 define i64 @test5(i64* %p, i64 %a, i64 %b, i64 %c) {
 ; CHECK-LABEL: test5:
 ; CHECK:   # %bb.0: # %entry
 ; CHECK-NEXT:movq (%rdi