--- /dev/null
+; Test that llvm-reduce can remove function linkage.
+;
+; RUN: llvm-reduce --abort-on-invalid-reduction --delta-passes=global-values --test FileCheck --test-arg --check-prefixes=CHECK-INTERESTINGNESS --test-arg %s --test-arg --input-file %s -o %t
+; RUN: FileCheck --check-prefix=CHECK-FINAL --implicit-check-not=internal %s < %t
+
+; CHECK-INTERESTINGNESS: define
+; CHECK-INTERESTINGNESS-SAME: void @f
+
+; CHECK-FINAL: define void @f()
+
+define void @f() {
+ ret void
+}
+
+; CHECK-INTERESTINGNESS: define
+; CHECK-INTERESTINGNESS-SAME: void @g
+
+; CHECK-FINAL: define void @g()
+
+define internal void @g() {
+ ret void
+}
return GV.isThreadLocal();
}
+static bool shouldReduceLinkage(GlobalValue &GV) {
+ return !GV.hasExternalLinkage();
+}
+
static void reduceGVs(Oracle &O, ReducerWorkItem &Program) {
for (auto &GV : Program.getModule().global_values()) {
if (shouldReduceDSOLocal(GV) && !O.shouldKeep())
GlobalValue::DLLStorageClassTypes::DefaultStorageClass);
if (shouldReduceThreadLocal(GV) && !O.shouldKeep())
GV.setThreadLocal(false);
+ if (shouldReduceLinkage(GV) && !O.shouldKeep()) {
+ bool IsImplicitDSOLocal = GV.isImplicitDSOLocal();
+ GV.setLinkage(GlobalValue::ExternalLinkage);
+ if (IsImplicitDSOLocal)
+ GV.setDSOLocal(false);
+ }
}
}