Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(110)

Side by Side Diff: lib/MC/MCAsmStreamer.cpp

Issue 1265823002: Auto-sandboxing: Don't expand instructions when in a bundle-locked group (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-llvm.git@master
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | lib/MC/MCObjectStreamer.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 //===- lib/MC/MCAsmStreamer.cpp - Text Assembly Output --------------------===// 1 //===- lib/MC/MCAsmStreamer.cpp - Text Assembly Output --------------------===//
2 // 2 //
3 // The LLVM Compiler Infrastructure 3 // The LLVM Compiler Infrastructure
4 // 4 //
5 // This file is distributed under the University of Illinois Open Source 5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details. 6 // License. See LICENSE.TXT for details.
7 // 7 //
8 //===----------------------------------------------------------------------===// 8 //===----------------------------------------------------------------------===//
9 9
10 #include "llvm/MC/MCStreamer.h" 10 #include "llvm/MC/MCStreamer.h"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 47
48 SmallString<128> CommentToEmit; 48 SmallString<128> CommentToEmit;
49 raw_svector_ostream CommentStream; 49 raw_svector_ostream CommentStream;
50 50
51 unsigned IsVerboseAsm : 1; 51 unsigned IsVerboseAsm : 1;
52 unsigned ShowInst : 1; 52 unsigned ShowInst : 1;
53 unsigned UseDwarfDirectory : 1; 53 unsigned UseDwarfDirectory : 1;
54 // @LOCALMOD: we don't have an MCAssembler object here, so we can't ask it 54 // @LOCALMOD: we don't have an MCAssembler object here, so we can't ask it
55 // if bundle alignment is enabled. Instead, just track the alignment here. 55 // if bundle alignment is enabled. Instead, just track the alignment here.
56 unsigned BundleAlignmentEnabled : 1; 56 unsigned BundleAlignmentEnabled : 1;
57 unsigned BundleLocked : 1;
57 58
58 void EmitRegisterName(int64_t Register); 59 void EmitRegisterName(int64_t Register);
59 void EmitCFIStartProcImpl(MCDwarfFrameInfo &Frame) override; 60 void EmitCFIStartProcImpl(MCDwarfFrameInfo &Frame) override;
60 void EmitCFIEndProcImpl(MCDwarfFrameInfo &Frame) override; 61 void EmitCFIEndProcImpl(MCDwarfFrameInfo &Frame) override;
61 62
62 public: 63 public:
63 MCAsmStreamer(MCContext &Context, std::unique_ptr<formatted_raw_ostream> os, 64 MCAsmStreamer(MCContext &Context, std::unique_ptr<formatted_raw_ostream> os,
64 bool isVerboseAsm, bool useDwarfDirectory, 65 bool isVerboseAsm, bool useDwarfDirectory,
65 MCInstPrinter *printer, MCCodeEmitter *emitter, 66 MCInstPrinter *printer, MCCodeEmitter *emitter,
66 MCAsmBackend *asmbackend, bool showInst) 67 MCAsmBackend *asmbackend, bool showInst)
(...skipping 1182 matching lines...) Expand 10 before | Expand all | Expand 10 after
1249 OS << " fixup " << char('A' + i) << " - " << "offset: " << F.getOffset() 1250 OS << " fixup " << char('A' + i) << " - " << "offset: " << F.getOffset()
1250 << ", value: " << *F.getValue() << ", kind: " << Info.Name << "\n"; 1251 << ", value: " << *F.getValue() << ", kind: " << Info.Name << "\n";
1251 } 1252 }
1252 } 1253 }
1253 1254
1254 void MCAsmStreamer::EmitInstruction(const MCInst &Inst, const MCSubtargetInfo &S TI) { 1255 void MCAsmStreamer::EmitInstruction(const MCInst &Inst, const MCSubtargetInfo &S TI) {
1255 assert(getCurrentSection().first && 1256 assert(getCurrentSection().first &&
1256 "Cannot emit contents before setting section!"); 1257 "Cannot emit contents before setting section!");
1257 1258
1258 // @LOCALMOD-START 1259 // @LOCALMOD-START
1259 if (NaClExpander && NaClExpander->expandInst(Inst, *this, STI)) 1260 if (NaClExpander && !BundleLocked &&
1261 NaClExpander->expandInst(Inst, *this, STI))
1260 return; 1262 return;
1261 1263
1262 if (BundleAlignmentEnabled && AsmBackend && 1264 if (BundleAlignmentEnabled && AsmBackend &&
1263 AsmBackend->CustomExpandInst(Inst, *this)) { 1265 AsmBackend->CustomExpandInst(Inst, *this)) {
1264 return; 1266 return;
1265 } 1267 }
1266 // @LOCALMOD-END 1268 // @LOCALMOD-END
1267 // Show the encoding in a comment if we have a code emitter. 1269 // Show the encoding in a comment if we have a code emitter.
1268 if (Emitter) 1270 if (Emitter)
1269 AddEncodingComment(Inst, STI); 1271 AddEncodingComment(Inst, STI);
(...skipping 15 matching lines...) Expand all
1285 void MCAsmStreamer::EmitBundleAlignMode(unsigned AlignPow2) { 1287 void MCAsmStreamer::EmitBundleAlignMode(unsigned AlignPow2) {
1286 OS << "\t.bundle_align_mode " << AlignPow2; 1288 OS << "\t.bundle_align_mode " << AlignPow2;
1287 BundleAlignmentEnabled = AlignPow2 > 0; // @LOCALMOD 1289 BundleAlignmentEnabled = AlignPow2 > 0; // @LOCALMOD
1288 EmitEOL(); 1290 EmitEOL();
1289 } 1291 }
1290 1292
1291 void MCAsmStreamer::EmitBundleLock(bool AlignToEnd) { 1293 void MCAsmStreamer::EmitBundleLock(bool AlignToEnd) {
1292 OS << "\t.bundle_lock"; 1294 OS << "\t.bundle_lock";
1293 if (AlignToEnd) 1295 if (AlignToEnd)
1294 OS << " align_to_end"; 1296 OS << " align_to_end";
1297 BundleLocked = true; // @LOCALMOD
1295 EmitEOL(); 1298 EmitEOL();
1296 } 1299 }
1297 1300
1298 void MCAsmStreamer::EmitBundleUnlock() { 1301 void MCAsmStreamer::EmitBundleUnlock() {
1299 OS << "\t.bundle_unlock"; 1302 OS << "\t.bundle_unlock";
1303 BundleLocked = false; // @LOCALMOD
1300 EmitEOL(); 1304 EmitEOL();
1301 } 1305 }
1302 1306
1303 /// EmitRawText - If this file is backed by an assembly streamer, this dumps 1307 /// EmitRawText - If this file is backed by an assembly streamer, this dumps
1304 /// the specified string in the output .s file. This capability is 1308 /// the specified string in the output .s file. This capability is
1305 /// indicated by the hasRawTextSupport() predicate. 1309 /// indicated by the hasRawTextSupport() predicate.
1306 void MCAsmStreamer::EmitRawTextImpl(StringRef String) { 1310 void MCAsmStreamer::EmitRawTextImpl(StringRef String) {
1307 if (!String.empty() && String.back() == '\n') 1311 if (!String.empty() && String.back() == '\n')
1308 String = String.substr(0, String.size()-1); 1312 String = String.substr(0, String.size()-1);
1309 OS << String; 1313 OS << String;
(...skipping 19 matching lines...) Expand all
1329 } 1333 }
1330 1334
1331 MCStreamer *llvm::createAsmStreamer(MCContext &Context, 1335 MCStreamer *llvm::createAsmStreamer(MCContext &Context,
1332 std::unique_ptr<formatted_raw_ostream> OS, 1336 std::unique_ptr<formatted_raw_ostream> OS,
1333 bool isVerboseAsm, bool useDwarfDirectory, 1337 bool isVerboseAsm, bool useDwarfDirectory,
1334 MCInstPrinter *IP, MCCodeEmitter *CE, 1338 MCInstPrinter *IP, MCCodeEmitter *CE,
1335 MCAsmBackend *MAB, bool ShowInst) { 1339 MCAsmBackend *MAB, bool ShowInst) {
1336 return new MCAsmStreamer(Context, std::move(OS), isVerboseAsm, 1340 return new MCAsmStreamer(Context, std::move(OS), isVerboseAsm,
1337 useDwarfDirectory, IP, CE, MAB, ShowInst); 1341 useDwarfDirectory, IP, CE, MAB, ShowInst);
1338 } 1342 }
OLDNEW
« no previous file with comments | « no previous file | lib/MC/MCObjectStreamer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698