diff options
author | Chad Rosier <mcrosier@apple.com> | 2012-08-15 21:55:19 +0000 |
---|---|---|
committer | Chad Rosier <mcrosier@apple.com> | 2012-08-15 21:55:19 +0000 |
commit | b5f9eb8a0709082bba8e8de3a6c643928570aaa0 (patch) | |
tree | 0363a655932e14e67bfa75109cb460a332fa9d29 /lib/Sema/SemaStmt.cpp | |
parent | bec224b33b383c993d127ef7f618ce27df7105e6 (diff) |
[ms-inline asm] Use a set container to remove redundant clobbers.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@161991 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaStmt.cpp')
-rw-r--r-- | lib/Sema/SemaStmt.cpp | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/lib/Sema/SemaStmt.cpp b/lib/Sema/SemaStmt.cpp index f2fd7e5312..27e420fadc 100644 --- a/lib/Sema/SemaStmt.cpp +++ b/lib/Sema/SemaStmt.cpp @@ -2878,9 +2878,8 @@ StmtResult Sema::ActOnMSAsmStmt(SourceLocation AsmLoc, SourceLocation EndLoc) { // MS-style inline assembly is not fully supported, so emit a warning. Diag(AsmLoc, diag::warn_unsupported_msasm); - unsigned NumClobberRegs = 0; SmallVector<StringRef,4> Clobbers; - SmallVector<std::string,4> ClobberRegs; + std::set<std::string> ClobberRegs; // Empty asm statements don't need to instantiate the AsmParser, etc. if (AsmToks.empty()) { @@ -2979,23 +2978,25 @@ StmtResult Sema::ActOnMSAsmStmt(SourceLocation AsmLoc, TheTarget->createMCInstPrinter(1, *MAI, *MII, *MRI, *STI); // Build the list of clobbers. - ClobberRegs.resize(NumClobberRegs + Desc.getNumDefs()); for (unsigned i = 0, e = Desc.getNumDefs(); i != e; ++i) { const llvm::MCOperand &Op = Inst.getOperand(i); if (!Op.isReg()) continue; - llvm::raw_string_ostream OS(ClobberRegs[NumClobberRegs]); + std::string Reg; + llvm::raw_string_ostream OS(Reg); IP->printRegName(OS, Op.getReg()); StringRef Clobber(OS.str()); if (!Context.getTargetInfo().isValidClobber(Clobber)) return StmtError(Diag(AsmLoc, diag::err_asm_unknown_register_name) << Clobber); - // FIXME: Asm blocks may result in redundant clobbers. - Clobbers.push_back(ClobberRegs[NumClobberRegs++]); + ClobberRegs.insert(Reg); } } + for (std::set<std::string>::iterator I = ClobberRegs.begin(), + E = ClobberRegs.end(); I != E; ++I) + Clobbers.push_back(*I); MSAsmStmt *NS = new (Context) MSAsmStmt(Context, AsmLoc, LBraceLoc, |