]> granicus.if.org Git - llvm/commitdiff
[GlobalMerge] Don't merge globals that may be preempted
authorJohn Brawn <john.brawn@arm.com>
Fri, 2 Jun 2017 10:24:14 +0000 (10:24 +0000)
committerJohn Brawn <john.brawn@arm.com>
Fri, 2 Jun 2017 10:24:14 +0000 (10:24 +0000)
When a global may be preempted it needs to be accessed directly, instead of
indirectly through a MergedGlobals symbol, for the preemption to work.

This fixes PR33136.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@304537 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/GlobalMerge.cpp
test/CodeGen/ARM/global-merge-external.ll

index 23812a2a2344d5634bea578e3f83ddf950759db5..3603f9b7ed930ebf600087347e9227b7b79ce330 100644 (file)
@@ -556,6 +556,10 @@ bool GlobalMerge::doInitialization(Module &M) {
     if (GV.isDeclaration() || GV.isThreadLocal() || GV.hasSection())
       continue;
 
+    // It's not safe to merge globals that may be preempted
+    if (TM && !TM->shouldAssumeDSOLocal(M, &GV))
+      continue;
+
     if (!(MergeExternalGlobals && GV.hasExternalLinkage()) &&
         !GV.hasInternalLinkage())
       continue;
index a9e0d199705a8b094b5bd39675c5c4ac6dbbe0be..03c977614320f3050a3a7b862a52caab8404665d 100644 (file)
@@ -2,6 +2,7 @@
 ; RUN: llc < %s -mtriple=arm-eabi  -arm-global-merge -global-merge-on-external=true  | FileCheck %s --check-prefix=CHECK-MERGE
 ; RUN: llc < %s -mtriple=arm-eabi  -arm-global-merge -global-merge-on-external=false | FileCheck %s --check-prefix=CHECK-NO-MERGE
 ; RUN: llc < %s -mtriple=arm-macho -arm-global-merge                                 | FileCheck %s --check-prefix=CHECK-NO-MERGE
+; RUN: llc < %s -mtriple=arm-eabi  -arm-global-merge -relocation-model=pic           | FileCheck %s --check-prefix=CHECK-NO-MERGE
 
 @x = global i32 0, align 4
 @y = global i32 0, align 4