Fix the check for regparm in FunctionType::ExtInfo

`getHasRegParm()` was working under the assumption that the RegParm
bits are the last field, which is no longer true, after adding the
`NoCfCheck` and `CmseNSCall` fields.

This causes a spurious "regparm 0" attribute to appear when a function
type is declared with either `__attribute__((nocf_check))` or
`__attribute__((cmse_nonsecure_call))`.

Differential Revision: https://reviews.llvm.org/D77270
This commit is contained in:
Momchil Velikov 2020-04-27 15:18:06 +01:00
parent 096b25a8d8
commit 334ac81054
2 changed files with 9 additions and 6 deletions

View File

@ -3518,13 +3518,12 @@ public:
enum { NoReturnMask = 0x20 };
enum { ProducesResultMask = 0x40 };
enum { NoCallerSavedRegsMask = 0x80 };
enum {
RegParmMask = 0x700,
RegParmOffset = 8
};
enum { NoCfCheckMask = 0x800 };
enum { CmseNSCallMask = 0x1000 };
enum {
RegParmMask = ~(CallConvMask | NoReturnMask | ProducesResultMask |
NoCallerSavedRegsMask | NoCfCheckMask | CmseNSCallMask),
RegParmOffset = 8
}; // Assumed to be the last field
uint16_t Bits = CC_C;
ExtInfo(unsigned Bits) : Bits(static_cast<uint16_t>(Bits)) {}
@ -3557,7 +3556,7 @@ public:
bool getCmseNSCall() const { return Bits & CmseNSCallMask; }
bool getNoCallerSavedRegs() const { return Bits & NoCallerSavedRegsMask; }
bool getNoCfCheck() const { return Bits & NoCfCheckMask; }
bool getHasRegParm() const { return (Bits >> RegParmOffset) != 0; }
bool getHasRegParm() const { return ((Bits & RegParmMask) >> RegParmOffset) != 0; }
unsigned getRegParm() const {
unsigned RegParm = (Bits & RegParmMask) >> RegParmOffset;

View File

@ -0,0 +1,4 @@
// RUN: %clang_cc1 -triple armv8.1m.main-eabi -mcmse -fsyntax-only %s -ast-dump | FileCheck %s
// REQUIRES: arm-registered-target
typedef int (*fn_t)(int) __attribute__((cmse_nonsecure_call));
// CHECK-NOT: regparm 0