[llvm] ef7267d - [llvm] llvm-ifs: Support for handling empty IFS and merging weak+strong symbols.
Puyan Lotfi via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 5 09:56:53 PST 2019
Author: Puyan Lotfi
Date: 2019-12-05T12:56:37-05:00
New Revision: ef7267def69f9416b53388a5b5ea612bed9573d9
URL: https://github.com/llvm/llvm-project/commit/ef7267def69f9416b53388a5b5ea612bed9573d9
DIFF: https://github.com/llvm/llvm-project/commit/ef7267def69f9416b53388a5b5ea612bed9573d9.diff
LOG: [llvm] llvm-ifs: Support for handling empty IFS and merging weak+strong symbols.
The following changes enable llvm-ifs to handle the following merge conflicts:
* Weak + Strong symbol merging for the same symbol
* empty vs non-empty triple field
* empty vs non-empty object file format
Differential Revision: https://reviews.llvm.org/D70834
Added:
llvm/test/tools/llvm-ifs/Inputs/strong-mismatch-size.ifs
llvm/test/tools/llvm-ifs/Inputs/strong-mismatch-type.ifs
llvm/test/tools/llvm-ifs/default-empty.ifs
llvm/test/tools/llvm-ifs/strong.ifs
llvm/test/tools/llvm-ifs/weak-mismatch.ifs
Modified:
llvm/test/tools/llvm-ifs/conflict-weak.ifs
llvm/tools/llvm-ifs/llvm-ifs.cpp
Removed:
################################################################################
diff --git a/llvm/test/tools/llvm-ifs/Inputs/strong-mismatch-size.ifs b/llvm/test/tools/llvm-ifs/Inputs/strong-mismatch-size.ifs
new file mode 100644
index 000000000000..9afb08802726
--- /dev/null
+++ b/llvm/test/tools/llvm-ifs/Inputs/strong-mismatch-size.ifs
@@ -0,0 +1,8 @@
+# NOTE: Used by weak-mismatch.ifs
+--- !experimental-ifs-v1
+IfsVersion: 1.0
+Triple: x86_64-unknown-linux-gnu
+ObjectFileFormat: ELF
+Symbols:
+ foobar: { Type: Object, Size: 2 }
+...
diff --git a/llvm/test/tools/llvm-ifs/Inputs/strong-mismatch-type.ifs b/llvm/test/tools/llvm-ifs/Inputs/strong-mismatch-type.ifs
new file mode 100644
index 000000000000..8fc550a644cb
--- /dev/null
+++ b/llvm/test/tools/llvm-ifs/Inputs/strong-mismatch-type.ifs
@@ -0,0 +1,8 @@
+# NOTE: Used by weak-mismatch.ifs
+--- !experimental-ifs-v1
+IfsVersion: 1.0
+Triple: x86_64-unknown-linux-gnu
+ObjectFileFormat: ELF
+Symbols:
+ foobar: { Type: Func }
+...
diff --git a/llvm/test/tools/llvm-ifs/conflict-weak.ifs b/llvm/test/tools/llvm-ifs/conflict-weak.ifs
index c7e604e6ad19..823b8f1866c3 100644
--- a/llvm/test/tools/llvm-ifs/conflict-weak.ifs
+++ b/llvm/test/tools/llvm-ifs/conflict-weak.ifs
@@ -1,12 +1,8 @@
-# RUN: not llvm-ifs -action write-ifs -o - %s %S/func.ifs 2>&1 | \
+# RUN: llvm-ifs -action write-ifs -o - %s %S/func.ifs 2>&1 | \
# RUN: FileCheck %s --check-prefixes=CHECK-IFS
-# Here we are testing to see if two symbols with identical names will fail to
-# merge in conflict due to one being weak and one not. Eventually this will work
-# when llvm-ifs has support for resolving these kinds of conflicts.
-# CHECK-IFS: error: Interface Stub: Weak Mismatch for a.
-# CHECK-IFS-NEXT: Filename:
-# CHECK-IFS-NEXT: Weak Values: 1 0
+# CHECK-IFS: Symbols:
+# CHECK-IFS-NEXT: a: { Type: Func, Weak: true }
--- !experimental-ifs-v1
IfsVersion: 1.0
diff --git a/llvm/test/tools/llvm-ifs/default-empty.ifs b/llvm/test/tools/llvm-ifs/default-empty.ifs
new file mode 100644
index 000000000000..9848f418f58c
--- /dev/null
+++ b/llvm/test/tools/llvm-ifs/default-empty.ifs
@@ -0,0 +1,25 @@
+# RUN: llvm-ifs -action write-ifs -o - %s | FileCheck --check-prefixes=CHECK-DEFAULT %s
+# RUN: llvm-ifs -action write-ifs -o - %s %S/weak.ifs | FileCheck --check-prefixes=CHECK-MERGE %s
+
+# CHECK-DEFAULT: --- !experimental-ifs-v1
+# CHECK-DEFAULT-NEXT: IfsVersion: 1.2
+# CHECK-DEFAULT-NEXT: Triple: ''
+# CHECK-DEFAULT-NEXT: ObjectFileFormat: ELF
+# CHECK-DEFAULT-NEXT: Symbols: {}
+# CHECK-DEFAULT-NEXT: ...
+
+# CHECK-MERGE: --- !experimental-ifs-v1
+# CHECK-MERGE-NEXT: IfsVersion: 1.0
+# CHECK-MERGE-NEXT: Triple: x86_64-unknown-linux-gnu
+# CHECK-MERGE-NEXT: ObjectFileFormat: ELF
+# CHECK-MERGE-NEXT: Symbols:
+# CHECK-MERGE-DAG: _Z8weakFuncv: { Type: Func, Weak: true }
+# CHECK-MERGE-DAG: _Z10strongFuncv: { Type: Func }
+# CHECK-MERGE: ...
+
+--- !experimental-ifs-v1
+IfsVersion: 1.2
+Triple: ''
+ObjectFileFormat: ELF
+Symbols: {}
+...
diff --git a/llvm/test/tools/llvm-ifs/strong.ifs b/llvm/test/tools/llvm-ifs/strong.ifs
new file mode 100644
index 000000000000..bdc930fbaaa3
--- /dev/null
+++ b/llvm/test/tools/llvm-ifs/strong.ifs
@@ -0,0 +1,17 @@
+# RUN: llvm-ifs -action write-ifs -o - %s %S/strong.ifs | FileCheck %s --check-prefixes=CHECK-IFS
+
+# CHECK-IFS: --- !experimental-ifs-v1
+# CHECK-IFS-NEXT: IfsVersion: 1.0
+# CHECK-IFS-NEXT: Triple: x86_64-unknown-linux-gnu
+# CHECK-IFS-NEXT: ObjectFileFormat: ELF
+# CHECK-IFS-NEXT: Symbols:
+# CHECK-IFS-DAG: _Z8weakFuncv: { Type: Func }
+# CHECK-IFS: ...
+
+--- !experimental-ifs-v1
+IfsVersion: 1.0
+Triple: x86_64-unknown-linux-gnu
+ObjectFileFormat: ELF
+Symbols:
+ _Z8weakFuncv: { Type: Func }
+...
diff --git a/llvm/test/tools/llvm-ifs/weak-mismatch.ifs b/llvm/test/tools/llvm-ifs/weak-mismatch.ifs
new file mode 100644
index 000000000000..15abc2064cc2
--- /dev/null
+++ b/llvm/test/tools/llvm-ifs/weak-mismatch.ifs
@@ -0,0 +1,19 @@
+# RUN: not llvm-ifs -action write-ifs -o - %s %S/Inputs/strong-mismatch-size.ifs 2>&1 | FileCheck %s --check-prefixes=CHECK-SIZE
+# RUN: not llvm-ifs -action write-ifs -o - %s %S/Inputs/strong-mismatch-type.ifs 2>&1 | FileCheck %s --check-prefixes=CHECK-TYPE
+
+# CHECK-SIZE: error: Interface Stub: Size Mismatch for foobar.
+# CHECK-SIZE-NEXT: Filename:
+# CHECK-SIZE-NEXT: Size Values: 1 2
+
+
+# CHECK-TYPE: error: Interface Stub: Type Mismatch for foobar.
+# CHECK-TYPE-NEXT: Filename:
+# CHECK-TYPE-NEXT: Type Values: Object Func
+
+--- !experimental-ifs-v1
+IfsVersion: 1.0
+Triple: x86_64-unknown-linux-gnu
+ObjectFileFormat: ELF
+Symbols:
+ foobar: { Type: Object, Size: 1, Weak: true }
+...
diff --git a/llvm/tools/llvm-ifs/llvm-ifs.cpp b/llvm/tools/llvm-ifs/llvm-ifs.cpp
index 2aadab988e2e..d5816f49f659 100644
--- a/llvm/tools/llvm-ifs/llvm-ifs.cpp
+++ b/llvm/tools/llvm-ifs/llvm-ifs.cpp
@@ -422,6 +422,10 @@ int main(int argc, char *argv[]) {
Stub.SOName = TargetStub->SOName;
Stub.NeededLibs = TargetStub->NeededLibs;
} else {
+ Stub.ObjectFileFormat = !Stub.ObjectFileFormat.empty()
+ ? Stub.ObjectFileFormat
+ : TargetStub->ObjectFileFormat;
+
if (Stub.IfsVersion != TargetStub->IfsVersion) {
if (Stub.IfsVersion.getMajor() != IFSVersionCurrent.getMajor()) {
WithColor::error()
@@ -434,7 +438,8 @@ int main(int argc, char *argv[]) {
if (TargetStub->IfsVersion > Stub.IfsVersion)
Stub.IfsVersion = TargetStub->IfsVersion;
}
- if (Stub.ObjectFileFormat != TargetStub->ObjectFileFormat) {
+ if (Stub.ObjectFileFormat != TargetStub->ObjectFileFormat &&
+ !TargetStub->ObjectFileFormat.empty()) {
WithColor::error() << "Interface Stub: ObjectFileFormat Mismatch."
<< "\nFilenames: " << PreviousInputFilePath << " "
<< InputFilePath << "\nObjectFileFormat Values: "
@@ -442,7 +447,7 @@ int main(int argc, char *argv[]) {
<< TargetStub->ObjectFileFormat << "\n";
return -1;
}
- if (Stub.Triple != TargetStub->Triple) {
+ if (Stub.Triple != TargetStub->Triple && !TargetStub->Triple.empty()) {
WithColor::error() << "Interface Stub: Triple Mismatch."
<< "\nFilenames: " << PreviousInputFilePath << " "
<< InputFilePath
@@ -494,13 +499,8 @@ int main(int argc, char *argv[]) {
return -1;
}
if (Symbol.Weak != SI->second.Weak) {
- // TODO: Add conflict resolution for Weak vs non-Weak.
- WithColor::error() << "Interface Stub: Weak Mismatch for "
- << Symbol.Name << ".\nFilename: " << InputFilePath
- << "\nWeak Values: " << SI->second.Weak << " "
- << Symbol.Weak << "\n";
-
- return -1;
+ Symbol.Weak = false;
+ continue;
}
// TODO: Not checking Warning. Will be dropped.
}
More information about the llvm-commits
mailing list