-
Notifications
You must be signed in to change notification settings - Fork 14k
WebAssembly: Move runtime libcall setting out of TargetLowering #142624
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
WebAssembly: Move runtime libcall setting out of TargetLowering #142624
Conversation
This stack of pull requests is managed by Graphite. Learn more about stacking. |
@llvm/pr-subscribers-lld-wasm @llvm/pr-subscribers-backend-webassembly Author: Matt Arsenault (arsenm) ChangesRuntimeLibcallInfo needs to be correct outside of codegen contexts. Full diff: https://github.com/llvm/llvm-project/pull/142624.diff 2 Files Affected:
diff --git a/llvm/lib/IR/RuntimeLibcalls.cpp b/llvm/lib/IR/RuntimeLibcalls.cpp
index db0373055160c..ec4dc1858e4a5 100644
--- a/llvm/lib/IR/RuntimeLibcalls.cpp
+++ b/llvm/lib/IR/RuntimeLibcalls.cpp
@@ -277,5 +277,10 @@ void RuntimeLibcallsInfo::initLibcalls(const Triple &TT) {
setLibcallName(RTLIB::MULO_I64, nullptr);
}
setLibcallName(RTLIB::MULO_I128, nullptr);
+ } else {
+ // Define the emscripten name for return address helper.
+ // TODO: when implementing other Wasm backends, make this generic or only do
+ // this on emscripten depending on what they end up doing.
+ setLibcallName(RTLIB::RETURN_ADDRESS, "emscripten_return_address");
}
}
diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
index aac3473311192..3cd923c0ba058 100644
--- a/llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
+++ b/llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
@@ -385,11 +385,6 @@ WebAssemblyTargetLowering::WebAssemblyTargetLowering(
setMaxAtomicSizeInBitsSupported(64);
- // Define the emscripten name for return address helper.
- // TODO: when implementing other Wasm backends, make this generic or only do
- // this on emscripten depending on what they end up doing.
- setLibcallName(RTLIB::RETURN_ADDRESS, "emscripten_return_address");
-
// Always convert switches to br_tables unless there is only one case, which
// is equivalent to a simple branch. This reduces code size for wasm, and we
// defer possible jump table optimizations to the VM.
|
@@ -277,5 +277,10 @@ void RuntimeLibcallsInfo::initLibcalls(const Triple &TT) { | |||
setLibcallName(RTLIB::MULO_I64, nullptr); | |||
} | |||
setLibcallName(RTLIB::MULO_I128, nullptr); | |||
} else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIRC to preserve existing behavior and because these libcalls were listed in RuntimeLibcallSignatureTable.
I don't think wasm is typically used with libgcc? Is that supported?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AFAIK there are no uses of libgcc with wasm.
Can you explain why? I see other calls to setLibcallName that are happening in ISelLowering.cpp file: e.g.
Are all of these wrong too? |
@@ -277,5 +277,10 @@ void RuntimeLibcallsInfo::initLibcalls(const Triple &TT) { | |||
setLibcallName(RTLIB::MULO_I64, nullptr); | |||
} | |||
setLibcallName(RTLIB::MULO_I128, nullptr); | |||
} else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be if (TT.isOSEmscripten())
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suspect this predates when we had an emscripten triple, and it should probably be behind isOSEmscripten()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not looking to change behavior here, this should be done separately
If you're doing LTO of with libc or compiler-rt included in the build, we need to maintain an accurate list of functions that may be required during later codegen
Yes |
91985a1
to
ac49d23
Compare
lld/test/wasm/lto/Inputs/libcall-return-addr.ll is failing. This was last moved in #126880, but this is now fixed and there should be no more cases in webassembly. I guess I could port the test to a different target that still has subtarget dependent libcall choices |
RuntimeLibcallInfo needs to be correct outside of codegen contexts.
I've tried to replicate the error on other targets but can't. The original patch seems wasm specific, and should not be reproducible with any libcalls anymore so I'll just delete the test |
ac49d23
to
9fd32f4
Compare
RuntimeLibcallInfo needs to be correct outside of codegen contexts.