Skip to content
This repository has been archived by the owner on Feb 21, 2019. It is now read-only.

Commit

Permalink
Fixed a private/internal symbool issue. Repo uses the MM_None mangling
Browse files Browse the repository at this point in the history
mode type and has an empty private global prefix.
  • Loading branch information
MaggieYingYi committed Jan 3, 2018
1 parent f671425 commit 9665035
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 14 deletions.
5 changes: 5 additions & 0 deletions lib/IR/DataLayout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,8 @@ const char *DataLayout::getManglingComponent(const Triple &T) {
return "-m:o";
if (T.isOSWindows() && T.isOSBinFormatCOFF())
return T.getArch() == Triple::x86 ? "-m:x" : "-m:w";
if (T.isOSBinFormatRepo())
return "-m:r";
return "-m:e";
}

Expand Down Expand Up @@ -389,6 +391,9 @@ void DataLayout::parseSpecifier(StringRef Desc) {
case 'x':
ManglingMode = MM_WinCOFFX86;
break;
case 'r':
ManglingMode = MM_None;
break;
}
break;
default:
Expand Down
4 changes: 2 additions & 2 deletions lib/MC/MCAsmInfoRepo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ using namespace llvm;
void MCAsmInfoRepo::anchor() {}

MCAsmInfoRepo::MCAsmInfoRepo() {
// Repo uses the MM_ELF mangling mode type.
// Repo uses the MM_None mangling mode type.
HasIdentDirective = false;
WeakRefDirective = "\t.weak\t";
PrivateGlobalPrefix = ".L";
PrivateGlobalPrefix = "";
PrivateLabelPrefix = ".L";
HasDotTypeDotSizeDirective = false;
}
2 changes: 1 addition & 1 deletion lib/MC/RepoObjectWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ StringRef RepoObjectWriter::getSymbolName(const MCAssembler &Asm,

SmallString<256> Buf;
const StringRef NameRef =
(Twine(Asm.getContext().getAsmInfo()->getPrivateLabelPrefix()) +
(Twine(Asm.getContext().getAsmInfo()->getPrivateGlobalPrefix()) +
Twine(TicketMember.getNameAsString()))
.toStringRef(Buf);

Expand Down
7 changes: 7 additions & 0 deletions test/Feature/repo_common.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
target triple = "x86_64-pc-linux-gnu-repo"

@.str = private unnamed_addr constant [13 x i8] c"Hello World\0A\00", align 1, !repo_ticket !0

!repo.tickets = !{!0}

!0 = !TicketNode(name: ".str", digest: [16 x i8] c"\FE\15n\B4!\B1\FC{(\E5^>\E5\E2\F5\00", linkage: private)
25 changes: 14 additions & 11 deletions test/Feature/repo_symbol_with_prefix.ll
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
; RUN: llc -filetype=obj %S/repo_common.ll -o /dev/null 2>&1
; RUN: llc -filetype=obj -debug-only repo-object %s -o /dev/null 2>&1 | FileCheck %s

; REQUIRES: asserts
Expand All @@ -6,24 +7,26 @@ source_filename = "test.c"
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu-repo"

@.str = private unnamed_addr constant [13 x i8] c"Hello World\0A\00", align 1, !repo_ticket !0
@.str = external unnamed_addr constant [13 x i8] , align 1, !repo_ticket !0
@.str.1 = private unnamed_addr constant [13 x i8] c"Hello World\0A\00", align 1, !repo_ticket !1

; Function Attrs: noinline nounwind optnone uwtable
define i32 @main() !repo_ticket !1 {

define i32 @main() !repo_ticket !2 {
entry:
%call = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i32 0, i32 0))
%call1 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i32 0, i32 0))
ret i32 0
}

declare i32 @printf(i8*, ...)

!repo.tickets = !{!0, !1, !2}

!repo.tickets = !{!0, !1}

!0 = !TicketNode(name: ".str", digest: [16 x i8] c"v\C6>J]\C8h\C1\0F\C1\D2\F3\A7\9C5O", linkage: private)
!1 = !TicketNode(name: "main", digest: [16 x i8] c"\1F8bZ\ED\DB\85O\7F@\15\DA\C7\C6\0Cc", linkage: external)


;CHECK: ticket name '.L.str' digest '4f359ca7f3d2c10fc168c85d4a3ec676' adding.
;CHECK: ticket name 'main' digest '630cc6c7da15407f4f85dbed5a62381f' adding.
!0 = !TicketNode(name: ".str", digest: [16 x i8] c"\FE\15n\B4!\B1\FC{(\E5^>\E5\E2\F5\00", linkage: private)
!1 = !TicketNode(name: ".str.1", digest: [16 x i8] c"\FE\15n\B4!\B1\FC{(\E5^>\E5\E2\F5\00", linkage: private)
!2 = !TicketNode(name: "main", digest: [16 x i8] c"|!wp\FB\AE\8F\D0\CE\D3\1AO\E4\17\A3\C2", linkage: external)

;CHECK: insert name: .str
;CHECK: insert name: .str.1
;CHECK-NOT: insert name: .L.str
;CHECK-NOT: insert name: .L.str.1

0 comments on commit 9665035

Please sign in to comment.