llvm.org GIT mirror llvm / f31f603
IRLinker: fix double scheduling of mapping a global value because of an alias This test was hitting an assertion in the value mapper because the IRLinker was trying to map two times @A while materializing the initializer for @C. Fix http://llvm.org/PR27850 Differential Revision: http://reviews.llvm.org/D20586 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270757 91177308-0d34-0410-b5e6-96231b3b80d8 Mehdi Amini 3 years ago
2 changed file(s) with 24 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
556556 return;
557557 }
558558
559 // When linking a global for an alias, it will always be linked. However we
560 // need to check if it was not already scheduled to satify a reference from a
561 // regular global value initializer. We know if it has been schedule if the
562 // "New" GlobalValue that is mapped here for the alias is the same as the one
563 // already mapped. If there is an entry in the ValueMap but the value is
564 // different, it means that the value already had a definition in the
565 // destination module (linkonce for instance), but we need a new definition
566 // for the alias ("New" will be different.
567 if (ForAlias && ValueMap.lookup(Old) == New)
568 return;
569
559570 if (ForAlias || shouldLink(New, *Old))
560571 linkGlobalValueBody(*New, *Old);
561572 }
0 ; RUN: llvm-link %s -S -o - | FileCheck %s
1 target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
2 target triple = "x86_64-apple-macosx10.9"
3
4 ; CHECK-DAG: @A = internal constant i8 1
5 ; CHECK-DAG: @B = alias i8, i8* @A
6 ; CHECK-DAG: @C = global [2 x i8*] [i8* @A, i8* @B]
7
8 @A = internal constant i8 1
9 @B = alias i8, i8* @A
10 @C = global [2 x i8*] [i8* @A, i8* @B]
11
12