[InstCombine] Signed saturation tests. NFC
[llvm-complete.git] / tools / llvm-c-test / metadata.c
blob4e1aa9cd99d881c8dcc3a9240a644a37b55a20ef
1 /*===-- object.c - tool for testing libLLVM and llvm-c API ----------------===*\
2 |* *|
3 |* Part of the LLVM Project, under the Apache License v2.0 with LLVM *|
4 |* Exceptions. *|
5 |* See https://llvm.org/LICENSE.txt for license information. *|
6 |* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception *|
7 |* *|
8 |*===----------------------------------------------------------------------===*|
9 |* *|
10 |* This file implements the --add-named-metadata-operand and --set-metadata *|
11 |* commands in llvm-c-test. *|
12 |* *|
13 \*===----------------------------------------------------------------------===*/
15 #include "llvm-c-test.h"
17 int llvm_add_named_metadata_operand(void) {
18 LLVMModuleRef m = LLVMModuleCreateWithName("Mod");
19 LLVMValueRef values[] = { LLVMConstInt(LLVMInt32Type(), 0, 0) };
21 // This used to trigger an assertion
22 LLVMAddNamedMetadataOperand(m, "name", LLVMMDNode(values, 1));
24 LLVMDisposeModule(m);
26 return 0;
29 int llvm_set_metadata(void) {
30 LLVMBuilderRef b = LLVMCreateBuilder();
31 LLVMValueRef values[] = { LLVMConstInt(LLVMInt32Type(), 0, 0) };
33 // This used to trigger an assertion
34 LLVMSetMetadata(
35 LLVMBuildRetVoid(b),
36 LLVMGetMDKindID("kind", 4),
37 LLVMMDNode(values, 1));
39 LLVMDisposeBuilder(b);
41 return 0;