llvm.org GIT mirror llvm / 7166565
[asan] Upgrade private linkage globals to internal linkage on COFF COFF comdats require symbol table entries, which means the comdat leader cannot have private linkage. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@317009 91177308-0d34-0410-b5e6-96231b3b80d8 Reid Kleckner 1 year, 11 months ago
2 changed file(s) with 16 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
17631763 C = M.getOrInsertComdat(G->getName());
17641764 }
17651765
1766 // Make this IMAGE_COMDAT_SELECT_NODUPLICATES on COFF.
1767 if (TargetTriple.isOSBinFormatCOFF())
1766 // Make this IMAGE_COMDAT_SELECT_NODUPLICATES on COFF. Also upgrade private
1767 // linkage to internal linkage so that a symbol table entry is emitted. This
1768 // is necessary in order to create the comdat group.
1769 if (TargetTriple.isOSBinFormatCOFF()) {
17681770 C->setSelectionKind(Comdat::NoDuplicates);
1771 if (G->hasPrivateLinkage())
1772 G->setLinkage(GlobalValue::InternalLinkage);
1773 }
17691774 G->setComdat(C);
17701775 }
17711776
1111 $mystr = comdat any
1212
1313 ; CHECK: $dead_global = comdat noduplicates
14 ; CHECK: $private_str = comdat noduplicates
15
1416 ; CHECK: @dead_global = local_unnamed_addr global { i32, [60 x i8] } { i32 42, [60 x i8] zeroinitializer }, comdat, align 32
17 ; CHECK: @private_str = internal unnamed_addr constant { [8 x i8], [56 x i8] } { [8 x i8] c"private\00", [56 x i8] zeroinitializer }, comdat, align 32
18
1519 ; CHECK: @__asan_global_dead_global = private global { {{.*}} }, section ".ASAN$GL", comdat($dead_global), align 64
20 ; CHECK: @__asan_global_private_str = private global { {{.*}} }, section ".ASAN$GL", comdat($private_str), align 64
1621
1722 @dead_global = local_unnamed_addr global i32 42, align 4
1823 @mystr = linkonce_odr unnamed_addr constant [5 x i8] c"main\00", comdat, align 1
24
25 ; Private globals will get upgraded to internal linkage.
26 @private_str = private unnamed_addr constant [8 x i8] c"private\00", align 1
1927
2028 ; Function Attrs: nounwind uwtable
2129 define i32 @main() local_unnamed_addr #0 {
2230 entry:
2331 %call = tail call i32 @puts(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @mystr, i64 0, i64 0))
32 %call2 = tail call i32 @puts(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @private_str, i64 0, i64 0))
2433 ret i32 0
2534 }
2635