Index: lib/Transforms/Scalar/LowerAtomic.cpp =================================================================== --- lib/Transforms/Scalar/LowerAtomic.cpp +++ lib/Transforms/Scalar/LowerAtomic.cpp @@ -155,8 +155,7 @@ } bool runOnFunction(Function &F) override { - if (skipFunction(F)) - return false; + // Don't skip optnone functions; atomics still need to be lowered. FunctionAnalysisManager DummyFAM; auto PA = Impl.run(F, DummyFAM); return !PA.areAllPreserved(); Index: test/Feature/optnone-opt.ll =================================================================== --- test/Feature/optnone-opt.ll +++ test/Feature/optnone-opt.ll @@ -57,7 +57,6 @@ ; Additional IR passes that opt doesn't turn on by default. ; OPT-MORE-DAG: Skipping pass 'Dead Code Elimination' ; OPT-MORE-DAG: Skipping pass 'Dead Instruction Elimination' -; OPT-MORE-DAG: Skipping pass 'Lower atomic intrinsics ; Loop IR passes that opt doesn't turn on by default. ; OPT-LOOP-DAG: Skipping pass 'Delete dead loops' Index: test/Transforms/LowerAtomic/atomic-swap.ll =================================================================== --- test/Transforms/LowerAtomic/atomic-swap.ll +++ test/Transforms/LowerAtomic/atomic-swap.ll @@ -26,3 +26,14 @@ ret i8 %j ; CHECK: ret i8 [[INST]] } + + +define i8 @swap_optnone() noinline optnone { +; CHECK-LABEL: @swap_optnone( + %i = alloca i8 + %j = atomicrmw xchg i8* %i, i8 42 monotonic +; CHECK: [[INST:%[a-z0-9]+]] = load +; CHECK-NEXT: store + ret i8 %j +; CHECK: ret i8 [[INST]] +}