[clang] [llvm] [FunctionAttrs][Attributor] Update nofree inference (PR #196266)
llvm-ci wrote: LLVM Buildbot has detected a new failure on builder `ppc64le-mlir-rhel-clang` running on `ppc64le-mlir-rhel-test` while building `clang,llvm` at step 6 "test-build-check-mlir-build-only-check-mlir". Full details are available at: https://lab.llvm.org/buildbot/#/builders/129/builds/45062 Here is the relevant piece of the build log for the reference ``` Step 6 (test-build-check-mlir-build-only-check-mlir) failure: 1200 seconds without output running [b'ninja', b'check-mlir'], attempting to kill ... PASS: MLIR :: Transforms/inlining.mlir (4191 of 4200) PASS: MLIR :: mlir-opt/split-markers.mlir (4192 of 4200) PASS: MLIR :: Pass/pipeline-parsing.mlir (4193 of 4200) PASS: MLIR :: mlir-runner/simple.mlir (4194 of 4200) PASS: MLIR :: Transforms/test-operation-folder.mlir (4195 of 4200) PASS: MLIR :: Pass/pipeline-options-parsing.mlir (4196 of 4200) PASS: MLIR :: mlir-runner/utils.mlir (4197 of 4200) PASS: MLIR :: mlir-tblgen/cpp-class-comments.td (4198 of 4200) PASS: MLIR :: mlir-tblgen/op-error.td (4199 of 4200) PASS: MLIR :: mlir-tblgen/llvm-intrinsics.td (4200 of 4200) command timed out: 1200 seconds without output running [b'ninja', b'check-mlir'], attempting to kill process killed by signal 9 program finished with exit code -1 elapsedTime=2656.076891 ``` https://github.com/llvm/llvm-project/pull/196266 ___ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [FunctionAttrs][Attributor] Update nofree inference (PR #196266)
https://github.com/nikic closed https://github.com/llvm/llvm-project/pull/196266 ___ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [FunctionAttrs][Attributor] Update nofree inference (PR #196266)
https://github.com/nikic auto_merge_enabled https://github.com/llvm/llvm-project/pull/196266 ___ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [FunctionAttrs][Attributor] Update nofree inference (PR #196266)
@@ -297,12 +297,12 @@ define void @f2() #0 {
; TEST 12 NoFree argument - positive.
define double @test12(ptr nocapture readonly %a) {
-; CHECK: Function Attrs: nofree nounwind
nikic wrote:
> > though the function attribute is not, and how the function could cause a
> > free through synchronization.
>
> This is due to imprecision in how I implemented this in Attributor. I just
> made nosync a precondition for nofree, but it would be more precise to do
> what I do in FunctionAttrs, and only require nofree for calls and nosync for
> everything else. Then we could infer nofree here because the call has nofree,
> but not nosync.
I've done this now, restoring the nofree in this case.
https://github.com/llvm/llvm-project/pull/196266
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [FunctionAttrs][Attributor] Update nofree inference (PR #196266)
github-actions[bot] wrote: # :penguin: Linux x64 Test Results * 174336 tests passed * 3341 tests skipped * 1 test failed ## Failed Tests (click on a test name to see its output) ### lldb-api lldb-api.python_api/run_locker/TestRunLocker.py ``` Script: -- /usr/bin/python3 /home/gha/actions-runner/_work/llvm-project/llvm-project/lldb/test/API/dotest.py -u CXXFLAGS -u CFLAGS --env LLVM_LIBS_DIR=/home/gha/actions-runner/_work/llvm-project/llvm-project/build/./lib --env LLVM_INCLUDE_DIR=/home/gha/actions-runner/_work/llvm-project/llvm-project/build/include --env LLVM_TOOLS_DIR=/home/gha/actions-runner/_work/llvm-project/llvm-project/build/./bin --libcxx-include-dir /home/gha/actions-runner/_work/llvm-project/llvm-project/build/include/c++/v1 --libcxx-include-target-dir /home/gha/actions-runner/_work/llvm-project/llvm-project/build/include/x86_64-unknown-linux-gnu/c++/v1 --libcxx-library-dir /home/gha/actions-runner/_work/llvm-project/llvm-project/build/./lib/x86_64-unknown-linux-gnu --triple x86_64-unknown-linux-gnu --build-dir /home/gha/actions-runner/_work/llvm-project/llvm-project/build/lldb-test-build.noindex --lldb-module-cache-dir /home/gha/actions-runner/_work/llvm-project/llvm-project/build/lldb-test-build.noindex/module-cache-lldb/lldb-api --clang-module-cache-dir /home/gha/actions-runner/_work/llvm-project/llvm-project/build/lldb-test-build.noindex/module-cache-clang/lldb-api --executable /home/gha/actions-runner/_work/llvm-project/llvm-project/build/./bin/lldb --compiler /home/gha/actions-runner/_work/llvm-project/llvm-project/build/./bin/clang --dsymutil /home/gha/actions-runner/_work/llvm-project/llvm-project/build/./bin/dsymutil --make /usr/bin/gmake --llvm-tools-dir /home/gha/actions-runner/_work/llvm-project/llvm-project/build/./bin --lldb-obj-root /home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/lldb --lldb-libs-dir /home/gha/actions-runner/_work/llvm-project/llvm-project/build/./lib --cmake-build-type Release /home/gha/actions-runner/_work/llvm-project/llvm-project/lldb/test/API/python_api/run_locker -p TestRunLocker.py -- Exit Code: 1 Command Output (stdout): -- lldb version 23.0.0git (https://github.com/llvm/llvm-project revision ab80de1ed213372b6eb9303026602444ee593d54) clang revision ab80de1ed213372b6eb9303026602444ee593d54 llvm revision ab80de1ed213372b6eb9303026602444ee593d54 "can't evaluate expressions when the process is running." Skipping the following test categories: msvcstl, dsym, pdb, gmodules, debugserver, objc -- Command Output (stderr): -- FAIL: LLDB (/home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/clang-x86_64) :: test_run_locker (TestRunLocker.TestRunLocker.test_run_locker) Log Files: - /home/gha/actions-runner/_work/llvm-project/llvm-project/build/lldb-test-build.noindex/python_api/run_locker/TestRunLocker/Failure_test_run_locker.log PASS: LLDB (/home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/clang-x86_64) :: test_run_locker_stop_at_entry (TestRunLocker.TestRunLocker.test_run_locker_stop_at_entry) == FAIL: test_run_locker (TestRunLocker.TestRunLocker.test_run_locker) Test that the run locker is set correctly when we launch -- Traceback (most recent call last): File "/home/gha/actions-runner/_work/llvm-project/llvm-project/lldb/packages/Python/lldbsuite/test/decorators.py", line 160, in wrapper return func(*args, **kwargs) ^ File "/home/gha/actions-runner/_work/llvm-project/llvm-project/lldb/test/API/python_api/run_locker/TestRunLocker.py", line 23, in test_run_locker self.runlocker_test(False) File "/home/gha/actions-runner/_work/llvm-project/llvm-project/lldb/test/API/python_api/run_locker/TestRunLocker.py", line 110, in runlocker_test self.assertIn( AssertionError: "can't evaluate expressions when the process is running" not found in '' Config=x86_64-/home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/clang -- Ran 2 tests in 0.631s FAILED (failures=1) -- ``` If these failures are unrelated to your changes (for example tests are broken or flaky at HEAD), please open an issue at https://github.com/llvm/llvm-project/issues and add the `infrastructure` label. https://github.com/llvm/llvm-project/pull/196266 ___ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [FunctionAttrs][Attributor] Update nofree inference (PR #196266)
@@ -297,12 +297,12 @@ define void @f2() #0 {
; TEST 12 NoFree argument - positive.
define double @test12(ptr nocapture readonly %a) {
-; CHECK: Function Attrs: nofree nounwind
antoniofrighetto wrote:
I just noticed a prior (broader) attempt to add nosync to lib-calls
(https://reviews.llvm.org/D98605). At least for math functions, I think it
should be fine to set noysnc (previous concerns were on FP exceptions and
errno).
https://github.com/llvm/llvm-project/pull/196266
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [FunctionAttrs][Attributor] Update nofree inference (PR #196266)
@@ -297,12 +297,12 @@ define void @f2() #0 {
; TEST 12 NoFree argument - positive.
define double @test12(ptr nocapture readonly %a) {
-; CHECK: Function Attrs: nofree nounwind
antoniofrighetto wrote:
I'm not immediately clear why the argument-level nofree is retained here,
though the function attribute is not, and how the function could cause a free
through synchronization. Is this desirable? I also wonder if we should
orthogonally teach BuildLibCalls to annotate cos, sin, et alia with nosync.
https://github.com/llvm/llvm-project/pull/196266
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [FunctionAttrs][Attributor] Update nofree inference (PR #196266)
llvmorg-github-actions[bot] wrote:
@llvm/pr-subscribers-llvm-transforms
Author: Nikita Popov (nikic)
Changes
This updates nofree inference after the semantics changes in
https://github.com/llvm/llvm-project/pull/195658.
FunctionAttrs currently only supports function-level nofree inference, so we
just need to check for potentially synchronizing instructions.
Attributor also supports argument nofree, in which case we make additional
changes:
* For callsite arguments, in addition to checking nofree, we also need to
check nocapture. If the call itself doesn't free the arg, it may still capture
it and then we may free it via the captured pointer later. The way this was
handled was already incorrect prior to the semantics changes.
* Reformulate the handling for other instructions in terms of looking for
provenance captures, as that's what the code was essentially doing, in a crude
way. I'm including this to avoid some regressions for cases where we can no
longer infer function nofree, but can still infer argument nofree.
---
Patch is 194.41 KiB, truncated to 20.00 KiB below, full version:
https://github.com/llvm/llvm-project/pull/196266.diff
31 Files Affected:
- (modified) clang/test/CodeGen/sanitize-metadata-nosanitize.c (+7-7)
- (modified) llvm/lib/Transforms/IPO/AttributorAttributes.cpp (+35-11)
- (modified) llvm/lib/Transforms/IPO/FunctionAttrs.cpp (+5-2)
- (modified) llvm/test/Transforms/Attributor/ArgumentPromotion/X86/thiscall.ll
(+2-2)
- (modified) llvm/test/Transforms/Attributor/align-atomic.ll (+2-2)
- (modified) llvm/test/Transforms/Attributor/align.ll (+14-14)
- (modified) llvm/test/Transforms/Attributor/dereferenceable-1.ll (+2-2)
- (modified) llvm/test/Transforms/Attributor/liveness.ll (+61-74)
- (modified) llvm/test/Transforms/Attributor/misc.ll (+2-2)
- (modified) llvm/test/Transforms/Attributor/noalias.ll (+9-5)
- (modified) llvm/test/Transforms/Attributor/nocapture-1.ll (+14-14)
- (modified) llvm/test/Transforms/Attributor/nocapture-2.ll (+2-2)
- (modified) llvm/test/Transforms/Attributor/nofpclass.ll (+87-44)
- (modified) llvm/test/Transforms/Attributor/nofree.ll (+25-27)
- (modified) llvm/test/Transforms/Attributor/nonnull.ll (+16-14)
- (modified) llvm/test/Transforms/Attributor/nosync.ll (+15-15)
- (modified) llvm/test/Transforms/Attributor/range.ll (+57-55)
- (modified) llvm/test/Transforms/Attributor/readattrs.ll (+5-5)
- (modified) llvm/test/Transforms/Attributor/undefined_behavior.ll (+22-22)
- (modified) llvm/test/Transforms/Attributor/value-simplify-assume.ll (+54-52)
- (modified) llvm/test/Transforms/Attributor/value-simplify-instances.ll
(+27-23)
- (modified)
llvm/test/Transforms/Attributor/value-simplify-pointer-info-struct.ll (+2-2)
- (modified) llvm/test/Transforms/Attributor/value-simplify-pointer-info.ll
(+56-53)
- (modified) llvm/test/Transforms/Attributor/value-simplify.ll (+15-14)
- (modified) llvm/test/Transforms/FunctionAttrs/atomic.ll (+1-1)
- (modified) llvm/test/Transforms/FunctionAttrs/nocapture.ll (+7-7)
- (modified) llvm/test/Transforms/FunctionAttrs/nonnull.ll (+6-12)
- (modified) llvm/test/Transforms/FunctionAttrs/nosync.ll (+9-9)
- (modified) llvm/test/Transforms/FunctionAttrs/readattrs.ll (+12-12)
- (modified) llvm/test/Transforms/FunctionAttrs/writeonly.ll (+2-2)
- (modified) llvm/test/Transforms/OpenMP/parallel_deletion.ll (+5-5)
``diff
diff --git a/clang/test/CodeGen/sanitize-metadata-nosanitize.c
b/clang/test/CodeGen/sanitize-metadata-nosanitize.c
index 01183709476f9..019853f51e6dd 100644
--- a/clang/test/CodeGen/sanitize-metadata-nosanitize.c
+++ b/clang/test/CodeGen/sanitize-metadata-nosanitize.c
@@ -21,7 +21,7 @@ __attribute__((noinline, not_tail_called)) void escape(const
volatile void *p) {
sink = p;
}
-// CHECK: Function Attrs: mustprogress nofree norecurse nounwind willreturn
memory(write, argmem: readwrite, inaccessiblemem: none, target_mem: none)
+// CHECK: Function Attrs: mustprogress norecurse nounwind willreturn
memory(write, argmem: readwrite, inaccessiblemem: none, target_mem: none)
// CHECK-LABEL: define dso_local i32 @normal_function(
// CHECK-SAME: ptr noundef [[X:%.*]], ptr noundef readonly captures(none)
[[Y:%.*]]) local_unnamed_addr #[[ATTR1:[0-9]+]] !pcsections [[META7:![0-9]+]] {
// CHECK-NEXT: [[ENTRY:.*:]]
@@ -38,7 +38,7 @@ int normal_function(int *x, int *y) {
return *y;
}
-// CHECK: Function Attrs: disable_sanitizer_instrumentation mustprogress
nofree norecurse nounwind willreturn memory(write, argmem: readwrite,
inaccessiblemem: none, target_mem: none)
+// CHECK: Function Attrs: disable_sanitizer_instrumentation mustprogress
norecurse nounwind willreturn memory(write, argmem: readwrite, inaccessiblemem:
none, target_mem: none)
// CHECK-LABEL: define dso_local i32 @test_disable_sanitize_instrumentation(
// CHECK-SAME: ptr noundef [[X:%.*]], ptr noundef readonly captures(none)
[[Y:%.*]]) local_unnamed_addr #[[ATTR2:[0-9]+]] {
// CHECK-
