1// RUN: %clangxx_msan -fsanitize-memory-track-origins -O0 %s -o %t && not %run %t 2>&1 | FileCheck %s
2// RUN: %clangxx_msan -fsanitize-memory-track-origins -O1 %s -o %t && not %run %t 2>&1 | FileCheck %s
3// RUN: %clangxx_msan -fsanitize-memory-track-origins -O2 %s -o %t && not %run %t 2>&1 | FileCheck %s
4
5// Test condition origin propagation through "select" IR instruction.
6
7#include <stdio.h>
8#include <stdint.h>
9
10__attribute__((noinline))
11int *max_by_ptr(int *a, int *b) {
12 return *a < *b ? b : a;
13}
14
15int main(void) {
16 int x;
17 int *volatile px = &x;
18 int y = 43;
19 int *p = max_by_ptr(a: px, b: &y);
20 // CHECK: Uninitialized value was created by an allocation of 'x' in the stack frame
21 return *p;
22}
23

source code of compiler-rt/test/msan/select_origin.cpp