[PATCH] D37262: The issues with X86 prefixes: step 2

Craig Topper via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 11 09:58:04 PDT 2017


craig.topper added inline comments.


================
Comment at: lib/Target/X86/AsmParser/X86AsmParser.cpp:2865
+
+  if (static_cast<X86Operand &>(*Operands.back()).Kind == X86Operand::Prefix) {
+    X86Operand &Prefix = static_cast<X86Operand &>(*Operands.pop_back_val());
----------------
Use isPrefix()?


================
Comment at: lib/Target/X86/AsmParser/X86AsmParser.cpp:2866
+  if (static_cast<X86Operand &>(*Operands.back()).Kind == X86Operand::Prefix) {
+    X86Operand &Prefix = static_cast<X86Operand &>(*Operands.pop_back_val());
+    Prefixes = Prefix.getPrefix();
----------------
I'm not sure this isn't a use after free. pop_back_val is going to return a std::unique_ptr which you dereferenced, but I'm not convinced anything is keeping the std::unique_ptr alive.


================
Comment at: lib/Target/X86/AsmParser/X86Operand.h:395
 
+  bool isPrefux() const { return Kind == Prefix; }
   bool isReg() const override { return Kind == Register; }
----------------
isPrefix*


https://reviews.llvm.org/D37262





More information about the llvm-commits mailing list