[PATCH] D136203: [ARM] Support -mexecute-only with -mlong-calls.

2022-10-24 Thread Eli Friedman via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes. Closed by commit rG7e8af2fc0c06: [ARM] Support -mexecute-only with -mlong-calls. (authored by ZhiyaoMa98, committed by efriedma). Changed prior to commit: https://reviews.llvm.org/D136203?vs=469049&id=470236#toc Reposito

[PATCH] D136203: [ARM] Support -mexecute-only with -mlong-calls.

2022-10-20 Thread Zhiyao Ma via Phabricator via cfe-commits
ZhiyaoMa98 added a comment. Just in case you assume that I have push permission, unfortunately I do not. Could you help me merge the patch in? Thanks. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D136203/new/ https://reviews.llvm.org/D136203 ___

[PATCH] D136203: [ARM] Support -mexecute-only with -mlong-calls.

2022-10-19 Thread Zhiyao Ma via Phabricator via cfe-commits
ZhiyaoMa98 updated this revision to Diff 469049. ZhiyaoMa98 marked an inline comment as done. ZhiyaoMa98 added a comment. Remove the unused `GA` variable. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D136203/new/ https://reviews.llvm.org/D136203 Files: clang/lib/Driver/ToolChains/Arc

[PATCH] D136203: [ARM] Support -mexecute-only with -mlong-calls.

2022-10-19 Thread Zhiyao Ma via Phabricator via cfe-commits
ZhiyaoMa98 updated this revision to Diff 468973. ZhiyaoMa98 marked an inline comment as done. ZhiyaoMa98 added a comment. Updated the comment to reflect that now we allow using `-mlong-calls` with `-mexecute-only`. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D136203/new/ https://revie

[PATCH] D136203: [ARM] Support -mexecute-only with -mlong-calls.

2022-10-19 Thread Eli Friedman via Phabricator via cfe-commits
efriedma accepted this revision. efriedma added a comment. This revision is now accepted and ready to land. LGTM with one small change. Comment at: clang/lib/Driver/ToolChains/Arch/ARM.cpp:779 // Supported only on ARMv6T2 and ARMv7 and above. // Cannot be combined wit

[PATCH] D136203: [ARM] Support -mexecute-only with -mlong-calls.

2022-10-19 Thread Zhiyao Ma via Phabricator via cfe-commits
ZhiyaoMa98 added a comment. > Then just assert we aren't execute-only in the non-movw path. When we are not execute-only, existing code handles it by using constant pools and we are all good. In the case where we are execute-only and long-calls at the same time, we assert that we have `movt` l

[PATCH] D136203: [ARM] Support -mexecute-only with -mlong-calls.

2022-10-19 Thread Zhiyao Ma via Phabricator via cfe-commits
ZhiyaoMa98 updated this revision to Diff 468957. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D136203/new/ https://reviews.llvm.org/D136203 Files: clang/lib/Driver/ToolChains/Arch/ARM.cpp clang/test/Driver/arm-execute-only.c llvm/lib/Target/ARM/ARMISelLowering.cpp llvm/test/CodeG

[PATCH] D136203: [ARM] Support -mexecute-only with -mlong-calls.

2022-10-19 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment. > I am thinking about adding a new option, say -mgot-calls to allow code > generation with the extra indirection. Is it sensible and shall I create > another diff to discuss that? That probably makes sense, yes. Comment at: llvm/lib/Target/ARM/ARMIS

[PATCH] D136203: [ARM] Support -mexecute-only with -mlong-calls.

2022-10-19 Thread Zhiyao Ma via Phabricator via cfe-commits
ZhiyaoMa98 marked an inline comment as done. ZhiyaoMa98 added a comment. I have updated the diff to avoid the extra indirection. I am thinking about adding a new option, say `-mgot-calls` to allow code generation with the extra indirection. Is it sensible and shall I create another diff to discu

[PATCH] D136203: [ARM] Support -mexecute-only with -mlong-calls.

2022-10-19 Thread Zhiyao Ma via Phabricator via cfe-commits
ZhiyaoMa98 updated this revision to Diff 468928. ZhiyaoMa98 edited the summary of this revision. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D136203/new/ https://reviews.llvm.org/D136203 Files: clang/lib/Driver/ToolChains/Arch/ARM.cpp clang/test/Driver/arm-execute-only.c llvm/lib/

[PATCH] D136203: [ARM] Support -mexecute-only with -mlong-calls.

2022-10-18 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment. One, -mlong-calls isn't currently compatible with PIE. Two, on ARM, there are no special plt relocations; the linker just takes care of it. (You can see the differences if you try to take the address of a function without calling it.) Repository: rG LLVM Github Mo

[PATCH] D136203: [ARM] Support -mexecute-only with -mlong-calls.

2022-10-18 Thread Zhiyao Ma via Phabricator via cfe-commits
ZhiyaoMa98 added a comment. Unfortunately, `-fPIE` seems not to be generating the PLT on LLVM for embedded ARM. C source file (test.c): extern void bar(void); void foo(void) { bar(); } LLVM with `clang -O2 -fPIE -fsemantic-interposition -mlong-calls --target=armv7em-none-eabi -c t

[PATCH] D136203: [ARM] Support -mexecute-only with -mlong-calls.

2022-10-18 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment. The construct you want is pretty similar to a GOT. if you compile with -fPIE -fsemantic-interposition, you get basically the code you want, except that the compiler uses a plt by default instead of a got. If we supported -fno-plt for ARM, it would be almost exactly wh

[PATCH] D136203: [ARM] Support -mexecute-only with -mlong-calls.

2022-10-18 Thread Zhiyao Ma via Phabricator via cfe-commits
ZhiyaoMa98 added a comment. > Can you describe a little more what you're trying to do here? Sure. My eventual goal is to enable fine-granular live-update on ARM based microcontrollers, which requires the system to do some relocation at runtime. Below I will describe the challenge with a simple

[PATCH] D136203: [ARM] Support -mexecute-only with -mlong-calls.

2022-10-18 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment. > that I can redirect the function call at runtime, for dynamic linking purpose. Can you describe a little more what you're trying to do here? If you want to replace the implementation of an existing function at runtime, you'd be better off implementing the indirection

[PATCH] D136203: [ARM] Support -mexecute-only with -mlong-calls.

2022-10-18 Thread Zhiyao Ma via Phabricator via cfe-commits
ZhiyaoMa98 added a comment. @efriedma Thank you for your suggestion. I will remove the extra indirection. I was wondering if you could also provide some insights about the RWPI case. I believe the same optimization also applies to RWPI. However, I actually want to store the function address as

[PATCH] D136203: [ARM] Support -mexecute-only with -mlong-calls.

2022-10-18 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added inline comments. Comment at: llvm/test/CodeGen/Thumb2/thumb2-execute-only-long-calls.ll:19 +; STATIC-NEXT: movt[[REG0]], :upper16:.LCP1_0 +; STATIC-NEXT: ldr [[REG1:r[0-9]+]], [[[REG0]]] +; STATIC-NEXT: blx [[REG1]] Is there some rea

[PATCH] D136203: [ARM] Support -mexecute-only with -mlong-calls.

2022-10-18 Thread Zhiyao Ma via Phabricator via cfe-commits
ZhiyaoMa98 created this revision. ZhiyaoMa98 added reviewers: labrinea, rengolin. Herald added subscribers: hiraditya, kristof.beyls. Herald added a project: All. ZhiyaoMa98 requested review of this revision. Herald added subscribers: cfe-commits, MaskRay. Herald added projects: clang, LLVM. Promo