[clang] [lld] [llvm] [LTO] enable `ObjCARCContractPass` only on optimized build (PR #101114)

Mikael Holmén via cfe-commits cfe-commits at lists.llvm.org
Thu Aug 15 04:11:49 PDT 2024


mikaelholmen wrote:

> @mikaelholmen I can't reproduce this on commit [e40915b](https://github.com/llvm/llvm-project/commit/e40915b7407eda4b370658da5c9606e310b55d19) with `-DLLVM_USE_SANITIZER=Undefined`. Kindly let me know how to reproduce this.
> 
> Looking from the code, I suspect that it's caused by uninitialized bool (
> 
> https://github.com/llvm/llvm-project/blob/539bf499615dbbfe98deaac1021f351eaad330ea/llvm/lib/Transforms/ObjCARC/ObjCARCContract.cpp#L553
> )

I think the problem is that the
```
Changed = CFGChanged = false; 
```
initialization done in
```
bool ObjCARCContract::run(Function &F, AAResults *A, DominatorTree *D) {
  if (!Run)
    return false;

  if (!EnableARCOpts)
    return false;

  Changed = CFGChanged = false;
```
is skipped if we bail out early due to "!Run" or "!EnableARCOpts".
But the pass always asks
```
  bool CFGChanged = OCAC.hasCFGChanged();
```
afterwards anyway.

https://github.com/llvm/llvm-project/pull/101114


More information about the cfe-commits mailing list