Skip to content

Commit

Permalink
[GlobalMerge] Don't merge globals that may be preempted
Browse files Browse the repository at this point in the history
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
  • Loading branch information
john-brawn-arm committed Jun 2, 2017
1 parent 899f9e9 commit 0f1cadd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/CodeGen/GlobalMerge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions test/CodeGen/ARM/global-merge-external.ll
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 0f1cadd

Please sign in to comment.