[BOLT][NFC] Use std::optional for readDWARFExpressionTargetReg
authorAmir Ayupov <aaupov@fb.com>
Sun, 11 Dec 2022 20:41:57 +0000 (12:41 -0800)
committerAmir Ayupov <aaupov@fb.com>
Mon, 12 Dec 2022 06:13:47 +0000 (22:13 -0800)
bolt/include/bolt/Utils/Utils.h
bolt/lib/Core/BinaryFunction.cpp
bolt/lib/Passes/RegReAssign.cpp
bolt/lib/Utils/Utils.cpp

index e550cd8..77ab11b 100644 (file)
@@ -43,7 +43,7 @@ std::string getUnescapedName(const StringRef &Name);
 
 // Determines which register a given DWARF expression is being assigned to.
 // If the expression is defining the CFA, return std::nullopt.
-Optional<uint8_t> readDWARFExpressionTargetReg(StringRef ExprBytes);
+std::optional<uint8_t> readDWARFExpressionTargetReg(StringRef ExprBytes);
 
 } // namespace bolt
 
index 361c87f..ec72cea 100644 (file)
@@ -2469,7 +2469,8 @@ private:
       CFARule = UNKNOWN;
       break;
     case MCCFIInstruction::OpEscape: {
-      Optional<uint8_t> Reg = readDWARFExpressionTargetReg(Instr.getValues());
+      std::optional<uint8_t> Reg =
+          readDWARFExpressionTargetReg(Instr.getValues());
       // Handle DW_CFA_def_cfa_expression
       if (!Reg) {
         CFARule = RuleNumber;
@@ -2573,7 +2574,8 @@ struct CFISnapshotDiff : public CFISnapshot {
       if (Instr.getOperation() != MCCFIInstruction::OpEscape) {
         Reg = Instr.getRegister();
       } else {
-        Optional<uint8_t> R = readDWARFExpressionTargetReg(Instr.getValues());
+        std::optional<uint8_t> R =
+            readDWARFExpressionTargetReg(Instr.getValues());
         // Handle DW_CFA_def_cfa_expression
         if (!R) {
           if (RestoredCFAReg && RestoredCFAOffset)
@@ -2719,7 +2721,8 @@ BinaryFunction::unwindCFIState(int32_t FromState, int32_t ToState,
       if (Instr.getOperation() != MCCFIInstruction::OpEscape) {
         Reg = Instr.getRegister();
       } else {
-        Optional<uint8_t> R = readDWARFExpressionTargetReg(Instr.getValues());
+        std::optional<uint8_t> R =
+            readDWARFExpressionTargetReg(Instr.getValues());
         // Handle DW_CFA_def_cfa_expression
         if (!R) {
           undoStateDefCfa();
index 4f2cd33..277d68d 100644 (file)
@@ -108,7 +108,7 @@ void RegReAssign::swap(BinaryFunction &Function, MCPhysReg A, MCPhysReg B) {
         if (CFI->getOperation() != MCCFIInstruction::OpEscape) {
           CFIReg = CFI->getRegister();
         } else {
-          Optional<uint8_t> Reg =
+          std::optional<uint8_t> Reg =
               readDWARFExpressionTargetReg(CFI->getValues());
           // Handle DW_CFA_def_cfa_expression
           if (!Reg)
index 183f4c2..ae12f17 100644 (file)
@@ -66,7 +66,7 @@ std::string getUnescapedName(const StringRef &Name) {
   return Output;
 }
 
-Optional<uint8_t> readDWARFExpressionTargetReg(StringRef ExprBytes) {
+std::optional<uint8_t> readDWARFExpressionTargetReg(StringRef ExprBytes) {
   uint8_t Opcode = ExprBytes[0];
   if (Opcode == dwarf::DW_CFA_def_cfa_expression)
     return std::nullopt;