[Verifier] Allow dllexport protected after D133267
authorFangrui Song <i@maskray.me>
Tue, 6 Sep 2022 22:28:29 +0000 (15:28 -0700)
committerFangrui Song <i@maskray.me>
Tue, 6 Sep 2022 22:28:29 +0000 (15:28 -0700)
I have noticed that this combo makes sense (D133266) but rejected it for
simplicity. It turns out to be used by PlayStation, so let's allow it.

llvm/lib/IR/Verifier.cpp
llvm/test/Verifier/dllstorage.ll

index da19afa..3921742 100644 (file)
@@ -664,8 +664,9 @@ void Verifier::visitGlobalValue(const GlobalValue &GV) {
     Check(!GV.hasComdat(), "Declaration may not be in a Comdat!", &GV);
 
   if (GV.hasDLLExportStorageClass()) {
-    Check(GV.hasDefaultVisibility(),
-          "dllexport GlobalValue must have default visibility", &GV);
+    Check(!GV.hasHiddenVisibility(),
+          "dllexport GlobalValue must have default or protected visibility",
+          &GV);
   }
   if (GV.hasDLLImportStorageClass()) {
     Check(GV.hasDefaultVisibility(),
index 4791691..8885d0f 100644 (file)
@@ -3,16 +3,14 @@
 target datalayout = "e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
 target triple = "x86_64-pc-windows-gnu"
 
-; CHECK:      dllexport GlobalValue must have default visibility
+; CHECK:      dllexport GlobalValue must have default or protected visibility
 ; CHECK-NEXT: ptr @dllexport_hidden
 declare hidden dllexport i32 @dllexport_hidden()
-; CHECK:      dllexport GlobalValue must have default visibility
-; CHECK-NEXT: ptr @dllexport_protected
 declare protected dllexport i32 @dllexport_protected()
 
-; CHECK:      dllimport GlobalValue must have default visibility
+; CHECK-NEXT: dllimport GlobalValue must have default visibility
 ; CHECK-NEXT: ptr @dllimport_hidden
 declare hidden dllimport i32 @dllimport_hidden()
-; CHECK:      dllimport GlobalValue must have default visibility
+; CHECK-NEXT: dllimport GlobalValue must have default visibility
 ; CHECK-NEXT: ptr @dllimport_protected
 declare protected dllimport i32 @dllimport_protected()