tangyouling created this revision.
tangyouling added reviewers: Sanitizers, browneee, kcc, SixWeining, xen0n, 
xry111, MaskRay, XiaodongLoong.
Herald added subscribers: Enna1, StephenFan, dberris.
Herald added a project: All.
tangyouling requested review of this revision.
Herald added projects: clang, Sanitizers.
Herald added a subscriber: cfe-commits.

Enable loongarch64 and add test support.

Depends on D140689 <https://reviews.llvm.org/D140689>


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D140690

Files:
  clang/lib/Driver/ToolChains/Linux.cpp
  compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake
  compiler-rt/test/dfsan/atomic.cpp
  compiler-rt/test/dfsan/basic.c
  compiler-rt/test/dfsan/conditional_callbacks.c
  compiler-rt/test/dfsan/conditional_callbacks_sig.c
  compiler-rt/test/dfsan/dfsan_get_track_origins.c
  compiler-rt/test/dfsan/event_callbacks.c
  compiler-rt/test/dfsan/fast8labels.c
  compiler-rt/test/dfsan/flags.c
  compiler-rt/test/dfsan/flush.c
  compiler-rt/test/dfsan/fncall.c
  compiler-rt/test/dfsan/force_zero.c
  compiler-rt/test/dfsan/fork.cpp
  compiler-rt/test/dfsan/gep.c
  compiler-rt/test/dfsan/interceptors.c
  compiler-rt/test/dfsan/libatomic.c
  compiler-rt/test/dfsan/lookup_table.c
  compiler-rt/test/dfsan/mmap_at_init.c
  compiler-rt/test/dfsan/origin_add_label.c
  compiler-rt/test/dfsan/origin_branch.c
  compiler-rt/test/dfsan/origin_disabled.c
  compiler-rt/test/dfsan/origin_id_stack_trace.c
  compiler-rt/test/dfsan/origin_invalid.c
  compiler-rt/test/dfsan/origin_ld_lost.c
  compiler-rt/test/dfsan/origin_ldst.c
  compiler-rt/test/dfsan/origin_limit.c
  compiler-rt/test/dfsan/origin_memcpy.c
  compiler-rt/test/dfsan/origin_memmove.c
  compiler-rt/test/dfsan/origin_memset.c
  compiler-rt/test/dfsan/origin_of_first_taint.c
  compiler-rt/test/dfsan/origin_overlapped.c
  compiler-rt/test/dfsan/origin_set_label.c
  compiler-rt/test/dfsan/origin_stack_trace.c
  compiler-rt/test/dfsan/origin_track_ld.c
  compiler-rt/test/dfsan/origin_unaligned_memtrans.c
  compiler-rt/test/dfsan/origin_untainted.c
  compiler-rt/test/dfsan/origin_with_sigactions.c
  compiler-rt/test/dfsan/origin_with_signals.cpp
  compiler-rt/test/dfsan/pair.cpp
  compiler-rt/test/dfsan/propagate.c
  compiler-rt/test/dfsan/pthread.c
  compiler-rt/test/dfsan/reaches_function.c
  compiler-rt/test/dfsan/release_shadow_space.c
  compiler-rt/test/dfsan/sigaction.c
  compiler-rt/test/dfsan/sigaction_stress_test.c
  compiler-rt/test/dfsan/stack_trace.c
  compiler-rt/test/dfsan/struct.c
  compiler-rt/test/dfsan/threaded_flush.c
  compiler-rt/test/dfsan/trace-cmp.c
  compiler-rt/test/dfsan/vararg.c
  compiler-rt/test/dfsan/write_callback.c

Index: compiler-rt/test/dfsan/write_callback.c
===================================================================
--- compiler-rt/test/dfsan/write_callback.c
+++ compiler-rt/test/dfsan/write_callback.c
@@ -1,6 +1,6 @@
 // RUN: %clang_dfsan %s -o %t && %run %t | FileCheck %s
 //
-// REQUIRES: x86_64-target-arch
+// REQUIRES: x86_64-target-arch || loongarch64-target-arch
 
 // Tests that the custom implementation of write() does writes with or without
 // a callback set using dfsan_set_write_callback().
Index: compiler-rt/test/dfsan/vararg.c
===================================================================
--- compiler-rt/test/dfsan/vararg.c
+++ compiler-rt/test/dfsan/vararg.c
@@ -2,7 +2,7 @@
 // RUN: not %run %t 2>&1 | FileCheck %s
 // RUN: %run %t foo
 //
-// REQUIRES: x86_64-target-arch
+// REQUIRES: x86_64-target-arch || loongarch64-target-arch
 
 #include <stdio.h>
 
Index: compiler-rt/test/dfsan/trace-cmp.c
===================================================================
--- compiler-rt/test/dfsan/trace-cmp.c
+++ compiler-rt/test/dfsan/trace-cmp.c
@@ -4,7 +4,7 @@
 // RUN: %clang_dfsan -fsanitize-coverage=trace-pc-guard,pc-table,func,trace-cmp %s -o %t
 // RUN: %run %t 2>&1 | FileCheck %s
 //
-// REQUIRES: x86_64-target-arch
+// REQUIRES: x86_64-target-arch || loongarch64-target-arch
 
 #include <stdio.h>
 #include <stdint.h>
Index: compiler-rt/test/dfsan/threaded_flush.c
===================================================================
--- compiler-rt/test/dfsan/threaded_flush.c
+++ compiler-rt/test/dfsan/threaded_flush.c
@@ -2,7 +2,7 @@
 // segfault.
 // RUN: %clang_dfsan %s -o %t && %run %t
 //
-// REQUIRES: x86_64-target-arch
+// REQUIRES: x86_64-target-arch || loongarch64-target-arch
 
 #include <assert.h>
 #include <pthread.h>
Index: compiler-rt/test/dfsan/struct.c
===================================================================
--- compiler-rt/test/dfsan/struct.c
+++ compiler-rt/test/dfsan/struct.c
@@ -1,7 +1,7 @@
 // RUN: %clang_dfsan %s -O1 -o %t && %run %t
 // RUN: %clang_dfsan %s -O0 -DO0 -o %t && %run %t
 //
-// REQUIRES: x86_64-target-arch
+// REQUIRES: x86_64-target-arch || loongarch64-target-arch
 
 #include <assert.h>
 #include <sanitizer/dfsan_interface.h>
Index: compiler-rt/test/dfsan/stack_trace.c
===================================================================
--- compiler-rt/test/dfsan/stack_trace.c
+++ compiler-rt/test/dfsan/stack_trace.c
@@ -1,7 +1,7 @@
 // RUN: %clang_dfsan -gmlt %s -o %t && %run %t >%t.out 2>&1
 // RUN: FileCheck %s < %t.out
 //
-// REQUIRES: x86_64-target-arch
+// REQUIRES: x86_64-target-arch || loongarch64-target-arch
 
 #include <assert.h>
 #include <sanitizer/dfsan_interface.h>
Index: compiler-rt/test/dfsan/sigaction_stress_test.c
===================================================================
--- compiler-rt/test/dfsan/sigaction_stress_test.c
+++ compiler-rt/test/dfsan/sigaction_stress_test.c
@@ -4,7 +4,7 @@
 //
 // Test that the state of shadows from a sigaction handler are consistent.
 //
-// REQUIRES: x86_64-target-arch
+// REQUIRES: x86_64-target-arch || loongarch64-target-arch
 
 #include <signal.h>
 #include <stdarg.h>
Index: compiler-rt/test/dfsan/sigaction.c
===================================================================
--- compiler-rt/test/dfsan/sigaction.c
+++ compiler-rt/test/dfsan/sigaction.c
@@ -1,7 +1,7 @@
 // RUN: %clang_dfsan -DUSE_SIGNAL_ACTION -Wno-error=int-conversion %s -o %t && %run %t
 // RUN: %clang_dfsan -Wno-error=int-conversion %s -o %t && %run %t
 //
-// REQUIRES: x86_64-target-arch
+// REQUIRES: x86_64-target-arch || loongarch64-target-arch
 
 #include <sanitizer/dfsan_interface.h>
 
Index: compiler-rt/test/dfsan/release_shadow_space.c
===================================================================
--- compiler-rt/test/dfsan/release_shadow_space.c
+++ compiler-rt/test/dfsan/release_shadow_space.c
@@ -3,7 +3,7 @@
 // DFSAN_OPTIONS=no_huge_pages_for_shadow=false RUN: %clang_dfsan %s -DORIGIN_TRACKING -mllvm -dfsan-track-origins=1 -o %t && %run %t
 // DFSAN_OPTIONS=no_huge_pages_for_shadow=true RUN: %clang_dfsan %s -DORIGIN_TRACKING -mllvm -dfsan-track-origins=1 -o %t && %run %t
 //
-// REQUIRES: x86_64-target-arch
+// REQUIRES: x86_64-target-arch || loongarch64-target-arch
 
 #include <assert.h>
 #include <sanitizer/dfsan_interface.h>
Index: compiler-rt/test/dfsan/reaches_function.c
===================================================================
--- compiler-rt/test/dfsan/reaches_function.c
+++ compiler-rt/test/dfsan/reaches_function.c
@@ -6,7 +6,7 @@
 // RUN: %clang_dfsan -gmlt -fsanitize-ignorelist=%S/Inputs/flags_abilist.txt -O2 -mllvm -dfsan-reaches-function-callbacks=1 -mllvm -dfsan-track-origins=2 %s %t-callbacks.o -o %t
 // RUN: %run %t 2>&1 | FileCheck --check-prefix=CHECK-ORIGIN-TRACKING %s
 
-// REQUIRES: x86_64-target-arch
+// REQUIRES: x86_64-target-arch || loongarch64-target-arch
 
 // Tests that callbacks are inserted for reached functions when
 // -dfsan-reaches-function-callbacks is specified.
Index: compiler-rt/test/dfsan/pthread.c
===================================================================
--- compiler-rt/test/dfsan/pthread.c
+++ compiler-rt/test/dfsan/pthread.c
@@ -8,7 +8,7 @@
 // RUN:     %run %t >%t.out 2>&1
 // RUN: FileCheck %s < %t.out
 //
-// REQUIRES: x86_64-target-arch
+// REQUIRES: x86_64-target-arch || loongarch64-target-arch
 
 #include <sanitizer/dfsan_interface.h>
 
Index: compiler-rt/test/dfsan/propagate.c
===================================================================
--- compiler-rt/test/dfsan/propagate.c
+++ compiler-rt/test/dfsan/propagate.c
@@ -1,6 +1,6 @@
 // RUN: %clang_dfsan %s -o %t && %run %t
 //
-// REQUIRES: x86_64-target-arch
+// REQUIRES: x86_64-target-arch || loongarch64-target-arch
 
 // Tests that labels are propagated through computation and that union labels
 // are properly created.
Index: compiler-rt/test/dfsan/pair.cpp
===================================================================
--- compiler-rt/test/dfsan/pair.cpp
+++ compiler-rt/test/dfsan/pair.cpp
@@ -1,7 +1,7 @@
 // RUN: %clangxx_dfsan %s -mllvm -dfsan-track-select-control-flow=false -mllvm -dfsan-combine-pointer-labels-on-load=false -O0 -DO0 -o %t && %run %t
 // RUN: %clangxx_dfsan %s -mllvm -dfsan-track-select-control-flow=false -mllvm -dfsan-combine-pointer-labels-on-load=false -O1 -o %t && %run %t
 //
-// REQUIRES: x86_64-target-arch
+// REQUIRES: x86_64-target-arch || loongarch64-target-arch
 
 #include <algorithm>
 #include <assert.h>
Index: compiler-rt/test/dfsan/origin_with_signals.cpp
===================================================================
--- compiler-rt/test/dfsan/origin_with_signals.cpp
+++ compiler-rt/test/dfsan/origin_with_signals.cpp
@@ -11,7 +11,7 @@
 // RUN:     %run %t >%t.out 2>&1
 // RUN: FileCheck %s < %t.out
 //
-// REQUIRES: x86_64-target-arch
+// REQUIRES: x86_64-target-arch || loongarch64-target-arch
 
 #include <sanitizer/dfsan_interface.h>
 
Index: compiler-rt/test/dfsan/origin_with_sigactions.c
===================================================================
--- compiler-rt/test/dfsan/origin_with_sigactions.c
+++ compiler-rt/test/dfsan/origin_with_sigactions.c
@@ -19,7 +19,7 @@
 // RUN:     %run %t >%t.out 2>&1
 // RUN: FileCheck %s < %t.out
 //
-// REQUIRES: x86_64-target-arch
+// REQUIRES: x86_64-target-arch || loongarch64-target-arch
 
 #include <sanitizer/dfsan_interface.h>
 
Index: compiler-rt/test/dfsan/origin_untainted.c
===================================================================
--- compiler-rt/test/dfsan/origin_untainted.c
+++ compiler-rt/test/dfsan/origin_untainted.c
@@ -2,7 +2,7 @@
 // RUN:     %run %t >%t.out 2>&1
 // RUN: FileCheck %s < %t.out
 //
-// REQUIRES: x86_64-target-arch
+// REQUIRES: x86_64-target-arch || loongarch64-target-arch
 
 #include <sanitizer/dfsan_interface.h>
 
Index: compiler-rt/test/dfsan/origin_unaligned_memtrans.c
===================================================================
--- compiler-rt/test/dfsan/origin_unaligned_memtrans.c
+++ compiler-rt/test/dfsan/origin_unaligned_memtrans.c
@@ -1,12 +1,12 @@
 // RUN: %clang_dfsan -gmlt -DOFFSET=0 -mllvm -dfsan-track-origins=1 %s -o %t && \
 // RUN:     %run %t >%t.out 2>&1
 // RUN: FileCheck %s --check-prefix=CHECK0 < %t.out
-// 
+//
 // RUN: %clang_dfsan -gmlt -DOFFSET=10 -mllvm -dfsan-track-origins=1 %s -o %t && \
 // RUN:     %run %t >%t.out 2>&1
 // RUN: FileCheck %s --check-prefix=CHECK10 < %t.out
 //
-// REQUIRES: x86_64-target-arch
+// REQUIRES: x86_64-target-arch || loongarch64-target-arch
 
 #include <sanitizer/dfsan_interface.h>
 
Index: compiler-rt/test/dfsan/origin_track_ld.c
===================================================================
--- compiler-rt/test/dfsan/origin_track_ld.c
+++ compiler-rt/test/dfsan/origin_track_ld.c
@@ -2,7 +2,7 @@
 // RUN:     %run %t > %t.out 2>&1
 // RUN: FileCheck %s < %t.out
 //
-// REQUIRES: x86_64-target-arch
+// REQUIRES: x86_64-target-arch || loongarch64-target-arch
 
 #include <sanitizer/dfsan_interface.h>
 
Index: compiler-rt/test/dfsan/origin_stack_trace.c
===================================================================
--- compiler-rt/test/dfsan/origin_stack_trace.c
+++ compiler-rt/test/dfsan/origin_stack_trace.c
@@ -6,7 +6,7 @@
 // RUN:     %run %t >%t.out 2>&1
 // RUN: FileCheck %s < %t.out
 //
-// REQUIRES: x86_64-target-arch
+// REQUIRES: x86_64-target-arch || loongarch64-target-arch
 
 #include <assert.h>
 #include <malloc.h>
Index: compiler-rt/test/dfsan/origin_set_label.c
===================================================================
--- compiler-rt/test/dfsan/origin_set_label.c
+++ compiler-rt/test/dfsan/origin_set_label.c
@@ -1,12 +1,12 @@
 // RUN: %clang_dfsan -gmlt -mllvm -dfsan-track-origins=1 %s -o %t && \
 // RUN:     %run %t >%t.out 2>&1
 // RUN: FileCheck %s < %t.out
-// 
+//
 // RUN: %clang_dfsan -gmlt -mllvm -dfsan-track-origins=1 -mllvm -dfsan-instrument-with-call-threshold=0 %s -o %t && \
 // RUN:     %run %t >%t.out 2>&1
 // RUN: FileCheck %s < %t.out
 //
-// REQUIRES: x86_64-target-arch
+// REQUIRES: x86_64-target-arch || loongarch64-target-arch
 
 #include <sanitizer/dfsan_interface.h>
 
Index: compiler-rt/test/dfsan/origin_overlapped.c
===================================================================
--- compiler-rt/test/dfsan/origin_overlapped.c
+++ compiler-rt/test/dfsan/origin_overlapped.c
@@ -2,7 +2,7 @@
 // RUN:     %run %t >%t.out 2>&1
 // RUN: FileCheck %s < %t.out
 //
-// REQUIRES: x86_64-target-arch
+// REQUIRES: x86_64-target-arch || loongarch64-target-arch
 
 #include <sanitizer/dfsan_interface.h>
 
Index: compiler-rt/test/dfsan/origin_of_first_taint.c
===================================================================
--- compiler-rt/test/dfsan/origin_of_first_taint.c
+++ compiler-rt/test/dfsan/origin_of_first_taint.c
@@ -1,7 +1,7 @@
 // RUN: %clang_dfsan -gmlt -mllvm -dfsan-track-origins=1 %s -o %t && \
 // RUN:     %run %t 2>&1 | FileCheck %s
 //
-// REQUIRES: x86_64-target-arch
+// REQUIRES: x86_64-target-arch || loongarch64-target-arch
 
 #include <assert.h>
 #include <sanitizer/dfsan_interface.h>
Index: compiler-rt/test/dfsan/origin_memset.c
===================================================================
--- compiler-rt/test/dfsan/origin_memset.c
+++ compiler-rt/test/dfsan/origin_memset.c
@@ -1,12 +1,12 @@
 // RUN: %clang_dfsan -gmlt -DOFFSET=0 -mllvm -dfsan-track-origins=1 %s -o %t && \
 // RUN:     %run %t >%t.out 2>&1
 // RUN: FileCheck %s --check-prefix=CHECK0 < %t.out
-// 
+//
 // RUN: %clang_dfsan -gmlt -DOFFSET=10 -mllvm -dfsan-track-origins=1 %s -o %t && \
 // RUN:     %run %t >%t.out 2>&1
 // RUN: FileCheck %s --check-prefix=CHECK10 < %t.out
 //
-// REQUIRES: x86_64-target-arch
+// REQUIRES: x86_64-target-arch || loongarch64-target-arch
 
 #include <sanitizer/dfsan_interface.h>
 
Index: compiler-rt/test/dfsan/origin_memmove.c
===================================================================
--- compiler-rt/test/dfsan/origin_memmove.c
+++ compiler-rt/test/dfsan/origin_memmove.c
@@ -6,7 +6,7 @@
 // RUN:     %run %t >%t.out 2>&1
 // RUN: FileCheck %s --check-prefix=CHECK10 < %t.out
 //
-// REQUIRES: x86_64-target-arch
+// REQUIRES: x86_64-target-arch || loongarch64-target-arch
 
 #include <sanitizer/dfsan_interface.h>
 
Index: compiler-rt/test/dfsan/origin_memcpy.c
===================================================================
--- compiler-rt/test/dfsan/origin_memcpy.c
+++ compiler-rt/test/dfsan/origin_memcpy.c
@@ -1,12 +1,12 @@
 // RUN: %clang_dfsan -gmlt -DOFFSET=0 -mllvm -dfsan-track-origins=1 %s -o %t && \
 // RUN:     %run %t >%t.out 2>&1
 // RUN: FileCheck %s --check-prefix=CHECK0 < %t.out
-// 
+//
 // RUN: %clang_dfsan -gmlt -DOFFSET=10 -mllvm -dfsan-track-origins=1 %s -o %t && \
 // RUN:     %run %t >%t.out 2>&1
 // RUN: FileCheck %s --check-prefix=CHECK10 < %t.out
 //
-// REQUIRES: x86_64-target-arch
+// REQUIRES: x86_64-target-arch || loongarch64-target-arch
 
 #include <sanitizer/dfsan_interface.h>
 
Index: compiler-rt/test/dfsan/origin_limit.c
===================================================================
--- compiler-rt/test/dfsan/origin_limit.c
+++ compiler-rt/test/dfsan/origin_limit.c
@@ -9,7 +9,7 @@
 // RUN: DFSAN_OPTIONS=origin_history_size=0 %run %t >%t.out 2>&1
 // RUN: FileCheck %s --check-prefix=CHECK0 < %t.out
 //
-// REQUIRES: x86_64-target-arch
+// REQUIRES: x86_64-target-arch || loongarch64-target-arch
 
 #include <sanitizer/dfsan_interface.h>
 
Index: compiler-rt/test/dfsan/origin_ldst.c
===================================================================
--- compiler-rt/test/dfsan/origin_ldst.c
+++ compiler-rt/test/dfsan/origin_ldst.c
@@ -22,7 +22,7 @@
 // RUN:     %run %t >%t.out 2>&1
 // RUN: FileCheck %s < %t.out
 //
-// REQUIRES: x86_64-target-arch
+// REQUIRES: x86_64-target-arch || loongarch64-target-arch
 //
 // Test origin tracking is accurate in terms of partial store/load, and
 // different aligments. Do not test alignments that are not power of 2.
Index: compiler-rt/test/dfsan/origin_ld_lost.c
===================================================================
--- compiler-rt/test/dfsan/origin_ld_lost.c
+++ compiler-rt/test/dfsan/origin_ld_lost.c
@@ -2,7 +2,7 @@
 // RUN:     %run %t >%t.out 2>&1
 // RUN: FileCheck %s < %t.out
 //
-// REQUIRES: x86_64-target-arch
+// REQUIRES: x86_64-target-arch || loongarch64-target-arch
 //
 // Test origin tracking can lost origins at 2-byte load with addr % 4 == 3.
 
Index: compiler-rt/test/dfsan/origin_invalid.c
===================================================================
--- compiler-rt/test/dfsan/origin_invalid.c
+++ compiler-rt/test/dfsan/origin_invalid.c
@@ -1,8 +1,8 @@
 // RUN: %clang_dfsan -gmlt -mllvm -dfsan-track-origins=1 %s -o %t && \
 // RUN:     %run %t >%t.out 2>&1
 // RUN: FileCheck %s < %t.out
-// 
-// REQUIRES: x86_64-target-arch
+//
+// REQUIRES: x86_64-target-arch || loongarch64-target-arch
 
 #include <sanitizer/dfsan_interface.h>
 
@@ -11,14 +11,18 @@
   dfsan_set_label(1, &a, sizeof(a));
 
   // Manually compute origin address for &a.
-  // See x86 MEM_TO_ORIGIN macro for logic to replicate here.
+  // See x86/loongarch64 MEM_TO_ORIGIN macro for logic to replicate here.
   // Alignment is also needed after to MEM_TO_ORIGIN.
   uint64_t origin_addr =
       (((uint64_t)&a ^ 0x500000000000ULL) + 0x100000000000ULL) & ~0x3ULL;
 
   // Take the address we computed, and store 0 in it to mess it up.
+#if defined(__loongarch_lp64)
+  asm("st.d $zero, %0, 0" : : "r"(origin_addr));
+#else
   asm("mov %0, %%rax": :"r"(origin_addr));
   asm("movq $0, (%rax)");
+#endif
   dfsan_print_origin_trace(&a, "invalid");
 }
 
Index: compiler-rt/test/dfsan/origin_id_stack_trace.c
===================================================================
--- compiler-rt/test/dfsan/origin_id_stack_trace.c
+++ compiler-rt/test/dfsan/origin_id_stack_trace.c
@@ -6,7 +6,7 @@
 // RUN:     %run %t >%t.out 2>&1
 // RUN: FileCheck %s < %t.out
 //
-// REQUIRES: x86_64-target-arch
+// REQUIRES: x86_64-target-arch || loongarch64-target-arch
 
 #include <sanitizer/dfsan_interface.h>
 #include <stdio.h>
Index: compiler-rt/test/dfsan/origin_disabled.c
===================================================================
--- compiler-rt/test/dfsan/origin_disabled.c
+++ compiler-rt/test/dfsan/origin_disabled.c
@@ -1,7 +1,7 @@
 // RUN: %clang_dfsan -gmlt %s -o %t && %run %t >%t.out 2>&1
 // RUN: FileCheck %s < %t.out
 //
-// REQUIRES: x86_64-target-arch
+// REQUIRES: x86_64-target-arch || loongarch64-target-arch
 
 #include <sanitizer/dfsan_interface.h>
 
Index: compiler-rt/test/dfsan/origin_branch.c
===================================================================
--- compiler-rt/test/dfsan/origin_branch.c
+++ compiler-rt/test/dfsan/origin_branch.c
@@ -2,7 +2,7 @@
 // RUN:     %run %t >%t.out 2>&1
 // RUN: FileCheck %s < %t.out
 //
-// REQUIRES: x86_64-target-arch
+// REQUIRES: x86_64-target-arch || loongarch64-target-arch
 
 #include <sanitizer/dfsan_interface.h>
 
Index: compiler-rt/test/dfsan/origin_add_label.c
===================================================================
--- compiler-rt/test/dfsan/origin_add_label.c
+++ compiler-rt/test/dfsan/origin_add_label.c
@@ -6,7 +6,7 @@
 // RUN:     %run %t >%t.out 2>&1
 // RUN: FileCheck %s < %t.out
 //
-// REQUIRES: x86_64-target-arch
+// REQUIRES: x86_64-target-arch || loongarch64-target-arch
 
 #include <sanitizer/dfsan_interface.h>
 
Index: compiler-rt/test/dfsan/mmap_at_init.c
===================================================================
--- compiler-rt/test/dfsan/mmap_at_init.c
+++ compiler-rt/test/dfsan/mmap_at_init.c
@@ -2,7 +2,7 @@
 // RUN: %clang_dfsan %s %t-calloc.o -o %t
 // RUN: %run %t
 //
-// REQUIRES: x86_64-target-arch
+// REQUIRES: x86_64-target-arch || loongarch64-target-arch
 //
 // Tests that calling mmap() during during dfsan initialization works.
 
Index: compiler-rt/test/dfsan/lookup_table.c
===================================================================
--- compiler-rt/test/dfsan/lookup_table.c
+++ compiler-rt/test/dfsan/lookup_table.c
@@ -2,7 +2,7 @@
 // RUN: %clang_dfsan %s -mllvm -dfsan-combine-offset-labels-on-gep=false -mllvm -dfsan-combine-pointer-labels-on-load=false -mllvm -dfsan-combine-taint-lookup-table=no_match -o %t && %run %t
 // RUN: %clang_dfsan %s -mllvm -dfsan-combine-offset-labels-on-gep=false -mllvm -dfsan-combine-pointer-labels-on-load=false -o %t && %run %t
 //
-// REQUIRES: x86_64-target-arch
+// REQUIRES: x86_64-target-arch || loongarch64-target-arch
 
 #include <sanitizer/dfsan_interface.h>
 #include <assert.h>
Index: compiler-rt/test/dfsan/libatomic.c
===================================================================
--- compiler-rt/test/dfsan/libatomic.c
+++ compiler-rt/test/dfsan/libatomic.c
@@ -3,7 +3,7 @@
 // RUN: %clang_dfsan -g3 -DDATA_BYTES=32 %s -fno-exceptions -latomic -o %t && %run %t
 // RUN: %clang_dfsan -g3 -DDATA_BYTES=32 -DORIGIN_TRACKING -mllvm -dfsan-track-origins=1 %s -fno-exceptions -latomic -o %t && %run %t
 //
-// REQUIRES: x86_64-target-arch
+// REQUIRES: x86_64-target-arch || loongarch64-target-arch
 
 #include <assert.h>
 #include <sanitizer/dfsan_interface.h>
Index: compiler-rt/test/dfsan/interceptors.c
===================================================================
--- compiler-rt/test/dfsan/interceptors.c
+++ compiler-rt/test/dfsan/interceptors.c
@@ -3,7 +3,7 @@
 //
 // Tests custom implementations of various glibc functions.
 //
-// REQUIRES: x86_64-target-arch
+// REQUIRES: x86_64-target-arch || loongarch64-target-arch
 
 #include <sanitizer/dfsan_interface.h>
 
Index: compiler-rt/test/dfsan/gep.c
===================================================================
--- compiler-rt/test/dfsan/gep.c
+++ compiler-rt/test/dfsan/gep.c
@@ -1,7 +1,7 @@
 // RUN: %clang_dfsan %s -mllvm -dfsan-combine-offset-labels-on-gep=false -Wno-error=int-conversion -o %t && %run %t
 // RUN: %clang_dfsan %s -DPROP_OFFSET_LABELS -Wno-error=int-conversion -o %t && %run %t
 //
-// REQUIRES: x86_64-target-arch
+// REQUIRES: x86_64-target-arch || loongarch64-target-arch
 
 // Tests that labels are propagated through GEP.
 
Index: compiler-rt/test/dfsan/fork.cpp
===================================================================
--- compiler-rt/test/dfsan/fork.cpp
+++ compiler-rt/test/dfsan/fork.cpp
@@ -8,7 +8,7 @@
 // RUN: %clangxx_dfsan -mllvm -dfsan-track-origins=1 %s -o %t
 // RUN: DFSAN_OPTIONS=store_context_size=1000,origin_history_size=0,origin_history_per_stack_limit=0 %run %t 2>&1 | FileCheck %s
 //
-// REQUIRES: x86_64-target-arch
+// REQUIRES: x86_64-target-arch || loongarch64-target-arch
 
 #include <assert.h>
 #include <errno.h>
Index: compiler-rt/test/dfsan/force_zero.c
===================================================================
--- compiler-rt/test/dfsan/force_zero.c
+++ compiler-rt/test/dfsan/force_zero.c
@@ -1,7 +1,7 @@
 // RUN: %clang_dfsan %s -fsanitize-ignorelist=%S/Inputs/flags_abilist.txt -DFORCE_ZERO_LABELS -o %t && %run %t
 // RUN: %clang_dfsan %s -o %t && %run %t
 //
-// REQUIRES: x86_64-target-arch
+// REQUIRES: x86_64-target-arch || loongarch64-target-arch
 
 #include <sanitizer/dfsan_interface.h>
 
Index: compiler-rt/test/dfsan/fncall.c
===================================================================
--- compiler-rt/test/dfsan/fncall.c
+++ compiler-rt/test/dfsan/fncall.c
@@ -1,6 +1,6 @@
 // RUN: %clang_dfsan %s -o %t && %run %t
 //
-// REQUIRES: x86_64-target-arch
+// REQUIRES: x86_64-target-arch || loongarch64-target-arch
 //
 // Tests that labels are propagated through function calls.
 
Index: compiler-rt/test/dfsan/flush.c
===================================================================
--- compiler-rt/test/dfsan/flush.c
+++ compiler-rt/test/dfsan/flush.c
@@ -2,7 +2,7 @@
 // RUN: %clang_dfsan %s -o %t && %run %t
 // RUN: %clang_dfsan -DORIGIN_TRACKING -mllvm -dfsan-track-origins=1 %s -o %t && %run %t
 //
-// REQUIRES: x86_64-target-arch
+// REQUIRES: x86_64-target-arch || loongarch64-target-arch
 
 #include <sanitizer/dfsan_interface.h>
 #include <assert.h>
Index: compiler-rt/test/dfsan/flags.c
===================================================================
--- compiler-rt/test/dfsan/flags.c
+++ compiler-rt/test/dfsan/flags.c
@@ -2,7 +2,7 @@
 // RUN: %clang_dfsan %s -fsanitize-ignorelist=%S/Inputs/flags_abilist.txt -mllvm -dfsan-debug-nonzero-labels -o %t && DFSAN_OPTIONS=warn_unimplemented=0 %run %t 2>&1 | count 0
 // RUN: %clang_dfsan %s -fsanitize-ignorelist=%S/Inputs/flags_abilist.txt -mllvm -dfsan-debug-nonzero-labels -o %t && DFSAN_OPTIONS=warn_nonzero_labels=1 %run %t 2>&1 | FileCheck --check-prefix=CHECK-NONZERO %s
 //
-// REQUIRES: x86_64-target-arch
+// REQUIRES: x86_64-target-arch || loongarch64-target-arch
 
 // Tests that flags work correctly.
 
Index: compiler-rt/test/dfsan/fast8labels.c
===================================================================
--- compiler-rt/test/dfsan/fast8labels.c
+++ compiler-rt/test/dfsan/fast8labels.c
@@ -1,7 +1,7 @@
 // RUN: %clang_dfsan %s -o %t
 // RUN: %run %t
 //
-// REQUIRES: x86_64-target-arch
+// REQUIRES: x86_64-target-arch || loongarch64-target-arch
 //
 #include <sanitizer/dfsan_interface.h>
 
Index: compiler-rt/test/dfsan/event_callbacks.c
===================================================================
--- compiler-rt/test/dfsan/event_callbacks.c
+++ compiler-rt/test/dfsan/event_callbacks.c
@@ -2,7 +2,7 @@
 // RUN: %clang_dfsan -O2 -mllvm -dfsan-event-callbacks %s %t-callbacks.o -o %t
 // RUN: %run %t FooBarBaz 2>&1 | FileCheck %s
 //
-// REQUIRES: x86_64-target-arch
+// REQUIRES: x86_64-target-arch || loongarch64-target-arch
 
 // Tests that callbacks are inserted for store events when
 // -dfsan-event-callbacks is specified.
Index: compiler-rt/test/dfsan/dfsan_get_track_origins.c
===================================================================
--- compiler-rt/test/dfsan/dfsan_get_track_origins.c
+++ compiler-rt/test/dfsan/dfsan_get_track_origins.c
@@ -2,7 +2,7 @@
 // RUN: %clang_dfsan -DTRACK_ORIGINS=1 -mllvm -dfsan-track-origins=1 %s -o %t && %run %t
 // RUN: %clang_dfsan -DTRACK_ORIGINS=0 %s -o %t && %run %t
 //
-// REQUIRES: x86_64-target-arch
+// REQUIRES: x86_64-target-arch || loongarch64-target-arch
 
 #include <sanitizer/dfsan_interface.h>
 
Index: compiler-rt/test/dfsan/conditional_callbacks_sig.c
===================================================================
--- compiler-rt/test/dfsan/conditional_callbacks_sig.c
+++ compiler-rt/test/dfsan/conditional_callbacks_sig.c
@@ -2,7 +2,7 @@
 // RUN: %clang_dfsan -fsanitize-ignorelist=%S/Inputs/flags_abilist.txt -O2 -mllvm -dfsan-conditional-callbacks %s %t-callbacks.o -o %t
 // RUN: %run %t FooBarBaz 2>&1 | FileCheck %s
 //
-// REQUIRES: x86_64-target-arch
+// REQUIRES: x86_64-target-arch || loongarch64-target-arch
 
 #include <assert.h>
 #include <sanitizer/dfsan_interface.h>
Index: compiler-rt/test/dfsan/conditional_callbacks.c
===================================================================
--- compiler-rt/test/dfsan/conditional_callbacks.c
+++ compiler-rt/test/dfsan/conditional_callbacks.c
@@ -6,7 +6,7 @@
 // RUN: %clang_dfsan -fsanitize-ignorelist=%S/Inputs/flags_abilist.txt -O2 -mllvm -dfsan-conditional-callbacks -mllvm -dfsan-track-origins=1 -DORIGINS %s %t-callbacks-orig.o -o %t-orig
 // RUN: %run %t-orig FooBarBaz 2>&1 | FileCheck %s
 //
-// REQUIRES: x86_64-target-arch
+// REQUIRES: x86_64-target-arch || loongarch64-target-arch
 
 // Tests that callbacks are inserted for conditionals when
 // -dfsan-conditional-callbacks is specified.
Index: compiler-rt/test/dfsan/basic.c
===================================================================
--- compiler-rt/test/dfsan/basic.c
+++ compiler-rt/test/dfsan/basic.c
@@ -1,6 +1,6 @@
 // RUN: %clang_dfsan %s -o %t && %run %t
 //
-// REQUIRES: x86_64-target-arch
+// REQUIRES: x86_64-target-arch || loongarch64-target-arch
 
 // Tests that labels are propagated through loads and stores.
 
Index: compiler-rt/test/dfsan/atomic.cpp
===================================================================
--- compiler-rt/test/dfsan/atomic.cpp
+++ compiler-rt/test/dfsan/atomic.cpp
@@ -1,7 +1,7 @@
 // RUN: %clangxx_dfsan %s -fno-exceptions -o %t && %run %t
 // RUN: %clangxx_dfsan -DORIGIN_TRACKING -mllvm -dfsan-track-origins=1 %s -fno-exceptions -o %t && %run %t
 //
-// REQUIRES: x86_64-target-arch
+// REQUIRES: x86_64-target-arch || loongarch64-target-arch
 //
 // Use -fno-exceptions to turn off exceptions to avoid instrumenting
 // __cxa_begin_catch, std::terminate and __gxx_personality_v0.
Index: compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake
===================================================================
--- compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake
+++ compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake
@@ -29,7 +29,7 @@
 set(ALL_ASAN_SUPPORTED_ARCH ${X86} ${X86_64} ${ARM32} ${ARM64} ${RISCV64}
     ${MIPS32} ${MIPS64} ${PPC64} ${S390X} ${SPARC} ${SPARCV9} ${HEXAGON}
     ${LOONGARCH64})
-set(ALL_DFSAN_SUPPORTED_ARCH ${X86_64} ${MIPS64} ${ARM64})
+set(ALL_DFSAN_SUPPORTED_ARCH ${X86_64} ${MIPS64} ${ARM64} ${LOONGARCH64})
 
 if(ANDROID)
   set(OS_NAME "Android")
Index: clang/lib/Driver/ToolChains/Linux.cpp
===================================================================
--- clang/lib/Driver/ToolChains/Linux.cpp
+++ clang/lib/Driver/ToolChains/Linux.cpp
@@ -763,7 +763,7 @@
   Res |= SanitizerKind::Memory;
   Res |= SanitizerKind::Vptr;
   Res |= SanitizerKind::SafeStack;
-  if (IsX86_64 || IsMIPS64 || IsAArch64)
+  if (IsX86_64 || IsMIPS64 || IsAArch64 || IsLoongArch64)
     Res |= SanitizerKind::DataFlow;
   if (IsX86_64 || IsMIPS64 || IsAArch64 || IsX86 || IsArmArch || IsPowerPC64 ||
       IsRISCV64 || IsSystemZ || IsHexagon || IsLoongArch64)
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to