[test] Make ELF tests immune to dso_local/dso_preemptable/(none) differences
authorFangrui Song <i@maskray.me>
Thu, 31 Dec 2020 21:37:35 +0000 (13:37 -0800)
committerFangrui Song <i@maskray.me>
Thu, 31 Dec 2020 21:59:44 +0000 (13:59 -0800)
ELF -cc1 -mrelocation-model pic will default to no semantic interposition plus
setting dso_local on default visibility external linkage definitions, so that
COFF, Mach-O and ELF output will be similar.

This patch makes tests immune to the differences.

clang/test/CodeGenCUDA/lambda-reference-var.cu
clang/test/CodeGenCXX/default_calling_conv.cpp
clang/test/Driver/hip-fpie-option.hip
clang/test/OpenMP/nvptx_declare_target_var_ctor_dtor_codegen.cpp

index 44b0129..2c62b0a 100644 (file)
@@ -47,7 +47,7 @@ __device__ void dev_capture_dev_ref_by_ref(int *out) {
   [&](){ ref++; *out = ref;}();
 }
 
-// DEV-LABEL: define void @_Z7dev_refPi(
+// DEV-LABEL: define{{.*}} void @_Z7dev_refPi(
 // DEV: %[[VAL:.*]] = load i32, i32* addrspacecast (i32 addrspace(1)* @global_device_var to i32*)
 // DEV: %[[VAL2:.*]] = add nsw i32 %[[VAL]], 1
 // DEV: store i32 %[[VAL2]], i32* addrspacecast (i32 addrspace(1)* @global_device_var to i32*)
@@ -94,7 +94,7 @@ void host_capture_host_ref_by_ref(int *out) {
   [&](){ ref++; *out = ref;}();
 }
 
-// HOST-LABEL: define void @_Z8host_refPi(
+// HOST-LABEL: define{{.*}} void @_Z8host_refPi(
 // HOST: %[[VAL:.*]] = load i32, i32* @global_host_var
 // HOST: %[[VAL2:.*]] = add nsw i32 %[[VAL]], 1
 // HOST: store i32 %[[VAL2]], i32* @global_host_var
@@ -120,7 +120,7 @@ void host_lambda_ref(int *out) {
   }();
 }
 
-// HOST-LABEL: define void @_Z28dev_capture_host_ref_by_copyPi(
+// HOST-LABEL: define{{.*}} void @_Z28dev_capture_host_ref_by_copyPi(
 // HOST: %[[CAP:.*]] = getelementptr inbounds %[[T3]], %[[T3]]* %{{.*}}, i32 0, i32 1
 // HOST: %[[VAL:.*]] = load i32, i32* @global_host_var
 // HOST: store i32 %[[VAL]], i32* %[[CAP]]
index d1f9571..e3d7ac4 100644 (file)
@@ -29,7 +29,7 @@ void __attribute__((fastcall)) test3() {}
 // ALL: define{{.*}} x86_stdcallcc void @_Z5test4v
 void __attribute__((stdcall)) test4() {}
 
-// ALL: define  x86_vectorcallcc void @_Z5test5v
+// ALL: define{{.*}} x86_vectorcallcc void @_Z5test5v
 void __attribute__((vectorcall)) test5() {}
 
 // ALL: define{{.*}} x86_regcallcc void @_Z17__regcall3__test6v
index 2b433cd..2e296a0 100644 (file)
@@ -31,8 +31,9 @@
 // RUN:   -fPIE \
 // RUN:   2>&1 | FileCheck -check-prefixes=DEV,HOST-PIE %s
 
-// DEV-DAG: {{".*clang.*".* "-triple" "amdgcn-amd-amdhsa".* "-mrelocation-model" "pic" "-pic-level" "[1|2]" "-mframe-pointer=all"}}
+// DEV-DAG: {{".*clang.*".* "-triple" "amdgcn-amd-amdhsa".* "-mrelocation-model" "pic" "-pic-level" "[1|2]".* "-mframe-pointer=all"}}
 // HOST-STATIC-DAG: {{".*clang.*".* "-triple" "x86_64-unknown-linux-gnu".* "-mrelocation-model" "static"}}
-// HOST-PIC-DAG: {{".*clang.*".* "-triple" "x86_64-unknown-linux-gnu".* "-mrelocation-model" "pic" "-pic-level" "2" "-mframe-pointer=all"}}
+// HOST-PIC-DAG: {{".*clang.*".* "-triple" "x86_64-unknown-linux-gnu".* "-mrelocation-model" "pic" "-pic-level" "2"}}
+// HOST-PIC-NOT: "-pic-is-pie"
 // HOST-PIE-DAG: {{".*clang.*".* "-triple" "x86_64-unknown-linux-gnu".* "-mrelocation-model" "pic" "-pic-level" "2" "-pic-is-pie"}}
 // DEV-NOT: {{".*clang.*".* "-triple" "amdgcn-amd-amdhsa".* "-pic-is-pie"}}
index 91a9c2a..496ac07 100644 (file)
@@ -18,7 +18,7 @@
 // DEVICE-DAG: [[C_ADDR:.+]] = internal global i32 0,
 // DEVICE-DAG: [[CD_ADDR:@.+]] ={{ hidden | }}global %struct.S zeroinitializer,
 // HOST-DAG: @[[C_ADDR:.+]] = internal global i32 0,
-// HOST-DAG: @[[CD_ADDR:.+]] ={{ hidden | }}global %struct.S zeroinitializer,
+// HOST-DAG: @[[CD_ADDR:.+]] ={{( hidden | dso_local)?}} global %struct.S zeroinitializer,
 
 #pragma omp declare target
 int foo() { return 0; }