[cfe-commits] r161991 - in /cfe/trunk: lib/Sema/SemaStmt.cpp test/CodeGen/ms-inline-asm.c
Chad Rosier
mcrosier at apple.com
Wed Aug 15 14:55:19 PDT 2012
Author: mcrosier
Date: Wed Aug 15 16:55:19 2012
New Revision: 161991
URL: http://llvm.org/viewvc/llvm-project?rev=161991&view=rev
Log:
[ms-inline asm] Use a set container to remove redundant clobbers.
Modified:
cfe/trunk/lib/Sema/SemaStmt.cpp
cfe/trunk/test/CodeGen/ms-inline-asm.c
Modified: cfe/trunk/lib/Sema/SemaStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaStmt.cpp?rev=161991&r1=161990&r2=161991&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaStmt.cpp (original)
+++ cfe/trunk/lib/Sema/SemaStmt.cpp Wed Aug 15 16:55:19 2012
@@ -2878,9 +2878,8 @@
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 @@
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,
Modified: cfe/trunk/test/CodeGen/ms-inline-asm.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/ms-inline-asm.c?rev=161991&r1=161990&r2=161991&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/ms-inline-asm.c (original)
+++ cfe/trunk/test/CodeGen/ms-inline-asm.c Wed Aug 15 16:55:19 2012
@@ -80,5 +80,5 @@
pop ebx
}
// CHECK: t10
-// CHECK: call void asm sideeffect "push ebx\0Amov ebx, 0x07\0Apop ebx", "~{ebx},~{ebx},~{dirflag},~{fpsr},~{flags}"() nounwind ia_nsdialect
+// CHECK: call void asm sideeffect "push ebx\0Amov ebx, 0x07\0Apop ebx", "~{ebx},~{dirflag},~{fpsr},~{flags}"() nounwind ia_nsdialect
}
More information about the cfe-commits
mailing list