Skip to content

[llvm] Use std::optional::value_or (NFC) #140014

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

kazutakahirata
Copy link
Contributor

No description provided.

@llvmbot llvmbot added PGO Profile Guided Optimizations llvm:transforms labels May 15, 2025
@llvmbot
Copy link
Member

llvmbot commented May 15, 2025

@llvm/pr-subscribers-pgo

@llvm/pr-subscribers-llvm-transforms

Author: Kazu Hirata (kazutakahirata)

Changes

Full diff: https://github.com/llvm/llvm-project/pull/140014.diff

2 Files Affected:

  • (modified) llvm/lib/ExecutionEngine/Orc/MachOPlatform.cpp (+1-1)
  • (modified) llvm/lib/Transforms/IPO/SampleProfile.cpp (+2-2)
diff --git a/llvm/lib/ExecutionEngine/Orc/MachOPlatform.cpp b/llvm/lib/ExecutionEngine/Orc/MachOPlatform.cpp
index 90194d7fcc119..369a047f65076 100644
--- a/llvm/lib/ExecutionEngine/Orc/MachOPlatform.cpp
+++ b/llvm/lib/ExecutionEngine/Orc/MachOPlatform.cpp
@@ -487,7 +487,7 @@ MachOPlatform::MachOPlatform(
     if ((Err = ES.getBootstrapMapValue<bool, bool>("darwin-use-ehframes-only",
                                                    ForceEHFrames)))
       return;
-    this->ForceEHFrames = ForceEHFrames.has_value() ? *ForceEHFrames : false;
+    this->ForceEHFrames = ForceEHFrames.value_or(false);
   }
 
   BootstrapInfo BI;
diff --git a/llvm/lib/Transforms/IPO/SampleProfile.cpp b/llvm/lib/Transforms/IPO/SampleProfile.cpp
index 4947a0da3bdb0..616eeae3b1fec 100644
--- a/llvm/lib/Transforms/IPO/SampleProfile.cpp
+++ b/llvm/lib/Transforms/IPO/SampleProfile.cpp
@@ -2151,8 +2151,8 @@ void SampleProfileLoader::removePseudoProbeInstsDiscriminator(Module &M) {
               std::optional<uint32_t> DwarfDiscriminator =
                   PseudoProbeDwarfDiscriminator::extractDwarfBaseDiscriminator(
                       Discriminator);
-              I.setDebugLoc(DIL->cloneWithDiscriminator(
-                  DwarfDiscriminator ? *DwarfDiscriminator : 0));
+              I.setDebugLoc(
+                  DIL->cloneWithDiscriminator(DwarfDiscriminator.value_or(0)));
             }
           }
       }

@kazutakahirata kazutakahirata merged commit 3667f29 into llvm:main May 15, 2025
14 checks passed
@kazutakahirata kazutakahirata deleted the cleanup_001_std_optional_value_or_llvm branch May 15, 2025 14:19
TIFitis pushed a commit to TIFitis/llvm-project that referenced this pull request May 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
llvm:transforms PGO Profile Guided Optimizations
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants