[llvm] r281708 - Move the Mangler from the AsmPrinter down to TLOF and clean up the

Bill Seurer via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 16 08:55:03 PDT 2016


This change causes many segmentation faults on powerpc both BE and LE in 
clang with the asan tests and possibly others.  All the powerpc 
buildbots are failing because of it.

See http://lab.llvm.org:8011/builders/clang-ppc64le-linux/builds/7648 
for the first occurance.

Sample from a local build:

[29/34] Generating ASAN_INST_TEST_OBJECTS.asan_test.cc.powerpc64le-inline.o
FAILED: cd 
/home/seurer/llvm/build/llvm-test3/projects/compiler-rt/lib/asan/tests 
&& /home/seurer/llvm/build/llvm-test3/./bin/clang -fPIC 
-fvisibility-inlines-hidden -Wall -W -Wno-unused-parameter 
-Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic 
-Wno-long-long -Wno-maybe-uninitialized -Wdelete-non-virtual-dtor 
-Wno-comment -Werror=date-time -std=c++11 -ffunction-sections 
-fdata-sections -Wall -std=c++11 -Wno-unused-parameter 
-Wno-unknown-warning-option -DGTEST_NO_LLVM_RAW_OSTREAM=1 
-DGTEST_HAS_RTTI=0 
-I/home/seurer/llvm/llvm-test3/utils/unittest/googletest/include 
-I/home/seurer/llvm/llvm-test3/utils/unittest/googletest 
-I/home/seurer/llvm/llvm-test3/projects/compiler-rt/include 
-I/home/seurer/llvm/llvm-test3/projects/compiler-rt/lib 
-I/home/seurer/llvm/llvm-test3/projects/compiler-rt/lib/asan 
-I/home/seurer/llvm/llvm-test3/projects/compiler-rt/lib/sanitizer_common/tests 
-fno-rtti -O2 -Wno-format -Werror=sign-compare -Wno-non-virtual-dtor 
-Wno-variadic-macros -gline-tables-only -DASAN_HAS_BLACKLIST=1 
-DASAN_HAS_EXCEPTIONS=1 -DASAN_UAR=0 -fsanitize=address 
-fsanitize-blacklist=/home/seurer/llvm/llvm-test3/projects/compiler-rt/lib/asan/tests/asan_test.ignore 
-m64 -c -o ASAN_INST_TEST_OBJECTS.asan_test.cc.powerpc64le-inline.o 
/home/seurer/llvm/llvm-test3/projects/compiler-rt/lib/asan/tests/asan_test.cc
#0 0x0000000011cd17c4 llvm::sys::PrintStackTrace(llvm::raw_ostream&) 
(/home/seurer/llvm/build/llvm-test3/bin/clang-4.0+0x11cd17c4)
#1 0x0000000011cd1d10 PrintStackTraceSignalHandler(void*) 
(/home/seurer/llvm/build/llvm-test3/bin/clang-4.0+0x11cd1d10)
#2 0x0000000011ccefbc llvm::sys::RunSignalHandlers() 
(/home/seurer/llvm/build/llvm-test3/bin/clang-4.0+0x11ccefbc)
#3 0x0000000011ccf1a4 SignalHandler(int) 
(/home/seurer/llvm/build/llvm-test3/bin/clang-4.0+0x11ccf1a4)
#4 0x00003fffa1690478  0x100478 
llvm::Mangler::getNameWithPrefix(llvm::raw_ostream&, llvm::GlobalValue 
const*, bool) const
#5 0x00003fffa1690478
#6 0x00003fffa1690478 llvm::Module::getNamedMetadata(llvm::Twine const&) 
const (+0x100478)
#7 0x0000000011829cf8 
llvm::Mangler::getNameWithPrefix(llvm::SmallVectorImpl<char>&, 
llvm::GlobalValue const*, bool) const 
(/home/seurer/llvm/build/llvm-test3/bin/clang-4.0+0x11829cf8)
#8 0x00000000118481e4 
llvm::TargetMachine::getNameWithPrefix(llvm::SmallVectorImpl<char>&, 
llvm::GlobalValue const*, llvm::Mangler&, bool) const 
(/home/seurer/llvm/build/llvm-test3/bin/clang-4.0+0x118481e4)
#9 0x000000001182b388 GetSymbolFromOperand(llvm::MachineOperand const&, 
llvm::AsmPrinter&) 
(/home/seurer/llvm/build/llvm-test3/bin/clang-4.0+0x1182b388)
#10 0x0000000012659b40 
llvm::LowerPPCMachineInstrToMCInst(llvm::MachineInstr const*, 
llvm::MCInst&, llvm::AsmPrinter&, bool) 
(/home/seurer/llvm/build/llvm-test3/bin/clang-4.0+0x12659b40)
#11 0x0000000010e4b75c (anonymous 
namespace)::PPCAsmPrinter::EmitInstruction(llvm::MachineInstr const*) 
(/home/seurer/llvm/build/llvm-test3/bin/clang-4.0+0x10e4b75c)
#12 0x0000000010e4c20c llvm::AsmPrinter::EmitFunctionBody() 
(/home/seurer/llvm/build/llvm-test3/bin/clang-4.0+0x10e4c20c)
#13 0x0000000010e49368 (anonymous 
namespace)::PPCAsmPrinter::runOnMachineFunction(llvm::MachineFunction&) 
(/home/seurer/llvm/build/llvm-test3/bin/clang-4.0+0x10e49368)
#14 0x00000000123146d0 
llvm::MachineFunctionPass::runOnFunction(llvm::Function&) 
(/home/seurer/llvm/build/llvm-test3/bin/clang-4.0+0x123146d0)
#15 0x0000000010e42c84 
llvm::FPPassManager::runOnFunction(llvm::Function&) 
(/home/seurer/llvm/build/llvm-test3/bin/clang-4.0+0x10e42c84)
#16 0x00000000114b69ec llvm::FPPassManager::runOnModule(llvm::Module&) 
(/home/seurer/llvm/build/llvm-test3/bin/clang-4.0+0x114b69ec)
#17 0x0000000011824fb8 llvm::legacy::PassManagerImpl::run(llvm::Module&) 
(/home/seurer/llvm/build/llvm-test3/bin/clang-4.0+0x11824fb8)
#18 0x00000000118250e8 llvm::legacy::PassManager::run(llvm::Module&) 
(/home/seurer/llvm/build/llvm-test3/bin/clang-4.0+0x118250e8)
#19 0x00000000118259a0 
clang::EmitBackendOutput(clang::DiagnosticsEngine&, 
clang::CodeGenOptions const&, clang::TargetOptions const&, 
clang::LangOptions const&, llvm::DataLayout const&, llvm::Module*, 
clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, 
std::default_delete<llvm::raw_pwrite_stream> >) 
(/home/seurer/llvm/build/llvm-test3/bin/clang-4.0+0x118259a0)
#20 0x0000000011825c7c 
clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) 
(/home/seurer/llvm/build/llvm-test3/bin/clang-4.0+0x11825c7c)
#21 0x0000000011e97e0c clang::ParseAST(clang::Sema&, bool, bool) 
(/home/seurer/llvm/build/llvm-test3/bin/clang-4.0+0x11e97e0c)
#22 0x00000000125b4fc8 clang::ASTFrontendAction::ExecuteAction() 
(/home/seurer/llvm/build/llvm-test3/bin/clang-4.0+0x125b4fc8)
#23 0x0000000012a3d7fc clang::CodeGenAction::ExecuteAction() 
(/home/seurer/llvm/build/llvm-test3/bin/clang-4.0+0x12a3d7fc)
#24 0x0000000012246c10 clang::FrontendAction::Execute() 
(/home/seurer/llvm/build/llvm-test3/bin/clang-4.0+0x12246c10)
#25 0x00000000125b5b14 
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) 
(/home/seurer/llvm/build/llvm-test3/bin/clang-4.0+0x125b5b14)
#26 0x0000000012247df8 
clang::ExecuteCompilerInvocation(clang::CompilerInstance*) 
(/home/seurer/llvm/build/llvm-test3/bin/clang-4.0+0x12247df8)
#27 0x00000000122172d0 cc1_main(llvm::ArrayRef<char const*>, char 
const*, void*) (/home/seurer/llvm/build/llvm-test3/bin/clang-4.0+0x122172d0)
#28 0x00000000122e8be8 main 
(/home/seurer/llvm/build/llvm-test3/bin/clang-4.0+0x122e8be8)
#29 0x00000000106668b8 generic_start_main 
/build/buildd/eglibc-2.19/csu/../csu/libc-start.c:287:0
#30 0x00000000105facd4 __libc_start_main 
/build/buildd/eglibc-2.19/csu/../sysdeps/unix/sysv/linux/powerpc/libc-start.c:93:0
0  clang-4.0 0x0000000011cd17c4 
llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 116
1  clang-4.0 0x0000000011cd1d10
2  clang-4.0 0x0000000011ccefbc llvm::sys::RunSignalHandlers() + 156
3  clang-4.0 0x0000000011ccf1a4
4            0x00003fffa1690478 __kernel_sigtramp_rt64 + 0
5  clang-4.0 0x0000000011829cf8 
llvm::Mangler::getNameWithPrefix(llvm::raw_ostream&, llvm::GlobalValue 
const*, bool) const + 152
6  clang-4.0 0x00000000118481e4 
llvm::Module::getNamedMetadata(llvm::Twine const&) const + 116
7  clang-4.0 0x000000001182b388 
llvm::Mangler::getNameWithPrefix(llvm::SmallVectorImpl<char>&, 
llvm::GlobalValue const*, bool) const + 136
8  clang-4.0 0x0000000012659b40 
llvm::TargetMachine::getNameWithPrefix(llvm::SmallVectorImpl<char>&, 
llvm::GlobalValue const*, llvm::Mangler&, bool) const + 64
9  clang-4.0 0x0000000010e4b75c
10 clang-4.0 0x0000000010e4c20c 
llvm::LowerPPCMachineInstrToMCInst(llvm::MachineInstr const*, 
llvm::MCInst&, llvm::AsmPrinter&, bool) + 444
11 clang-4.0 0x0000000010e49368
12 clang-4.0 0x00000000123146d0 llvm::AsmPrinter::EmitFunctionBody() + 2192
13 clang-4.0 0x0000000010e42c84
14 clang-4.0 0x00000000114b69ec 
llvm::MachineFunctionPass::runOnFunction(llvm::Function&) + 876
15 clang-4.0 0x0000000011824fb8 
llvm::FPPassManager::runOnFunction(llvm::Function&) + 744
16 clang-4.0 0x00000000118250e8 
llvm::FPPassManager::runOnModule(llvm::Module&) + 104
17 clang-4.0 0x00000000118259a0 
llvm::legacy::PassManagerImpl::run(llvm::Module&) + 1056
18 clang-4.0 0x0000000011825c7c 
llvm::legacy::PassManager::run(llvm::Module&) + 28
19 clang-4.0 0x0000000011e97e0c 
clang::EmitBackendOutput(clang::DiagnosticsEngine&, 
clang::CodeGenOptions const&, clang::TargetOptions const&, 
clang::LangOptions const&, llvm::DataLayout const&, llvm::Module*, 
clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, 
std::default_delete<llvm::raw_pwrite_stream> >) + 3596
20 clang-4.0 0x00000000125b4fc8
21 clang-4.0 0x0000000012a3d7fc clang::ParseAST(clang::Sema&, bool, 
bool) + 1068
22 clang-4.0 0x0000000012246c10 
clang::ASTFrontendAction::ExecuteAction() + 112
23 clang-4.0 0x00000000125b5b14 clang::CodeGenAction::ExecuteAction() + 132
24 clang-4.0 0x0000000012247df8 clang::FrontendAction::Execute() + 664
25 clang-4.0 0x00000000122172d0 
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 416
26 clang-4.0 0x00000000122e8be8 
clang::ExecuteCompilerInvocation(clang::CompilerInstance*) + 3400
27 clang-4.0 0x00000000106668b8 cc1_main(llvm::ArrayRef<char const*>, 
char const*, void*) + 3256
28 clang-4.0 0x00000000105facd4 main + 2164
29 libc.so.6 0x00003fffa1094d00
30 libc.so.6 0x00003fffa1094ef8 __libc_start_main + 200
Stack dump:
0.	Program arguments: /home/seurer/llvm/build/llvm-test3/bin/clang-4.0 
-cc1 -triple powerpc64le-unknown-linux-gnu -emit-obj -disable-free 
-main-file-name asan_test.cc -mrelocation-model pic -pic-level 2 
-mthread-model posix -mdisable-fp-elim -fmath-errno -masm-verbose 
-mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu 
ppc64le -mfloat-abi hard -target-abi elfv2 -dwarf-column-info 
-debug-info-kind=line-tables-only -dwarf-version=4 -debugger-tuning=gdb 
-ffunction-sections -fdata-sections -coverage-notes-file 
/home/seurer/llvm/build/llvm-test3/projects/compiler-rt/lib/asan/tests/ASAN_INST_TEST_OBJECTS.asan_test.cc.powerpc64le-inline.gcno 
-resource-dir /home/seurer/llvm/build/llvm-test3/bin/../lib/clang/4.0.0 
-D GTEST_NO_LLVM_RAW_OSTREAM=1 -D GTEST_HAS_RTTI=0 -I 
/home/seurer/llvm/llvm-test3/utils/unittest/googletest/include -I 
/home/seurer/llvm/llvm-test3/utils/unittest/googletest -I 
/home/seurer/llvm/llvm-test3/projects/compiler-rt/include -I 
/home/seurer/llvm/llvm-test3/projects/compiler-rt/lib -I 
/home/seurer/llvm/llvm-test3/projects/compiler-rt/lib/asan -I 
/home/seurer/llvm/llvm-test3/projects/compiler-rt/lib/sanitizer_common/tests 
-D ASAN_HAS_BLACKLIST=1 -D ASAN_HAS_EXCEPTIONS=1 -D ASAN_UAR=0 
-internal-isystem 
/usr/lib/gcc/powerpc64le-linux-gnu/4.8/../../../../include/c++/4.8 
-internal-isystem 
/usr/lib/gcc/powerpc64le-linux-gnu/4.8/../../../../include/powerpc64le-linux-gnu/c++/4.8 
-internal-isystem 
/usr/lib/gcc/powerpc64le-linux-gnu/4.8/../../../../include/powerpc64le-linux-gnu/c++/4.8 
-internal-isystem 
/usr/lib/gcc/powerpc64le-linux-gnu/4.8/../../../../include/c++/4.8/backward 
-internal-isystem /usr/local/include -internal-isystem 
/home/seurer/llvm/build/llvm-test3/bin/../lib/clang/4.0.0/include 
-internal-externc-isystem /usr/include/powerpc64le-linux-gnu 
-internal-externc-isystem /include -internal-externc-isystem 
/usr/include -O2 -Wall -W -Wno-unused-parameter -Wwrite-strings 
-Wcast-qual -Wno-missing-field-initializers -Wno-long-long 
-Wno-maybe-uninitialized -Wdelete-non-virtual-dtor -Wno-comment 
-Werror=date-time -Wall -Wno-unused-parameter 
-Wno-unknown-warning-option -Wno-format -Werror=sign-compare 
-Wno-non-virtual-dtor -Wno-variadic-macros -pedantic -std=c++11 
-fdeprecated-macro -fdebug-compilation-dir 
/home/seurer/llvm/build/llvm-test3/projects/compiler-rt/lib/asan/tests 
-ferror-limit 19 -fmessage-length 0 -fvisibility-inlines-hidden 
-fsanitize=address 
-fsanitize-blacklist=/home/seurer/llvm/build/llvm-test3/bin/../lib/clang/4.0.0/asan_blacklist.txt 
-fsanitize-blacklist=/home/seurer/llvm/llvm-test3/projects/compiler-rt/lib/asan/tests/asan_test.ignore 
-fdepfile-entry=/home/seurer/llvm/llvm-test3/projects/compiler-rt/lib/asan/tests/asan_test.ignore 
-fno-assume-sane-operator-new -fno-rtti -fno-signed-char 
-fobjc-runtime=gcc -fcxx-exceptions -fexceptions 
-fdiagnostics-show-option -vectorize-loops -vectorize-slp -o 
ASAN_INST_TEST_OBJECTS.asan_test.cc.powerpc64le-inline.o -x c++ 
/home/seurer/llvm/llvm-test3/projects/compiler-rt/lib/asan/tests/asan_test.cc 

1.	<eof> parser at end of file
2.	Code generation
3.	Running pass 'Function Pass Manager' on module 
'/home/seurer/llvm/llvm-test3/projects/compiler-rt/lib/asan/tests/asan_test.cc'.
4.	Running pass 'Linux PPC Assembly Printer' on function '@asan.module_ctor'
clang-4.0: error: unable to execute command: Segmentation fault (core 
dumped)
clang-4.0: error: clang frontend command failed due to signal (use -v to 
see invocation)
clang version 4.0.0 (trunk 281708)
Target: powerpc64le-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/seurer/llvm/build/llvm-test3/./bin
clang-4.0: note: diagnostic msg: PLEASE submit a bug report to 
http://llvm.org/bugs/ and include the crash backtrace, preprocessed 
source, and associated run script.
clang-4.0: note: diagnostic msg:


On 09/16/16 02:33, Eric Christopher via llvm-commits wrote:
> Author: echristo
> Date: Fri Sep 16 02:33:15 2016
> New Revision: 281708
>
> URL: http://llvm.org/viewvc/llvm-project?rev=281708&view=rev
> Log:
> Move the Mangler from the AsmPrinter down to TLOF and clean up the
> TLOF API accordingly.
>
> Modified:
>     llvm/trunk/include/llvm/CodeGen/TargetLoweringObjectFileImpl.h
>     llvm/trunk/include/llvm/Target/TargetLoweringObjectFile.h
>     llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
>     llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp
>     llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCFIException.cpp
>     llvm/trunk/lib/CodeGen/AsmPrinter/WinException.cpp
>     llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
>     llvm/trunk/lib/LTO/LTOModule.cpp
>     llvm/trunk/lib/Target/AArch64/AArch64TargetObjectFile.cpp
>     llvm/trunk/lib/Target/AArch64/AArch64TargetObjectFile.h
>     llvm/trunk/lib/Target/AMDGPU/AMDGPUTargetObjectFile.cpp
>     llvm/trunk/lib/Target/AMDGPU/AMDGPUTargetObjectFile.h
>     llvm/trunk/lib/Target/ARM/ARMAsmPrinter.cpp
>     llvm/trunk/lib/Target/ARM/ARMTargetObjectFile.cpp
>     llvm/trunk/lib/Target/ARM/ARMTargetObjectFile.h
>     llvm/trunk/lib/Target/Hexagon/HexagonTargetObjectFile.cpp
>     llvm/trunk/lib/Target/Hexagon/HexagonTargetObjectFile.h
>     llvm/trunk/lib/Target/Lanai/LanaiTargetObjectFile.cpp
>     llvm/trunk/lib/Target/Lanai/LanaiTargetObjectFile.h
>     llvm/trunk/lib/Target/Mips/MipsTargetObjectFile.cpp
>     llvm/trunk/lib/Target/Mips/MipsTargetObjectFile.h
>     llvm/trunk/lib/Target/NVPTX/NVPTXISelLowering.cpp
>     llvm/trunk/lib/Target/NVPTX/NVPTXTargetObjectFile.h
>     llvm/trunk/lib/Target/PowerPC/PPCTargetObjectFile.cpp
>     llvm/trunk/lib/Target/PowerPC/PPCTargetObjectFile.h
>     llvm/trunk/lib/Target/Sparc/SparcTargetObjectFile.cpp
>     llvm/trunk/lib/Target/Sparc/SparcTargetObjectFile.h
>     llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp
>     llvm/trunk/lib/Target/TargetMachine.cpp
>     llvm/trunk/lib/Target/X86/X86AsmPrinter.cpp
>     llvm/trunk/lib/Target/X86/X86TargetObjectFile.cpp
>     llvm/trunk/lib/Target/X86/X86TargetObjectFile.h
>     llvm/trunk/lib/Target/XCore/XCoreAsmPrinter.cpp
>     llvm/trunk/lib/Target/XCore/XCoreTargetObjectFile.cpp
>     llvm/trunk/lib/Target/XCore/XCoreTargetObjectFile.h
>
> Modified: llvm/trunk/include/llvm/CodeGen/TargetLoweringObjectFileImpl.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/TargetLoweringObjectFileImpl.h?rev=281708&r1=281707&r2=281708&view=diff
> ==============================================================================
> --- llvm/trunk/include/llvm/CodeGen/TargetLoweringObjectFileImpl.h (original)
> +++ llvm/trunk/include/llvm/CodeGen/TargetLoweringObjectFileImpl.h Fri Sep 16 02:33:15 2016
> @@ -54,14 +54,12 @@ public:
>                                     unsigned &Align) const override;
>
>    MCSection *getExplicitSectionGlobal(const GlobalValue *GV, SectionKind Kind,
> -                                      Mangler &Mang,
>                                        const TargetMachine &TM) const override;
>
>    MCSection *SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
> -                                    Mangler &Mang,
>                                      const TargetMachine &TM) const override;
>
> -  MCSection *getSectionForJumpTable(const Function &F, Mangler &Mang,
> +  MCSection *getSectionForJumpTable(const Function &F,
>                                      const TargetMachine &TM) const override;
>
>    bool shouldPutJumpTableInFunctionSection(bool UsesLabelDifference,
> @@ -69,14 +67,14 @@ public:
>
>    /// Return an MCExpr to use for a reference to the specified type info global
>    /// variable from exception handling information.
> -  const MCExpr *
> -  getTTypeGlobalReference(const GlobalValue *GV, unsigned Encoding,
> -                          Mangler &Mang, const TargetMachine &TM,
> -                          MachineModuleInfo *MMI,
> -                          MCStreamer &Streamer) const override;
> +  const MCExpr *getTTypeGlobalReference(const GlobalValue *GV,
> +                                        unsigned Encoding,
> +                                        const TargetMachine &TM,
> +                                        MachineModuleInfo *MMI,
> +                                        MCStreamer &Streamer) const override;
>
>    // The symbol that gets passed to .cfi_personality.
> -  MCSymbol *getCFIPersonalitySymbol(const GlobalValue *GV, Mangler &Mang,
> +  MCSymbol *getCFIPersonalitySymbol(const GlobalValue *GV,
>                                      const TargetMachine &TM,
>                                      MachineModuleInfo *MMI) const override;
>
> @@ -87,7 +85,7 @@ public:
>                                    const MCSymbol *KeySym) const override;
>
>    const MCExpr *lowerRelativeReference(const GlobalValue *LHS,
> -                                       const GlobalValue *RHS, Mangler &Mang,
> +                                       const GlobalValue *RHS,
>                                         const TargetMachine &TM) const override;
>  };
>
> @@ -103,14 +101,12 @@ public:
>    /// Emit the module flags that specify the garbage collection information.
>    void emitModuleFlags(MCStreamer &Streamer,
>                         ArrayRef<Module::ModuleFlagEntry> ModuleFlags,
> -                       Mangler &Mang, const TargetMachine &TM) const override;
> +                       const TargetMachine &TM) const override;
>
>    MCSection *SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
> -                                    Mangler &Mang,
>                                      const TargetMachine &TM) const override;
>
>    MCSection *getExplicitSectionGlobal(const GlobalValue *GV, SectionKind Kind,
> -                                      Mangler &Mang,
>                                        const TargetMachine &TM) const override;
>
>    MCSection *getSectionForConstant(const DataLayout &DL, SectionKind Kind,
> @@ -118,14 +114,14 @@ public:
>                                     unsigned &Align) const override;
>
>    /// The mach-o version of this method defaults to returning a stub reference.
> -  const MCExpr *
> -  getTTypeGlobalReference(const GlobalValue *GV, unsigned Encoding,
> -                          Mangler &Mang, const TargetMachine &TM,
> -                          MachineModuleInfo *MMI,
> -                          MCStreamer &Streamer) const override;
> +  const MCExpr *getTTypeGlobalReference(const GlobalValue *GV,
> +                                        unsigned Encoding,
> +                                        const TargetMachine &TM,
> +                                        MachineModuleInfo *MMI,
> +                                        MCStreamer &Streamer) const override;
>
>    // The symbol that gets passed to .cfi_personality.
> -  MCSymbol *getCFIPersonalitySymbol(const GlobalValue *GV, Mangler &Mang,
> +  MCSymbol *getCFIPersonalitySymbol(const GlobalValue *GV,
>                                      const TargetMachine &TM,
>                                      MachineModuleInfo *MMI) const override;
>
> @@ -136,7 +132,7 @@ public:
>                                            MCStreamer &Streamer) const override;
>
>    void getNameWithPrefix(SmallVectorImpl<char> &OutName, const GlobalValue *GV,
> -                         Mangler &Mang, const TargetMachine &TM) const override;
> +                         const TargetMachine &TM) const override;
>  };
>
>
> @@ -149,32 +145,30 @@ public:
>
>    void Initialize(MCContext &Ctx, const TargetMachine &TM) override;
>    MCSection *getExplicitSectionGlobal(const GlobalValue *GV, SectionKind Kind,
> -                                      Mangler &Mang,
>                                        const TargetMachine &TM) const override;
>
>    MCSection *SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
> -                                    Mangler &Mang,
>                                      const TargetMachine &TM) const override;
>
>    void getNameWithPrefix(SmallVectorImpl<char> &OutName, const GlobalValue *GV,
> -                         Mangler &Mang, const TargetMachine &TM) const override;
> +                         const TargetMachine &TM) const override;
>
> -  MCSection *getSectionForJumpTable(const Function &F, Mangler &Mang,
> +  MCSection *getSectionForJumpTable(const Function &F,
>                                      const TargetMachine &TM) const override;
>
>    /// Emit Obj-C garbage collection and linker options. Only linker option
>    /// emission is implemented for COFF.
>    void emitModuleFlags(MCStreamer &Streamer,
>                         ArrayRef<Module::ModuleFlagEntry> ModuleFlags,
> -                       Mangler &Mang, const TargetMachine &TM) const override;
> +                       const TargetMachine &TM) const override;
>
>    MCSection *getStaticCtorSection(unsigned Priority,
>                                    const MCSymbol *KeySym) const override;
>    MCSection *getStaticDtorSection(unsigned Priority,
>                                    const MCSymbol *KeySym) const override;
>
> -  void emitLinkerFlagsForGlobal(raw_ostream &OS, const GlobalValue *GV,
> -                                const Mangler &Mang) const override;
> +  void emitLinkerFlagsForGlobal(raw_ostream &OS,
> +                                const GlobalValue *GV) const override;
>  };
>
>  } // end namespace llvm
>
> Modified: llvm/trunk/include/llvm/Target/TargetLoweringObjectFile.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetLoweringObjectFile.h?rev=281708&r1=281707&r2=281708&view=diff
> ==============================================================================
> --- llvm/trunk/include/llvm/Target/TargetLoweringObjectFile.h (original)
> +++ llvm/trunk/include/llvm/Target/TargetLoweringObjectFile.h Fri Sep 16 02:33:15 2016
> @@ -37,6 +37,9 @@ namespace llvm {
>  class TargetLoweringObjectFile : public MCObjectFileInfo {
>    MCContext *Ctx;
>
> +  /// Name-mangler for global names.
> +  Mangler *Mang;
> +
>    TargetLoweringObjectFile(
>      const TargetLoweringObjectFile&) = delete;
>    void operator=(const TargetLoweringObjectFile&) = delete;
> @@ -53,10 +56,11 @@ protected:
>
>  public:
>    MCContext &getContext() const { return *Ctx; }
> +  Mangler &getMangler() const { return *Mang; }
>
>    TargetLoweringObjectFile()
> -      : MCObjectFileInfo(), Ctx(nullptr), SupportIndirectSymViaGOTPCRel(false),
> -        SupportGOTPCRelWithOffset(true) {}
> +      : MCObjectFileInfo(), Ctx(nullptr), Mang(nullptr),
> +        SupportIndirectSymViaGOTPCRel(false), SupportGOTPCRelWithOffset(true) {}
>
>    virtual ~TargetLoweringObjectFile();
>
> @@ -71,7 +75,7 @@ public:
>    /// Emit the module flags that the platform cares about.
>    virtual void emitModuleFlags(MCStreamer &Streamer,
>                                 ArrayRef<Module::ModuleFlagEntry> Flags,
> -                               Mangler &Mang, const TargetMachine &TM) const {}
> +                               const TargetMachine &TM) const {}
>
>    /// Given a constant with the SectionKind, return a section that it should be
>    /// placed in.
> @@ -89,21 +93,21 @@ public:
>    /// variable or function definition. This should not be passed external (or
>    /// available externally) globals.
>    MCSection *SectionForGlobal(const GlobalValue *GV, SectionKind Kind,
> -                              Mangler &Mang, const TargetMachine &TM) const;
> +                              const TargetMachine &TM) const;
>
>    /// This method computes the appropriate section to emit the specified global
>    /// variable or function definition. This should not be passed external (or
>    /// available externally) globals.
> -  MCSection *SectionForGlobal(const GlobalValue *GV, Mangler &Mang,
> +  MCSection *SectionForGlobal(const GlobalValue *GV,
>                                const TargetMachine &TM) const {
> -    return SectionForGlobal(GV, getKindForGlobal(GV, TM), Mang, TM);
> +    return SectionForGlobal(GV, getKindForGlobal(GV, TM), TM);
>    }
>
>    virtual void getNameWithPrefix(SmallVectorImpl<char> &OutName,
> -                                 const GlobalValue *GV, Mangler &Mang,
> +                                 const GlobalValue *GV,
>                                   const TargetMachine &TM) const;
>
> -  virtual MCSection *getSectionForJumpTable(const Function &F, Mangler &Mang,
> +  virtual MCSection *getSectionForJumpTable(const Function &F,
>                                              const TargetMachine &TM) const;
>
>    virtual bool shouldPutJumpTableInFunctionSection(bool UsesLabelDifference,
> @@ -114,37 +118,35 @@ public:
>    /// assume that GV->hasSection() is true.
>    virtual MCSection *
>    getExplicitSectionGlobal(const GlobalValue *GV, SectionKind Kind,
> -                           Mangler &Mang, const TargetMachine &TM) const = 0;
> +                           const TargetMachine &TM) const = 0;
>
>    /// Allow the target to completely override section assignment of a global.
> -  virtual const MCSection *getSpecialCasedSectionGlobals(const GlobalValue *GV,
> -                                                         SectionKind Kind,
> -                                                         Mangler &Mang) const {
> +  virtual const MCSection *
> +  getSpecialCasedSectionGlobals(const GlobalValue *GV, SectionKind Kind) const {
>      return nullptr;
>    }
>
>    /// Return an MCExpr to use for a reference to the specified global variable
>    /// from exception handling information.
> -  virtual const MCExpr *
> -  getTTypeGlobalReference(const GlobalValue *GV, unsigned Encoding,
> -                          Mangler &Mang, const TargetMachine &TM,
> -                          MachineModuleInfo *MMI, MCStreamer &Streamer) const;
> +  virtual const MCExpr *getTTypeGlobalReference(const GlobalValue *GV,
> +                                                unsigned Encoding,
> +                                                const TargetMachine &TM,
> +                                                MachineModuleInfo *MMI,
> +                                                MCStreamer &Streamer) const;
>
>    /// Return the MCSymbol for a private symbol with global value name as its
>    /// base, with the specified suffix.
>    MCSymbol *getSymbolWithGlobalValueBase(const GlobalValue *GV,
> -                                         StringRef Suffix, Mangler &Mang,
> +                                         StringRef Suffix,
>                                           const TargetMachine &TM) const;
>
>    // The symbol that gets passed to .cfi_personality.
>    virtual MCSymbol *getCFIPersonalitySymbol(const GlobalValue *GV,
> -                                            Mangler &Mang,
>                                              const TargetMachine &TM,
>                                              MachineModuleInfo *MMI) const;
>
> -  const MCExpr *
> -  getTTypeReference(const MCSymbolRefExpr *Sym, unsigned Encoding,
> -                    MCStreamer &Streamer) const;
> +  const MCExpr *getTTypeReference(const MCSymbolRefExpr *Sym, unsigned Encoding,
> +                                  MCStreamer &Streamer) const;
>
>    virtual MCSection *getStaticCtorSection(unsigned Priority,
>                                            const MCSymbol *KeySym) const {
> @@ -160,9 +162,9 @@ public:
>    /// emitting the address in debug info.
>    virtual const MCExpr *getDebugThreadLocalSymbol(const MCSymbol *Sym) const;
>
> -  virtual const MCExpr *
> -  lowerRelativeReference(const GlobalValue *LHS, const GlobalValue *RHS,
> -                         Mangler &Mang, const TargetMachine &TM) const {
> +  virtual const MCExpr *lowerRelativeReference(const GlobalValue *LHS,
> +                                               const GlobalValue *RHS,
> +                                               const TargetMachine &TM) const {
>      return nullptr;
>    }
>
> @@ -187,12 +189,12 @@ public:
>      return nullptr;
>    }
>
> -  virtual void emitLinkerFlagsForGlobal(raw_ostream &OS, const GlobalValue *GV,
> -                                        const Mangler &Mang) const {}
> +  virtual void emitLinkerFlagsForGlobal(raw_ostream &OS,
> +                                        const GlobalValue *GV) const {}
>
>  protected:
>    virtual MCSection *SelectSectionForGlobal(const GlobalValue *GV,
> -                                            SectionKind Kind, Mangler &Mang,
> +                                            SectionKind Kind,
>                                              const TargetMachine &TM) const = 0;
>  };
>
>
> Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp?rev=281708&r1=281707&r2=281708&view=diff
> ==============================================================================
> --- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (original)
> +++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Fri Sep 16 02:33:15 2016
> @@ -184,8 +184,6 @@ bool AsmPrinter::doInitialization(Module
>
>    OutStreamer->InitSections(false);
>
> -  Mang = new Mangler();
> -
>    // Emit the version-min deplyment target directive if needed.
>    //
>    // FIXME: If we end up with a collection of these sorts of Darwin-specific
> @@ -340,11 +338,11 @@ void AsmPrinter::EmitLinkage(const Globa
>
>  void AsmPrinter::getNameWithPrefix(SmallVectorImpl<char> &Name,
>                                     const GlobalValue *GV) const {
> -  TM.getNameWithPrefix(Name, GV, *Mang);
> +  TM.getNameWithPrefix(Name, GV, getObjFileLowering().getMangler());
>  }
>
>  MCSymbol *AsmPrinter::getSymbol(const GlobalValue *GV) const {
> -  return TM.getSymbol(GV, *Mang);
> +  return TM.getSymbol(GV, getObjFileLowering().getMangler());
>  }
>
>  /// EmitGlobalVariable - Emit the specified global variable to the .s file.
> @@ -424,8 +422,7 @@ void AsmPrinter::EmitGlobalVariable(cons
>    }
>
>    // Determine to which section this global should be emitted.
> -  MCSection *TheSection =
> -      getObjFileLowering().SectionForGlobal(GV, GVKind, *Mang, TM);
> +  MCSection *TheSection = getObjFileLowering().SectionForGlobal(GV, GVKind, TM);
>
>    // If we have a bss global going to a section that supports the
>    // zerofill directive, do so here.
> @@ -483,7 +480,7 @@ void AsmPrinter::EmitGlobalVariable(cons
>    if (GVKind.isThreadLocal() && MAI->hasMachoTBSSDirective()) {
>      // Emit the .tbss symbol
>      MCSymbol *MangSym =
> -      OutContext.getOrCreateSymbol(GVSym->getName() + Twine("$tlv$init"));
> +        OutContext.getOrCreateSymbol(GVSym->getName() + Twine("$tlv$init"));
>
>      if (GVKind.isThreadBSS()) {
>        TheSection = getObjFileLowering().getTLSBSSSection();
> @@ -550,8 +547,7 @@ void AsmPrinter::EmitFunctionHeader() {
>    // Print the 'header' of function.
>    const Function *F = MF->getFunction();
>
> -  OutStreamer->SwitchSection(
> -      getObjFileLowering().SectionForGlobal(F, *Mang, TM));
> +  OutStreamer->SwitchSection(getObjFileLowering().SectionForGlobal(F, TM));
>    EmitVisibility(CurrentFnSym, F->getVisibility());
>
>    EmitLinkage(F, CurrentFnSym);
> @@ -1143,7 +1139,7 @@ bool AsmPrinter::doFinalization(Module &
>    SmallVector<Module::ModuleFlagEntry, 8> ModuleFlags;
>    M.getModuleFlagsMetadata(ModuleFlags);
>    if (!ModuleFlags.empty())
> -    TLOF.emitModuleFlags(*OutStreamer, ModuleFlags, *Mang, TM);
> +    TLOF.emitModuleFlags(*OutStreamer, ModuleFlags, TM);
>
>    if (TM.getTargetTriple().isOSBinFormatELF()) {
>      MachineModuleInfoELF &MMIELF = MMI->getObjFileInfo<MachineModuleInfoELF>();
> @@ -1246,7 +1242,6 @@ bool AsmPrinter::doFinalization(Module &
>    // after everything else has gone out.
>    EmitEndOfAsmFile(M);
>
> -  delete Mang; Mang = nullptr;
>    MMI = nullptr;
>
>    OutStreamer->Finish();
> @@ -1392,7 +1387,7 @@ void AsmPrinter::EmitJumpTableInfo() {
>        *F);
>    if (JTInDiffSection) {
>      // Drop it in the readonly section.
> -    MCSection *ReadOnlySection = TLOF.getSectionForJumpTable(*F, *Mang, TM);
> +    MCSection *ReadOnlySection = TLOF.getSectionForJumpTable(*F, TM);
>      OutStreamer->SwitchSection(ReadOnlySection);
>    }
>
> @@ -1831,8 +1826,8 @@ const MCExpr *AsmPrinter::lowerConstant(
>        APInt RHSOffset;
>        if (IsConstantOffsetFromGlobal(CE->getOperand(1), RHSGV, RHSOffset,
>                                       getDataLayout())) {
> -        const MCExpr *RelocExpr = getObjFileLowering().lowerRelativeReference(
> -            LHSGV, RHSGV, *Mang, TM);
> +        const MCExpr *RelocExpr =
> +            getObjFileLowering().lowerRelativeReference(LHSGV, RHSGV, TM);
>          if (!RelocExpr)
>            RelocExpr = MCBinaryExpr::createSub(
>                MCSymbolRefExpr::create(getSymbol(LHSGV), Ctx),
> @@ -2373,8 +2368,7 @@ MCSymbol *AsmPrinter::GetJTSetSymbol(uns
>
>  MCSymbol *AsmPrinter::getSymbolWithGlobalValueBase(const GlobalValue *GV,
>                                                     StringRef Suffix) const {
> -  return getObjFileLowering().getSymbolWithGlobalValueBase(GV, Suffix, *Mang,
> -                                                           TM);
> +  return getObjFileLowering().getSymbolWithGlobalValueBase(GV, Suffix, TM);
>  }
>
>  /// Return the MCSymbol for the specified ExternalSymbol.
>
> Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp?rev=281708&r1=281707&r2=281708&view=diff
> ==============================================================================
> --- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp (original)
> +++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp Fri Sep 16 02:33:15 2016
> @@ -138,8 +138,7 @@ void AsmPrinter::EmitTTypeReference(cons
>      const TargetLoweringObjectFile &TLOF = getObjFileLowering();
>
>      const MCExpr *Exp =
> -        TLOF.getTTypeGlobalReference(GV, Encoding, *Mang, TM, MMI,
> -                                     *OutStreamer);
> +        TLOF.getTTypeGlobalReference(GV, Encoding, TM, MMI, *OutStreamer);
>      OutStreamer->EmitValue(Exp, GetSizeOfEncodedValue(Encoding));
>    } else
>      OutStreamer->EmitIntValue(0, GetSizeOfEncodedValue(Encoding));
>
> Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCFIException.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCFIException.cpp?rev=281708&r1=281707&r2=281708&view=diff
> ==============================================================================
> --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCFIException.cpp (original)
> +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCFIException.cpp Fri Sep 16 02:33:15 2016
> @@ -160,8 +160,7 @@ void DwarfCFIException::beginFragment(co
>
>    const TargetLoweringObjectFile &TLOF = Asm->getObjFileLowering();
>    unsigned PerEncoding = TLOF.getPersonalityEncoding();
> -  const MCSymbol *Sym =
> -      TLOF.getCFIPersonalitySymbol(P, *Asm->Mang, Asm->TM, MMI);
> +  const MCSymbol *Sym = TLOF.getCFIPersonalitySymbol(P, Asm->TM, MMI);
>    Asm->OutStreamer->EmitCFIPersonality(Sym, PerEncoding);
>
>    // Provide LSDA information.
>
> Modified: llvm/trunk/lib/CodeGen/AsmPrinter/WinException.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/WinException.cpp?rev=281708&r1=281707&r2=281708&view=diff
> ==============================================================================
> --- llvm/trunk/lib/CodeGen/AsmPrinter/WinException.cpp (original)
> +++ llvm/trunk/lib/CodeGen/AsmPrinter/WinException.cpp Fri Sep 16 02:33:15 2016
> @@ -204,7 +204,7 @@ void WinException::beginFunclet(const Ma
>      if (F->hasPersonalityFn())
>        PerFn = dyn_cast<Function>(F->getPersonalityFn()->stripPointerCasts());
>      const MCSymbol *PersHandlerSym =
> -        TLOF.getCFIPersonalitySymbol(PerFn, *Asm->Mang, Asm->TM, MMI);
> +        TLOF.getCFIPersonalitySymbol(PerFn, Asm->TM, MMI);
>
>      // Classify the personality routine so that we may reason about it.
>      EHPersonality Per = EHPersonality::Unknown;
>
> Modified: llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp?rev=281708&r1=281707&r2=281708&view=diff
> ==============================================================================
> --- llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp (original)
> +++ llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp Fri Sep 16 02:33:15 2016
> @@ -50,14 +50,14 @@ using namespace dwarf;
>  //===----------------------------------------------------------------------===//
>
>  MCSymbol *TargetLoweringObjectFileELF::getCFIPersonalitySymbol(
> -    const GlobalValue *GV, Mangler &Mang, const TargetMachine &TM,
> +    const GlobalValue *GV, const TargetMachine &TM,
>      MachineModuleInfo *MMI) const {
>    unsigned Encoding = getPersonalityEncoding();
>    if ((Encoding & 0x80) == dwarf::DW_EH_PE_indirect)
>      return getContext().getOrCreateSymbol(StringRef("DW.ref.") +
> -                                          TM.getSymbol(GV, Mang)->getName());
> +                                          TM.getSymbol(GV, getMangler())->getName());
>    if ((Encoding & 0x70) == dwarf::DW_EH_PE_absptr)
> -    return TM.getSymbol(GV, Mang);
> +    return TM.getSymbol(GV, getMangler());
>    report_fatal_error("We do not support this DWARF encoding yet!");
>  }
>
> @@ -84,20 +84,19 @@ void TargetLoweringObjectFileELF::emitPe
>  }
>
>  const MCExpr *TargetLoweringObjectFileELF::getTTypeGlobalReference(
> -    const GlobalValue *GV, unsigned Encoding, Mangler &Mang,
> -    const TargetMachine &TM, MachineModuleInfo *MMI,
> -    MCStreamer &Streamer) const {
> +    const GlobalValue *GV, unsigned Encoding, const TargetMachine &TM,
> +    MachineModuleInfo *MMI, MCStreamer &Streamer) const {
>
>    if (Encoding & dwarf::DW_EH_PE_indirect) {
>      MachineModuleInfoELF &ELFMMI = MMI->getObjFileInfo<MachineModuleInfoELF>();
>
> -    MCSymbol *SSym = getSymbolWithGlobalValueBase(GV, ".DW.stub", Mang, TM);
> +    MCSymbol *SSym = getSymbolWithGlobalValueBase(GV, ".DW.stub", TM);
>
>      // Add information about the stub reference to ELFMMI so that the stub
>      // gets emitted by the asmprinter.
>      MachineModuleInfoImpl::StubValueTy &StubSym = ELFMMI.getGVStubEntry(SSym);
>      if (!StubSym.getPointer()) {
> -      MCSymbol *Sym = TM.getSymbol(GV, Mang);
> +      MCSymbol *Sym = TM.getSymbol(GV, getMangler());
>        StubSym = MachineModuleInfoImpl::StubValueTy(Sym, !GV->hasLocalLinkage());
>      }
>
> @@ -106,8 +105,8 @@ const MCExpr *TargetLoweringObjectFileEL
>                          Encoding & ~dwarf::DW_EH_PE_indirect, Streamer);
>    }
>
> -  return TargetLoweringObjectFile::
> -    getTTypeGlobalReference(GV, Encoding, Mang, TM, MMI, Streamer);
> +  return TargetLoweringObjectFile::getTTypeGlobalReference(GV, Encoding, TM,
> +                                                           MMI, Streamer);
>  }
>
>  static SectionKind
> @@ -205,8 +204,7 @@ static const Comdat *getELFComdat(const
>  }
>
>  MCSection *TargetLoweringObjectFileELF::getExplicitSectionGlobal(
> -    const GlobalValue *GV, SectionKind Kind, Mangler &Mang,
> -    const TargetMachine &TM) const {
> +    const GlobalValue *GV, SectionKind Kind, const TargetMachine &TM) const {
>    StringRef SectionName = GV->getSection();
>
>    // Infer section flags from the section name if we can.
> @@ -310,8 +308,7 @@ selectELFSectionForGlobal(MCContext &Ctx
>  }
>
>  MCSection *TargetLoweringObjectFileELF::SelectSectionForGlobal(
> -    const GlobalValue *GV, SectionKind Kind, Mangler &Mang,
> -    const TargetMachine &TM) const {
> +    const GlobalValue *GV, SectionKind Kind, const TargetMachine &TM) const {
>    unsigned Flags = getELFSectionFlags(Kind);
>
>    // If we have -ffunction-section or -fdata-section then we should emit the
> @@ -325,12 +322,12 @@ MCSection *TargetLoweringObjectFileELF::
>    }
>    EmitUniqueSection |= GV->hasComdat();
>
> -  return selectELFSectionForGlobal(getContext(), GV, Kind, Mang, TM,
> +  return selectELFSectionForGlobal(getContext(), GV, Kind, getMangler(), TM,
>                                     EmitUniqueSection, Flags, &NextUniqueID);
>  }
>
>  MCSection *TargetLoweringObjectFileELF::getSectionForJumpTable(
> -    const Function &F, Mangler &Mang, const TargetMachine &TM) const {
> +    const Function &F, const TargetMachine &TM) const {
>    // If the function can be removed, produce a unique section so that
>    // the table doesn't prevent the removal.
>    const Comdat *C = F.getComdat();
> @@ -339,7 +336,7 @@ MCSection *TargetLoweringObjectFileELF::
>      return ReadOnlySection;
>
>    return selectELFSectionForGlobal(getContext(), &F, SectionKind::getReadOnly(),
> -                                   Mang, TM, EmitUniqueSection, ELF::SHF_ALLOC,
> +                                   getMangler(), TM, EmitUniqueSection, ELF::SHF_ALLOC,
>                                     &NextUniqueID);
>  }
>
> @@ -423,7 +420,7 @@ MCSection *TargetLoweringObjectFileELF::
>  }
>
>  const MCExpr *TargetLoweringObjectFileELF::lowerRelativeReference(
> -    const GlobalValue *LHS, const GlobalValue *RHS, Mangler &Mang,
> +    const GlobalValue *LHS, const GlobalValue *RHS,
>      const TargetMachine &TM) const {
>    // We may only use a PLT-relative relocation to refer to unnamed_addr
>    // functions.
> @@ -437,9 +434,9 @@ const MCExpr *TargetLoweringObjectFileEL
>      return nullptr;
>
>    return MCBinaryExpr::createSub(
> -      MCSymbolRefExpr::create(TM.getSymbol(LHS, Mang), PLTRelativeVariantKind,
> +      MCSymbolRefExpr::create(TM.getSymbol(LHS, getMangler()), PLTRelativeVariantKind,
>                                getContext()),
> -      MCSymbolRefExpr::create(TM.getSymbol(RHS, Mang), getContext()),
> +      MCSymbolRefExpr::create(TM.getSymbol(RHS, getMangler()), getContext()),
>        getContext());
>  }
>
> @@ -490,10 +487,9 @@ void TargetLoweringObjectFileMachO::Init
>  }
>
>  /// emitModuleFlags - Perform code emission for module flags.
> -void TargetLoweringObjectFileMachO::
> -emitModuleFlags(MCStreamer &Streamer,
> -                ArrayRef<Module::ModuleFlagEntry> ModuleFlags,
> -                Mangler &Mang, const TargetMachine &TM) const {
> +void TargetLoweringObjectFileMachO::emitModuleFlags(
> +    MCStreamer &Streamer, ArrayRef<Module::ModuleFlagEntry> ModuleFlags,
> +    const TargetMachine &TM) const {
>    unsigned VersionVal = 0;
>    unsigned ImageInfoFlags = 0;
>    MDNode *LinkerOptions = nullptr;
> @@ -567,8 +563,7 @@ static void checkMachOComdat(const Globa
>  }
>
>  MCSection *TargetLoweringObjectFileMachO::getExplicitSectionGlobal(
> -    const GlobalValue *GV, SectionKind Kind, Mangler &Mang,
> -    const TargetMachine &TM) const {
> +    const GlobalValue *GV, SectionKind Kind, const TargetMachine &TM) const {
>    // Parse the section specifier and create it if valid.
>    StringRef Segment, Section;
>    unsigned TAA = 0, StubSize = 0;
> @@ -609,8 +604,7 @@ MCSection *TargetLoweringObjectFileMachO
>  }
>
>  MCSection *TargetLoweringObjectFileMachO::SelectSectionForGlobal(
> -    const GlobalValue *GV, SectionKind Kind, Mangler &Mang,
> -    const TargetMachine &TM) const {
> +    const GlobalValue *GV, SectionKind Kind, const TargetMachine &TM) const {
>    checkMachOComdat(GV);
>
>    // Handle thread local data.
> @@ -695,23 +689,21 @@ MCSection *TargetLoweringObjectFileMachO
>  }
>
>  const MCExpr *TargetLoweringObjectFileMachO::getTTypeGlobalReference(
> -    const GlobalValue *GV, unsigned Encoding, Mangler &Mang,
> -    const TargetMachine &TM, MachineModuleInfo *MMI,
> -    MCStreamer &Streamer) const {
> +    const GlobalValue *GV, unsigned Encoding, const TargetMachine &TM,
> +    MachineModuleInfo *MMI, MCStreamer &Streamer) const {
>    // The mach-o version of this method defaults to returning a stub reference.
>
>    if (Encoding & DW_EH_PE_indirect) {
>      MachineModuleInfoMachO &MachOMMI =
>        MMI->getObjFileInfo<MachineModuleInfoMachO>();
>
> -    MCSymbol *SSym =
> -        getSymbolWithGlobalValueBase(GV, "$non_lazy_ptr", Mang, TM);
> +    MCSymbol *SSym = getSymbolWithGlobalValueBase(GV, "$non_lazy_ptr", TM);
>
>      // Add information about the stub reference to MachOMMI so that the stub
>      // gets emitted by the asmprinter.
>      MachineModuleInfoImpl::StubValueTy &StubSym = MachOMMI.getGVStubEntry(SSym);
>      if (!StubSym.getPointer()) {
> -      MCSymbol *Sym = TM.getSymbol(GV, Mang);
> +      MCSymbol *Sym = TM.getSymbol(GV, getMangler());
>        StubSym = MachineModuleInfoImpl::StubValueTy(Sym, !GV->hasLocalLinkage());
>      }
>
> @@ -720,24 +712,24 @@ const MCExpr *TargetLoweringObjectFileMa
>                          Encoding & ~dwarf::DW_EH_PE_indirect, Streamer);
>    }
>
> -  return TargetLoweringObjectFile::getTTypeGlobalReference(GV, Encoding, Mang,
> -                                                           TM, MMI, Streamer);
> +  return TargetLoweringObjectFile::getTTypeGlobalReference(GV, Encoding, TM,
> +                                                           MMI, Streamer);
>  }
>
>  MCSymbol *TargetLoweringObjectFileMachO::getCFIPersonalitySymbol(
> -    const GlobalValue *GV, Mangler &Mang, const TargetMachine &TM,
> +    const GlobalValue *GV, const TargetMachine &TM,
>      MachineModuleInfo *MMI) const {
>    // The mach-o version of this method defaults to returning a stub reference.
>    MachineModuleInfoMachO &MachOMMI =
>      MMI->getObjFileInfo<MachineModuleInfoMachO>();
>
> -  MCSymbol *SSym = getSymbolWithGlobalValueBase(GV, "$non_lazy_ptr", Mang, TM);
> +  MCSymbol *SSym = getSymbolWithGlobalValueBase(GV, "$non_lazy_ptr", TM);
>
>    // Add information about the stub reference to MachOMMI so that the stub
>    // gets emitted by the asmprinter.
>    MachineModuleInfoImpl::StubValueTy &StubSym = MachOMMI.getGVStubEntry(SSym);
>    if (!StubSym.getPointer()) {
> -    MCSymbol *Sym = TM.getSymbol(GV, Mang);
> +    MCSymbol *Sym = TM.getSymbol(GV, getMangler());
>      StubSym = MachineModuleInfoImpl::StubValueTy(Sym, !GV->hasLocalLinkage());
>    }
>
> @@ -818,13 +810,13 @@ static bool canUsePrivateLabel(const MCA
>  }
>
>  void TargetLoweringObjectFileMachO::getNameWithPrefix(
> -    SmallVectorImpl<char> &OutName, const GlobalValue *GV, Mangler &Mang,
> +    SmallVectorImpl<char> &OutName, const GlobalValue *GV,
>      const TargetMachine &TM) const {
>    SectionKind GVKind = TargetLoweringObjectFile::getKindForGlobal(GV, TM);
> -  const MCSection *TheSection = SectionForGlobal(GV, GVKind, Mang, TM);
> +  const MCSection *TheSection = SectionForGlobal(GV, GVKind, TM);
>    bool CannotUsePrivateLabel =
>        !canUsePrivateLabel(*TM.getMCAsmInfo(), *TheSection);
> -  Mang.getNameWithPrefix(OutName, GV, CannotUsePrivateLabel);
> +  getMangler().getNameWithPrefix(OutName, GV, CannotUsePrivateLabel);
>  }
>
>  //===----------------------------------------------------------------------===//
> @@ -911,8 +903,7 @@ static int getSelectionForCOFF(const Glo
>  }
>
>  MCSection *TargetLoweringObjectFileCOFF::getExplicitSectionGlobal(
> -    const GlobalValue *GV, SectionKind Kind, Mangler &Mang,
> -    const TargetMachine &TM) const {
> +    const GlobalValue *GV, SectionKind Kind, const TargetMachine &TM) const {
>    int Selection = 0;
>    unsigned Characteristics = getCOFFSectionFlags(Kind, TM);
>    StringRef Name = GV->getSection();
> @@ -926,7 +917,7 @@ MCSection *TargetLoweringObjectFileCOFF:
>        ComdatGV = GV;
>
>      if (!ComdatGV->hasPrivateLinkage()) {
> -      MCSymbol *Sym = TM.getSymbol(ComdatGV, Mang);
> +      MCSymbol *Sym = TM.getSymbol(ComdatGV, getMangler());
>        COMDATSymName = Sym->getName();
>        Characteristics |= COFF::IMAGE_SCN_LNK_COMDAT;
>      } else {
> @@ -951,8 +942,7 @@ static const char *getCOFFSectionNameFor
>  }
>
>  MCSection *TargetLoweringObjectFileCOFF::SelectSectionForGlobal(
> -    const GlobalValue *GV, SectionKind Kind, Mangler &Mang,
> -    const TargetMachine &TM) const {
> +    const GlobalValue *GV, SectionKind Kind, const TargetMachine &TM) const {
>    // If we have -ffunction-sections then we should emit the global value to a
>    // uniqued section specifically for it.
>    bool EmitUniquedSection;
> @@ -980,13 +970,13 @@ MCSection *TargetLoweringObjectFileCOFF:
>        UniqueID = NextUniqueID++;
>
>      if (!ComdatGV->hasPrivateLinkage()) {
> -      MCSymbol *Sym = TM.getSymbol(ComdatGV, Mang);
> +      MCSymbol *Sym = TM.getSymbol(ComdatGV, getMangler());
>        StringRef COMDATSymName = Sym->getName();
>        return getContext().getCOFFSection(Name, Characteristics, Kind,
>                                           COMDATSymName, Selection, UniqueID);
>      } else {
>        SmallString<256> TmpData;
> -      Mang.getNameWithPrefix(TmpData, GV, /*CannotUsePrivateLabel=*/true);
> +      getMangler().getNameWithPrefix(TmpData, GV, /*CannotUsePrivateLabel=*/true);
>        return getContext().getCOFFSection(Name, Characteristics, Kind, TmpData,
>                                           Selection, UniqueID);
>      }
> @@ -1011,7 +1001,7 @@ MCSection *TargetLoweringObjectFileCOFF:
>  }
>
>  void TargetLoweringObjectFileCOFF::getNameWithPrefix(
> -    SmallVectorImpl<char> &OutName, const GlobalValue *GV, Mangler &Mang,
> +    SmallVectorImpl<char> &OutName, const GlobalValue *GV,
>      const TargetMachine &TM) const {
>    bool CannotUsePrivateLabel = false;
>    if (GV->hasPrivateLinkage() &&
> @@ -1019,11 +1009,11 @@ void TargetLoweringObjectFileCOFF::getNa
>         (isa<GlobalVariable>(GV) && TM.getDataSections())))
>      CannotUsePrivateLabel = true;
>
> -  Mang.getNameWithPrefix(OutName, GV, CannotUsePrivateLabel);
> +  getMangler().getNameWithPrefix(OutName, GV, CannotUsePrivateLabel);
>  }
>
>  MCSection *TargetLoweringObjectFileCOFF::getSectionForJumpTable(
> -    const Function &F, Mangler &Mang, const TargetMachine &TM) const {
> +    const Function &F, const TargetMachine &TM) const {
>    // If the function can be removed, produce a unique section so that
>    // the table doesn't prevent the removal.
>    const Comdat *C = F.getComdat();
> @@ -1035,7 +1025,7 @@ MCSection *TargetLoweringObjectFileCOFF:
>    if (F.hasPrivateLinkage())
>      return ReadOnlySection;
>
> -  MCSymbol *Sym = TM.getSymbol(&F, Mang);
> +  MCSymbol *Sym = TM.getSymbol(&F, getMangler());
>    StringRef COMDATSymName = Sym->getName();
>
>    SectionKind Kind = SectionKind::getReadOnly();
> @@ -1048,10 +1038,9 @@ MCSection *TargetLoweringObjectFileCOFF:
>                                       COFF::IMAGE_COMDAT_SELECT_ASSOCIATIVE, UniqueID);
>  }
>
> -void TargetLoweringObjectFileCOFF::
> -emitModuleFlags(MCStreamer &Streamer,
> -                ArrayRef<Module::ModuleFlagEntry> ModuleFlags,
> -                Mangler &Mang, const TargetMachine &TM) const {
> +void TargetLoweringObjectFileCOFF::emitModuleFlags(
> +    MCStreamer &Streamer, ArrayRef<Module::ModuleFlagEntry> ModuleFlags,
> +    const TargetMachine &TM) const {
>    MDNode *LinkerOptions = nullptr;
>
>    for (const auto &MFE : ModuleFlags) {
> @@ -1115,7 +1104,7 @@ MCSection *TargetLoweringObjectFileCOFF:
>  }
>
>  void TargetLoweringObjectFileCOFF::emitLinkerFlagsForGlobal(
> -    raw_ostream &OS, const GlobalValue *GV, const Mangler &Mang) const {
> +    raw_ostream &OS, const GlobalValue *GV) const {
>    if (!GV->hasDLLExportStorageClass() || GV->isDeclaration())
>      return;
>
> @@ -1129,14 +1118,14 @@ void TargetLoweringObjectFileCOFF::emitL
>    if (TT.isWindowsGNUEnvironment() || TT.isWindowsCygwinEnvironment()) {
>      std::string Flag;
>      raw_string_ostream FlagOS(Flag);
> -    Mang.getNameWithPrefix(FlagOS, GV, false);
> +    getMangler().getNameWithPrefix(FlagOS, GV, false);
>      FlagOS.flush();
>      if (Flag[0] == GV->getParent()->getDataLayout().getGlobalPrefix())
>        OS << Flag.substr(1);
>      else
>        OS << Flag;
>    } else {
> -    Mang.getNameWithPrefix(OS, GV, false);
> +    getMangler().getNameWithPrefix(OS, GV, false);
>    }
>
>    if (!GV->getValueType()->isFunctionTy()) {
>
> Modified: llvm/trunk/lib/LTO/LTOModule.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/LTO/LTOModule.cpp?rev=281708&r1=281707&r2=281708&view=diff
> ==============================================================================
> --- llvm/trunk/lib/LTO/LTOModule.cpp (original)
> +++ llvm/trunk/lib/LTO/LTOModule.cpp Fri Sep 16 02:33:15 2016
> @@ -19,7 +19,6 @@
>  #include "llvm/IR/Constants.h"
>  #include "llvm/IR/DiagnosticPrinter.h"
>  #include "llvm/IR/LLVMContext.h"
> -#include "llvm/IR/Mangler.h"
>  #include "llvm/IR/Metadata.h"
>  #include "llvm/IR/Module.h"
>  #include "llvm/MC/MCExpr.h"
> @@ -648,12 +647,10 @@ void LTOModule::parseMetadata() {
>    }
>
>    // Globals
> -  Mangler Mang;
>    for (const NameAndAttributes &Sym : _symbols) {
>      if (!Sym.symbol)
>        continue;
> -    _target->getObjFileLowering()->emitLinkerFlagsForGlobal(OS, Sym.symbol,
> -                                                            Mang);
> +    _target->getObjFileLowering()->emitLinkerFlagsForGlobal(OS, Sym.symbol);
>    }
>
>    // Add other interesting metadata here.
>
> Modified: llvm/trunk/lib/Target/AArch64/AArch64TargetObjectFile.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AArch64/AArch64TargetObjectFile.cpp?rev=281708&r1=281707&r2=281708&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Target/AArch64/AArch64TargetObjectFile.cpp (original)
> +++ llvm/trunk/lib/Target/AArch64/AArch64TargetObjectFile.cpp Fri Sep 16 02:33:15 2016
> @@ -30,15 +30,14 @@ AArch64_MachoTargetObjectFile::AArch64_M
>  }
>
>  const MCExpr *AArch64_MachoTargetObjectFile::getTTypeGlobalReference(
> -    const GlobalValue *GV, unsigned Encoding, Mangler &Mang,
> -    const TargetMachine &TM, MachineModuleInfo *MMI,
> -    MCStreamer &Streamer) const {
> +    const GlobalValue *GV, unsigned Encoding, const TargetMachine &TM,
> +    MachineModuleInfo *MMI, MCStreamer &Streamer) const {
>    // On Darwin, we can reference dwarf symbols with foo at GOT-., which
>    // is an indirect pc-relative reference. The default implementation
>    // won't reference using the GOT, so we need this target-specific
>    // version.
>    if (Encoding & (DW_EH_PE_indirect | DW_EH_PE_pcrel)) {
> -    const MCSymbol *Sym = TM.getSymbol(GV, Mang);
> +    const MCSymbol *Sym = TM.getSymbol(GV, getMangler());
>      const MCExpr *Res =
>          MCSymbolRefExpr::create(Sym, MCSymbolRefExpr::VK_GOT, getContext());
>      MCSymbol *PCSym = getContext().createTempSymbol();
> @@ -48,13 +47,13 @@ const MCExpr *AArch64_MachoTargetObjectF
>    }
>
>    return TargetLoweringObjectFileMachO::getTTypeGlobalReference(
> -      GV, Encoding, Mang, TM, MMI, Streamer);
> +      GV, Encoding, TM, MMI, Streamer);
>  }
>
>  MCSymbol *AArch64_MachoTargetObjectFile::getCFIPersonalitySymbol(
> -    const GlobalValue *GV, Mangler &Mang, const TargetMachine &TM,
> +    const GlobalValue *GV, const TargetMachine &TM,
>      MachineModuleInfo *MMI) const {
> -  return TM.getSymbol(GV, Mang);
> +  return TM.getSymbol(GV, getMangler());
>  }
>
>  const MCExpr *AArch64_MachoTargetObjectFile::getIndirectSymViaGOTPCRel(
>
> Modified: llvm/trunk/lib/Target/AArch64/AArch64TargetObjectFile.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AArch64/AArch64TargetObjectFile.h?rev=281708&r1=281707&r2=281708&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Target/AArch64/AArch64TargetObjectFile.h (original)
> +++ llvm/trunk/lib/Target/AArch64/AArch64TargetObjectFile.h Fri Sep 16 02:33:15 2016
> @@ -27,12 +27,12 @@ public:
>    AArch64_MachoTargetObjectFile();
>
>    const MCExpr *getTTypeGlobalReference(const GlobalValue *GV,
> -                                        unsigned Encoding, Mangler &Mang,
> +                                        unsigned Encoding,
>                                          const TargetMachine &TM,
>                                          MachineModuleInfo *MMI,
>                                          MCStreamer &Streamer) const override;
>
> -  MCSymbol *getCFIPersonalitySymbol(const GlobalValue *GV, Mangler &Mang,
> +  MCSymbol *getCFIPersonalitySymbol(const GlobalValue *GV,
>                                      const TargetMachine &TM,
>                                      MachineModuleInfo *MMI) const override;
>
>
> Modified: llvm/trunk/lib/Target/AMDGPU/AMDGPUTargetObjectFile.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AMDGPU/AMDGPUTargetObjectFile.cpp?rev=281708&r1=281707&r2=281708&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Target/AMDGPU/AMDGPUTargetObjectFile.cpp (original)
> +++ llvm/trunk/lib/Target/AMDGPU/AMDGPUTargetObjectFile.cpp Fri Sep 16 02:33:15 2016
> @@ -20,12 +20,10 @@ using namespace llvm;
>  // Generic Object File
>  //===----------------------------------------------------------------------===//
>
> -MCSection *AMDGPUTargetObjectFile::SelectSectionForGlobal(const GlobalValue *GV,
> -                                                          SectionKind Kind,
> -                                                          Mangler &Mang,
> -                                                const TargetMachine &TM) const {
> +MCSection *AMDGPUTargetObjectFile::SelectSectionForGlobal(
> +    const GlobalValue *GV, SectionKind Kind, const TargetMachine &TM) const {
>    if (Kind.isReadOnly() && AMDGPU::isReadOnlySegment(GV))
>      return TextSection;
>
> -  return TargetLoweringObjectFileELF::SelectSectionForGlobal(GV, Kind, Mang, TM);
> +  return TargetLoweringObjectFileELF::SelectSectionForGlobal(GV, Kind, TM);
>  }
>
> Modified: llvm/trunk/lib/Target/AMDGPU/AMDGPUTargetObjectFile.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AMDGPU/AMDGPUTargetObjectFile.h?rev=281708&r1=281707&r2=281708&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Target/AMDGPU/AMDGPUTargetObjectFile.h (original)
> +++ llvm/trunk/lib/Target/AMDGPU/AMDGPUTargetObjectFile.h Fri Sep 16 02:33:15 2016
> @@ -24,7 +24,6 @@ namespace llvm {
>  class AMDGPUTargetObjectFile : public TargetLoweringObjectFileELF {
>    public:
>      MCSection *SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
> -                                      Mangler &Mang,
>                                        const TargetMachine &TM) const override;
>  };
>
>
> Modified: llvm/trunk/lib/Target/ARM/ARMAsmPrinter.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMAsmPrinter.cpp?rev=281708&r1=281707&r2=281708&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Target/ARM/ARMAsmPrinter.cpp (original)
> +++ llvm/trunk/lib/Target/ARM/ARMAsmPrinter.cpp Fri Sep 16 02:33:15 2016
> @@ -543,11 +543,11 @@ void ARMAsmPrinter::EmitEndOfAsmFile(Mod
>      raw_string_ostream OS(Flags);
>
>      for (const auto &Function : M)
> -      TLOF.emitLinkerFlagsForGlobal(OS, &Function, *Mang);
> +      TLOF.emitLinkerFlagsForGlobal(OS, &Function);
>      for (const auto &Global : M.globals())
> -      TLOF.emitLinkerFlagsForGlobal(OS, &Global, *Mang);
> +      TLOF.emitLinkerFlagsForGlobal(OS, &Global);
>      for (const auto &Alias : M.aliases())
> -      TLOF.emitLinkerFlagsForGlobal(OS, &Alias, *Mang);
> +      TLOF.emitLinkerFlagsForGlobal(OS, &Alias);
>
>      OS.flush();
>
>
> Modified: llvm/trunk/lib/Target/ARM/ARMTargetObjectFile.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMTargetObjectFile.cpp?rev=281708&r1=281707&r2=281708&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Target/ARM/ARMTargetObjectFile.cpp (original)
> +++ llvm/trunk/lib/Target/ARM/ARMTargetObjectFile.cpp Fri Sep 16 02:33:15 2016
> @@ -41,16 +41,15 @@ void ARMElfTargetObjectFile::Initialize(
>  }
>
>  const MCExpr *ARMElfTargetObjectFile::getTTypeGlobalReference(
> -    const GlobalValue *GV, unsigned Encoding, Mangler &Mang,
> -    const TargetMachine &TM, MachineModuleInfo *MMI,
> -    MCStreamer &Streamer) const {
> +    const GlobalValue *GV, unsigned Encoding, const TargetMachine &TM,
> +    MachineModuleInfo *MMI, MCStreamer &Streamer) const {
>    if (TM.getMCAsmInfo()->getExceptionHandlingType() != ExceptionHandling::ARM)
>      return TargetLoweringObjectFileELF::getTTypeGlobalReference(
> -        GV, Encoding, Mang, TM, MMI, Streamer);
> +        GV, Encoding, TM, MMI, Streamer);
>
>    assert(Encoding == DW_EH_PE_absptr && "Can handle absptr encoding only");
>
> -  return MCSymbolRefExpr::create(TM.getSymbol(GV, Mang),
> +  return MCSymbolRefExpr::create(TM.getSymbol(GV, getMangler()),
>                                   MCSymbolRefExpr::VK_ARM_TARGET2, getContext());
>  }
>
>
> Modified: llvm/trunk/lib/Target/ARM/ARMTargetObjectFile.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMTargetObjectFile.h?rev=281708&r1=281707&r2=281708&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Target/ARM/ARMTargetObjectFile.h (original)
> +++ llvm/trunk/lib/Target/ARM/ARMTargetObjectFile.h Fri Sep 16 02:33:15 2016
> @@ -28,11 +28,11 @@ public:
>
>    void Initialize(MCContext &Ctx, const TargetMachine &TM) override;
>
> -  const MCExpr *
> -  getTTypeGlobalReference(const GlobalValue *GV, unsigned Encoding,
> -                          Mangler &Mang, const TargetMachine &TM,
> -                          MachineModuleInfo *MMI,
> -                          MCStreamer &Streamer) const override;
> +  const MCExpr *getTTypeGlobalReference(const GlobalValue *GV,
> +                                        unsigned Encoding,
> +                                        const TargetMachine &TM,
> +                                        MachineModuleInfo *MMI,
> +                                        MCStreamer &Streamer) const override;
>
>    /// \brief Describe a TLS variable address within debug info.
>    const MCExpr *getDebugThreadLocalSymbol(const MCSymbol *Sym) const override;
>
> Modified: llvm/trunk/lib/Target/Hexagon/HexagonTargetObjectFile.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Hexagon/HexagonTargetObjectFile.cpp?rev=281708&r1=281707&r2=281708&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Target/Hexagon/HexagonTargetObjectFile.cpp (original)
> +++ llvm/trunk/lib/Target/Hexagon/HexagonTargetObjectFile.cpp Fri Sep 16 02:33:15 2016
> @@ -100,10 +100,8 @@ void HexagonTargetObjectFile::Initialize
>                                 ELF::SHF_HEX_GPREL);
>  }
>
> -
>  MCSection *HexagonTargetObjectFile::SelectSectionForGlobal(
> -      const GlobalValue *GV, SectionKind Kind, Mangler &Mang,
> -      const TargetMachine &TM) const {
> +    const GlobalValue *GV, SectionKind Kind, const TargetMachine &TM) const {
>    TRACE("[SelectSectionForGlobal] GV(" << GV->getName() << ") ");
>    TRACE("input section(" << GV->getSection() << ") ");
>
> @@ -118,7 +116,7 @@ MCSection *HexagonTargetObjectFile::Sele
>           << (Kind.isBSSLocal() ? "kind_bss_local " : "" ));
>
>    if (isGlobalInSmallSection(GV, TM))
> -    return selectSmallSectionForGlobal(GV, Kind, Mang, TM);
> +    return selectSmallSectionForGlobal(GV, Kind, TM);
>
>    if (Kind.isCommon()) {
>      // This is purely for LTO+Linker Script because commons don't really have a
> @@ -130,14 +128,11 @@ MCSection *HexagonTargetObjectFile::Sele
>
>    TRACE("default_ELF_section\n");
>    // Otherwise, we work the same as ELF.
> -  return TargetLoweringObjectFileELF::SelectSectionForGlobal(GV, Kind,
> -              Mang, TM);
> +  return TargetLoweringObjectFileELF::SelectSectionForGlobal(GV, Kind, TM);
>  }
>
> -
>  MCSection *HexagonTargetObjectFile::getExplicitSectionGlobal(
> -      const GlobalValue *GV, SectionKind Kind, Mangler &Mang,
> -      const TargetMachine &TM) const {
> +    const GlobalValue *GV, SectionKind Kind, const TargetMachine &TM) const {
>    TRACE("[getExplicitSectionGlobal] GV(" << GV->getName() << ") from("
>          << GV->getSection() << ") ");
>    TRACE((GV->hasPrivateLinkage() ? "private_linkage " : "")
> @@ -161,12 +156,11 @@ MCSection *HexagonTargetObjectFile::getE
>    }
>
>    if (isGlobalInSmallSection(GV, TM))
> -    return selectSmallSectionForGlobal(GV, Kind, Mang, TM);
> +    return selectSmallSectionForGlobal(GV, Kind, TM);
>
>    // Otherwise, we work the same as ELF.
>    TRACE("default_ELF_section\n");
> -  return TargetLoweringObjectFileELF::getExplicitSectionGlobal(GV, Kind,
> -            Mang, TM);
> +  return TargetLoweringObjectFileELF::getExplicitSectionGlobal(GV, Kind, TM);
>  }
>
>
> @@ -302,10 +296,8 @@ unsigned HexagonTargetObjectFile::getSma
>    return 0;
>  }
>
> -
>  MCSection *HexagonTargetObjectFile::selectSmallSectionForGlobal(
> -      const GlobalValue *GV, SectionKind Kind, Mangler &Mang,
> -      const TargetMachine &TM) const {
> +    const GlobalValue *GV, SectionKind Kind, const TargetMachine &TM) const {
>    const Type *GTy = GV->getType()->getElementType();
>    unsigned Size = getSmallestAddressableSize(GTy, GV, TM);
>
> @@ -386,6 +378,5 @@ MCSection *HexagonTargetObjectFile::sele
>
>    TRACE("default ELF section\n");
>    // Otherwise, we work the same as ELF.
> -  return TargetLoweringObjectFileELF::SelectSectionForGlobal(GV, Kind,
> -              Mang, TM);
> +  return TargetLoweringObjectFileELF::SelectSectionForGlobal(GV, Kind, TM);
>  }
>
> Modified: llvm/trunk/lib/Target/Hexagon/HexagonTargetObjectFile.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Hexagon/HexagonTargetObjectFile.h?rev=281708&r1=281707&r2=281708&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Target/Hexagon/HexagonTargetObjectFile.h (original)
> +++ llvm/trunk/lib/Target/Hexagon/HexagonTargetObjectFile.h Fri Sep 16 02:33:15 2016
> @@ -20,10 +20,10 @@ namespace llvm {
>      void Initialize(MCContext &Ctx, const TargetMachine &TM) override;
>
>      MCSection *SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
> -        Mangler &Mang, const TargetMachine &TM) const override;
> +                                      const TargetMachine &TM) const override;
>
>      MCSection *getExplicitSectionGlobal(const GlobalValue *GV, SectionKind Kind,
> -        Mangler &Mang, const TargetMachine &TM) const override;
> +                                        const TargetMachine &TM) const override;
>
>      bool isGlobalInSmallSection(const GlobalValue *GV, const TargetMachine &TM)
>          const;
> @@ -40,7 +40,8 @@ namespace llvm {
>          const TargetMachine &TM) const;
>
>      MCSection *selectSmallSectionForGlobal(const GlobalValue *GV,
> -        SectionKind Kind, Mangler &Mang, const TargetMachine &TM) const;
> +                                           SectionKind Kind,
> +                                           const TargetMachine &TM) const;
>    };
>
>  } // namespace llvm
>
> Modified: llvm/trunk/lib/Target/Lanai/LanaiTargetObjectFile.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Lanai/LanaiTargetObjectFile.cpp?rev=281708&r1=281707&r2=281708&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Target/Lanai/LanaiTargetObjectFile.cpp (original)
> +++ llvm/trunk/lib/Target/Lanai/LanaiTargetObjectFile.cpp Fri Sep 16 02:33:15 2016
> @@ -90,10 +90,8 @@ bool LanaiTargetObjectFile::isGlobalInSm
>        GV->getParent()->getDataLayout().getTypeAllocSize(Ty));
>  }
>
> -MCSection *
> -LanaiTargetObjectFile::SelectSectionForGlobal(const GlobalValue *GV,
> -                                              SectionKind Kind, Mangler &Mang,
> -                                              const TargetMachine &TM) const {
> +MCSection *LanaiTargetObjectFile::SelectSectionForGlobal(
> +    const GlobalValue *GV, SectionKind Kind, const TargetMachine &TM) const {
>    // Handle Small Section classification here.
>    if (Kind.isBSS() && isGlobalInSmallSection(GV, TM, Kind))
>      return SmallBSSSection;
> @@ -101,8 +99,7 @@ LanaiTargetObjectFile::SelectSectionForG
>      return SmallDataSection;
>
>    // Otherwise, we work the same as ELF.
> -  return TargetLoweringObjectFileELF::SelectSectionForGlobal(GV, Kind, Mang,
> -                                                             TM);
> +  return TargetLoweringObjectFileELF::SelectSectionForGlobal(GV, Kind, TM);
>  }
>
>  /// Return true if this constant should be placed into small data section.
>
> Modified: llvm/trunk/lib/Target/Lanai/LanaiTargetObjectFile.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Lanai/LanaiTargetObjectFile.h?rev=281708&r1=281707&r2=281708&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Target/Lanai/LanaiTargetObjectFile.h (original)
> +++ llvm/trunk/lib/Target/Lanai/LanaiTargetObjectFile.h Fri Sep 16 02:33:15 2016
> @@ -31,7 +31,6 @@ public:
>                                    const TargetMachine &TM) const;
>
>    MCSection *SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
> -                                    Mangler &Mang,
>                                      const TargetMachine &TM) const override;
>
>    /// Return true if this constant should be placed into small data section.
>
> Modified: llvm/trunk/lib/Target/Mips/MipsTargetObjectFile.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MipsTargetObjectFile.cpp?rev=281708&r1=281707&r2=281708&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Target/Mips/MipsTargetObjectFile.cpp (original)
> +++ llvm/trunk/lib/Target/Mips/MipsTargetObjectFile.cpp Fri Sep 16 02:33:15 2016
> @@ -113,10 +113,8 @@ IsGlobalInSmallSectionImpl(const GlobalV
>        GV->getParent()->getDataLayout().getTypeAllocSize(Ty));
>  }
>
> -MCSection *
> -MipsTargetObjectFile::SelectSectionForGlobal(const GlobalValue *GV,
> -                                             SectionKind Kind, Mangler &Mang,
> -                                             const TargetMachine &TM) const {
> +MCSection *MipsTargetObjectFile::SelectSectionForGlobal(
> +    const GlobalValue *GV, SectionKind Kind, const TargetMachine &TM) const {
>    // TODO: Could also support "weak" symbols as well with ".gnu.linkonce.s.*"
>    // sections?
>
> @@ -127,7 +125,7 @@ MipsTargetObjectFile::SelectSectionForGl
>      return SmallDataSection;
>
>    // Otherwise, we work the same as ELF.
> -  return TargetLoweringObjectFileELF::SelectSectionForGlobal(GV, Kind, Mang,TM);
> +  return TargetLoweringObjectFileELF::SelectSectionForGlobal(GV, Kind, TM);
>  }
>
>  /// Return true if this constant should be placed into small data section.
>
> Modified: llvm/trunk/lib/Target/Mips/MipsTargetObjectFile.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MipsTargetObjectFile.h?rev=281708&r1=281707&r2=281708&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Target/Mips/MipsTargetObjectFile.h (original)
> +++ llvm/trunk/lib/Target/Mips/MipsTargetObjectFile.h Fri Sep 16 02:33:15 2016
> @@ -32,7 +32,6 @@ class MipsTargetMachine;
>                                      const TargetMachine &TM) const;
>
>      MCSection *SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
> -                                      Mangler &Mang,
>                                        const TargetMachine &TM) const override;
>
>      /// Return true if this constant should be placed into small data section.
>
> Modified: llvm/trunk/lib/Target/NVPTX/NVPTXISelLowering.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/NVPTX/NVPTXISelLowering.cpp?rev=281708&r1=281707&r2=281708&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Target/NVPTX/NVPTXISelLowering.cpp (original)
> +++ llvm/trunk/lib/Target/NVPTX/NVPTXISelLowering.cpp Fri Sep 16 02:33:15 2016
> @@ -4576,9 +4576,7 @@ NVPTXTargetObjectFile::~NVPTXTargetObjec
>    delete static_cast<NVPTXSection *>(DwarfMacinfoSection);
>  }
>
> -MCSection *
> -NVPTXTargetObjectFile::SelectSectionForGlobal(const GlobalValue *GV,
> -                                              SectionKind Kind, Mangler &Mang,
> -                                              const TargetMachine &TM) const {
> +MCSection *NVPTXTargetObjectFile::SelectSectionForGlobal(
> +    const GlobalValue *GV, SectionKind Kind, const TargetMachine &TM) const {
>    return getDataSection();
>  }
>
> Modified: llvm/trunk/lib/Target/NVPTX/NVPTXTargetObjectFile.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/NVPTX/NVPTXTargetObjectFile.h?rev=281708&r1=281707&r2=281708&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Target/NVPTX/NVPTXTargetObjectFile.h (original)
> +++ llvm/trunk/lib/Target/NVPTX/NVPTXTargetObjectFile.h Fri Sep 16 02:33:15 2016
> @@ -92,13 +92,11 @@ public:
>    }
>
>    MCSection *getExplicitSectionGlobal(const GlobalValue *GV, SectionKind Kind,
> -                                      Mangler &Mang,
>                                        const TargetMachine &TM) const override {
>      return DataSection;
>    }
>
>    MCSection *SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
> -                                    Mangler &Mang,
>                                      const TargetMachine &TM) const override;
>  };
>
>
> Modified: llvm/trunk/lib/Target/PowerPC/PPCTargetObjectFile.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCTargetObjectFile.cpp?rev=281708&r1=281707&r2=281708&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Target/PowerPC/PPCTargetObjectFile.cpp (original)
> +++ llvm/trunk/lib/Target/PowerPC/PPCTargetObjectFile.cpp Fri Sep 16 02:33:15 2016
> @@ -23,8 +23,7 @@ Initialize(MCContext &Ctx, const TargetM
>  }
>
>  MCSection *PPC64LinuxTargetObjectFile::SelectSectionForGlobal(
> -    const GlobalValue *GV, SectionKind Kind, Mangler &Mang,
> -    const TargetMachine &TM) const {
> +    const GlobalValue *GV, SectionKind Kind, const TargetMachine &TM) const {
>    // Here override ReadOnlySection to DataRelROSection for PPC64 SVR4 ABI
>    // when we have a constant that contains global relocations.  This is
>    // necessary because of this ABI's handling of pointers to functions in
> @@ -46,8 +45,7 @@ MCSection *PPC64LinuxTargetObjectFile::S
>        Kind = SectionKind::getReadOnlyWithRel();
>    }
>
> -  return TargetLoweringObjectFileELF::SelectSectionForGlobal(GV, Kind,
> -                                                             Mang, TM);
> +  return TargetLoweringObjectFileELF::SelectSectionForGlobal(GV, Kind, TM);
>  }
>
>  const MCExpr *PPC64LinuxTargetObjectFile::
>
> Modified: llvm/trunk/lib/Target/PowerPC/PPCTargetObjectFile.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCTargetObjectFile.h?rev=281708&r1=281707&r2=281708&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Target/PowerPC/PPCTargetObjectFile.h (original)
> +++ llvm/trunk/lib/Target/PowerPC/PPCTargetObjectFile.h Fri Sep 16 02:33:15 2016
> @@ -23,7 +23,6 @@ namespace llvm {
>      void Initialize(MCContext &Ctx, const TargetMachine &TM) override;
>
>      MCSection *SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
> -                                      Mangler &Mang,
>                                        const TargetMachine &TM) const override;
>
>      /// \brief Describe a TLS variable address within debug info.
>
> Modified: llvm/trunk/lib/Target/Sparc/SparcTargetObjectFile.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Sparc/SparcTargetObjectFile.cpp?rev=281708&r1=281707&r2=281708&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Target/Sparc/SparcTargetObjectFile.cpp (original)
> +++ llvm/trunk/lib/Target/Sparc/SparcTargetObjectFile.cpp Fri Sep 16 02:33:15 2016
> @@ -16,20 +16,19 @@
>  using namespace llvm;
>
>  const MCExpr *SparcELFTargetObjectFile::getTTypeGlobalReference(
> -    const GlobalValue *GV, unsigned Encoding, Mangler &Mang,
> -    const TargetMachine &TM, MachineModuleInfo *MMI,
> -    MCStreamer &Streamer) const {
> +    const GlobalValue *GV, unsigned Encoding, const TargetMachine &TM,
> +    MachineModuleInfo *MMI, MCStreamer &Streamer) const {
>
>    if (Encoding & dwarf::DW_EH_PE_pcrel) {
>      MachineModuleInfoELF &ELFMMI = MMI->getObjFileInfo<MachineModuleInfoELF>();
>
> -    MCSymbol *SSym = getSymbolWithGlobalValueBase(GV, ".DW.stub", Mang, TM);
> +    MCSymbol *SSym = getSymbolWithGlobalValueBase(GV, ".DW.stub", TM);
>
>      // Add information about the stub reference to ELFMMI so that the stub
>      // gets emitted by the asmprinter.
>      MachineModuleInfoImpl::StubValueTy &StubSym = ELFMMI.getGVStubEntry(SSym);
>      if (!StubSym.getPointer()) {
> -      MCSymbol *Sym = TM.getSymbol(GV, Mang);
> +      MCSymbol *Sym = TM.getSymbol(GV, getMangler());
>        StubSym = MachineModuleInfoImpl::StubValueTy(Sym, !GV->hasLocalLinkage());
>      }
>
> @@ -38,6 +37,6 @@ const MCExpr *SparcELFTargetObjectFile::
>                                 MCSymbolRefExpr::create(SSym, Ctx), Ctx);
>    }
>
> -  return TargetLoweringObjectFileELF::getTTypeGlobalReference(
> -      GV, Encoding, Mang, TM, MMI, Streamer);
> +  return TargetLoweringObjectFileELF::getTTypeGlobalReference(GV, Encoding, TM,
> +                                                              MMI, Streamer);
>  }
>
> Modified: llvm/trunk/lib/Target/Sparc/SparcTargetObjectFile.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Sparc/SparcTargetObjectFile.h?rev=281708&r1=281707&r2=281708&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Target/Sparc/SparcTargetObjectFile.h (original)
> +++ llvm/trunk/lib/Target/Sparc/SparcTargetObjectFile.h Fri Sep 16 02:33:15 2016
> @@ -23,11 +23,11 @@ public:
>      TargetLoweringObjectFileELF()
>    {}
>
> -  const MCExpr *
> -  getTTypeGlobalReference(const GlobalValue *GV, unsigned Encoding,
> -                          Mangler &Mang, const TargetMachine &TM,
> -                          MachineModuleInfo *MMI,
> -                          MCStreamer &Streamer) const override;
> +  const MCExpr *getTTypeGlobalReference(const GlobalValue *GV,
> +                                        unsigned Encoding,
> +                                        const TargetMachine &TM,
> +                                        MachineModuleInfo *MMI,
> +                                        MCStreamer &Streamer) const override;
>  };
>
>  } // end namespace llvm
>
> Modified: llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp?rev=281708&r1=281707&r2=281708&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp (original)
> +++ llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp Fri Sep 16 02:33:15 2016
> @@ -43,11 +43,13 @@ using namespace llvm;
>  void TargetLoweringObjectFile::Initialize(MCContext &ctx,
>                                            const TargetMachine &TM) {
>    Ctx = &ctx;
> +  Mang = new Mangler();
>    InitMCObjectFileInfo(TM.getTargetTriple(), TM.isPositionIndependent(),
>                         TM.getCodeModel(), *Ctx);
>  }
>
>  TargetLoweringObjectFile::~TargetLoweringObjectFile() {
> +  delete Mang;
>  }
>
>  static bool isSuitableForBSS(const GlobalVariable *GV, bool NoZerosInBSS) {
> @@ -101,21 +103,20 @@ static bool IsNullTerminatedString(const
>  }
>
>  MCSymbol *TargetLoweringObjectFile::getSymbolWithGlobalValueBase(
> -    const GlobalValue *GV, StringRef Suffix, Mangler &Mang,
> -    const TargetMachine &TM) const {
> +    const GlobalValue *GV, StringRef Suffix, const TargetMachine &TM) const {
>    assert(!Suffix.empty());
>
>    SmallString<60> NameStr;
>    NameStr += GV->getParent()->getDataLayout().getPrivateGlobalPrefix();
> -  TM.getNameWithPrefix(NameStr, GV, Mang);
> +  TM.getNameWithPrefix(NameStr, GV, *Mang);
>    NameStr.append(Suffix.begin(), Suffix.end());
>    return Ctx->getOrCreateSymbol(NameStr);
>  }
>
>  MCSymbol *TargetLoweringObjectFile::getCFIPersonalitySymbol(
> -    const GlobalValue *GV, Mangler &Mang, const TargetMachine &TM,
> +    const GlobalValue *GV, const TargetMachine &TM,
>      MachineModuleInfo *MMI) const {
> -  return TM.getSymbol(GV, Mang);
> +  return TM.getSymbol(GV, *Mang);
>  }
>
>  void TargetLoweringObjectFile::emitPersonalityValue(MCStreamer &Streamer,
> @@ -230,21 +231,18 @@ SectionKind TargetLoweringObjectFile::ge
>  /// This method computes the appropriate section to emit the specified global
>  /// variable or function definition.  This should not be passed external (or
>  /// available externally) globals.
> -MCSection *
> -TargetLoweringObjectFile::SectionForGlobal(const GlobalValue *GV,
> -                                           SectionKind Kind, Mangler &Mang,
> -                                           const TargetMachine &TM) const {
> +MCSection *TargetLoweringObjectFile::SectionForGlobal(
> +    const GlobalValue *GV, SectionKind Kind, const TargetMachine &TM) const {
>    // Select section name.
>    if (GV->hasSection())
> -    return getExplicitSectionGlobal(GV, Kind, Mang, TM);
> -
> +    return getExplicitSectionGlobal(GV, Kind, TM);
>
>    // Use default section depending on the 'type' of global
> -  return SelectSectionForGlobal(GV, Kind, Mang, TM);
> +  return SelectSectionForGlobal(GV, Kind, TM);
>  }
>
>  MCSection *TargetLoweringObjectFile::getSectionForJumpTable(
> -    const Function &F, Mangler &Mang, const TargetMachine &TM) const {
> +    const Function &F, const TargetMachine &TM) const {
>    unsigned Align = 0;
>    return getSectionForConstant(F.getParent()->getDataLayout(),
>                                 SectionKind::getReadOnly(), /*C=*/nullptr,
> @@ -284,11 +282,10 @@ MCSection *TargetLoweringObjectFile::get
>  /// reference to the specified global variable from exception
>  /// handling information.
>  const MCExpr *TargetLoweringObjectFile::getTTypeGlobalReference(
> -    const GlobalValue *GV, unsigned Encoding, Mangler &Mang,
> -    const TargetMachine &TM, MachineModuleInfo *MMI,
> -    MCStreamer &Streamer) const {
> +    const GlobalValue *GV, unsigned Encoding, const TargetMachine &TM,
> +    MachineModuleInfo *MMI, MCStreamer &Streamer) const {
>    const MCSymbolRefExpr *Ref =
> -      MCSymbolRefExpr::create(TM.getSymbol(GV, Mang), getContext());
> +      MCSymbolRefExpr::create(TM.getSymbol(GV, *Mang), getContext());
>
>    return getTTypeReference(Ref, Encoding, Streamer);
>  }
> @@ -320,7 +317,7 @@ const MCExpr *TargetLoweringObjectFile::
>  }
>
>  void TargetLoweringObjectFile::getNameWithPrefix(
> -    SmallVectorImpl<char> &OutName, const GlobalValue *GV, Mangler &Mang,
> +    SmallVectorImpl<char> &OutName, const GlobalValue *GV,
>      const TargetMachine &TM) const {
> -  Mang.getNameWithPrefix(OutName, GV, /*CannotUsePrivateLabel=*/false);
> +  Mang->getNameWithPrefix(OutName, GV, /*CannotUsePrivateLabel=*/false);
>  }
>
> Modified: llvm/trunk/lib/Target/TargetMachine.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/TargetMachine.cpp?rev=281708&r1=281707&r2=281708&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Target/TargetMachine.cpp (original)
> +++ llvm/trunk/lib/Target/TargetMachine.cpp Fri Sep 16 02:33:15 2016
> @@ -208,7 +208,7 @@ void TargetMachine::getNameWithPrefix(Sm
>      return;
>    }
>    const TargetLoweringObjectFile *TLOF = getObjFileLowering();
> -  TLOF->getNameWithPrefix(Name, GV, Mang, *this);
> +  TLOF->getNameWithPrefix(Name, GV, *this);
>  }
>
>  MCSymbol *TargetMachine::getSymbol(const GlobalValue *GV, Mangler &Mang) const {
>
> Modified: llvm/trunk/lib/Target/X86/X86AsmPrinter.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86AsmPrinter.cpp?rev=281708&r1=281707&r2=281708&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Target/X86/X86AsmPrinter.cpp (original)
> +++ llvm/trunk/lib/Target/X86/X86AsmPrinter.cpp Fri Sep 16 02:33:15 2016
> @@ -627,11 +627,11 @@ void X86AsmPrinter::EmitEndOfAsmFile(Mod
>      raw_string_ostream FlagsOS(Flags);
>
>      for (const auto &Function : M)
> -      TLOFCOFF.emitLinkerFlagsForGlobal(FlagsOS, &Function, *Mang);
> +      TLOFCOFF.emitLinkerFlagsForGlobal(FlagsOS, &Function);
>      for (const auto &Global : M.globals())
> -      TLOFCOFF.emitLinkerFlagsForGlobal(FlagsOS, &Global, *Mang);
> +      TLOFCOFF.emitLinkerFlagsForGlobal(FlagsOS, &Global);
>      for (const auto &Alias : M.aliases())
> -      TLOFCOFF.emitLinkerFlagsForGlobal(FlagsOS, &Alias, *Mang);
> +      TLOFCOFF.emitLinkerFlagsForGlobal(FlagsOS, &Alias);
>
>      FlagsOS.flush();
>
>
> Modified: llvm/trunk/lib/Target/X86/X86TargetObjectFile.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86TargetObjectFile.cpp?rev=281708&r1=281707&r2=281708&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Target/X86/X86TargetObjectFile.cpp (original)
> +++ llvm/trunk/lib/Target/X86/X86TargetObjectFile.cpp Fri Sep 16 02:33:15 2016
> @@ -24,14 +24,13 @@ using namespace llvm;
>  using namespace dwarf;
>
>  const MCExpr *X86_64MachoTargetObjectFile::getTTypeGlobalReference(
> -    const GlobalValue *GV, unsigned Encoding, Mangler &Mang,
> -    const TargetMachine &TM, MachineModuleInfo *MMI,
> -    MCStreamer &Streamer) const {
> +    const GlobalValue *GV, unsigned Encoding, const TargetMachine &TM,
> +    MachineModuleInfo *MMI, MCStreamer &Streamer) const {
>
>    // On Darwin/X86-64, we can reference dwarf symbols with foo at GOTPCREL+4, which
>    // is an indirect pc-relative reference.
>    if ((Encoding & DW_EH_PE_indirect) && (Encoding & DW_EH_PE_pcrel)) {
> -    const MCSymbol *Sym = TM.getSymbol(GV, Mang);
> +    const MCSymbol *Sym = TM.getSymbol(GV, getMangler());
>      const MCExpr *Res =
>        MCSymbolRefExpr::create(Sym, MCSymbolRefExpr::VK_GOTPCREL, getContext());
>      const MCExpr *Four = MCConstantExpr::create(4, getContext());
> @@ -39,13 +38,13 @@ const MCExpr *X86_64MachoTargetObjectFil
>    }
>
>    return TargetLoweringObjectFileMachO::getTTypeGlobalReference(
> -      GV, Encoding, Mang, TM, MMI, Streamer);
> +      GV, Encoding, TM, MMI, Streamer);
>  }
>
>  MCSymbol *X86_64MachoTargetObjectFile::getCFIPersonalitySymbol(
> -    const GlobalValue *GV, Mangler &Mang, const TargetMachine &TM,
> +    const GlobalValue *GV, const TargetMachine &TM,
>      MachineModuleInfo *MMI) const {
> -  return TM.getSymbol(GV, Mang);
> +  return TM.getSymbol(GV, getMangler());
>  }
>
>  const MCExpr *X86_64MachoTargetObjectFile::getIndirectSymViaGOTPCRel(
> @@ -74,7 +73,7 @@ X86LinuxNaClTargetObjectFile::Initialize
>  }
>
>  const MCExpr *X86WindowsTargetObjectFile::lowerRelativeReference(
> -    const GlobalValue *LHS, const GlobalValue *RHS, Mangler &Mang,
> +    const GlobalValue *LHS, const GlobalValue *RHS,
>      const TargetMachine &TM) const {
>    // Our symbols should exist in address space zero, cowardly no-op if
>    // otherwise.
> @@ -95,8 +94,9 @@ const MCExpr *X86WindowsTargetObjectFile
>        cast<GlobalVariable>(RHS)->hasInitializer() || RHS->hasSection())
>      return nullptr;
>
> -  return MCSymbolRefExpr::create(
> -      TM.getSymbol(LHS, Mang), MCSymbolRefExpr::VK_COFF_IMGREL32, getContext());
> +  return MCSymbolRefExpr::create(TM.getSymbol(LHS, getMangler()),
> +                                 MCSymbolRefExpr::VK_COFF_IMGREL32,
> +                                 getContext());
>  }
>
>  static std::string APIntToHexString(const APInt &AI) {
>
> Modified: llvm/trunk/lib/Target/X86/X86TargetObjectFile.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86TargetObjectFile.h?rev=281708&r1=281707&r2=281708&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Target/X86/X86TargetObjectFile.h (original)
> +++ llvm/trunk/lib/Target/X86/X86TargetObjectFile.h Fri Sep 16 02:33:15 2016
> @@ -19,15 +19,15 @@ namespace llvm {
>    /// x86-64.
>    class X86_64MachoTargetObjectFile : public TargetLoweringObjectFileMachO {
>    public:
> -    const MCExpr *
> -    getTTypeGlobalReference(const GlobalValue *GV, unsigned Encoding,
> -                            Mangler &Mang, const TargetMachine &TM,
> -                            MachineModuleInfo *MMI,
> -                            MCStreamer &Streamer) const override;
> +    const MCExpr *getTTypeGlobalReference(const GlobalValue *GV,
> +                                          unsigned Encoding,
> +                                          const TargetMachine &TM,
> +                                          MachineModuleInfo *MMI,
> +                                          MCStreamer &Streamer) const override;
>
>      // getCFIPersonalitySymbol - The symbol that gets passed to
>      // .cfi_personality.
> -    MCSymbol *getCFIPersonalitySymbol(const GlobalValue *GV, Mangler &Mang,
> +    MCSymbol *getCFIPersonalitySymbol(const GlobalValue *GV,
>                                        const TargetMachine &TM,
>                                        MachineModuleInfo *MMI) const override;
>
> @@ -59,7 +59,6 @@ namespace llvm {
>    class X86WindowsTargetObjectFile : public TargetLoweringObjectFileCOFF {
>      const MCExpr *
>      lowerRelativeReference(const GlobalValue *LHS, const GlobalValue *RHS,
> -                           Mangler &Mang,
>                             const TargetMachine &TM) const override;
>
>      /// \brief Given a mergeable constant with the specified size and relocation
>
> Modified: llvm/trunk/lib/Target/XCore/XCoreAsmPrinter.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/XCore/XCoreAsmPrinter.cpp?rev=281708&r1=281707&r2=281708&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Target/XCore/XCoreAsmPrinter.cpp (original)
> +++ llvm/trunk/lib/Target/XCore/XCoreAsmPrinter.cpp Fri Sep 16 02:33:15 2016
> @@ -115,8 +115,7 @@ void XCoreAsmPrinter::EmitGlobalVariable
>      return;
>
>    const DataLayout &DL = getDataLayout();
> -  OutStreamer->SwitchSection(
> -      getObjFileLowering().SectionForGlobal(GV, *Mang, TM));
> +  OutStreamer->SwitchSection(getObjFileLowering().SectionForGlobal(GV, TM));
>
>    MCSymbol *GVSym = getSymbol(GV);
>    const Constant *C = GV->getInitializer();
>
> Modified: llvm/trunk/lib/Target/XCore/XCoreTargetObjectFile.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/XCore/XCoreTargetObjectFile.cpp?rev=281708&r1=281707&r2=281708&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Target/XCore/XCoreTargetObjectFile.cpp (original)
> +++ llvm/trunk/lib/Target/XCore/XCoreTargetObjectFile.cpp Fri Sep 16 02:33:15 2016
> @@ -95,10 +95,8 @@ static unsigned getXCoreSectionFlags(Sec
>    return Flags;
>  }
>
> -MCSection *
> -XCoreTargetObjectFile::getExplicitSectionGlobal(const GlobalValue *GV,
> -                                                SectionKind Kind, Mangler &Mang,
> -                                                const TargetMachine &TM) const {
> +MCSection *XCoreTargetObjectFile::getExplicitSectionGlobal(
> +    const GlobalValue *GV, SectionKind Kind, const TargetMachine &TM) const {
>    StringRef SectionName = GV->getSection();
>    // Infer section flags from the section name if we can.
>    bool IsCPRel = SectionName.startswith(".cp.");
> @@ -108,10 +106,8 @@ XCoreTargetObjectFile::getExplicitSectio
>                                      getXCoreSectionFlags(Kind, IsCPRel));
>  }
>
> -MCSection *
> -XCoreTargetObjectFile::SelectSectionForGlobal(const GlobalValue *GV,
> -                                              SectionKind Kind, Mangler &Mang,
> -                                              const TargetMachine &TM) const {
> +MCSection *XCoreTargetObjectFile::SelectSectionForGlobal(
> +    const GlobalValue *GV, SectionKind Kind, const TargetMachine &TM) const {
>
>    bool UseCPRel = GV->isLocalLinkage(GV->getLinkage());
>
>
> Modified: llvm/trunk/lib/Target/XCore/XCoreTargetObjectFile.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/XCore/XCoreTargetObjectFile.h?rev=281708&r1=281707&r2=281708&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Target/XCore/XCoreTargetObjectFile.h (original)
> +++ llvm/trunk/lib/Target/XCore/XCoreTargetObjectFile.h Fri Sep 16 02:33:15 2016
> @@ -26,11 +26,9 @@ static const unsigned CodeModelLargeSize
>      void Initialize(MCContext &Ctx, const TargetMachine &TM) override;
>
>      MCSection *getExplicitSectionGlobal(const GlobalValue *GV, SectionKind Kind,
> -                                        Mangler &Mang,
>                                          const TargetMachine &TM) const override;
>
>      MCSection *SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
> -                                      Mangler &Mang,
>                                        const TargetMachine &TM) const override;
>
>      MCSection *getSectionForConstant(const DataLayout &DL, SectionKind Kind,
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>


-- 

-Bill Seurer



More information about the llvm-commits mailing list