r348982 - Revert "Declares __cpu_model as dso local"

2018-12-12 Thread Haibo Huang via cfe-commits
Author: hhb
Date: Wed Dec 12 14:39:51 2018
New Revision: 348982

URL: http://llvm.org/viewvc/llvm-project?rev=348982&view=rev
Log:
Revert "Declares __cpu_model as dso local"

This reverts r348978


Modified:
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/test/CodeGen/builtin-cpu-is.c
cfe/trunk/test/CodeGen/builtin-cpu-supports.c

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=348982&r1=348981&r2=348982&view=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Wed Dec 12 14:39:51 2018
@@ -9465,7 +9465,6 @@ Value *CodeGenFunction::EmitX86CpuIs(Str
 
   // Grab the global __cpu_model.
   llvm::Constant *CpuModel = CGM.CreateRuntimeVariable(STy, "__cpu_model");
-  cast(CpuModel)->setDSOLocal(true);
 
   // Calculate the index needed to access the correct field based on the
   // range. Also adjust the expected value.
@@ -9538,7 +9537,6 @@ llvm::Value *CodeGenFunction::EmitX86Cpu
 
 // Grab the global __cpu_model.
 llvm::Constant *CpuModel = CGM.CreateRuntimeVariable(STy, "__cpu_model");
-cast(CpuModel)->setDSOLocal(true);
 
 // Grab the first (0th) element from the field __cpu_features off of the
 // global in the struct STy.
@@ -9558,8 +9556,6 @@ llvm::Value *CodeGenFunction::EmitX86Cpu
   if (Features2 != 0) {
 llvm::Constant *CpuFeatures2 = CGM.CreateRuntimeVariable(Int32Ty,
  
"__cpu_features2");
-cast(CpuFeatures2)->setDSOLocal(true);
-
 Value *Features =
 Builder.CreateAlignedLoad(CpuFeatures2, CharUnits::fromQuantity(4));
 
@@ -9577,7 +9573,6 @@ Value *CodeGenFunction::EmitX86CpuInit()
   llvm::FunctionType *FTy = llvm::FunctionType::get(VoidTy,
 /*Variadic*/ false);
   llvm::Constant *Func = CGM.CreateRuntimeFunction(FTy, 
"__cpu_indicator_init");
-  cast(Func)->setDSOLocal(true);
   return Builder.CreateCall(Func);
 }
 

Modified: cfe/trunk/test/CodeGen/builtin-cpu-is.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/builtin-cpu-is.c?rev=348982&r1=348981&r2=348982&view=diff
==
--- cfe/trunk/test/CodeGen/builtin-cpu-is.c (original)
+++ cfe/trunk/test/CodeGen/builtin-cpu-is.c Wed Dec 12 14:39:51 2018
@@ -4,8 +4,6 @@
 // global, the bit grab, and the icmp correct.
 extern void a(const char *);
 
-// CHECK: @__cpu_model = external dso_local global { i32, i32, i32, [1 x i32] }
-
 void intel() {
   if (__builtin_cpu_is("intel"))
 a("intel");

Modified: cfe/trunk/test/CodeGen/builtin-cpu-supports.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/builtin-cpu-supports.c?rev=348982&r1=348981&r2=348982&view=diff
==
--- cfe/trunk/test/CodeGen/builtin-cpu-supports.c (original)
+++ cfe/trunk/test/CodeGen/builtin-cpu-supports.c Wed Dec 12 14:39:51 2018
@@ -4,9 +4,6 @@
 // global, the bit grab, and the icmp correct.
 extern void a(const char *);
 
-// CHECK: @__cpu_model = external dso_local global { i32, i32, i32, [1 x i32] }
-// CHECK: @__cpu_features2 = external dso_local global i32
-
 int main() {
   __builtin_cpu_init();
 
@@ -28,5 +25,3 @@ int main() {
 
   return 0;
 }
-
-// CHECK: declare dso_local void @__cpu_indicator_init()


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


r349825 - Declares __cpu_model as dso local

2018-12-20 Thread Haibo Huang via cfe-commits
Author: hhb
Date: Thu Dec 20 13:33:59 2018
New Revision: 349825

URL: http://llvm.org/viewvc/llvm-project?rev=349825&view=rev
Log:
Declares __cpu_model as dso local

__builtin_cpu_supports and __builtin_cpu_is use information in __cpu_model to 
decide cpu features. Before this change, __cpu_model was not declared as dso 
local. The generated code looks up the address in GOT when reading __cpu_model. 
This makes it impossible to use these functions in ifunc, because at that time 
GOT entries have not been relocated. This change makes it dso local.

Differential Revision: https://reviews.llvm.org/D53850


Modified:
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/test/CodeGen/builtin-cpu-is.c
cfe/trunk/test/CodeGen/builtin-cpu-supports.c

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=349825&r1=349824&r2=349825&view=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Thu Dec 20 13:33:59 2018
@@ -9537,6 +9537,7 @@ Value *CodeGenFunction::EmitX86CpuIs(Str
 
   // Grab the global __cpu_model.
   llvm::Constant *CpuModel = CGM.CreateRuntimeVariable(STy, "__cpu_model");
+  cast(CpuModel)->setDSOLocal(true);
 
   // Calculate the index needed to access the correct field based on the
   // range. Also adjust the expected value.
@@ -9609,6 +9610,7 @@ llvm::Value *CodeGenFunction::EmitX86Cpu
 
 // Grab the global __cpu_model.
 llvm::Constant *CpuModel = CGM.CreateRuntimeVariable(STy, "__cpu_model");
+cast(CpuModel)->setDSOLocal(true);
 
 // Grab the first (0th) element from the field __cpu_features off of the
 // global in the struct STy.
@@ -9628,6 +9630,8 @@ llvm::Value *CodeGenFunction::EmitX86Cpu
   if (Features2 != 0) {
 llvm::Constant *CpuFeatures2 = CGM.CreateRuntimeVariable(Int32Ty,
  
"__cpu_features2");
+cast(CpuFeatures2)->setDSOLocal(true);
+
 Value *Features =
 Builder.CreateAlignedLoad(CpuFeatures2, CharUnits::fromQuantity(4));
 
@@ -9645,6 +9649,9 @@ Value *CodeGenFunction::EmitX86CpuInit()
   llvm::FunctionType *FTy = llvm::FunctionType::get(VoidTy,
 /*Variadic*/ false);
   llvm::Constant *Func = CGM.CreateRuntimeFunction(FTy, 
"__cpu_indicator_init");
+  cast(Func)->setDSOLocal(true);
+  cast(Func)->setDLLStorageClass(
+  llvm::GlobalValue::DefaultStorageClass);
   return Builder.CreateCall(Func);
 }
 

Modified: cfe/trunk/test/CodeGen/builtin-cpu-is.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/builtin-cpu-is.c?rev=349825&r1=349824&r2=349825&view=diff
==
--- cfe/trunk/test/CodeGen/builtin-cpu-is.c (original)
+++ cfe/trunk/test/CodeGen/builtin-cpu-is.c Thu Dec 20 13:33:59 2018
@@ -4,6 +4,8 @@
 // global, the bit grab, and the icmp correct.
 extern void a(const char *);
 
+// CHECK: @__cpu_model = external dso_local global { i32, i32, i32, [1 x i32] }
+
 void intel() {
   if (__builtin_cpu_is("intel"))
 a("intel");

Modified: cfe/trunk/test/CodeGen/builtin-cpu-supports.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/builtin-cpu-supports.c?rev=349825&r1=349824&r2=349825&view=diff
==
--- cfe/trunk/test/CodeGen/builtin-cpu-supports.c (original)
+++ cfe/trunk/test/CodeGen/builtin-cpu-supports.c Thu Dec 20 13:33:59 2018
@@ -4,6 +4,9 @@
 // global, the bit grab, and the icmp correct.
 extern void a(const char *);
 
+// CHECK: @__cpu_model = external dso_local global { i32, i32, i32, [1 x i32] }
+// CHECK: @__cpu_features2 = external dso_local global i32
+
 int main() {
   __builtin_cpu_init();
 
@@ -25,3 +28,5 @@ int main() {
 
   return 0;
 }
+
+// CHECK: declare dso_local void @__cpu_indicator_init()


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