Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SandboxIR] Add setOperand() and RAUW,RUWIf,RUOW #98410

Merged
merged 2 commits into from
Jul 12, 2024
Merged

Conversation

vporpo
Copy link
Contributor

@vporpo vporpo commented Jul 10, 2024

This patch adds the following member functions:

  • User::setOperand()
  • User::replaceUsesOfWith()
  • Value::replaceAllUsesWith()
  • Value::replaceUsesWithIf()

@@ -303,6 +309,13 @@ class Value {
#endif
};

/// Helper Attorney-Client class that gives access to the underlying IR.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could the ValueAttorney be in the cpp file? It is kind of a public loop hole.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will only give access to the LLVM Value to its friends, so I don't see how it is a loop hole.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we add friend class User; in Value instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes we can, and in this case it makes sense to use a friend because the User class is expected to be tightly coupled to the Value class. But for classes that are not as closely related to the IR, like the transaction tracker, it is nicer to use a client-attorney class to restrict access to just the LLVM Value and nothing else. Anyway, I will remove it for now and add it in later.

llvm/lib/SandboxIR/SandboxIR.cpp Outdated Show resolved Hide resolved
@@ -303,6 +309,13 @@ class Value {
#endif
};

/// Helper Attorney-Client class that gives access to the underlying IR.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we add friend class User; in Value instead?

This patch adds the following member functions:
- User::setOperand()
- User::replaceUsesOfWith()
- Value::replaceAllUsesWith()
- Value::replaceUsesWithIf()
Copy link
Contributor

@aeubanks aeubanks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm with comments addressed

llvm/unittests/SandboxIR/SandboxIRTest.cpp Outdated Show resolved Hide resolved
llvm/unittests/SandboxIR/SandboxIRTest.cpp Outdated Show resolved Hide resolved
llvm/unittests/SandboxIR/SandboxIRTest.cpp Show resolved Hide resolved
Copy link
Contributor

@echristo echristo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I'd like to see the comments expanded in SandboxIR in general to talk about what aspects you need to handle specifically before delegating down to LLVM IR. Right now it's a little hard to tell what is part of the layer on top of LLVM IR and what's just a delegate.

As an example: the asserts in rauw are the same as in the delegate .

@vporpo
Copy link
Contributor Author

vporpo commented Jul 11, 2024

Ah yes, we have not added any of the transaction tracking code yet, so the IR will currently delegate everything down to LLVM IR. Once we add the tracking code all these functions that modify the IR's state, like RAUW, setOperand, moveBefore etc. will include code that tracks the state change. The first patches that will add some of this functionality are a couple of patches down the road.

@echristo
Copy link
Contributor

echristo commented Jul 11, 2024 via email

@vporpo
Copy link
Contributor Author

vporpo commented Jul 11, 2024

OK I will update this patch with some comments and I will follow up with another one that adds these comments to the remaining functions.
So just to confirm, you would like to see comments in the declaration of functions like sandboxir::Value::repalceAllUsesWith() that look like: Delegate for llvm::Value::replaceAllUsesWith().

The assumption is that all SandboxIR functions with the same name as the corresponding LLVM IR function is almost always a delegate, but yeah clarifying that is always helpful.

@vporpo
Copy link
Contributor Author

vporpo commented Jul 12, 2024

I will upload the additional comments in a separate patch.

@vporpo vporpo merged commit ecd2bf7 into llvm:main Jul 12, 2024
7 of 9 checks passed
@vporpo vporpo deleted the SBVec branch July 12, 2024 05:00
@llvm-ci
Copy link
Collaborator

llvm-ci commented Jul 12, 2024

LLVM Buildbot has detected a new failure on builder sanitizer-x86_64-linux running on sanitizer-buildbot1 while building llvm at step 2 "annotate".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/66/builds/1401

Here is the relevant piece of the build log for the reference:

Step 2 (annotate) failure: 'python ../sanitizer_buildbot/sanitizers/zorg/buildbot/builders/sanitizers/buildbot_selector.py' (failure)
...
llvm-lit: /b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/lit.common.cfg.py:60: warning: Path reported by clang does not exist: "/b/sanitizer-x86_64-linux/build/build_symbolizer/lib/clang/19/lib/x86_64-unknown-linux-gnu". This path was found by running ['/b/sanitizer-x86_64-linux/build/build_symbolizer/./bin/clang', '--target=x86_64-unknown-linux-gnu', '-m64', '-print-runtime-dir'].
llvm-lit: /b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/lit.common.cfg.py:60: warning: Path reported by clang does not exist: "/b/sanitizer-x86_64-linux/build/build_symbolizer/lib/clang/19/lib/x86_64-unknown-linux-gnu". This path was found by running ['/b/sanitizer-x86_64-linux/build/build_symbolizer/./bin/clang', '--target=x86_64-unknown-linux-gnu', '-Wthread-safety', '-Wthread-safety-reference', '-Wthread-safety-beta', '-print-runtime-dir'].
llvm-lit: /b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/lit.common.cfg.py:60: warning: Path reported by clang does not exist: "/b/sanitizer-x86_64-linux/build/build_symbolizer/lib/clang/19/lib/x86_64-unknown-linux-gnu". This path was found by running ['/b/sanitizer-x86_64-linux/build/build_symbolizer/./bin/clang', '--target=x86_64-unknown-linux-gnu', '-m64', '-print-runtime-dir'].
llvm-lit: /b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/lit.common.cfg.py:60: warning: Path reported by clang does not exist: "/b/sanitizer-x86_64-linux/build/build_symbolizer/lib/clang/19/lib/x86_64-unknown-linux-gnu". This path was found by running ['/b/sanitizer-x86_64-linux/build/build_symbolizer/./bin/clang', '--target=x86_64-unknown-linux-gnu', '-m64', '-print-runtime-dir'].
llvm-lit: /b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/lit.common.cfg.py:60: warning: Path reported by clang does not exist: "/b/sanitizer-x86_64-linux/build/build_symbolizer/lib/clang/19/lib/x86_64-unknown-linux-gnu". This path was found by running ['/b/sanitizer-x86_64-linux/build/build_symbolizer/./bin/clang', '--target=x86_64-unknown-linux-gnu', '-m64', '-print-runtime-dir'].
llvm-lit: /b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/lit.common.cfg.py:60: warning: Path reported by clang does not exist: "/b/sanitizer-x86_64-linux/build/build_symbolizer/lib/clang/19/lib/x86_64-unknown-linux-gnu". This path was found by running ['/b/sanitizer-x86_64-linux/build/build_symbolizer/./bin/clang', '--target=x86_64-unknown-linux-gnu', '-m64', '-print-runtime-dir'].
llvm-lit: /b/sanitizer-x86_64-linux/build/llvm-project/llvm/utils/lit/lit/main.py:72: note: The test suite configuration requested an individual test timeout of 0 seconds but a timeout of 900 seconds was requested on the command line. Forcing timeout to be 900 seconds.
-- Testing: 9996 tests, 80 workers --
Testing:  0.. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 90..
TIMEOUT: SanitizerCommon-hwasan-x86_64-Linux :: Posix/fork_threaded.c (9996 of 9996)
******************** TEST 'SanitizerCommon-hwasan-x86_64-Linux :: Posix/fork_threaded.c' FAILED ********************
Exit Code: -9
Timeout: Reached timeout of 900 seconds

Command Output (stderr):
--
RUN: at line 1: /b/sanitizer-x86_64-linux/build/build_symbolizer/./bin/clang  -gline-tables-only -fsanitize=hwaddress -fuse-ld=lld -fsanitize-hwaddress-experimental-aliasing  -m64 -funwind-tables  -I/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test -ldl -O0 /b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/sanitizer_common/TestCases/Posix/fork_threaded.c -o /b/sanitizer-x86_64-linux/build/build_symbolizer/runtimes/runtimes-bins/compiler-rt/test/sanitizer_common/hwasan-x86_64-Linux/Posix/Output/fork_threaded.c.tmp && env HWASAN_OPTIONS=die_after_fork=0  /b/sanitizer-x86_64-linux/build/build_symbolizer/runtimes/runtimes-bins/compiler-rt/test/sanitizer_common/hwasan-x86_64-Linux/Posix/Output/fork_threaded.c.tmp
+ /b/sanitizer-x86_64-linux/build/build_symbolizer/./bin/clang -gline-tables-only -fsanitize=hwaddress -fuse-ld=lld -fsanitize-hwaddress-experimental-aliasing -m64 -funwind-tables -I/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test -ldl -O0 /b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/sanitizer_common/TestCases/Posix/fork_threaded.c -o /b/sanitizer-x86_64-linux/build/build_symbolizer/runtimes/runtimes-bins/compiler-rt/test/sanitizer_common/hwasan-x86_64-Linux/Posix/Output/fork_threaded.c.tmp
+ env HWASAN_OPTIONS=die_after_fork=0 /b/sanitizer-x86_64-linux/build/build_symbolizer/runtimes/runtimes-bins/compiler-rt/test/sanitizer_common/hwasan-x86_64-Linux/Posix/Output/fork_threaded.c.tmp
==2956766==ERROR: HWAddressSanitizer: invalid-free on address 0x483400000c00 at pc 0x5fd1d6380a49 on thread T2
tags: 05/00 (ptr/mem)
==2956652==ERROR: HWAddressSanitizer: out of memory: allocator is trying to allocate 0xf800001210 bytes

--

********************
Testing:  0.. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 90.. 

64 warning(s) in tests
Slowest Tests:
--------------------------------------------------------------------------
900.07s: SanitizerCommon-hwasan-x86_64-Linux :: Posix/fork_threaded.c
80.55s: libFuzzer-i386-default-Linux :: value-profile-switch.test
77.69s: libFuzzer-i386-libcxx-Linux :: value-profile-switch.test
74.61s: libFuzzer-i386-static-libcxx-Linux :: value-profile-switch.test
56.52s: ThreadSanitizer-x86_64 :: bench_threads.cpp
56.21s: libFuzzer-i386-default-Linux :: disable-leaks.test
55.34s: libFuzzer-i386-libcxx-Linux :: disable-leaks.test
54.13s: libFuzzer-i386-static-libcxx-Linux :: disable-leaks.test
49.90s: libFuzzer-x86_64-default-Linux :: out-of-process-fuzz.test
49.12s: libFuzzer-i386-libcxx-Linux :: fork_corpus_groups.test
47.06s: libFuzzer-x86_64-libcxx-Linux :: out-of-process-fuzz.test
46.46s: libFuzzer-x86_64-libcxx-Linux :: fork.test
46.42s: libFuzzer-i386-default-Linux :: fork.test
45.57s: libFuzzer-i386-static-libcxx-Linux :: fork_corpus_groups.test
44.97s: libFuzzer-i386-static-libcxx-Linux :: fork.test
44.57s: libFuzzer-i386-default-Linux :: fork_corpus_groups.test
44.42s: libFuzzer-i386-libcxx-Linux :: fork.test
44.07s: libFuzzer-x86_64-default-Linux :: fork.test
Step 12 (test compiler-rt symbolizer) failure: test compiler-rt symbolizer (failure)
...
llvm-lit: /b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/lit.common.cfg.py:60: warning: Path reported by clang does not exist: "/b/sanitizer-x86_64-linux/build/build_symbolizer/lib/clang/19/lib/x86_64-unknown-linux-gnu". This path was found by running ['/b/sanitizer-x86_64-linux/build/build_symbolizer/./bin/clang', '--target=x86_64-unknown-linux-gnu', '-m64', '-print-runtime-dir'].
llvm-lit: /b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/lit.common.cfg.py:60: warning: Path reported by clang does not exist: "/b/sanitizer-x86_64-linux/build/build_symbolizer/lib/clang/19/lib/x86_64-unknown-linux-gnu". This path was found by running ['/b/sanitizer-x86_64-linux/build/build_symbolizer/./bin/clang', '--target=x86_64-unknown-linux-gnu', '-Wthread-safety', '-Wthread-safety-reference', '-Wthread-safety-beta', '-print-runtime-dir'].
llvm-lit: /b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/lit.common.cfg.py:60: warning: Path reported by clang does not exist: "/b/sanitizer-x86_64-linux/build/build_symbolizer/lib/clang/19/lib/x86_64-unknown-linux-gnu". This path was found by running ['/b/sanitizer-x86_64-linux/build/build_symbolizer/./bin/clang', '--target=x86_64-unknown-linux-gnu', '-m64', '-print-runtime-dir'].
llvm-lit: /b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/lit.common.cfg.py:60: warning: Path reported by clang does not exist: "/b/sanitizer-x86_64-linux/build/build_symbolizer/lib/clang/19/lib/x86_64-unknown-linux-gnu". This path was found by running ['/b/sanitizer-x86_64-linux/build/build_symbolizer/./bin/clang', '--target=x86_64-unknown-linux-gnu', '-m64', '-print-runtime-dir'].
llvm-lit: /b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/lit.common.cfg.py:60: warning: Path reported by clang does not exist: "/b/sanitizer-x86_64-linux/build/build_symbolizer/lib/clang/19/lib/x86_64-unknown-linux-gnu". This path was found by running ['/b/sanitizer-x86_64-linux/build/build_symbolizer/./bin/clang', '--target=x86_64-unknown-linux-gnu', '-m64', '-print-runtime-dir'].
llvm-lit: /b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/lit.common.cfg.py:60: warning: Path reported by clang does not exist: "/b/sanitizer-x86_64-linux/build/build_symbolizer/lib/clang/19/lib/x86_64-unknown-linux-gnu". This path was found by running ['/b/sanitizer-x86_64-linux/build/build_symbolizer/./bin/clang', '--target=x86_64-unknown-linux-gnu', '-m64', '-print-runtime-dir'].
llvm-lit: /b/sanitizer-x86_64-linux/build/llvm-project/llvm/utils/lit/lit/main.py:72: note: The test suite configuration requested an individual test timeout of 0 seconds but a timeout of 900 seconds was requested on the command line. Forcing timeout to be 900 seconds.
-- Testing: 9996 tests, 80 workers --
Testing:  0.. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 90..
TIMEOUT: SanitizerCommon-hwasan-x86_64-Linux :: Posix/fork_threaded.c (9996 of 9996)
******************** TEST 'SanitizerCommon-hwasan-x86_64-Linux :: Posix/fork_threaded.c' FAILED ********************
Exit Code: -9
Timeout: Reached timeout of 900 seconds

Command Output (stderr):
--
RUN: at line 1: /b/sanitizer-x86_64-linux/build/build_symbolizer/./bin/clang  -gline-tables-only -fsanitize=hwaddress -fuse-ld=lld -fsanitize-hwaddress-experimental-aliasing  -m64 -funwind-tables  -I/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test -ldl -O0 /b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/sanitizer_common/TestCases/Posix/fork_threaded.c -o /b/sanitizer-x86_64-linux/build/build_symbolizer/runtimes/runtimes-bins/compiler-rt/test/sanitizer_common/hwasan-x86_64-Linux/Posix/Output/fork_threaded.c.tmp && env HWASAN_OPTIONS=die_after_fork=0  /b/sanitizer-x86_64-linux/build/build_symbolizer/runtimes/runtimes-bins/compiler-rt/test/sanitizer_common/hwasan-x86_64-Linux/Posix/Output/fork_threaded.c.tmp
+ /b/sanitizer-x86_64-linux/build/build_symbolizer/./bin/clang -gline-tables-only -fsanitize=hwaddress -fuse-ld=lld -fsanitize-hwaddress-experimental-aliasing -m64 -funwind-tables -I/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test -ldl -O0 /b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/sanitizer_common/TestCases/Posix/fork_threaded.c -o /b/sanitizer-x86_64-linux/build/build_symbolizer/runtimes/runtimes-bins/compiler-rt/test/sanitizer_common/hwasan-x86_64-Linux/Posix/Output/fork_threaded.c.tmp
+ env HWASAN_OPTIONS=die_after_fork=0 /b/sanitizer-x86_64-linux/build/build_symbolizer/runtimes/runtimes-bins/compiler-rt/test/sanitizer_common/hwasan-x86_64-Linux/Posix/Output/fork_threaded.c.tmp
==2956766==ERROR: HWAddressSanitizer: invalid-free on address 0x483400000c00 at pc 0x5fd1d6380a49 on thread T2
tags: 05/00 (ptr/mem)
==2956652==ERROR: HWAddressSanitizer: out of memory: allocator is trying to allocate 0xf800001210 bytes

--

********************
Testing:  0.. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 90..

64 warning(s) in tests
Slowest Tests:
--------------------------------------------------------------------------
900.07s: SanitizerCommon-hwasan-x86_64-Linux :: Posix/fork_threaded.c
80.55s: libFuzzer-i386-default-Linux :: value-profile-switch.test
77.69s: libFuzzer-i386-libcxx-Linux :: value-profile-switch.test
74.61s: libFuzzer-i386-static-libcxx-Linux :: value-profile-switch.test
56.52s: ThreadSanitizer-x86_64 :: bench_threads.cpp
56.21s: libFuzzer-i386-default-Linux :: disable-leaks.test
55.34s: libFuzzer-i386-libcxx-Linux :: disable-leaks.test
54.13s: libFuzzer-i386-static-libcxx-Linux :: disable-leaks.test
49.90s: libFuzzer-x86_64-default-Linux :: out-of-process-fuzz.test
49.12s: libFuzzer-i386-libcxx-Linux :: fork_corpus_groups.test
47.06s: libFuzzer-x86_64-libcxx-Linux :: out-of-process-fuzz.test
46.46s: libFuzzer-x86_64-libcxx-Linux :: fork.test
46.42s: libFuzzer-i386-default-Linux :: fork.test
45.57s: libFuzzer-i386-static-libcxx-Linux :: fork_corpus_groups.test
44.97s: libFuzzer-i386-static-libcxx-Linux :: fork.test
44.57s: libFuzzer-i386-default-Linux :: fork_corpus_groups.test
44.42s: libFuzzer-i386-libcxx-Linux :: fork.test
44.07s: libFuzzer-x86_64-default-Linux :: fork.test

aaryanshukla pushed a commit to aaryanshukla/llvm-project that referenced this pull request Jul 14, 2024
This patch adds the following member functions:
- User::setOperand()
- User::replaceUsesOfWith()
- Value::replaceAllUsesWith()
- Value::replaceUsesWithIf()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants