[PATCH] D111161: [UnknownProvenance] Add bitcode support.

Jeroen Dobbelaere via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 12 01:36:07 PST 2023


jeroen.dobbelaere updated this revision to Diff 488532.
jeroen.dobbelaere added a comment.
Herald added a subscriber: StephenFan.

Rebased to ef545ef62a833152d8975ff16333b57cc41befcc <https://reviews.llvm.org/rGef545ef62a833152d8975ff16333b57cc41befcc> (Jan 9, 2023)


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D111161/new/

https://reviews.llvm.org/D111161

Files:
  llvm/include/llvm/Bitcode/LLVMBitCodes.h
  llvm/lib/Bitcode/Reader/BitcodeReader.cpp
  llvm/lib/Bitcode/Writer/BitcodeWriter.cpp


Index: llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
===================================================================
--- llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
+++ llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
@@ -2559,6 +2559,8 @@
       Code = bitc::CST_CODE_POISON;
     } else if (isa<UndefValue>(C)) {
       Code = bitc::CST_CODE_UNDEF;
+    } else if (isa<UnknownProvenance>(C)) {
+      Code = bitc::CST_CODE_UNKNOWN_PROVENANCE;
     } else if (const ConstantInt *IV = dyn_cast<ConstantInt>(C)) {
       if (IV->getBitWidth() <= 64) {
         uint64_t V = IV->getSExtValue();
Index: llvm/lib/Bitcode/Reader/BitcodeReader.cpp
===================================================================
--- llvm/lib/Bitcode/Reader/BitcodeReader.cpp
+++ llvm/lib/Bitcode/Reader/BitcodeReader.cpp
@@ -3001,6 +3001,11 @@
     case bitc::CST_CODE_UNDEF:     // UNDEF
       V = UndefValue::get(CurTy);
       break;
+    case bitc::CST_CODE_UNKNOWN_PROVENANCE: // UNKNOWN_PROVENANCE
+      if (!CurTy->isPointerTy())
+        return error("Invalid type for a unknown_provenance");
+      V = UnknownProvenance::get(cast<PointerType>(CurTy));
+      break;
     case bitc::CST_CODE_POISON:    // POISON
       V = PoisonValue::get(CurTy);
       break;
Index: llvm/include/llvm/Bitcode/LLVMBitCodes.h
===================================================================
--- llvm/include/llvm/Bitcode/LLVMBitCodes.h
+++ llvm/include/llvm/Bitcode/LLVMBitCodes.h
@@ -411,6 +411,7 @@
                               //                 sideeffect|alignstack|
                               //                 asmdialect|unwind,
                               //                 asmstr,conststr]
+  CST_CODE_UNKNOWN_PROVENANCE = 31, // UNKNOWN_PROVENANCE
 };
 
 /// CastOpcodes - These are values used in the bitcode files to encode which


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D111161.488532.patch
Type: text/x-patch
Size: 1824 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230112/473de0af/attachment.bin>


More information about the llvm-commits mailing list