This is an archive of the discontinued LLVM Phabricator instance.

[X86] -fpatchable-function-entry=N,0: place patch label after ENDBR{32,64}
ClosedPublic

Authored by MaskRay on Jan 30 2020, 6:29 PM.

Details

Summary

Similar to D73680 (AArch64 BTI).

A local linkage function whose address is not taken does not need ENDBR32/ENDBR64. Placing the patch label after ENDBR32/ENDBR64 has the advantage that code does not need to differentiate whether the function has an initial ENDBR.

Also, add 32-bit tests and test that .cfi_startproc is at the function
entry. The line information has a general implementation and is tested
by AArch64/patchable-function-entry-empty.mir

Diff Detail

Event Timeline

MaskRay created this revision.Jan 30 2020, 6:29 PM

Unit tests: fail. 62356 tests passed, 1 failed and 839 were skipped.

failed: libc++.std/containers/sequences/array/array_creation/to_array.fail.cpp

clang-tidy: pass.

clang-format: pass.

Build artifacts: diff.json, clang-tidy.txt, clang-format.patch, CMakeCache.txt, console-log.txt, test-results.xml

Pre-merge checks is in beta. Report issue. Please join beta or enable it for your project.

MaskRay updated this revision to Diff 241629.Jan 30 2020, 7:51 PM
MaskRay edited the summary of this revision. (Show Details)

Improve tests

Unit tests: fail. 62356 tests passed, 1 failed and 839 were skipped.

failed: libc++.std/containers/sequences/array/array_creation/to_array.fail.cpp

clang-tidy: pass.

clang-format: pass.

Build artifacts: diff.json, clang-tidy.txt, clang-format.patch, CMakeCache.txt, console-log.txt, test-results.xml

Pre-merge checks is in beta. Report issue. Please join beta or enable it for your project.

llvm/test/CodeGen/X86/patchable-function-entry-ibt.ll
67

I think @f1i is missing the function attribute "branch-target-enforcement"?

MaskRay updated this revision to Diff 241753.Jan 31 2020, 9:20 AM

Delete "branch-target-enforcement" added by mistake

MaskRay marked 2 inline comments as done.Jan 31 2020, 9:21 AM
MaskRay added inline comments.
llvm/test/CodeGen/X86/patchable-function-entry-ibt.ll
67

x86 uses a module flag "cf-protection-branch", instead of a function attribute.

Deleted the function attribute "branch-target-enforcement" attached to f0.

Unit tests: pass. 62371 tests passed, 0 failed and 839 were skipped.

clang-tidy: pass.

clang-format: pass.

Build artifacts: diff.json, clang-tidy.txt, clang-format.patch, CMakeCache.txt, console-log.txt, test-results.xml

Pre-merge checks is in beta. Report issue. Please join beta or enable it for your project.

nickdesaulniers added subscribers: mrutland, nsz.
nickdesaulniers accepted this revision.Feb 3 2020, 6:42 AM

Thanks for the patch. This looks more consistent with aarch64 now. + some x86 folks in cases there's more to endbr{32|64} than meets the eye.

llvm/test/CodeGen/X86/patchable-function-entry-ibt.ll
69

Do you want to add a CHECK-NEXT that the .cfi_startproc is placed after this CHECK?

This revision is now accepted and ready to land.Feb 3 2020, 6:42 AM
MaskRay updated this revision to Diff 242119.Feb 3 2020, 10:07 AM

Add CHECK-NEXT: .cfi_startproc

Unit tests: fail. 62298 tests passed, 121 failed and 845 were skipped.

failed: Clang.CXX/modules-ts/basic/basic_link/p3.cppm
failed: Clang.CXX/modules-ts/codegen-basics.cppm
failed: Clang.CodeGen/arm-aapcs-vfp.c
failed: Clang.CodeGen/attr-cpuspecific.c
failed: Clang.CodeGen/attr-target-mv-func-ptrs.c
failed: Clang.CodeGen/attr-target-mv-va-args.c
failed: Clang.CodeGenCUDA/address-spaces.cu
failed: Clang.CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu
failed: Clang.CodeGenCUDA/amdgpu-kernel-attrs.cu
failed: Clang.CodeGenCUDA/amdgpu-visibility.cu
failed: Clang.CodeGenCUDA/convergent.cu
failed: Clang.CodeGenCUDA/cuda-builtin-vars.cu
failed: Clang.CodeGenCUDA/device-stub.cu
failed: Clang.CodeGenCUDA/device-var-init.cu
failed: Clang.CodeGenCUDA/device-vtable.cu
failed: Clang.CodeGenCUDA/function-overload.cu
failed: Clang.CodeGenCUDA/kernel-amdgcn.cu
failed: Clang.CodeGenCUDA/kernel-args.cu
failed: Clang.CodeGenCUDA/library-builtin.cu
failed: Clang.CodeGenCUDA/link-device-bitcode.cu
failed: Clang.CodeGenCUDA/nothrow.cu
failed: Clang.CodeGenCUDA/propagate-metadata.cu
failed: Clang.CodeGenCUDA/ptx-kernels.cu
failed: Clang.CodeGenCUDA/types.cu
failed: Clang.CodeGenCUDA/usual-deallocators.cu
failed: Clang.CodeGenCXX/attr-exclude_from_explicit_instantiation.dont_assume_extern_instantiation.cpp
failed: Clang.CodeGenCXX/attr-target-mv-diff-ns.cpp
failed: Clang.CodeGenCXX/attr-target-mv-member-funcs.cpp
failed: Clang.CodeGenCXX/attr-target-mv-out-of-line-defs.cpp
failed: Clang.CodeGenCXX/attr-target-mv-overloads.cpp
failed: Clang.CodeGenCXX/attr.cpp
failed: Clang.CodeGenCXX/builtin-source-location.cpp
failed: Clang.CodeGenCXX/conditional-temporaries.cpp
failed: Clang.CodeGenCXX/const-init-cxx2a.cpp
failed: Clang.CodeGenCXX/ctor-dtor-alias.cpp
failed: Clang.CodeGenCXX/cxx0x-initializer-stdinitializerlist-pr12086.cpp
failed: Clang.CodeGenCXX/cxx0x-initializer-stdinitializerlist-startend.cpp
failed: Clang.CodeGenCXX/cxx0x-initializer-stdinitializerlist.cpp
failed: Clang.CodeGenCXX/cxx11-extern-constexpr.cpp
failed: Clang.CodeGenCXX/cxx11-initializer-aggregate.cpp
failed: Clang.CodeGenCXX/cxx11-thread-local-reference.cpp
failed: Clang.CodeGenCXX/cxx11-thread-local-visibility.cpp
failed: Clang.CodeGenCXX/cxx1y-variable-template-linkage.cpp
failed: Clang.CodeGenCXX/cxx1z-inline-variables.cpp
failed: Clang.CodeGenCXX/explicit-instantiation.cpp
failed: Clang.CodeGenCXX/inheriting-constructor.cpp
failed: Clang.CodeGenCXX/member-function-pointers.cpp
failed: Clang.CodeGenCXX/microsoft-uuidof.cpp
failed: Clang.CodeGenCXX/no-odr-use.cpp
failed: Clang.CodeGenCXX/pragma-visibility.cpp
failed: Clang.CodeGenCXX/regcall.cpp
failed: Clang.CodeGenCXX/static-data-member.cpp
failed: Clang.CodeGenCXX/static-init.cpp
failed: Clang.CodeGenCXX/static-member-variable-explicit-specialization.cpp
failed: Clang.CodeGenCXX/visibility-inlines-hidden-staticvar.cpp
failed: Clang.CodeGenCXX/vtable-linkage.cpp
failed: Clang.CodeGenCXX/x86_64-arguments.cpp
failed: Clang.CodeGenCoroutines/coro-await-resume-eh.cpp
failed: Clang.CodeGenCoroutines/coro-await.cpp
failed: Clang.CodeGenCoroutines/coro-cleanup.cpp
failed: Clang.CodeGenCoroutines/coro-gro-nrvo.cpp
failed: Clang.CodeGenCoroutines/coro-params.cpp
failed: Clang.CodeGenCoroutines/coro-ret-void.cpp
failed: Clang.CodeGenObjC/assign.m
failed: Clang.CodeGenObjC/constant-strings.m
failed: Clang.CodeGenObjC/gnu-exceptions.m
failed: Clang.CodeGenObjC/gnustep2-proto.m
failed: Clang.CodeGenObjC/objfw.m
failed: Clang.CodeGenObjC/property.m
failed: Clang.CodeGenObjC/stret_lookup.m
failed: Clang.CodeGenObjCXX/designated-initializers.mm
failed: Clang.CodeGenObjCXX/objfw-exceptions.mm
failed: Clang.CodeGenOpenCL/addr-space-struct-arg.cl
failed: Clang.CodeGenOpenCL/address-spaces-conversions.cl
failed: Clang.CodeGenOpenCL/amdgcn-automatic-variable.cl
failed: Clang.CodeGenOpenCL/amdgcn-large-globals.cl
failed: Clang.CodeGenOpenCL/amdgpu-abi-struct-coerce.cl
failed: Clang.CodeGenOpenCL/amdgpu-attrs.cl
failed: Clang.CodeGenOpenCL/amdgpu-call-kernel.cl
failed: Clang.CodeGenOpenCL/amdgpu-calling-conv.cl
failed: Clang.CodeGenOpenCL/amdgpu-enqueue-kernel.cl
failed: Clang.CodeGenOpenCL/amdgpu-nullptr.cl
failed: Clang.CodeGenOpenCL/as_type.cl
failed: Clang.CodeGenOpenCL/bool_cast.cl
failed: Clang.CodeGenOpenCL/cl20-device-side-enqueue.cl
failed: Clang.CodeGenOpenCL/constant-addr-space-globals.cl
failed: Clang.CodeGenOpenCL/convergent.cl
failed: Clang.CodeGenOpenCL/extension-begin.cl
failed: Clang.CodeGenOpenCL/kernel-arg-info.cl
failed: Clang.CodeGenOpenCL/kernels-have-spir-cc-by-default.cl
failed: Clang.CodeGenOpenCL/partial_initializer.cl
failed: Clang.CodeGenOpenCL/pipe_types.cl
failed: Clang.CodeGenOpenCL/ptx-calls.cl
failed: Clang.CodeGenOpenCL/ptx-kernels.cl
failed: Clang.CodeGenOpenCL/sampler.cl
failed: Clang.CodeGenOpenCL/shifts.cl
failed: Clang.CodeGenOpenCL/spir-calling-conv.cl
failed: Clang.CodeGenOpenCL/vectorLoadStore.cl
failed: Clang.CodeGenOpenCL/visibility.cl
failed: Clang.CodeGenOpenCL/vla.cl
failed: Clang.CodeGenOpenCLCXX/address-space-deduction.cl
failed: Clang.CodeGenOpenCLCXX/addrspace-derived-base.cl
failed: Clang.CodeGenOpenCLCXX/addrspace-operators.cl
failed: Clang.CodeGenOpenCLCXX/addrspace-references.cl
failed: Clang.CodeGenOpenCLCXX/addrspace-with-class.cl
failed: Clang.CodeGenOpenCLCXX/constexpr.cl
failed: Clang.Modules/codegen-flags.test
failed: Clang.Modules/codegen-opt.test
failed: Clang.Modules/codegen.test
failed: Clang.Modules/initializers.cpp
failed: Clang.Modules/templates-2.mm
failed: Clang.Modules/templates.mm
failed: Clang.OpenMP/allocate_codegen.cpp
failed: Clang.OpenMP/declare_variant_mixed_codegen.c
failed: Clang.OpenMP/parallel_codegen.cpp
failed: Clang.OpenMP/parallel_master_codegen.cpp
failed: Clang.OpenMP/simd_metadata.c
failed: Clang.OpenMP/threadprivate_codegen.cpp
failed: Clang.PCH/codegen.cpp
failed: Clang.Parser/pragma-visibility2.c
failed: Clang.Profile/cxx-abc-deleting-dtor.cpp

clang-tidy: pass.

clang-format: pass.

Build artifacts: diff.json, clang-tidy.txt, clang-format.patch, CMakeCache.txt, console-log.txt, test-results.xml

Pre-merge checks is in beta. Report issue. Please join beta or enable it for your project.

Looks good?

This revision was automatically updated to reflect the committed changes.