diff options
author | John Brawn <john.brawn@arm.com> | 2017-06-02 10:24:14 +0000 |
---|---|---|
committer | John Brawn <john.brawn@arm.com> | 2017-06-02 10:24:14 +0000 |
commit | 0f1cadd92008a2671cae9b8ef0890007dc923f39 (patch) | |
tree | 56083d0818d0c3990ae83f810947e0a8f1246952 | |
parent | 899f9e9ab67a90feb86473064f17d396d0409f94 (diff) |
[GlobalMerge] Don't merge globals that may be preempted
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
-rw-r--r-- | lib/CodeGen/GlobalMerge.cpp | 4 | ||||
-rw-r--r-- | test/CodeGen/ARM/global-merge-external.ll | 1 |
2 files changed, 5 insertions, 0 deletions
diff --git a/lib/CodeGen/GlobalMerge.cpp b/lib/CodeGen/GlobalMerge.cpp index 23812a2a234..3603f9b7ed9 100644 --- a/lib/CodeGen/GlobalMerge.cpp +++ b/lib/CodeGen/GlobalMerge.cpp @@ -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; diff --git a/test/CodeGen/ARM/global-merge-external.ll b/test/CodeGen/ARM/global-merge-external.ll index a9e0d199705..03c97761432 100644 --- a/test/CodeGen/ARM/global-merge-external.ll +++ b/test/CodeGen/ARM/global-merge-external.ll @@ -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 |