forked from OSchip/llvm-project
				
			Hide the stub created for MO_ExternalSymbol too.
given
declare void @llvm.memset.p0i8.i32(i8* nocapture, i8, i32, i32, i1)
declare void @foo()
define void @bar() {
  call void @foo()
  call void @llvm.memset.p0i8.i32(i8* null, i8 0, i32 188, i32 1, i1 false)
  ret void
}
We used to produce
L_foo$stub:
        .indirect_symbol        _foo
        .ascii  "\364\364\364\364\364"
_memset$stub:
        .indirect_symbol        _memset
        .ascii  "\364\364\364\364\364"
We not produce a private stub for memset too.
Stubs are not needed with recent linkers, but we still produce them for darwin8.
Thanks to David Fang for confirming that gcc used to do this too.
llvm-svn: 196468
			
			
This commit is contained in:
		
							parent
							
								
									89cc49fe5d
								
							
						
					
					
						commit
						01d19d0299
					
				| 
						 | 
					@ -90,18 +90,25 @@ GetSymbolFromOperand(const MachineOperand &MO) const {
 | 
				
			||||||
    break;
 | 
					    break;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  if (!Suffix.empty())
 | 
				
			||||||
 | 
					    Name += MAI.getPrivateGlobalPrefix();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  unsigned PrefixLen = Name.size();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (MO.isGlobal()) {
 | 
					  if (MO.isGlobal()) {
 | 
				
			||||||
    const GlobalValue *GV = MO.getGlobal();
 | 
					    const GlobalValue *GV = MO.getGlobal();
 | 
				
			||||||
    bool isImplicitlyPrivate = !Suffix.empty();
 | 
					    getMang()->getNameWithPrefix(Name, GV, false);
 | 
				
			||||||
    getMang()->getNameWithPrefix(Name, GV, isImplicitlyPrivate);
 | 
					 | 
				
			||||||
  } else if (MO.isSymbol()) {
 | 
					  } else if (MO.isSymbol()) {
 | 
				
			||||||
    getMang()->getNameWithPrefix(Name, MO.getSymbolName());
 | 
					    getMang()->getNameWithPrefix(Name, MO.getSymbolName());
 | 
				
			||||||
  } else if (MO.isMBB()) {
 | 
					  } else if (MO.isMBB()) {
 | 
				
			||||||
    Name += MO.getMBB()->getSymbol()->getName();
 | 
					    Name += MO.getMBB()->getSymbol()->getName();
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					  unsigned OrigLen = Name.size() - PrefixLen;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  Name += Suffix;
 | 
					  Name += Suffix;
 | 
				
			||||||
  MCSymbol *Sym = Ctx.GetOrCreateSymbol(Name.str());
 | 
					  MCSymbol *Sym = Ctx.GetOrCreateSymbol(Name);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  StringRef OrigName = StringRef(Name).substr(PrefixLen, OrigLen);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // If the target flags on the operand changes the name of the symbol, do that
 | 
					  // If the target flags on the operand changes the name of the symbol, do that
 | 
				
			||||||
  // before we return the symbol.
 | 
					  // before we return the symbol.
 | 
				
			||||||
| 
						 | 
					@ -144,10 +151,9 @@ GetSymbolFromOperand(const MachineOperand &MO) const {
 | 
				
			||||||
        StubValueTy(AsmPrinter.getSymbol(MO.getGlobal()),
 | 
					        StubValueTy(AsmPrinter.getSymbol(MO.getGlobal()),
 | 
				
			||||||
                    !MO.getGlobal()->hasInternalLinkage());
 | 
					                    !MO.getGlobal()->hasInternalLinkage());
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
      Name.erase(Name.end()-5, Name.end());
 | 
					 | 
				
			||||||
      StubSym =
 | 
					      StubSym =
 | 
				
			||||||
        MachineModuleInfoImpl::
 | 
					        MachineModuleInfoImpl::
 | 
				
			||||||
        StubValueTy(Ctx.GetOrCreateSymbol(Name.str()), false);
 | 
					        StubValueTy(Ctx.GetOrCreateSymbol(OrigName), false);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    break;
 | 
					    break;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -5,7 +5,7 @@ declare void @llvm.memset.i32(i8*, i8, i32, i32) nounwind
 | 
				
			||||||
define fastcc void @t1() nounwind {
 | 
					define fastcc void @t1() nounwind {
 | 
				
			||||||
entry:
 | 
					entry:
 | 
				
			||||||
; CHECK-LABEL: t1:
 | 
					; CHECK-LABEL: t1:
 | 
				
			||||||
; CHECK: calll _memset
 | 
					; CHECK: calll L_memset$stub
 | 
				
			||||||
  call void @llvm.memset.p0i8.i32(i8* null, i8 0, i32 188, i32 1, i1 false)
 | 
					  call void @llvm.memset.p0i8.i32(i8* null, i8 0, i32 188, i32 1, i1 false)
 | 
				
			||||||
  unreachable
 | 
					  unreachable
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -13,7 +13,7 @@ entry:
 | 
				
			||||||
define fastcc void @t2(i8 signext %c) nounwind {
 | 
					define fastcc void @t2(i8 signext %c) nounwind {
 | 
				
			||||||
entry:
 | 
					entry:
 | 
				
			||||||
; CHECK-LABEL: t2:
 | 
					; CHECK-LABEL: t2:
 | 
				
			||||||
; CHECK: calll _memset
 | 
					; CHECK: calll L_memset$stub
 | 
				
			||||||
  call void @llvm.memset.p0i8.i32(i8* undef, i8 %c, i32 76, i32 1, i1 false)
 | 
					  call void @llvm.memset.p0i8.i32(i8* undef, i8 %c, i32 76, i32 1, i1 false)
 | 
				
			||||||
  unreachable
 | 
					  unreachable
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -8,7 +8,7 @@
 | 
				
			||||||
define double @foo(double %a) nounwind readonly ssp {
 | 
					define double @foo(double %a) nounwind readonly ssp {
 | 
				
			||||||
entry:
 | 
					entry:
 | 
				
			||||||
; X32-LABEL: foo:
 | 
					; X32-LABEL: foo:
 | 
				
			||||||
; X32: jmp _sin$stub
 | 
					; X32: jmp L_sin$stub
 | 
				
			||||||
 | 
					
 | 
				
			||||||
; X64-LABEL: foo:
 | 
					; X64-LABEL: foo:
 | 
				
			||||||
; X64: jmp _sin
 | 
					; X64: jmp _sin
 | 
				
			||||||
| 
						 | 
					@ -18,7 +18,7 @@ entry:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
define float @bar(float %a) nounwind readonly ssp {
 | 
					define float @bar(float %a) nounwind readonly ssp {
 | 
				
			||||||
; X32-LABEL: bar:
 | 
					; X32-LABEL: bar:
 | 
				
			||||||
; X32: jmp _sinf$stub
 | 
					; X32: jmp L_sinf$stub
 | 
				
			||||||
 | 
					
 | 
				
			||||||
; X64-LABEL: bar:
 | 
					; X64-LABEL: bar:
 | 
				
			||||||
; X64: jmp _sinf
 | 
					; X64: jmp _sinf
 | 
				
			||||||
| 
						 | 
					@ -27,9 +27,9 @@ entry:
 | 
				
			||||||
  ret float %0
 | 
					  ret float %0
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
; X32-LABEL: _sin$stub:
 | 
					; X32-LABEL: L_sin$stub:
 | 
				
			||||||
; X32-NEXT:   .indirect_symbol        _sin
 | 
					; X32-NEXT:   .indirect_symbol        _sin
 | 
				
			||||||
; X32-LABEL: _sinf$stub:
 | 
					; X32-LABEL: L_sinf$stub:
 | 
				
			||||||
; X32-NEXT:   .indirect_symbol        _sinf
 | 
					; X32-NEXT:   .indirect_symbol        _sinf
 | 
				
			||||||
 | 
					
 | 
				
			||||||
declare float @sinf(float) nounwind readonly
 | 
					declare float @sinf(float) nounwind readonly
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue