[PATCH] D53850: Declares __cpu_model as hidden symbol
hhb updated this revision to Diff 171748. https://reviews.llvm.org/D53850 Files: lib/CodeGen/CGBuiltin.cpp test/CodeGen/builtin-cpu-is.c test/CodeGen/builtin-cpu-supports.c Index: test/CodeGen/builtin-cpu-supports.c === --- test/CodeGen/builtin-cpu-supports.c +++ test/CodeGen/builtin-cpu-supports.c @@ -4,6 +4,8 @@ // global, the bit grab, and the icmp correct. extern void a(const char *); +// CHECK: @__cpu_model = external hidden global { i32, i32, i32, [1 x i32] } + int main() { __builtin_cpu_init(); Index: test/CodeGen/builtin-cpu-is.c === --- test/CodeGen/builtin-cpu-is.c +++ test/CodeGen/builtin-cpu-is.c @@ -4,6 +4,8 @@ // global, the bit grab, and the icmp correct. extern void a(const char *); +// CHECK: @__cpu_model = external hidden global { i32, i32, i32, [1 x i32] } + void intel() { if (__builtin_cpu_is("intel")) a("intel"); Index: lib/CodeGen/CGBuiltin.cpp === --- lib/CodeGen/CGBuiltin.cpp +++ lib/CodeGen/CGBuiltin.cpp @@ -9016,6 +9016,8 @@ // Grab the global __cpu_model. llvm::Constant *CpuModel = CGM.CreateRuntimeVariable(STy, "__cpu_model"); + cast(CpuModel)->setVisibility( + llvm::GlobalValue::HiddenVisibility); // Calculate the index needed to access the correct field based on the // range. Also adjust the expected value. @@ -9082,6 +9084,8 @@ // Grab the global __cpu_model. llvm::Constant *CpuModel = CGM.CreateRuntimeVariable(STy, "__cpu_model"); + cast(CpuModel)->setVisibility( + llvm::GlobalValue::HiddenVisibility); // Grab the first (0th) element from the field __cpu_features off of the // global in the struct STy. Index: test/CodeGen/builtin-cpu-supports.c === --- test/CodeGen/builtin-cpu-supports.c +++ test/CodeGen/builtin-cpu-supports.c @@ -4,6 +4,8 @@ // global, the bit grab, and the icmp correct. extern void a(const char *); +// CHECK: @__cpu_model = external hidden global { i32, i32, i32, [1 x i32] } + int main() { __builtin_cpu_init(); Index: test/CodeGen/builtin-cpu-is.c === --- test/CodeGen/builtin-cpu-is.c +++ test/CodeGen/builtin-cpu-is.c @@ -4,6 +4,8 @@ // global, the bit grab, and the icmp correct. extern void a(const char *); +// CHECK: @__cpu_model = external hidden global { i32, i32, i32, [1 x i32] } + void intel() { if (__builtin_cpu_is("intel")) a("intel"); Index: lib/CodeGen/CGBuiltin.cpp === --- lib/CodeGen/CGBuiltin.cpp +++ lib/CodeGen/CGBuiltin.cpp @@ -9016,6 +9016,8 @@ // Grab the global __cpu_model. llvm::Constant *CpuModel = CGM.CreateRuntimeVariable(STy, "__cpu_model"); + cast(CpuModel)->setVisibility( + llvm::GlobalValue::HiddenVisibility); // Calculate the index needed to access the correct field based on the // range. Also adjust the expected value. @@ -9082,6 +9084,8 @@ // Grab the global __cpu_model. llvm::Constant *CpuModel = CGM.CreateRuntimeVariable(STy, "__cpu_model"); + cast(CpuModel)->setVisibility( + llvm::GlobalValue::HiddenVisibility); // Grab the first (0th) element from the field __cpu_features off of the // global in the struct STy. ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D53850: Declares __cpu_model as hidden symbol
hhb updated this revision to Diff 171787. hhb added a comment. Rebase. Change to SetDSOLocal. https://reviews.llvm.org/D53850 Files: lib/CodeGen/CGBuiltin.cpp test/CodeGen/builtin-cpu-is.c test/CodeGen/builtin-cpu-supports.c Index: test/CodeGen/builtin-cpu-supports.c === --- test/CodeGen/builtin-cpu-supports.c +++ test/CodeGen/builtin-cpu-supports.c @@ -4,6 +4,8 @@ // global, the bit grab, and the icmp correct. extern void a(const char *); +// CHECK: @__cpu_model = external hidden global { i32, i32, i32, [1 x i32] } + int main() { __builtin_cpu_init(); Index: test/CodeGen/builtin-cpu-is.c === --- test/CodeGen/builtin-cpu-is.c +++ test/CodeGen/builtin-cpu-is.c @@ -4,6 +4,8 @@ // global, the bit grab, and the icmp correct. extern void a(const char *); +// CHECK: @__cpu_model = external hidden global { i32, i32, i32, [1 x i32] } + void intel() { if (__builtin_cpu_is("intel")) a("intel"); Index: lib/CodeGen/CGBuiltin.cpp === --- lib/CodeGen/CGBuiltin.cpp +++ lib/CodeGen/CGBuiltin.cpp @@ -9016,6 +9016,8 @@ // Grab the global __cpu_model. llvm::Constant *CpuModel = CGM.CreateRuntimeVariable(STy, "__cpu_model"); + cast(CpuModel)->setVisibility( + llvm::GlobalValue::HiddenVisibility); // Calculate the index needed to access the correct field based on the // range. Also adjust the expected value. @@ -9082,6 +9084,8 @@ // Grab the global __cpu_model. llvm::Constant *CpuModel = CGM.CreateRuntimeVariable(STy, "__cpu_model"); + cast(CpuModel)->setVisibility( + llvm::GlobalValue::HiddenVisibility); // Grab the first (0th) element from the field __cpu_features off of the // global in the struct STy. Index: test/CodeGen/builtin-cpu-supports.c === --- test/CodeGen/builtin-cpu-supports.c +++ test/CodeGen/builtin-cpu-supports.c @@ -4,6 +4,8 @@ // global, the bit grab, and the icmp correct. extern void a(const char *); +// CHECK: @__cpu_model = external hidden global { i32, i32, i32, [1 x i32] } + int main() { __builtin_cpu_init(); Index: test/CodeGen/builtin-cpu-is.c === --- test/CodeGen/builtin-cpu-is.c +++ test/CodeGen/builtin-cpu-is.c @@ -4,6 +4,8 @@ // global, the bit grab, and the icmp correct. extern void a(const char *); +// CHECK: @__cpu_model = external hidden global { i32, i32, i32, [1 x i32] } + void intel() { if (__builtin_cpu_is("intel")) a("intel"); Index: lib/CodeGen/CGBuiltin.cpp === --- lib/CodeGen/CGBuiltin.cpp +++ lib/CodeGen/CGBuiltin.cpp @@ -9016,6 +9016,8 @@ // Grab the global __cpu_model. llvm::Constant *CpuModel = CGM.CreateRuntimeVariable(STy, "__cpu_model"); + cast(CpuModel)->setVisibility( + llvm::GlobalValue::HiddenVisibility); // Calculate the index needed to access the correct field based on the // range. Also adjust the expected value. @@ -9082,6 +9084,8 @@ // Grab the global __cpu_model. llvm::Constant *CpuModel = CGM.CreateRuntimeVariable(STy, "__cpu_model"); + cast(CpuModel)->setVisibility( + llvm::GlobalValue::HiddenVisibility); // Grab the first (0th) element from the field __cpu_features off of the // global in the struct STy. ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D53850: Declares __cpu_model as hidden symbol
hhb updated this revision to Diff 171789. https://reviews.llvm.org/D53850 Files: lib/CodeGen/CGBuiltin.cpp test/CodeGen/builtin-cpu-is.c test/CodeGen/builtin-cpu-supports.c Index: test/CodeGen/builtin-cpu-supports.c === --- test/CodeGen/builtin-cpu-supports.c +++ test/CodeGen/builtin-cpu-supports.c @@ -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 @@ return 0; } + +// CHECK: declare dso_local void @__cpu_indicator_init() Index: test/CodeGen/builtin-cpu-is.c === --- test/CodeGen/builtin-cpu-is.c +++ test/CodeGen/builtin-cpu-is.c @@ -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"); Index: lib/CodeGen/CGBuiltin.cpp === --- lib/CodeGen/CGBuiltin.cpp +++ lib/CodeGen/CGBuiltin.cpp @@ -9089,6 +9089,7 @@ // 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. @@ -9161,6 +9162,7 @@ // 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. @@ -9180,6 +9182,8 @@ if (Features2 != 0) { llvm::Constant *CpuFeatures2 = CGM.CreateRuntimeVariable(Int32Ty, "__cpu_features2"); +cast(CpuFeatures2)->setDSOLocal(true); + Value *Features = Builder.CreateAlignedLoad(CpuFeatures2, CharUnits::fromQuantity(4)); @@ -9197,6 +9201,7 @@ 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); } Index: test/CodeGen/builtin-cpu-supports.c === --- test/CodeGen/builtin-cpu-supports.c +++ test/CodeGen/builtin-cpu-supports.c @@ -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 @@ return 0; } + +// CHECK: declare dso_local void @__cpu_indicator_init() Index: test/CodeGen/builtin-cpu-is.c === --- test/CodeGen/builtin-cpu-is.c +++ test/CodeGen/builtin-cpu-is.c @@ -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"); Index: lib/CodeGen/CGBuiltin.cpp === --- lib/CodeGen/CGBuiltin.cpp +++ lib/CodeGen/CGBuiltin.cpp @@ -9089,6 +9089,7 @@ // 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. @@ -9161,6 +9162,7 @@ // 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. @@ -9180,6 +9182,8 @@ if (Features2 != 0) { llvm::Constant *CpuFeatures2 = CGM.CreateRuntimeVariable(Int32Ty, "__cpu_features2"); +cast(CpuFeatures2)->setDSOLocal(true); + Value *Features = Builder.CreateAlignedLoad(CpuFeatures2, CharUnits::fromQuantity(4)); @@ -9197,6 +9201,7 @@ 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); } __
[PATCH] D53850: Declares __cpu_model as dso local
hhb added inline comments. Comment at: lib/CodeGen/CGBuiltin.cpp:9013 Features, llvm::ConstantInt::get(Int32Ty, FeaturesMask)); return Builder.CreateICmpNE(Bitset, llvm::ConstantInt::get(Int32Ty, 0)); } craig.topper wrote: > This code looks to be out of date. It's missing the changes from r344832 that > added another runtime variable that presumably has the same issue. By the way, what is the reason for gcc to add a separate __cpu_feature2, but not adding an element to __cpu_model.__cpu_features array? https://reviews.llvm.org/D53850 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D53850: Declares __cpu_model as dso local
hhb added a comment. Ping.. Repository: rC Clang https://reviews.llvm.org/D53850 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D53850: Declares __cpu_model as dso local
hhb added a comment. Anyone can have a look at this change? Repository: rC Clang https://reviews.llvm.org/D53850 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D53850: Declares __cpu_model as dso local
This revision was automatically updated to reflect the committed changes. Closed by commit rL348978: Declares __cpu_model as dso local (authored by hhb, committed by ). Herald added a subscriber: llvm-commits. Changed prior to commit: https://reviews.llvm.org/D53850?vs=171789&id=177915#toc Repository: rL LLVM CHANGES SINCE LAST ACTION https://reviews.llvm.org/D53850/new/ https://reviews.llvm.org/D53850 Files: cfe/trunk/lib/CodeGen/CGBuiltin.cpp cfe/trunk/test/CodeGen/builtin-cpu-is.c cfe/trunk/test/CodeGen/builtin-cpu-supports.c Index: cfe/trunk/test/CodeGen/builtin-cpu-is.c === --- cfe/trunk/test/CodeGen/builtin-cpu-is.c +++ cfe/trunk/test/CodeGen/builtin-cpu-is.c @@ -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"); Index: cfe/trunk/test/CodeGen/builtin-cpu-supports.c === --- cfe/trunk/test/CodeGen/builtin-cpu-supports.c +++ cfe/trunk/test/CodeGen/builtin-cpu-supports.c @@ -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 @@ return 0; } + +// CHECK: declare dso_local void @__cpu_indicator_init() Index: cfe/trunk/lib/CodeGen/CGBuiltin.cpp === --- cfe/trunk/lib/CodeGen/CGBuiltin.cpp +++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp @@ -9465,6 +9465,7 @@ // 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. @@ -9537,6 +9538,7 @@ // 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. @@ -9556,6 +9558,8 @@ if (Features2 != 0) { llvm::Constant *CpuFeatures2 = CGM.CreateRuntimeVariable(Int32Ty, "__cpu_features2"); +cast(CpuFeatures2)->setDSOLocal(true); + Value *Features = Builder.CreateAlignedLoad(CpuFeatures2, CharUnits::fromQuantity(4)); @@ -9573,6 +9577,7 @@ 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); } Index: cfe/trunk/test/CodeGen/builtin-cpu-is.c === --- cfe/trunk/test/CodeGen/builtin-cpu-is.c +++ cfe/trunk/test/CodeGen/builtin-cpu-is.c @@ -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"); Index: cfe/trunk/test/CodeGen/builtin-cpu-supports.c === --- cfe/trunk/test/CodeGen/builtin-cpu-supports.c +++ cfe/trunk/test/CodeGen/builtin-cpu-supports.c @@ -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 @@ return 0; } + +// CHECK: declare dso_local void @__cpu_indicator_init() Index: cfe/trunk/lib/CodeGen/CGBuiltin.cpp === --- cfe/trunk/lib/CodeGen/CGBuiltin.cpp +++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp @@ -9465,6 +9465,7 @@ // 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. @@ -9537,6 +9538,7 @@ // 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. @@ -9556,6 +9558,8 @@ if (Features2 != 0) { llvm::Constant *CpuFeatures2 = CGM.CreateRuntimeVariable(Int32Ty,