File tree Expand file tree Collapse file tree 2 files changed +20
-7
lines changed Expand file tree Collapse file tree 2 files changed +20
-7
lines changed Original file line number Diff line number Diff line change @@ -603,15 +603,16 @@ Value *IRLinker::materialize(Value *V, bool ForIndirectSymbol) {
603
603
return New;
604
604
}
605
605
606
- // When linking a global for an indirect symbol, it will always be linked.
607
- // However we need to check if it was not already scheduled to satisfy a
608
- // reference from a regular global value initializer. We know if it has been
609
- // schedule if the "New" GlobalValue that is mapped here for the indirect
610
- // symbol is the same as the one already mapped. If there is an entry in the
606
+ // If the global is being linked for an indirect symbol, it may have already
607
+ // been scheduled to satisfy a regular symbol. Similarly, a global being linked
608
+ // for a regular symbol may have already been scheduled for an indirect
609
+ // symbol. Check for these cases by looking in the other value map and
610
+ // confirming the same value has been scheduled. If there is an entry in the
611
611
// ValueMap but the value is different, it means that the value already had a
612
612
// definition in the destination module (linkonce for instance), but we need a
613
- // new definition for the indirect symbol ("New" will be different.
614
- if (ForIndirectSymbol && ValueMap.lookup (SGV) == New)
613
+ // new definition for the indirect symbol ("New" will be different).
614
+ if ((ForIndirectSymbol && ValueMap.lookup (SGV) == New) ||
615
+ (!ForIndirectSymbol && IndirectSymbolValueMap.lookup (SGV) == New))
615
616
return New;
616
617
617
618
if (ForIndirectSymbol || shouldLink (New, *SGV))
Original file line number Diff line number Diff line change
1
+ ; RUN: llvm-link %s -S -o - | FileCheck %s
2
+ target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
3
+ target triple = "x86_64-apple-macosx10.9"
4
+
5
+ ; CHECK-DAG: @gv0 = constant i64* @alias
6
+ ; CHECK-DAG: @gv1 = constant i64 ptrtoint (i64* @gv1 to i64)
7
+ ; CHECK-DAG: @alias = alias i64, i64* @gv1
8
+
9
+ @gv0 = constant i64* @alias
10
+ @gv1 = constant i64 ptrtoint (i64* @gv1 to i64 )
11
+
12
+ @alias = alias i64 , i64* @gv1
You can’t perform that action at this time.
0 commit comments