diff options
author | Eric Christopher <echristo@gmail.com> | 2015-02-20 19:54:07 +0000 |
---|---|---|
committer | Eric Christopher <echristo@gmail.com> | 2015-02-20 19:54:07 +0000 |
commit | db51e2a52abd84a2d07887609768e7724063d405 (patch) | |
tree | dc5bf523325e3460bb72b65d874a3cb76296a26c | |
parent | c5515ef1bb88c03367e750a495c5804c3aa441c8 (diff) | |
download | bcm5719-llvm-db51e2a52abd84a2d07887609768e7724063d405.tar.gz bcm5719-llvm-db51e2a52abd84a2d07887609768e7724063d405.zip |
Fix an asan use-after-free bug introduced by the asm printer
changes to remove non-Function based subtargets out of the asm
printer. For module level emission we'll need to construct up
an MCSubtargetInfo so that we can encode instructions for
emission.
llvm-svn: 230050
-rw-r--r-- | llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp b/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp index c31d024003f..480b790a99b 100644 --- a/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp +++ b/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp @@ -1303,7 +1303,17 @@ static MCSymbol *GetAnonSym(MCSymbol *Sym, MCContext &Ctx) { void PPCDarwinAsmPrinter:: EmitFunctionStubs(const MachineModuleInfoMachO::SymbolListTy &Stubs) { bool isPPC64 = TM.getDataLayout()->getPointerSizeInBits() == 64; - + + // Construct a local MCSubtargetInfo and shadow EmitToStreamer here. + // This is because the MachineFunction won't exist (but have not yet been + // freed) and since we're at the global level we can use the default + // constructed subtarget. + std::unique_ptr<MCSubtargetInfo> STI(TM.getTarget().createMCSubtargetInfo( + TM.getTargetTriple(), TM.getTargetCPU(), TM.getTargetFeatureString())); + auto EmitToStreamer = [&STI] (MCStreamer &S, const MCInst &Inst) { + S.EmitInstruction(Inst, *STI); + }; + const TargetLoweringObjectFileMachO &TLOFMacho = static_cast<const TargetLoweringObjectFileMachO &>(getObjFileLowering()); |