[clang] f4f6adc - [clang] Don't emit IFUNC when targeting Fuchsia

Alex Brachet via cfe-commits cfe-commits at lists.llvm.org
Thu Jun 16 08:38:47 PDT 2022


Author: Alex Brachet
Date: 2022-06-16T15:38:12Z
New Revision: f4f6adc451a2dc901c08c2fdac81ef2cf98a5cc6

URL: https://github.com/llvm/llvm-project/commit/f4f6adc451a2dc901c08c2fdac81ef2cf98a5cc6
DIFF: https://github.com/llvm/llvm-project/commit/f4f6adc451a2dc901c08c2fdac81ef2cf98a5cc6.diff

LOG: [clang] Don't emit IFUNC when targeting Fuchsia

Fuchsia's dynamic linker does not and will never support IFUNC's.

Differential revision: https://reviews.llvm.org/D127933

Added: 
    

Modified: 
    clang/include/clang/Basic/TargetInfo.h
    clang/test/CodeGen/attr-target-mv-va-args.c

Removed: 
    


################################################################################
diff  --git a/clang/include/clang/Basic/TargetInfo.h b/clang/include/clang/Basic/TargetInfo.h
index 5877123dab249..32a330a044c45 100644
--- a/clang/include/clang/Basic/TargetInfo.h
+++ b/clang/include/clang/Basic/TargetInfo.h
@@ -1355,7 +1355,9 @@ class TargetInfo : public virtual TransferrableTargetInfo,
   bool supportsMultiVersioning() const { return getTriple().isX86(); }
 
   /// Identify whether this target supports IFuncs.
-  bool supportsIFunc() const { return getTriple().isOSBinFormatELF(); }
+  bool supportsIFunc() const {
+    return getTriple().isOSBinFormatELF() && !getTriple().isOSFuchsia();
+  }
 
   // Validate the contents of the __builtin_cpu_supports(const char*)
   // argument.

diff  --git a/clang/test/CodeGen/attr-target-mv-va-args.c b/clang/test/CodeGen/attr-target-mv-va-args.c
index db3f4da079cfb..c51eaffcdde74 100644
--- a/clang/test/CodeGen/attr-target-mv-va-args.c
+++ b/clang/test/CodeGen/attr-target-mv-va-args.c
@@ -1,5 +1,6 @@
 // RUN: %clang_cc1 -no-opaque-pointers -triple x86_64-linux-gnu -emit-llvm %s -o - | FileCheck %s --check-prefix=LINUX
-// RUN: %clang_cc1 -no-opaque-pointers -triple x86_64-windows-pc -emit-llvm %s -o - | FileCheck %s --check-prefix=WINDOWS
+// RUN: %clang_cc1 -no-opaque-pointers -triple x86_64-windows-pc -emit-llvm %s -o - | FileCheck %s --check-prefixes=NO-IFUNC,WINDOWS
+// RUN: %clang_cc1 -no-opaque-pointers -triple x86_64-fuchsia -emit-llvm %s -o - | FileCheck %s --check-prefixes=NO-IFUNC,FUCHSIA
 int __attribute__((target("sse4.2"))) foo(int i, ...) { return 0; }
 int __attribute__((target("arch=sandybridge"))) foo(int i, ...);
 int __attribute__((target("arch=ivybridge"))) foo(int i, ...) {return 1;}
@@ -27,19 +28,21 @@ int bar(void) {
 // LINUX: ret i32 (i32, ...)* @foo
 // LINUX: declare i32 @foo.arch_sandybridge(i32 noundef, ...)
 
-// WINDOWS: define dso_local i32 @foo.sse4.2(i32 noundef %i, ...)
-// WINDOWS: ret i32 0
-// WINDOWS: define dso_local i32 @foo.arch_ivybridge(i32 noundef %i, ...)
-// WINDOWS: ret i32 1
-// WINDOWS: define dso_local i32 @foo(i32 noundef %i, ...)
-// WINDOWS: ret i32 2
-// WINDOWS: define dso_local i32 @bar()
-// WINDOWS: call i32 (i32, ...) @foo.resolver(i32 noundef 1, i32 noundef 97, double
-// WINDOWS: call i32 (i32, ...) @foo.resolver(i32 noundef 2, double noundef 2.2{{[0-9Ee+]+}}, i8* noundef getelementptr inbounds
+// NO-IFUNC: define dso_local i32 @foo.sse4.2(i32 noundef %i, ...)
+// NO-IFUNC: ret i32 0
+// NO-IFUNC: define dso_local i32 @foo.arch_ivybridge(i32 noundef %i, ...)
+// NO-IFUNC: ret i32 1
+// NO-IFUNC: define dso_local i32 @foo(i32 noundef %i, ...)
+// NO-IFUNC: ret i32 2
+// NO-IFUNC: define dso_local i32 @bar()
+// NO-IFUNC: call i32 (i32, ...) @foo.resolver(i32 noundef 1, i32 noundef 97, double
+// NO-IFUNC: call i32 (i32, ...) @foo.resolver(i32 noundef 2, double noundef 2.2{{[0-9Ee+]+}}, i8* noundef getelementptr inbounds
 
 // WINDOWS: define weak_odr dso_local i32 @foo.resolver(i32 %0, ...) comdat
-// WINDOWS: musttail call i32 (i32, ...) @foo.arch_sandybridge
-// WINDOWS: musttail call i32 (i32, ...) @foo.arch_ivybridge
-// WINDOWS: musttail call i32 (i32, ...) @foo.sse4.2
-// WINDOWS: musttail call i32 (i32, ...) @foo
+// FUCHSIA: define weak_odr i32 @foo.resolver(i32 %0, ...) comdat
+// NO-IFUNC: musttail call i32 (i32, ...) @foo.arch_sandybridge
+// NO-IFUNC: musttail call i32 (i32, ...) @foo.arch_ivybridge
+// NO-IFUNC: musttail call i32 (i32, ...) @foo.sse4.2
+// NO-IFUNC: musttail call i32 (i32, ...) @foo
 // WINDOWS: declare dso_local i32 @foo.arch_sandybridge(i32 noundef, ...)
+// FUCHSIA: declare i32 @foo.arch_sandybridge(i32 noundef, ...)


        


More information about the cfe-commits mailing list