]> granicus.if.org Git - clang/commitdiff
Make global named registers internal variables
authorRenato Golin <renato.golin@linaro.org>
Wed, 21 May 2014 10:40:27 +0000 (10:40 +0000)
committerRenato Golin <renato.golin@linaro.org>
Wed, 21 May 2014 10:40:27 +0000 (10:40 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@209289 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/ASTContext.cpp
test/CodeGen/named_reg_global.c

index fe735dc92fc99db95ce429078183f46142b7069d..99547f817582edd3453e1f8bae1654ea3b96ec5a 100644 (file)
@@ -7874,6 +7874,9 @@ bool ASTContext::DeclMustBeEmitted(const Decl *D) {
   if (const VarDecl *VD = dyn_cast<VarDecl>(D)) {
     if (!VD->isFileVarDecl())
       return false;
+    // Global named register variables (GNU extension) are never emitted.
+    if (VD->getStorageClass() == SC_Register)
+      return false;
   } else if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
     // We never need to emit an uninstantiated function template.
     if (FD->getTemplatedKind() == FunctionDecl::TK_FunctionTemplate)
index a1ee40c6f737336a9166391bc5702db04c4a05a9..20f8b328c2d1850719df5b70f386d651d0620160 100644 (file)
@@ -3,6 +3,7 @@
 // RUN: %clang_cc1 -triple arm64-linux-gnu -S -emit-llvm %s -o - | FileCheck %s
 // RUN: %clang_cc1 -triple armv7-linux-gnu -S -emit-llvm %s -o - | FileCheck %s
 
+// CHECK-NOT: @sp = common global
 register unsigned long current_stack_pointer asm("sp");
 
 // CHECK: define{{.*}} i[[bits:[0-9]+]] @get_stack_pointer_addr()