Index: llvm/lib/CodeGen/IntrinsicLowering.cpp =================================================================== --- llvm/lib/CodeGen/IntrinsicLowering.cpp +++ llvm/lib/CodeGen/IntrinsicLowering.cpp @@ -371,7 +371,11 @@ case Intrinsic::var_annotation: break; // Strip out these intrinsics + case Intrinsic::noalias_decl: case Intrinsic::noalias: + case Intrinsic::side_noalias: + case Intrinsic::noalias_arg_guard: + case Intrinsic::noalias_copy_guard: // Just forward the value CI->replaceAllUsesWith(CI->getOperand(0)); break; Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp =================================================================== --- llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp +++ llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp @@ -6412,9 +6412,18 @@ case Intrinsic::noalias: case Intrinsic::launder_invariant_group: case Intrinsic::strip_invariant_group: + case Intrinsic::side_noalias: + case Intrinsic::noalias_arg_guard: + case Intrinsic::noalias_copy_guard: // Drop the intrinsic, but forward the value setValue(&I, getValue(I.getOperand(0))); return; + case Intrinsic::noalias_decl: + // Generate a dummy value - it will never be used and should get optimized + // away + setValue(&I, DAG.getUNDEF(TLI.getPointerTy(DAG.getDataLayout()))); + return; + case Intrinsic::assume: case Intrinsic::var_annotation: case Intrinsic::sideeffect: Index: llvm/test/CodeGen/Generic/noalias.ll =================================================================== --- llvm/test/CodeGen/Generic/noalias.ll +++ llvm/test/CodeGen/Generic/noalias.ll @@ -1,12 +1,13 @@ ; RUN: llc < %s -define i8* @main(i8* %p) { - %v = call i8* @llvm.noalias.p0i8(i8* %p, metadata !1) - ret i8* %v +define i32* @test(i32* %p) { + %p.decl = tail call i8* @llvm.noalias.decl.p0i8.p0p0i32.i32(i32** null, i32 0, metadata !0) + %v = call i32* @llvm.noalias.p0i32.p0i8.p0p0i32.i32(i32* %p, i8* %p.decl, i32** null, i32 0, metadata !0) + ret i32* %v } -declare i8* @llvm.noalias.p0i8(i8*, metadata) nounwind +declare i8* @llvm.noalias.decl.p0i8.p0p0i32.i32(i32**, i32, metadata) argmemonly nounwind +declare i32* @llvm.noalias.p0i32.p0i8.p0p0i32.i32(i32*, i8*, i32**, i32, metadata) argmemonly nounwind speculatable !0 = !{!0, !"some domain"} !1 = !{!1, !0, !"some scope"} - Index: llvm/test/CodeGen/Generic/side_noalias.ll =================================================================== --- /dev/null +++ llvm/test/CodeGen/Generic/side_noalias.ll @@ -0,0 +1,15 @@ +; RUN: llc < %s + +define i32* @test(i32* %p) { + %p.decl = tail call i8* @llvm.noalias.decl.p0i8.p0p0i32.i32(i32** null, i32 0, metadata !0) + %p.side = tail call i32* @llvm.side.noalias.p0i32.p0i8.p0p0i32.p0p0i32.i32(i32* %p, i8* %p.decl, i32** null, i32** undef, i32 0, metadata !0) + %p.guard = call i32* @llvm.noalias.arg.guard.p0i32.p0i32(i32* %p, i32* %p.side) + ret i32* %p.guard +} + +declare i8* @llvm.noalias.decl.p0i8.p0p0i32.i32(i32**, i32, metadata) argmemonly nounwind +declare i32* @llvm.side.noalias.p0i32.p0i8.p0p0i32.p0p0i32.i32(i32*, i8*, i32**, i32**, i32, metadata) argmemonly nounwind speculatable +declare i32* @llvm.noalias.arg.guard.p0i32.p0i32(i32*, i32*) nounwind readnone + +!0 = !{!0, !"some domain"} +!1 = !{!1, !0, !"some scope"}