[PATCH] D72222: [Driver][CodeGen] Add -fpatchable-function-entry=N[,0]

Fangrui Song via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jan 23 16:49:41 PST 2020


MaskRay added a comment.

In D72222#1837358 <https://reviews.llvm.org/D72222#1837358>, @nickdesaulniers wrote:

> In D72222#1837184 <https://reviews.llvm.org/D72222#1837184>, @MaskRay wrote:
>
> > @peter.smith The build was smooth. Do I need other options to reproduce?
>
>
> I was able to reproduce:
>
>   $ git clone --depth 1 git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
>   $ cd linux-next
>   $ ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- make CC=clang -j71 allyesconfig
>   $ ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- make CC=clang -j71 mm/kasan/quarantine.o
>
>
> The exact compiler invocation (via tacking on `V=1` to the above `make` command is:
>
>   $ clang -Wp,-MD,mm/kasan/.quarantine.o.d  -nostdinc -isystem /android0/llvm-project/llvm/build/lib/clang/11.0.0/include -I./arch/arm64/include -I./arch/arm64/include/generated  -I./include -I./arch/arm64/include/uapi -I./arch/arm64/include/generated/uapi -I./include/uapi -I./include/generated/uapi -include ./include/linux/kconfig.h -include ./include/linux/compiler_types.h -D__KERNEL__ -mlittle-endian -DCC_USING_PATCHABLE_FUNCTION_ENTRY -DKASAN_SHADOW_SCALE_SHIFT=3 -Qunused-arguments -Wall -Wundef -Werror=strict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -fshort-wchar -fno-PIE -Werror=implicit-function-declaration -Werror=implicit-int -Wno-format-security -std=gnu89 --target=aarch64-linux-gnu --prefix=/usr/bin/ --gcc-toolchain=/usr -no-integrated-as -Werror=unknown-warning-option -mgeneral-regs-only -DCONFIG_CC_HAS_K_CONSTRAINT=1 -fno-asynchronous-unwind-tables -DKASAN_SHADOW_SCALE_SHIFT=3 -fno-delete-null-pointer-checks -Wno-address-of-packed-member -O2 -Wframe-larger-than=2048 -fstack-protector-strong -Wno-format-invalid-specifier -Wno-gnu -Wno-tautological-compare -mno-global-merge -Wno-unused-const-variable -fno-omit-frame-pointer -fno-optimize-sibling-calls -ftrivial-auto-var-init=pattern -fpatchable-function-entry=2 -Wdeclaration-after-statement -Wvla -Wno-pointer-sign -fno-strict-overflow -fno-merge-all-constants -fno-stack-check -Werror=date-time -Werror=incompatible-pointer-types -fmacro-prefix-map=./= -Wno-initializer-overrides -Wno-format -Wno-sign-compare -Wno-format-zero-length   -fno-builtin      -DKBUILD_MODFILE='"mm/kasan/quarantine"' -DKBUILD_BASENAME='"quarantine"' -DKBUILD_MODNAME='"quarantine"' -c -o mm/kasan/quarantine.o mm/kasan/quarantine.c
>
>   creduce spits out:
>
>
> // $ clang -O2 quarantine.i
>  __attribute__((patchable_function_entry(0))) a() {
>
>   b(({
>     c:
>       &&c;
>   }));
>
> }
>
>  


Thanks. Looks like the following is sufficient to reproduce. (I incorrectly thought an empty entry MachineBasicBlock was impossible.) I take the opportunity to add test coverage (testing debug-location: D73301 <https://reviews.llvm.org/D73301>)

  define void @foo() #0 {
  entry:
    unreachable
  }
  
  attributes #0 = { "patchable-function-entry"="2" }

A -DLLVM_ENABLE_ASSERTIONS=on build is required to trigger the assertion failure. My `make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- HOSTGCC=gcc CC=~/llvm/ReleaseAssert/bin/clang LD=~/llvm/ReleaseAssert/bin/ld.lld O=/tmp/arm64 allmodconfig all -j 30` build succeeded. Now I will be in favor of pushing the bugfix to release/10.x .

Not clear about -fpatchable-function-entry=N,M where M>0 (D73070 <https://reviews.llvm.org/D73070>, D73071 <https://reviews.llvm.org/D73071>, D73072 <https://reviews.llvm.org/D73072>). For completeness, I'd like them to be included in release/10.x so we will not have a clang 10 that does not work with M>0.

For `BTI c` issue, GCC has several releases that do not work with -mbranch-protection=bti. The Linux kernel has to develop some mechanism to detect the undesirable placement of `bti c`, if there are -mbranch-protection=bti users. So I don't think that inconsistency in clang 10.0.0 with GCC will be a problem.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D72222/new/

https://reviews.llvm.org/D72222





More information about the cfe-commits mailing list