Skip to content

Commit

Permalink
Fix CppConfiguration#isLLVMOptimizedFdo() method to work with --fdo_p…
Browse files Browse the repository at this point in the history
…rofile

This method is used to determine whether a zipper executable should be loaded. Currently it only checks whether the file specified by --fdo_optimize is a zip file. As we cannot check whether --fdo_profile points to a zip file in this phase, we load it unconditionally in the case of --fdo_profile optimization.

PiperOrigin-RevId: 195087124
  • Loading branch information
scentini authored and Copybara-Service committed May 2, 2018
1 parent 86a9b6f commit ac656a9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,9 @@ public RuleClass build(Builder builder, RuleDefinitionEnvironment env) {
LabelLateBoundDefault.fromTargetConfiguration(
CppConfiguration.class,
null,
// TODO(b/69547565): Remove call to isLLVMOptimizedFdo
// TODO(b/69547565): Remove call to shouldIncludeZipperInToolchain
(rule, attributes, cppConfig) ->
cppConfig.isLLVMOptimizedFdo() ? zipper : null)))
cppConfig.shouldIncludeZipperInToolchain() ? zipper : null)))
.add(attr(":libc_top", LABEL).value(LIBC_TOP))
.add(attr(":fdo_optimize", LABEL).singleArtifact().value(FDO_OPTIMIZE_LABEL))
.add(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -892,12 +892,12 @@ private final boolean isLLVMCompiler() {
*/
// TODO(b/64384912): Remove in favor of overload with isLLVMCompiler.
@Deprecated
public boolean isLLVMOptimizedFdo() {
return cppOptions.getFdoOptimize() != null
&& (CppFileTypes.LLVM_PROFILE.matches(cppOptions.getFdoOptimize())
|| CppFileTypes.LLVM_PROFILE_RAW.matches(cppOptions.getFdoOptimize())
|| (isLLVMCompiler()
&& cppOptions.getFdoOptimize().endsWith(".zip")));
public boolean shouldIncludeZipperInToolchain() {
return (cppOptions.getFdoOptimize() != null
&& (CppFileTypes.LLVM_PROFILE.matches(cppOptions.getFdoOptimize())
|| CppFileTypes.LLVM_PROFILE_RAW.matches(cppOptions.getFdoOptimize())
|| (isLLVMCompiler() && cppOptions.getFdoOptimize().endsWith(".zip"))))
|| (cppOptions.getFdoProfileLabel() != null);
}

/** Returns true if LIPO optimization is implied by the flags of this build. */
Expand Down

0 comments on commit ac656a9

Please sign in to comment.