-
Notifications
You must be signed in to change notification settings - Fork 15k
[AMDPGU] Auto-upgrade ELF mangling in the data layout #163644
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
Conversation
|
@llvm/pr-subscribers-llvm-ir @llvm/pr-subscribers-lto Author: Joseph Huber (jhuber6) ChangesSummary: Full diff: https://github.com/llvm/llvm-project/pull/163644.diff 3 Files Affected:
diff --git a/llvm/lib/Linker/IRMover.cpp b/llvm/lib/Linker/IRMover.cpp
index 1bff6cd25156d..6b84fea4a4952 100644
--- a/llvm/lib/Linker/IRMover.cpp
+++ b/llvm/lib/Linker/IRMover.cpp
@@ -1489,6 +1489,13 @@ Error IRLinker::run() {
SrcTriple.getOSName() == "unknown");
EnableTripleWarning = !SrcHasLibDeviceTriple;
EnableDLWarning = !(SrcHasLibDeviceTriple && SrcHasLibDeviceDL);
+ } else if (SrcTriple.isAMDGPU() && DstTriple.isAMDGPU()) {
+ StringRef SrcDL = SrcM->getDataLayoutStr();
+ StringRef DstDL = DstM.getDataLayoutStr();
+
+ // Suppress the data layout warning if the old layout without ELF mangling
+ // specified is used.
+ EnableDLWarning = DstDL.drop_front(4) != SrcDL;
}
if (EnableDLWarning && (SrcM->getDataLayout() != DstM.getDataLayout())) {
diff --git a/llvm/test/Linker/Inputs/legacy-amdgcn.ll b/llvm/test/Linker/Inputs/legacy-amdgcn.ll
new file mode 100644
index 0000000000000..19d622d5f887f
--- /dev/null
+++ b/llvm/test/Linker/Inputs/legacy-amdgcn.ll
@@ -0,0 +1,2 @@
+target datalayout = "e-p:64:64-p1:64:64-p2:32:32-p3:32:32-p4:64:64-p5:32:32-p6:32:32-p7:160:256:256:32-p8:128:128:128:48-p9:192:256:256:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-S32-A5-G1-ni:7:8:9"
+target triple = "amdgcn-amd-amdhsa"
diff --git a/llvm/test/Linker/amdgcn-triple.ll b/llvm/test/Linker/amdgcn-triple.ll
new file mode 100644
index 0000000000000..9244277d1a1b0
--- /dev/null
+++ b/llvm/test/Linker/amdgcn-triple.ll
@@ -0,0 +1,6 @@
+; RUN: llvm-link %s %S/Inputs/legacy-amdgcn.ll -S -o - 2>&1 | FileCheck %s
+
+; CHECK-NOT: Linking two modules of different data layouts
+; CHECK: target triple = "amdgcn-amd-amdhsa"
+target datalayout = "e-m:e-p:64:64-p1:64:64-p2:32:32-p3:32:32-p4:64:64-p5:32:32-p6:32:32-p7:160:256:256:32-p8:128:128:128:48-p9:192:256:256:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-S32-A5-G1-ni:7:8:9"
+target triple = "amdgcn-amd-amdhsa"
|
|
I'm not sure if we can do this in IR auto upgrade instead of suppressing the warning? |
IR Linker auto upgrades are currently applied after this check I believe, but I suppose we could add one beforehand? Not sure if that's correct either because it is a legitimately different data layout with different semantics. This mostly just suppresses the warning because there's nothing the user can do about it and it's unreasonable for an empty |
This depends because in this particular case it doesn't actually change anything, and this is also the whole point of IR upgrade. I don't prefer to suppress any warning if it is not the only solution but I'm also open to other opinions. |
We do the same for the CUDA devlice libs, I could hard code the module names to a list if you'd prefer. |
|
I guess at least we might want it to be more robust, like to drop the entire ELF mangling specification and then compare, instead of just cut off the first 4 chars. |
That's exactly what dropping the first 4 chars does, I was first going to check if they're the same minus the mangling but the DataLayout doesn't expose that and I figured it wasn't worth modifying the class for this dumb use-case. |
|
This should be handled in UpgradeDataLayoutString(), not ad-hoc in IRMover. |
Didn't know that existed, certainly makes things more straightforward. Thanks. |
|
Generally we just update the four .ll files in the device library. Are there other libraries we're concerned about now where a warning wouldn't be desired? |
It's all the files with a data layout, and if we changed this I suppose there should be auto-upgrade anyway. |
|
An alternative can be just to do what NVPTX is doing, which is just to compare the key specs that we care about most, since we only support one "mode" for anything specified in data layout anyway, though I'm not sure if that's the right thing to do. |
Aren't there only 4 files? Isn't the warning a good thing in general? |
OpenMP currently uses these, HIP has |
|
This applies to all the data layouts, I could make it only apply to this very specific one if necessary, but I'm assuming this is what we want. |
For those, I'd say the warning is exposing a problem which should be fixed by updating the 4 .ll files in the device library, |
Those libraries are external to LLVM so it will take a long time for users to get the newer version. |
I don't think that's a great reason to disable this warning in the compiler. |
There's tons of existing auto-upgrading for AMDGPU already, I don't think this is that different but I'm not an expert on the existing handling. |
|
All data layout changes are generally expected to come with an auto-upgrade. |
|
It seems like |
Definitely, I was actually just reading up on the Data Layout semantics and remembered that |
Summary: The changes in llvm#163011 caused all ELF platforms to default to ELF mangling. We want to auto upgrade this for linking in new programs to old ones. contains
Summary:
The changes in #163011 caused
all ELF platforms to default to ELF mangling. We want to auto upgrade
this for linking in new programs to old ones.